Skip to content

Commit b5ce072

Browse files
author
KDr2
committed
build commit which changes VERION but not tagged
If no dylib releases for current tag, try the previous release
1 parent 63162a7 commit b5ce072

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

deps/build.jl

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,27 @@
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+
121
@static if Sys.isapple()
222
println("BinaryBuilder has a problem of its macOS support, so we build the dylib by ourselves.")
323
using Libdl
4-
julia_root = Libdl.dlpath("libjulia") |> dirname |> dirname |>abspath
24+
julia_root = Libdl.dlpath("libjulia") |> dirname |> dirname |> abspath
525
LIBS = "$(julia_root)/lib"
626
LIBSJL = "$(julia_root)/lib/julia"
727
INCLUDES = "$(julia_root)/include/julia"
@@ -18,10 +38,5 @@
1838
end;
1939
else
2040
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)
2742
end

0 commit comments

Comments
 (0)