diff --git a/.github/scripts/patch_yosys_config.sh b/.github/scripts/patch_yosys_config.sh new file mode 100755 index 000000000..5c6ed9127 --- /dev/null +++ b/.github/scripts/patch_yosys_config.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Patches any yosys-config scripts to replace the fixed build path with a relative one +# Inspired by https://github.com/YosysHQ/oss-cad-suite-build/blob/f41b9ae59c6afe323b41a069da48c3835f0846b0/scripts/package-linux.sh#L248 + +search_path="${1:-.}" + +for yosysconfig in $(find "$search_path" -type f -name yosys-config); do + echo "Fixing paths in" "$yosysconfig" + + patch -ns "$yosysconfig" << EOT +1a2 +> install_prefix="\$(readlink -f "\$(dirname "\${BASH_SOURCE[0]}")/..")" +EOT + + # Get current fixed prefix that is already in the file + old_prefix="$(readlink -f "$(dirname "$yosysconfig")/..")" + + sed -i "s,\"$old_prefix,\"\$install_prefix,g" "$yosysconfig" + sed -i "s,'$old_prefix,\"\$install_prefix\"',g" "$yosysconfig" + sed -i "s,$old_prefix,\"\$install_prefix\",g" "$yosysconfig" + +done diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 42bf5f1e8..ca48f8ec5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -161,6 +161,7 @@ jobs: export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -rR -j$(nproc) -Oline -f build_binaries.mk ${BUILD_BINARIES_ARGS} \ install-surelog install-yosys install-plugin + ./.github/scripts/patch_yosys_config.sh out # By default actions/upload-artifact@v2 do not preserve file permissions # tar directory to workaround this issue # See https://github.com/actions/upload-artifact/issues/38