Skip to content

Commit

Permalink
Patch yosys-config to report accurate paths (#2167)
Browse files Browse the repository at this point in the history
Fixes #2164
  • Loading branch information
tgorochowik authored Nov 28, 2023
2 parents e520639 + a9e2e0d commit b8ed72d
Show file tree
Hide file tree
Showing 2 changed files with 77 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
54 changes: 54 additions & 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 Expand Up @@ -486,6 +487,59 @@ jobs:
grep ^ERROR log.txt || exit 0
exit 1
test-plugin-with-bundled-yosys:
name: Test With Bundled Yosys
runs-on: [self-hosted, Linux, X64]
container: debian:trixie
needs: build-binaries
env:
DEBIAN_FRONTEND: noninteractive
PIPX_BIN_DIR: /usr/local/bin

steps:
- uses: actions/checkout@v3
with:
submodules: false
fetch-depth: 1

- name: Install Prerequisites
run: |
apt update -qq
apt install -y --no-install-recommends pipx git
pipx install git+https://github.com/antmicro/tuttest#egg=tuttest
- name: Install Dependencies
run: |
# Don't need all the build dependencies, but will ensure everything
# yosys needs at runtime will be installed
tuttest README.md dependencies | bash -
- name: Download binaries
uses: actions/download-artifact@v2
with:
name: binaries-debian

- name: Extract
run: |
# Extract into a different directory than it was built in
# to ensure no path dependencies
tar --one-top-level -xf binaries-debian.tar
- name: Verify yosys-config
run: |
# Check that the directories reported by yosys-config exist
echo "yosys-config reports data directory is" $(binaries-debian/out/current/bin/yosys-config --datdir)
ls $(binaries-debian/out/current/bin/yosys-config --datdir) > /dev/null
- name: Load Plugin
run: |
binaries-debian/out/current/bin/yosys \
-Q -m systemverilog \
-p "help read_systemverilog" \
-p "help read_uhdm" 2>&1 | tee log.txt
grep ^ERROR log.txt || exit 0
exit 1
# needed for test linting
upload-event-file:
name: Upload GHA event file
Expand Down

0 comments on commit b8ed72d

Please sign in to comment.