Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying the dev directory #866

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 30 additions & 17 deletions src/AutoBuild.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,23 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
# Are we skipping building and just outputting JSON?
meta_json, meta_json_file = extract_flag!(ARGS, "--meta-json")

# Output settings. If provided by the user, we need to resolve the relative paths.
output, output_path = extract_flag!(ARGS, "--output", pwd())
if output
output_path = abspath(joinpath(pwd(), output_path))
end
output_bin, output_bin_path = extract_flag!(ARGS, "--output-bin", joinpath(output_path, "products"))
if output_bin
output_bin_path = abspath(joinpath(pwd(), output_bin_path))
end
# TODO: change the default of output_jll_path to joinpath(output_path, "$(src_name)_jll")
output_jll, output_jll_path = extract_flag!(ARGS, "--output-jll", joinpath(Pkg.devdir(), "$(src_name)_jll"))
if output_jll
output_jll_path = abspath(joinpath(pwd(), output_jll_path))
end
# Shove the _jll path into `kwargs` so that we are passing it along
kwargs = (; kwargs..., code_dir = output_jll_path)

# This sets whether we are going to deploy our binaries/wrapper code to GitHub releases
deploy, deploy_repo = extract_flag!(ARGS, "--deploy", "JuliaBinaryWrappers/$(src_name)_jll.jl")
deploy_bin, deploy_bin_repo = extract_flag!(ARGS, "--deploy-bin", "JuliaBinaryWrappers/$(src_name)_jll.jl")
Expand Down Expand Up @@ -170,13 +187,6 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
error("Cannot register with a local deployment!")
end

if deploy_bin || deploy_jll
code_dir = joinpath(Pkg.devdir(), "$(src_name)_jll")

# Shove them into `kwargs` so that we are conditionally passing them along
kwargs = (; kwargs..., code_dir = code_dir)
end

# If --meta-json was passed, error out if any confusing options were passed
meta_json_stream = nothing
if meta_json
Expand Down Expand Up @@ -218,7 +228,7 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
# We need to make sure that the JLL repo at least exists, so that we can deploy binaries to it
# even if we're not planning to register things to it today.
if deploy_jll_repo != "local"
init_jll_package(src_name, code_dir, deploy_jll_repo)
init_jll_package(src_name, output_jll_path, deploy_jll_repo)
end
end

Expand Down Expand Up @@ -265,9 +275,10 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
# Build the given platforms using the given sources
build_output_meta = autobuild(
# Controls output product placement, mount directory placement, etc...
pwd(),
output_path,

args...;
products_dir = output_bin_path,

# Flags
verbose=verbose,
Expand All @@ -287,18 +298,18 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,

# The location the binaries will be available from
bin_path = "https://github.com/$(deploy_jll_repo)/releases/download/$(tag)"
build_jll_package(src_name, build_version, sources, code_dir, build_output_meta,
build_jll_package(src_name, build_version, sources, output_jll_path, build_output_meta,
dependencies, bin_path; verbose=verbose, extra_kwargs...)
if deploy_jll_repo != "local"
push_jll_package(src_name, build_version; code_dir=code_dir, deploy_repo=deploy_jll_repo)
push_jll_package(src_name, build_version; code_dir=output_jll_path, deploy_repo=deploy_jll_repo)
end
if register
if verbose
@info("Registering new wrapper code version $(build_version)...")
end

register_jll(src_name, build_version, dependencies, julia_compat;
deploy_repo=deploy_jll_repo, code_dir=code_dir)
deploy_repo=deploy_jll_repo, code_dir=output_jll_path)
end
end

Expand All @@ -307,7 +318,7 @@ function build_tarballs(ARGS, src_name, src_version, sources, script,
if verbose
@info("Deploying binaries to release $(tag) on $(deploy_bin_repo) via `ghr`...")
end
upload_to_github_releases(deploy_bin_repo, tag, joinpath(pwd(), "products"); verbose=verbose)
upload_to_github_releases(deploy_bin_repo, tag, output_bin_path; verbose=verbose)
end

return build_output_meta
Expand Down Expand Up @@ -580,6 +591,8 @@ here are the relevant actors, broken down in brief:

* `code_dir`: sets where autogenerated JLL packages will be put.

* `products_dir`: sets the directory where generated tarballs get put.

* `require_license` enables a special audit pass that requires licenses to be
installed by all packages.
"""
Expand All @@ -597,6 +610,7 @@ function autobuild(dir::AbstractString,
ignore_audit_errors::Bool = true,
autofix::Bool = true,
code_dir::Union{String,Nothing} = nothing,
products_dir::String = joinpath(dir, "products"),
require_license::Bool = true,
kwargs...)
@nospecialize
Expand Down Expand Up @@ -633,9 +647,8 @@ function autobuild(dir::AbstractString,
# We must prepare our sources. Download them, hash them, etc...
source_files = download_source.(sources; verbose=verbose)

# Our build products will go into ./products
out_path = joinpath(dir, "products")
try mkpath(out_path) catch; end
# Our build products will go into products_dir (usually ./products)
try mkpath(products_dir) catch; end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you didn't introduce this line, but I don't think we want to wrap mkpath with a try/catch block 🤔

Copy link
Contributor Author

@mortenpi mortenpi Nov 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going back in Git blame, it looks like it used to be a very common pattern 3 years ago, but it looks like this is the last remaining relic. I can remove the try ... catch.


for platform in sort(collect(platforms), by = triplet)
# We build in a platform-specific directory
Expand Down Expand Up @@ -801,7 +814,7 @@ function autobuild(dir::AbstractString,
# Once we're built up, go ahead and package this dest_prefix out
tarball_path, tarball_hash, git_hash = package(
dest_prefix,
joinpath(out_path, src_name),
joinpath(products_dir, src_name),
src_version;
platform=platform,
verbose=verbose,
Expand Down