Skip to content

Commit

Permalink
[polymake] move dependency tree artifact generator from init_block to…
Browse files Browse the repository at this point in the history
… jl script (#2092)

for compatibility with julia 1.6+
(then we can use it in Polymake.jl but also in the ci for libpolymake_julia)
  • Loading branch information
benlorenz authored Nov 13, 2020
1 parent ab88c17 commit aa1cdd5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 29 deletions.
36 changes: 7 additions & 29 deletions P/polymake/build_tarballs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using BinaryBuilder, Pkg

name = "polymake"
version = v"4.2.0"
version = v"4.2.1"

# Collection of sources required to build polymake
sources = [
Expand Down Expand Up @@ -72,7 +72,7 @@ ninja -v -C build/Opt install
if [[ $target == *darwin* ]]; then
atomic_patch -R -p1 ../patches/polymake-cross-build.patch
fi
install -m 444 -D support/*.pl $prefix/share/polymake/support/
install -m 644 -D support/*.pl $prefix/share/polymake/support/
# replace miniperl
sed -i -e "s/miniperl-for-build/perl/" ${libdir}/polymake/config.ninja ${bindir}/polymake*
Expand All @@ -88,6 +88,9 @@ sed -e "s#${prefix}#\${prefix}#g" ${libdir}/polymake/config.ninja > ${libdir}/po
# cleanup symlink tree
rm -rf ${prefix}/deps
# copy julia script to generate dependency-tree at load time
cp ../patches/generate_deps_tree.jl $prefix/share/polymake
install_license COPYING
"""

Expand All @@ -105,6 +108,7 @@ products = [
LibraryProduct("libpolymake-apps-rt", :libpolymake_apps_rt; dont_dlopen=true)
ExecutableProduct("polymake", :polymake)
ExecutableProduct("polymake-config", Symbol("polymake_config"))
FileProduct("share/polymake/generate_deps_tree.jl", :generate_deps_tree)
]

# Dependencies that must be installed before this package can be built
Expand All @@ -123,31 +127,5 @@ dependencies = [
]

# Build the tarballs, and possibly a `build.jl` as well.
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version=v"7", init_block="""
mutable_artifacts_toml = joinpath(dirname(@__DIR__), "MutableArtifacts.toml")
polymake_tree = "polymake_tree"
polymake_tree_hash = artifact_hash(polymake_tree, mutable_artifacts_toml)
# create a directory tree for polymake with links to dependencies
# looking similiar to the tree in the build environment
# for compiling wrappers at run-time
polymake_tree_hash = create_artifact() do art_dir
mkpath(joinpath(art_dir,"deps"))
for dep in [FLINT_jll, GMP_jll, MPFR_jll, PPL_jll, Perl_jll, bliss_jll, boost_jll, cddlib_jll, lrslib_jll, normaliz_jll]
symlink(dep.artifact_dir, joinpath(art_dir,"deps","\$dep"))
end
for dir in readdir(polymake_jll.artifact_dir)
symlink(joinpath(polymake_jll.artifact_dir,dir), joinpath(art_dir,dir))
end
end
bind_artifact!(mutable_artifacts_toml,
polymake_tree,
polymake_tree_hash;
force=true
)
# Point polymake to our custom tree
ENV["POLYMAKE_DEPS_TREE"] = artifact_path(polymake_tree_hash)
""")
build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; preferred_gcc_version=v"7")

39 changes: 39 additions & 0 deletions P/polymake/bundled/patches/generate_deps_tree.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Pkg.Artifacts
using polymake_jll

function prepare_deps_tree()
mutable_artifacts_toml = joinpath(dirname(pathof(polymake_jll)), "..", "MutableArtifacts.toml")
polymake_tree = "polymake_tree"
polymake_tree_hash = artifact_hash(polymake_tree, mutable_artifacts_toml)

# create a directory tree for polymake with links to dependencies
# looking similiar to the tree in the build environment
# for compiling wrappers at run-time
polymake_tree_hash = create_artifact() do art_dir
mkpath(joinpath(art_dir,"deps"))
for dep in [polymake_jll.FLINT_jll,
polymake_jll.GMP_jll,
polymake_jll.MPFR_jll,
polymake_jll.PPL_jll,
polymake_jll.Perl_jll,
polymake_jll.bliss_jll,
polymake_jll.boost_jll,
polymake_jll.cddlib_jll,
polymake_jll.lrslib_jll,
polymake_jll.normaliz_jll]
symlink(dep.artifact_dir, joinpath(art_dir,"deps","$dep"))
end
for dir in readdir(polymake_jll.artifact_dir)
symlink(joinpath(polymake_jll.artifact_dir,dir), joinpath(art_dir,dir))
end
end

bind_artifact!(mutable_artifacts_toml,
polymake_tree,
polymake_tree_hash;
force=true
)

# Point polymake to our custom tree
return artifact_path(polymake_tree_hash)
end

0 comments on commit aa1cdd5

Please sign in to comment.