From 5a5e83e11cd674b5c997661f8d5f1cae6486f4b0 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 26 Sep 2022 11:35:07 +0200 Subject: [PATCH] GHDL for darwin-x64 --- .github/workflows/darwin-x64.yml | 79 +++++++++++++++++++++++++++- default/rules/ghdl.py | 2 +- default/rules/yosys.py | 2 +- default/scripts/ghdl-yosys-plugin.sh | 7 ++- default/scripts/ghdl.sh | 9 +++- scripts/package-darwin.sh | 4 ++ 6 files changed, 97 insertions(+), 6 deletions(-) diff --git a/.github/workflows/darwin-x64.yml b/.github/workflows/darwin-x64.yml index d8e8708..b4bf763 100644 --- a/.github/workflows/darwin-x64.yml +++ b/.github/workflows/darwin-x64.yml @@ -149,6 +149,79 @@ jobs: tag: bucket-darwin-x64 artifacts: "darwin-x64-yosys.tgz" token: ${{ secrets.GITHUB_TOKEN }} + darwin-x64-ghdl: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v2 + with: + repository: 'yosyshq/oss-cad-suite-build' + - name: Cache sources + id: cache-sources + uses: actions/cache@v2 + with: + path: _sources + key: cache-sources-ghdl + - name: Download previous build + run: | + URL="https://github.com/yosyshq/oss-cad-suite-build/releases/download/bucket-darwin-x64/darwin-x64-ghdl.tgz" + if wget --spider "${URL}" 2>/dev/null; then + wget -qO- "${URL}" | tar xvfz - + else + echo "Previous version not found in bucket" + fi + - name: Build + run: ./builder.py build --arch=darwin-x64 --target=ghdl --single --tar + - uses: ncipollo/release-action@v1 + if: hashFiles('darwin-x64-ghdl.tgz') != '' + with: + allowUpdates: True + prerelease: True + omitBody: True + omitBodyDuringUpdate: True + omitNameDuringUpdate: True + tag: bucket-darwin-x64 + artifacts: "darwin-x64-ghdl.tgz" + token: ${{ secrets.GITHUB_TOKEN }} + darwin-x64-ghdl-yosys-plugin: + runs-on: ubuntu-latest + continue-on-error: true + needs: [ darwin-x64-ghdl, darwin-x64-yosys ] + steps: + - uses: actions/checkout@v2 + with: + repository: 'yosyshq/oss-cad-suite-build' + - name: Cache sources + id: cache-sources + uses: actions/cache@v2 + with: + path: _sources + key: cache-sources-ghdl-yosys-plugin + - name: Download previous build + run: | + URL="https://github.com/yosyshq/oss-cad-suite-build/releases/download/bucket-darwin-x64/darwin-x64-ghdl-yosys-plugin.tgz" + if wget --spider "${URL}" 2>/dev/null; then + wget -qO- "${URL}" | tar xvfz - + else + echo "Previous version not found in bucket" + fi + - name: Download darwin-x64-ghdl + run: wget -qO- "https://github.com/yosyshq/oss-cad-suite-build/releases/download/bucket-darwin-x64/darwin-x64-ghdl.tgz" | tar xvfz - + - name: Download darwin-x64-yosys + run: wget -qO- "https://github.com/yosyshq/oss-cad-suite-build/releases/download/bucket-darwin-x64/darwin-x64-yosys.tgz" | tar xvfz - + - name: Build + run: ./builder.py build --arch=darwin-x64 --target=ghdl-yosys-plugin --single --tar + - uses: ncipollo/release-action@v1 + if: hashFiles('darwin-x64-ghdl-yosys-plugin.tgz') != '' + with: + allowUpdates: True + prerelease: True + omitBody: True + omitBodyDuringUpdate: True + omitNameDuringUpdate: True + tag: bucket-darwin-x64 + artifacts: "darwin-x64-ghdl-yosys-plugin.tgz" + token: ${{ secrets.GITHUB_TOKEN }} darwin-x64-nextpnr-generic: runs-on: ubuntu-latest continue-on-error: true @@ -1657,7 +1730,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} darwin-x64-default: runs-on: ubuntu-latest - needs: [ darwin-x64-aiger, darwin-x64-avy, darwin-x64-bitwuzla, darwin-x64-boolector, darwin-x64-cocotb, darwin-x64-cvc4, darwin-x64-cvc5, darwin-x64-dfu-util, darwin-x64-ecpdap, darwin-x64-ecpprog, darwin-x64-flask, darwin-x64-fujprog, darwin-x64-graphviz, darwin-x64-gtkwave, darwin-x64-iceprogduino, darwin-x64-icesprog, darwin-x64-icestorm, darwin-x64-iverilog, darwin-x64-mcy, darwin-x64-nextpnr-ecp5, darwin-x64-nextpnr-generic, darwin-x64-nextpnr-ice40, darwin-x64-nextpnr-machxo2, darwin-x64-nextpnr-nexus, darwin-x64-openfpgaloader, darwin-x64-openocd, darwin-x64-pono, darwin-x64-prjoxide, darwin-x64-prjtrellis, darwin-x64-pyhdl, darwin-x64-python-programmers, darwin-x64-python3, darwin-x64-sby, darwin-x64-sby-gui, darwin-x64-system-resources, darwin-x64-utils, darwin-x64-verilator, darwin-x64-xdot, darwin-x64-yices, darwin-x64-yosys, darwin-x64-z3 ] + needs: [ darwin-x64-aiger, darwin-x64-avy, darwin-x64-bitwuzla, darwin-x64-boolector, darwin-x64-cocotb, darwin-x64-cvc4, darwin-x64-cvc5, darwin-x64-dfu-util, darwin-x64-ecpdap, darwin-x64-ecpprog, darwin-x64-flask, darwin-x64-fujprog, darwin-x64-ghdl, darwin-x64-ghdl-yosys-plugin, darwin-x64-graphviz, darwin-x64-gtkwave, darwin-x64-iceprogduino, darwin-x64-icesprog, darwin-x64-icestorm, darwin-x64-iverilog, darwin-x64-mcy, darwin-x64-nextpnr-ecp5, darwin-x64-nextpnr-generic, darwin-x64-nextpnr-ice40, darwin-x64-nextpnr-machxo2, darwin-x64-nextpnr-nexus, darwin-x64-openfpgaloader, darwin-x64-openocd, darwin-x64-pono, darwin-x64-prjoxide, darwin-x64-prjtrellis, darwin-x64-pyhdl, darwin-x64-python-programmers, darwin-x64-python3, darwin-x64-sby, darwin-x64-sby-gui, darwin-x64-system-resources, darwin-x64-utils, darwin-x64-verilator, darwin-x64-xdot, darwin-x64-yices, darwin-x64-yosys, darwin-x64-z3 ] steps: - name: Get current date id: date @@ -1689,6 +1762,10 @@ jobs: run: wget -qO- "https://github.com/yosyshq/oss-cad-suite-build/releases/download/bucket-darwin-x64/darwin-x64-flask.tgz" | tar xvfz - - name: Download darwin-x64-fujprog run: wget -qO- "https://github.com/yosyshq/oss-cad-suite-build/releases/download/bucket-darwin-x64/darwin-x64-fujprog.tgz" | tar xvfz - + - name: Download darwin-x64-ghdl + run: wget -qO- "https://github.com/yosyshq/oss-cad-suite-build/releases/download/bucket-darwin-x64/darwin-x64-ghdl.tgz" | tar xvfz - + - name: Download darwin-x64-ghdl-yosys-plugin + run: wget -qO- "https://github.com/yosyshq/oss-cad-suite-build/releases/download/bucket-darwin-x64/darwin-x64-ghdl-yosys-plugin.tgz" | tar xvfz - - name: Download darwin-x64-graphviz run: wget -qO- "https://github.com/yosyshq/oss-cad-suite-build/releases/download/bucket-darwin-x64/darwin-x64-graphviz.tgz" | tar xvfz - - name: Download darwin-x64-gtkwave diff --git a/default/rules/ghdl.py b/default/rules/ghdl.py index 61993f3..3396d36 100644 --- a/default/rules/ghdl.py +++ b/default/rules/ghdl.py @@ -11,5 +11,5 @@ Target( name = 'ghdl', sources = [ 'ghdl' ], - arch = [ 'linux-x64' ], + arch = [ 'linux-x64', 'darwin-x64' ], ) diff --git a/default/rules/yosys.py b/default/rules/yosys.py index 80c591a..2ab3320 100644 --- a/default/rules/yosys.py +++ b/default/rules/yosys.py @@ -51,7 +51,7 @@ name = 'ghdl-yosys-plugin', sources = [ 'ghdl-yosys-plugin' ], dependencies = [ 'ghdl', 'yosys' ], - arch = [ 'linux-x64' ], + arch = [ 'linux-x64', 'darwin-x64' ], ) SourceLocation( diff --git a/default/scripts/ghdl-yosys-plugin.sh b/default/scripts/ghdl-yosys-plugin.sh index 6a421f1..5423ab6 100644 --- a/default/scripts/ghdl-yosys-plugin.sh +++ b/default/scripts/ghdl-yosys-plugin.sh @@ -1,5 +1,10 @@ cd ghdl-yosys-plugin sed -i 's,/yosyshq/share,/yosys/yosyshq/share,g' ../yosys/yosyshq/bin/yosys-config -make GHDL=../ghdl/yosyshq/bin/ghdl YOSYS_CONFIG=../yosys/yosyshq/bin/yosys-config CFLAGS="-I ../yosys/yosyshq/share/yosys/include" +if [ ${ARCH} == 'darwin-x64' ]; then + sed -i '11,13d' Makefile + make GHDL=../ghdl/yosyshq/bin/ghdl YOSYS_CONFIG=../yosys/yosyshq/bin/yosys-config CFLAGS="-I ../yosys/yosyshq/share/yosys/include" LIBGHDL_LIB="${BUILD_DIR}/ghdl${INSTALL_PREFIX}/lib/libghdl-3_0_0_dev.dylib" LIBGHDL_INC="${BUILD_DIR}/ghdl${INSTALL_PREFIX}/include/" +else + make GHDL=../ghdl/yosyshq/bin/ghdl YOSYS_CONFIG=../yosys/yosyshq/bin/yosys-config CFLAGS="-I ../yosys/yosyshq/share/yosys/include" +fi mkdir -p ${OUTPUT_DIR}${INSTALL_PREFIX}/share/yosys/plugins cp -rf ghdl.so ${OUTPUT_DIR}${INSTALL_PREFIX}/share/yosys/plugins/. \ No newline at end of file diff --git a/default/scripts/ghdl.sh b/default/scripts/ghdl.sh index 0c84d20..059e9d1 100644 --- a/default/scripts/ghdl.sh +++ b/default/scripts/ghdl.sh @@ -9,8 +9,13 @@ if [ ${ARCH} == 'linux-arm' ] || [ ${ARCH} == 'linux-arm64' ] || [ ${ARCH} == 'l param=--with-llvm-config='llvm-config' LDFLAGS=-L/usr/lib/${CROSS_NAME} elif [ ${ARCH} == 'darwin-x64' ]; then - export PATH="$PATH:/opt/gnat/bin" - export GNAT_LARGS="-static-libgcc" + wget https://github.com/ghdl/ghdl/releases/download/nightly/ghdl-macos-10.15-mcode.tgz + mkdir -p ${OUTPUT_DIR}${INSTALL_PREFIX} + tar xvfz ghdl-macos-10.15-mcode.tgz -C ${OUTPUT_DIR}${INSTALL_PREFIX} + install_name_tool -id @executable_path/../lib/libghdl-3_0_0_dev.dylib ${OUTPUT_DIR}${INSTALL_PREFIX}/lib/libghdl-3_0_0_dev.dylib + wget https://github.com/mmicko/macos-resources/releases/download/v2/libgnat-2019.dylib + cp libgnat-2019.dylib ${OUTPUT_DIR}${INSTALL_PREFIX}/lib/. + exit 0 elif [ ${ARCH} == 'windows-x64' ]; then sed -i 's,grt-all libs.vhdl.llvm all.vpi,grt-all all.vpi,g' Makefile.in sed -i 's,install.llvm.program install.vhdllib,install.llvm.program ,g' Makefile.in diff --git a/scripts/package-darwin.sh b/scripts/package-darwin.sh index 789b8ac..2bedac4 100644 --- a/scripts/package-darwin.sh +++ b/scripts/package-darwin.sh @@ -184,6 +184,10 @@ for binfile in $(find lib -type f | xargs file | grep Mach-O | grep bundle | cut echo $binfile dylibbundler -of -b -x $binfile -p @executable_path/../lib -d ${OUTPUT_DIR}${INSTALL_PREFIX}/lib done +for binfile in $(find share -type f | xargs file | grep Mach-O | grep shared | cut -f1 -d:); do + echo $binfile + dylibbundler -of -b -x $binfile -p @executable_path/../lib -d ${OUTPUT_DIR}${INSTALL_PREFIX}/lib +done if [ ${PRELOAD} == 'True' ]; then dylibbundler -of -b -x lib/libtabby.dylib -p @executable_path/../lib -d ${OUTPUT_DIR}${INSTALL_PREFIX}/lib fi