|
| 1 | +function find_prev_tag(tag) |
| 2 | + project_root = (@__DIR__) |> dirname |> abspath |
| 3 | + tags = readlines(`git -C $project_root tag`) |
| 4 | + sort!(tags) |
| 5 | + idx = indexin([tag], tags)[1] |
| 6 | + if idx == nothing return "NO-PREV-TAG" end |
| 7 | + return get(tags, idx - 1, "NO-PREV-TAG") |
| 8 | +end |
| 9 | + |
| 10 | +function include_build_script(version_str, try_prev=false) |
| 11 | + build_script_url = "https://github.com/TuringLang/Libtask.jl/releases/download/v$(version_str)/build_LibtaskDylib.v$(version_str).jl" |
| 12 | + build_script = joinpath(@__DIR__, "tmp-build.jl") |
| 13 | + build_script = try download(build_script_url, build_script) catch end |
| 14 | + if build_script == nothing && try_prev # no such file |
| 15 | + version_str = find_prev_tag("v$version_str") |> strip |> (x) -> lstrip(x, ['v']) |
| 16 | + return include_build_script(version_str, false) |
| 17 | + end |
| 18 | + include(build_script) |
| 19 | +end |
| 20 | + |
1 | 21 | @static if Sys.isapple() |
2 | 22 | println("BinaryBuilder has a problem of its macOS support, so we build the dylib by ourselves.") |
3 | 23 | using Libdl |
4 | | - julia_root = Libdl.dlpath("libjulia") |> dirname |> dirname |>abspath |
| 24 | + julia_root = Libdl.dlpath("libjulia") |> dirname |> dirname |> abspath |
5 | 25 | LIBS = "$(julia_root)/lib" |
6 | 26 | LIBSJL = "$(julia_root)/lib/julia" |
7 | 27 | INCLUDES = "$(julia_root)/include/julia" |
|
18 | 38 | end; |
19 | 39 | else |
20 | 40 | version_str = read(joinpath(@__DIR__, "../VERSION"), String) |> strip |> (x) -> lstrip(x, ['v']) |
21 | | - # TODO CHANGE URL |
22 | | - # https://github.com/KDr2/Libtask.jl/releases/download/T001/build_LibtaskDylib.v1.0.0.jl |
23 | | - build_script_url = "https://github.com/TuringLang/Libtask.jl/releases/download/v$(version_str)/build_LibtaskDylib.v$(version_str).jl" |
24 | | - build_script = joinpath(@__DIR__, "tmp-build.jl") |
25 | | - download(build_script_url, build_script) |
26 | | - include(build_script) |
| 41 | + include_build_script(version_str, true) |
27 | 42 | end |
0 commit comments