Commit 67fcec5c authored by Volker Mische's avatar Volker Mische
Browse files

fix: build Rust parts from source if available

Old workflow:

 - Checkout submodule
 - Try to download precompiled assets
   - If downloading fails, compile the checked out submoduke

New workflow:

 - Download precompiled assets if submodule directory is empty
   - If download fails checkout the submodule
   - Compile the submodule
 - If the submodule directory is not empty, compile what is in there

The new workflow makes it easy to have a custom version of the submodule
checked out in the directory and getting everything built correctly.
parent 0aeff9f9
...@@ -7,9 +7,10 @@ source "install-shared.bash" ...@@ -7,9 +7,10 @@ source "install-shared.bash"
subm_dir="rust-fil-sector-builder" subm_dir="rust-fil-sector-builder"
git submodule update --init --recursive $subm_dir # If the directory is empty, try to download the pre-built tarballs or
# checkout the source code as fallback
if download_release_tarball tarball_path "${subm_dir}"; then if [ -z "$(ls -A $subm_dir)" ]; then
if download_release_tarball tarball_path "${subm_dir}"; then
tmp_dir=$(mktemp -d) tmp_dir=$(mktemp -d)
tar -C "$tmp_dir" -xzf "$tarball_path" tar -C "$tmp_dir" -xzf "$tarball_path"
...@@ -18,31 +19,38 @@ if download_release_tarball tarball_path "${subm_dir}"; then ...@@ -18,31 +19,38 @@ if download_release_tarball tarball_path "${subm_dir}"; then
cp "${tmp_dir}/lib/pkgconfig/sector_builder_ffi.pc" . cp "${tmp_dir}/lib/pkgconfig/sector_builder_ffi.pc" .
cp "${tmp_dir}/bin/paramcache" . cp "${tmp_dir}/bin/paramcache" .
else
exit 0
else
(>&2 echo "failed to find or obtain precompiled assets for ${subm_dir} - falling back to local build") (>&2 echo "failed to find or obtain precompiled assets for ${subm_dir} - falling back to local build")
build_from_source "${subm_dir}" git submodule update --init --recursive $subm_dir
fi
fi
# Directory is not empty, hence compiling whatever source is in there
(>&2 echo "building ${subm_dir} from source")
build_from_source "${subm_dir}"
mkdir -p include mkdir -p include
mkdir -p lib/pkgconfig mkdir -p lib/pkgconfig
find "${subm_dir}/target/release" -type f -name sector_builder_ffi.h -exec cp -- "{}" . \; find "${subm_dir}/target/release" -type f -name sector_builder_ffi.h -exec cp -- "{}" . \;
find "${subm_dir}/target/release" -type f -name libsector_builder_ffi.a -exec cp -- "{}" . \; find "${subm_dir}/target/release" -type f -name libsector_builder_ffi.a -exec cp -- "{}" . \;
find "${subm_dir}" -type f -name sector_builder_ffi.pc -exec cp -- "{}" . \; find "${subm_dir}" -type f -name sector_builder_ffi.pc -exec cp -- "{}" . \;
if [[ ! -f "./sector_builder_ffi.h" ]]; then if [[ ! -f "./sector_builder_ffi.h" ]]; then
(>&2 echo "failed to install sector_builder_ffi.h") (>&2 echo "failed to install sector_builder_ffi.h")
exit 1 exit 1
fi fi
if [[ ! -f "./libsector_builder_ffi.a" ]]; then if [[ ! -f "./libsector_builder_ffi.a" ]]; then
(>&2 echo "failed to install libsector_builder_ffi.a") (>&2 echo "failed to install libsector_builder_ffi.a")
exit 1 exit 1
fi fi
if [[ ! -f "./sector_builder_ffi.pc" ]]; then if [[ ! -f "./sector_builder_ffi.pc" ]]; then
(>&2 echo "failed to install sector_builder_ffi.pc") (>&2 echo "failed to install sector_builder_ffi.pc")
exit 1 exit 1
fi
(>&2 echo "WARNING: paramcache was not installed - you may wish to 'cargo install' it")
fi fi
(>&2 echo "WARNING: paramcache was not installed - you may wish to 'cargo install' it")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment