Skip to content

Commit 806240c

Browse files
authored
Use Yggdrasil to host binary (#58)
* use Yggdrasil to host binary * remove unused file, put version selection to deps.jl * bring TagBot back, remove auto tag * use auto-generated build.jl * update build.jl * use original build.jl, select version in Libtask.jl * again, write deps.jl by ourselves * use products filter instead of deps.jl writer
1 parent 4e201c5 commit 806240c

File tree

8 files changed

+70
-252
lines changed

8 files changed

+70
-252
lines changed

Diff for: .github/backup/.travis.yml

-59
This file was deleted.

Diff for: .github/backup/appveyor.yml

-38
This file was deleted.

Diff for: .github/workflows/BuildDylib.yaml

+5-16
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ name: Build Dylib
22

33
on:
44
push:
5-
branches:
6-
- master
7-
# tags: '*'
8-
release:
9-
types:
10-
- created
11-
pull_request:
12-
types: [opened, synchronize, reopened]
5+
paths:
6+
- 'deps/Makefile'
7+
- 'deps/task.c'
8+
- 'deps/build_tarballs.jl'
9+
- 'deps/build_dylib.sh'
1310

1411
jobs:
1512
build:
@@ -25,18 +22,10 @@ jobs:
2522
uses: julia-actions/setup-julia@latest
2623
with:
2724
version: ${{ matrix.julia-version }}
28-
- name: Tag commit
29-
env:
30-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31-
run: deps/gh-auto-tag
3225
- name: Install dependencies
3326
run: julia -e 'using Pkg; Pkg.add("BinaryProvider"); Pkg.add("BinaryBuilder");'
3427
- name: Build
3528
env:
3629
BINARYBUILDER_DOWNLOADS_CACHE: downloads
3730
BINARYBUILDER_AUTOMATIC_APPLE: true
3831
run: julia deps/build_tarballs.jl
39-
- name: Upload to release
40-
env:
41-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42-
run: deps/gh-update-to-release

Diff for: deps/build.jl

+48-55
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,58 @@
1-
function find_prev_tag(tag)
2-
project_root = (@__DIR__) |> dirname |> abspath
3-
run(`git -C $project_root fetch --tags`)
4-
tags = readlines(`git -C $project_root tag`)
5-
sort!(tags)
6-
idx = indexin([tag], tags)[1]
7-
if idx == nothing return "NO-PREV-TAG" end
8-
return get(tags, idx - 1, "NO-PREV-TAG")
9-
end
1+
###
2+
### This file is generated by running
3+
### ` julia generate_buildjl.jl L/Libtask/build_tarballs.jl`
4+
### in the Yggdrasil root directory, with 2 updates:
5+
### 1. add prefix tp products, see https://github.com/JuliaPackaging/Yggdrasil#binaryproviderjl,
6+
### 2. products filter
7+
###
8+
9+
using BinaryProvider # requires BinaryProvider 0.3.0 or later
10+
11+
# Parse some basic command-line arguments
12+
const verbose = "--verbose" in ARGS
13+
const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr")))
14+
products = [
15+
LibraryProduct(prefix, ["libtask_v1_0"], :libtask_v1_0),
16+
LibraryProduct(prefix, ["libtask_v1_1"], :libtask_v1_1),
17+
LibraryProduct(prefix, ["libtask_v1_2"], :libtask_v1_2),
18+
LibraryProduct(prefix, ["libtask_v1_3"], :libtask_v1_3),
19+
]
1020

11-
# modify build-tmp.jl to only check correct version libs
12-
function install_products_filter(build_file)
13-
prod_filter = raw"""products_tmp = filter(products) do prod
21+
products_tmp = filter(products) do prod
1422
endswith(prod.libnames[1], "$(VERSION.major)_$(VERSION.minor)")
1523
end
1624
length(products_tmp) == 0 && (products_tmp = [products[end]])
1725
products = products_tmp
18-
"""
19-
lines = open(build_file) do io
20-
read(io, String) |> x -> split(x, "\n")
21-
end
22-
prod_in, prod_out, filter_written = false, false, false
23-
open(build_file, "w") do io
24-
for line in lines
25-
if occursin("products = [", line)
26-
prod_in = true
27-
end
28-
if prod_in && line == "]"
29-
prod_out = true
30-
end
31-
write(io, line * "\n")
32-
if prod_out && !filter_written
33-
write(io, prod_filter * "\n")
34-
filter_written = true
35-
end
36-
end
37-
end
38-
end
3926

40-
function include_build_script(version_str, try_prev=false)
41-
build_script_url = "https://github.com/TuringLang/Libtask.jl/releases/download/v$(version_str)/build_LibtaskDylib.v$(version_str).jl"
42-
build_script = joinpath(@__DIR__, "tmp-build.jl")
43-
build_script = try download(build_script_url, build_script) catch end
44-
if build_script == nothing && try_prev # no such file
45-
version_str = find_prev_tag("v$version_str") |> strip |> (x) -> lstrip(x, ['v'])
46-
return include_build_script(version_str, false)
47-
end
48-
install_products_filter(build_script)
49-
include(build_script)
27+
# Download binaries from hosted location
28+
bin_prefix = "https://github.com/JuliaBinaryWrappers/Libtask_jll.jl/releases/download/Libtask-v0.3.0+0"
29+
30+
# Listing of files generated by BinaryBuilder:
31+
download_info = Dict(
32+
Linux(:aarch64, libc=:glibc) => ("$bin_prefix/Libtask.v0.3.0.aarch64-linux-gnu.tar.gz", "e541c0df11d48b45e9334018c014ae0d012b75f92ffbc49fc4ab6eed35593731"),
33+
Linux(:i686, libc=:glibc) => ("$bin_prefix/Libtask.v0.3.0.i686-linux-gnu.tar.gz", "7f68bd21609adf35878f9b16f56151ab5f6f609999a40291ed270c1a4d0331a0"),
34+
Windows(:i686) => ("$bin_prefix/Libtask.v0.3.0.i686-w64-mingw32.tar.gz", "62950b53a892fb8c699ddbb4ccc9f19b12681f64fbf85a546345d5b0f23dc8d7"),
35+
MacOS(:x86_64) => ("$bin_prefix/Libtask.v0.3.0.x86_64-apple-darwin14.tar.gz", "fff6523dde93e6dc12b96a8bf1e3c35a78d8dba7cdc95cd0e5dd13225d1972df"),
36+
Linux(:x86_64, libc=:glibc) => ("$bin_prefix/Libtask.v0.3.0.x86_64-linux-gnu.tar.gz", "be4c590e8f13df31855be20f31c1c4ce98f499fc5173cd35c8e8b72b79e0dc5a"),
37+
Windows(:x86_64) => ("$bin_prefix/Libtask.v0.3.0.x86_64-w64-mingw32.tar.gz", "267473eb211e5060b98cede7f30336d2a7453542617521f27941d353dcfe42e8"),
38+
)
39+
40+
# Install unsatisfied or updated dependencies:
41+
unsatisfied = any(!satisfied(p; verbose=verbose) for p in products)
42+
dl_info = choose_download(download_info, platform_key_abi())
43+
if dl_info === nothing && unsatisfied
44+
# If we don't have a compatible .tar.gz to download, complain.
45+
# Alternatively, you could attempt to install from a separate provider,
46+
# build from source or something even more ambitious here.
47+
error("Your platform (\"$(Sys.MACHINE)\", parsed as \"$(triplet(platform_key_abi()))\") is not supported by this package!")
5048
end
5149

52-
function get_version_str()
53-
path = joinpath(@__DIR__, "../Project.toml")
54-
version_reg = r"version\s*=\s*\"(.*)\""
55-
open(path) do file
56-
lines = readlines(file)
57-
for line in lines
58-
m = match(version_reg, line)
59-
if isa(m, RegexMatch) return m.captures[1] end
60-
end
61-
end
50+
# If we have a download, and we are unsatisfied (or the version we're
51+
# trying to install is not itself installed) then load it up!
52+
if unsatisfied || !isinstalled(dl_info...; prefix=prefix)
53+
# Download and install binaries
54+
install(dl_info...; prefix=prefix, force=true, verbose=verbose)
6255
end
6356

64-
version_str = get_version_str() |> strip |> (x) -> lstrip(x, ['v'])
65-
include_build_script(version_str, true)
57+
# Write out a deps.jl file that will contain mappings for our products
58+
write_deps_file(joinpath(@__DIR__, "deps.jl"), products, verbose=verbose)

Diff for: deps/gh-auto-tag

-21
This file was deleted.

Diff for: deps/gh-update-to-release

-49
This file was deleted.

Diff for: src/Libtask.jl

+17-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,25 @@ module Libtask
33
export CTask, consume, produce, TArray, get, tzeros, tfill, TRef
44

55
# Try to load the binary dependency
6-
if isfile(joinpath(@__DIR__, ".." , "deps", "deps.jl"))
7-
include("../deps/deps.jl")
8-
check_deps()
9-
else
6+
const depsjl_path = joinpath(@__DIR__, "..", "deps", "deps.jl")
7+
if !isfile(depsjl_path)
108
error("Libtask is not properly installed. Please run `import Pkg; Pkg.build(\"Libtask\")`")
119
end
10+
include(depsjl_path)
11+
12+
function __init__()
13+
check_deps()
14+
end
15+
16+
@static if VERSION < v"1.0.9999" # (-, v1.1)
17+
const libtask = libtask_v1_0
18+
elseif VERSION < v"1.1.9999" # [v1.1, v1.2)
19+
const libtask = libtask_v1_1
20+
elseif VERSION < v"1.2.9999" # [v1.2, v1.3)
21+
const libtask = libtask_v1_2
22+
else # [v1.3, +)
23+
const libtask = libtask_v1_3
24+
end
1225

1326
include("taskcopy.jl")
1427
include("tarray.jl")

Diff for: src/taskcopy.jl

-10
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
# Utility function for self-copying mechanism
22

3-
@static if VERSION < v"1.0.9999" # (-, v1.1)
4-
const libtask = libtask_v1_0
5-
elseif VERSION < v"1.1.9999" # [v1.1, v1.2)
6-
const libtask = libtask_v1_1
7-
elseif VERSION < v"1.2.9999" # [v1.2, v1.3)
8-
const libtask = libtask_v1_2
9-
else # [v1.3, +)
10-
const libtask = libtask_v1_3
11-
end
12-
133
n_copies() = n_copies(current_task())
144
n_copies(t::Task) = begin
155
isa(t.storage, Nothing) && (t.storage = IdDict())

0 commit comments

Comments
 (0)