Skip to content

Commit

Permalink
add patch script for yosys-config
Browse files Browse the repository at this point in the history
to replace baked-in paths with relative ones
  • Loading branch information
aWZHY0yQH81uOYvH committed Nov 25, 2023
1 parent e520639 commit 64dcc99
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/scripts/patch_yosys_config.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 64dcc99

Please sign in to comment.