Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

WIP: Pkg Artifacts with legacy mode #4

Merged
merged 11 commits into from
Jun 23, 2020
Merged
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/deps/build.log
/deps/build_*.jl
/deps/deps.jl
/deps/usr/
Manifest.toml
38 changes: 37 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: julia
dist: bionic

os:
- linux
Expand All @@ -17,8 +18,43 @@ branches:
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/ # release tags

notifications:
- email: false
email: false

jobs:
allow_failures:
- julia: nightly
include:
- &test-revdeps-short
stage: test revdeps
os: linux
julia: 1.0
script:
- julia --project=revdeps -e 'using Pkg; Pkg.develop(PackageSpec(path=Base.pwd())); Pkg.build("LoadFlint");'
- julia --project=revdeps -e 'using Pkg; Pkg.add("Nemo"); Pkg.build("Nemo"); Pkg.test("Nemo");'
- <<: *test-revdeps-short
os: osx
julia: 1.0
- <<: *test-revdeps-short
os: windows
julia: 1.0
- <<: *test-revdeps-short
os: windows
julia: 1.4
- &test-revdeps-full
stage: test revdeps full
os: linux
julia: 1.4
script:
- julia --project=revdeps -e 'using Pkg; Pkg.develop(PackageSpec(path=Base.pwd())); Pkg.build("LoadFlint");'
- julia --project=revdeps -e 'using Pkg; Pkg.add("Nemo"); Pkg.build("Nemo"); Pkg.test("Nemo");'
- julia --project=revdeps -e 'using Pkg; Pkg.add("Polymake"); Pkg.build("Polymake"); Pkg.test("Polymake");'
- julia --project=revdeps -e 'using Polymake; c = polytope.cube(3); using Nemo; CC, s = Nemo.PolynomialRing(ComplexField(256), "s"); println(s);'
- <<: *test-revdeps-full
os: linux
julia: 1.3
- <<: *test-revdeps-full
os: osx
julia: 1.4
- <<: *test-revdeps-full
os: osx
julia: 1.3
7 changes: 5 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name = "LoadFlint"
uuid = "472f376f-f1cf-461b-9ac1-d103423be9b7"
authors = ["Claus Fieker <[email protected]>"]
version = "0.1.3"
version = "0.1.4"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
BinaryProvider = "b99e7846-7c00-51b0-8f62-c81ae34c0232"
FLINT_jll = "e134572f-a0d5-539d-bddf-3cad8db41a82"
GMP_jll = "781609d7-10c4-51f6-84f2-b8444358ff6d"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
MPFR_jll = "3a97d323-0669-5f0c-9066-3539efd106a3"

[compat]
BinaryProvider = "0.4, 0.5"
Expand Down
298 changes: 43 additions & 255 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,273 +1,61 @@
using Libdl

using BinaryProvider

# Parse some basic command-line arguments
const verbose = "--verbose" in ARGS

issource_build = "NEMO_SOURCE_BUILD" in keys(ENV) && ENV["NEMO_SOURCE_BUILD"] == "1"

const prefixpath = joinpath(@__DIR__, "usr")

const wdir = joinpath(@__DIR__)

if !issource_build
# Dependencies that must be installed before this package can be built
dependencies = [
# This has to be in sync with the corresponding commit in the source build below (for flint, arb, antic)
"https://github.com/JuliaPackaging/Yggdrasil/releases/download/GMP-v6.1.2-1/build_GMP.v6.1.2.jl",
"https://github.com/JuliaPackaging/Yggdrasil/releases/download/MPFR-v4.0.2-1/build_MPFR.v4.0.2.jl",
"https://github.com/thofma/Flint2Builder/releases/download/f46562/build_libflint.v0.0.0-f465622699d5c4c22bb3617596f8ae86e4570652.jl"
]

const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr")))

products = []

for url in dependencies
build_file = joinpath(@__DIR__, basename(url))
if !isfile(build_file)
download(url, build_file)
end
end
# this file is only for julia older than 1.3

# Execute the build scripts for the dependencies in an isolated module to avoid overwriting
# any variables/constants here
for url in dependencies
build_file = joinpath(@__DIR__, basename(url))
m = @eval module $(gensym()); include($build_file); end
append!(products, m.products)
end

filenames = ["libgmp.la", "libgmpxx.la", "libmpfr.la"]
for filename in filenames
fpath = joinpath(prefixpath, "lib", filename)
txt = read(fpath, String)
open(fpath, "w") do f
write(f, replace(txt, "/workspace/destdir" => prefixpath))
end
end

else
println("Doing a source build for C dependencies...")
if "NEMO_BUILD_THREADS" in keys(ENV)
build_threads = ENV["NEMO_BUILD_THREADS"]
println("Using $build_threads threads for building as specified by NEMO_BUILD_THREADS.")
else
build_threads = Sys.CPU_THREADS
println("Using $build_threads threads (detected that many CPU threads).")
end

