From 64dcc995b1fe0cd6ceb0db212a5ce067fd7eed96 Mon Sep 17 00:00:00 2001 From: aWZHY0yQH81uOYvH <32046476+aWZHY0yQH81uOYvH@users.noreply.github.com> Date: Fri, 24 Nov 2023 16:12:07 -0800 Subject: [PATCH] add patch script for `yosys-config` to replace baked-in paths with relative ones --- .github/scripts/patch_yosys_config.sh | 23 +++++++++++++++++++++++ .github/workflows/main.yml | 1 + 2 files changed, 24 insertions(+) create mode 100755 .github/scripts/patch_yosys_config.sh 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