@show M4_VERSION = "1.4.17"
@show YASM_VERSION = "1.3.0"
@show MPIR_VERSION = "3.0.0-90740d8fdf03b941b55723b449831c52fd7f51ca"
@show MPFR_VERSION = "4.0.0"
@show FLINT_VERSION = "f465622699d5c4c22bb3617596f8ae86e4570652"
@show ARB_VERSION = "6c3738555d00b8b8b24a1f5e0065ef787432513c"
@show ANTIC_VERSION = "364f97edd9b6af537787113cf910f16d7bbc48a3"

if Sys.iswindows()
error("Source build not available on Windows")
end

println("Removing old binaries ...")

rm(prefixpath, force = true, recursive = true)
mkdir(prefixpath)
mkdir(joinpath(prefixpath, "lib"))

if Sys.isapple() && !("CC" in keys(ENV))
ENV["CC"] = "clang"
ENV["CXX"] = "clang++"
end

LDFLAGS = "-Wl,-rpath,$prefixpath/lib -Wl,-rpath,\$\$ORIGIN/../share/julia/site/v$(VERSION.major).$(VERSION.minor)/Nemo/local/lib"
DLCFLAGS = "-fPIC -fno-common"

cd(wdir)
using Libdl

try
run(`m4 --version`)
catch
println("Building m4 ... ")
M4_FILE = "m4-" * M4_VERSION * ".tar.bz2"
download("http://ftp.gnu.org/gnu/m4/$M4_FILE", joinpath(wdir, "$M4_FILE"))
if "FLINT_PATH" in keys(ENV)

run(`tar -xvf $M4_FILE`)
run(`rm $M4_FILE`)
cd(joinpath("$wdir", "m4-$M4_VERSION"))
run(`./configure --prefix=$prefixpath`)
run(`make`)
run(`make install`)
println("DONE")
if VERSION >= v"1.3.0-rc4"
error("please use Pkg Overrides.toml for custom flint installations in julia >= 1.3")
end

cd(wdir)

# install yasm

if !ispath(joinpath(wdir, "yasm-$YASM_VERSION"))
println("Building yasm ... ")
YASM_FILE = "yasm-" * YASM_VERSION * ".tar.gz"
download("https://github.com/yasm/yasm/archive/v$(YASM_VERSION).tar.gz", YASM_FILE)
run(`tar -xvf $YASM_FILE`)
run(`rm $YASM_FILE`)
cd(joinpath("$wdir","yasm-$YASM_VERSION"))
run(`./autogen.sh`)
run(`./configure`)
run(`make`)
println("DONE")
end

cd(wdir)

# install GMP/MPIR

MPIR_FILE = "mpir-" * MPIR_VERSION * ".tar.bz2"

if !ispath(joinpath(wdir, "mpir-$MPIR_VERSION"))
println("Downloading MPIR sources ... ")
download("http://nemocas.org/binaries/$MPIR_FILE", joinpath(wdir, MPIR_FILE))
println("DONE")
end

println("Building MPIR ... ")
if isfile(joinpath(wdir, MPIR_FILE))
run(`tar -xvf $MPIR_FILE`)
run(`rm $MPIR_FILE`)
end
cd("$wdir/mpir-$MPIR_VERSION")
try
run(`m4 --version`)
run(`./configure --with-yasm=$wdir/yasm-$YASM_VERSION/yasm --prefix=$prefixpath --enable-gmpcompat --disable-static --enable-shared`)
catch
run(`./configure --with-yasm=$wdir/yasm-$YASM_VERSION/yasm --prefix=$prefixpath M4=$prefixpath/bin/m4 --enable-gmpcompat --disable-static --enable-shared`)
end
run(`make -j$build_threads`)
run(`make install`)
cd(wdir)
run(`rm -rf bin`)
println("DONE")

cd(wdir)

# install MPFR

MPFR_FILE = "mpfr-" * MPFR_VERSION * ".tar.bz2"

if !ispath(joinpath(wdir, "mpfr-$MPFR_VERSION"))
println("Downloading MPFR sources ... ")
download("http://ftp.vim.org/ftp/gnu/mpfr/$MPFR_FILE", joinpath(wdir, MPFR_FILE))

println("DONE")
end

println("Building MPFR ... ")
if isfile(joinpath(wdir, MPFR_FILE))
run(`tar -xvf $MPFR_FILE`)
run(`rm $MPFR_FILE`)
end
cd("$wdir/mpfr-$MPFR_VERSION")
withenv("LD_LIBRARY_PATH"=>"$prefixpath/lib", "LDFLAGS"=>LDFLAGS) do
run(`./configure --prefix=$prefixpath --with-gmp=$prefixpath --disable-static --enable-shared`)
run(`make -j$build_threads`)
run(`make install`)
end
println("DONE")

cd(wdir)

# INSTALL FLINT
flint_path = ENV["FLINT_PATH"]
if !isfile(flint_path)
error("FLINT_PATH: file does not exists")
end

try
println("Cloning flint2 ... ")
run(`git clone https://github.com/wbhart/flint2.git`)
cd(joinpath("$wdir", "flint2"))
run(`git checkout $FLINT_VERSION`)
cd(wdir)
catch
if ispath(joinpath("$wdir", "flint2"))
open(`patch -R --forward -d flint2 -r -`, "r", open("../deps-PIE-ftbfs.patch"))
cd(joinpath("$wdir", "flint2"))
run(`git fetch`)
run(`git checkout $FLINT_VERSION`)
cd(wdir)
end
end
open(`patch --forward -d flint2 -r -`, "r", open("../deps-PIE-ftbfs.patch"))
println("DONE")
open(joinpath(@__DIR__,"deps.jl"), "w") do f
println(f, """
using Libdl
libflint = "$flint_path"
if Libdl.dlopen_e(libflint) in (C_NULL, nothing)
error("$(libflint) cannot be opened, Please check FLINT_PATH environment variable and re-run Pkg.build("LoadFlint"), then restart Julia.")
end
# there must be some libgmp loaded for libflint
libgmp = filter(x->occursin(r"libgmp[.-]", x), dllist())[1]
libmpfr = filter(x->occursin(r"libmpfr[.-]", x), dllist())[1]

println("Building flint ... ")
cd(joinpath("$wdir", "flint2"))
withenv("LD_LIBRARY_PATH"=>"$prefixpath/lib", "LDFLAGS"=>LDFLAGS) do
run(`./configure --prefix=$prefixpath --disable-static --enable-shared --with-mpir=$prefixpath --with-mpfr=$prefixpath`)
run(`make -j$build_threads`)
run(`make install`)
end
""")
end

println("DONE")
elseif VERSION < v"1.3.0-rc4"

cd(wdir)
using BinaryProvider

# INSTALL ARB
# Parse some basic command-line arguments
const verbose = "--verbose" in ARGS

println("Cloning arb ... ")
try
run(`git clone https://github.com/fredrik-johansson/arb.git`)
cd(joinpath("$wdir", "arb"))
run(`git checkout $ARB_VERSION`)
cd(wdir)
catch
if ispath(joinpath("$wdir", "arb"))
#open(`patch -R --forward -d arb -r -`, "r", open("../deps-PIE-ftbfs.patch"))
cd(joinpath("$wdir", "arb"))
run(`git fetch`)
run(`git checkout $ARB_VERSION`)
cd(wdir)
end
end
println("DONE")
# GMP and MPFR might not be needed on unix as julia should have those loaded already
# but on windows flint will not load without them so we put leave them here for simplicity
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# but on windows flint will not load without them so we put leave them here for simplicity
# but on windows flint will not load without them so we leave them here for simplicity

dependencies = [
# This has to be in sync with the jll packages (using generate_build.jl and build_tarballs.jl from Yggdrasil)
"build_GMP.v6.1.2.jl",
"build_MPFR.v4.0.2.jl",
"build_FLINT.v2.6.0.jl",
]

println("Building arb ... ")
cd(joinpath("$wdir", "arb"))
withenv("LD_LIBRARY_PATH"=>"$prefixpath/lib", "LDFLAGS"=>LDFLAGS) do
run(`./configure --prefix=$prefixpath --disable-static --enable-shared --with-mpir=$prefixpath --with-mpfr=$prefixpath --with-flint=$prefixpath`)
run(`make -j$build_threads`)
run(`make install`)
end
println("DONE")
const prefix = Prefix(get([a for a in ARGS if a != "--verbose"], 1, joinpath(@__DIR__, "usr")))

cd(wdir)
products = []

# INSTALL ANTIC
# Execute the build scripts for the dependencies in an isolated module to avoid overwriting
# any variables/constants here
for file in dependencies
build_file = joinpath(@__DIR__, file)
m = @eval module $(gensym()); include($build_file); end
append!(products, m.products)
end

println("Cloning antic ... ")
try
run(`git clone https://github.com/wbhart/antic.git`)
cd(joinpath("$wdir", "antic"))
run(`git checkout $ANTIC_VERSION`)
cd(wdir)
catch
if ispath(joinpath("$wdir", "antic"))
#open(`patch -R --forward -d antic -r -`, "r", open("../deps-PIE-ftbfs.patch"))
cd(joinpath("$wdir", "antic"))
run(`git fetch`)
run(`git checkout $ANTIC_VERSION`)
cd(wdir)
end
end
println("DONE")
write_deps_file(joinpath(@__DIR__, "deps.jl"), Array{Product,1}(products), verbose=verbose)

println("Building antic ... ")
cd(joinpath("$wdir", "antic"))
withenv("LD_LIBRARY_PATH"=>"$prefixpath/lib", "LDFLAGS"=>LDFLAGS) do
run(`./configure --prefix=$prefixpath --disable-static --enable-shared --with-mpir=$prefixpath --with-mpfr=$prefixpath --with-flint=$prefixpath`)
run(`make -j$build_threads`)
run(`make install`)
end
println("DONE")
cd(wdir)
end

push!(Libdl.DL_LOAD_PATH, joinpath(prefixpath, "lib"), joinpath(prefixpath, "bin"))

Loading