From 0a536417f6be75fcf26720767a61bd1f57a685b5 Mon Sep 17 00:00:00 2001 From: Baruch Sterin Date: Sun, 23 Jan 2022 00:16:10 +0100 Subject: Build CMake on GitHub Actions Also, resolve CMake build problems on macOS: Pass CMAKE_OSX_SYSROOT as an environment variable SDKROOT when buildind the arch_flags executable. --- .github/disabled-workflows/build-posix.yml | 62 ---------------------------- .github/disabled-workflows/build-windows.yml | 48 --------------------- .github/workflows/build-posix-cmake.yml | 6 +-- .github/workflows/build-posix.yml | 62 ++++++++++++++++++++++++++++ .github/workflows/build-windows.yml | 48 +++++++++++++++++++++ CMakeLists.txt | 5 +++ README.md | 5 ++- 7 files changed, 121 insertions(+), 115 deletions(-) delete mode 100644 .github/disabled-workflows/build-posix.yml delete mode 100644 .github/disabled-workflows/build-windows.yml create mode 100644 .github/workflows/build-posix.yml create mode 100644 .github/workflows/build-windows.yml diff --git a/.github/disabled-workflows/build-posix.yml b/.github/disabled-workflows/build-posix.yml deleted file mode 100644 index aa97aca2..00000000 --- a/.github/disabled-workflows/build-posix.yml +++ /dev/null @@ -1,62 +0,0 @@ -on: [push] - -jobs: - - build-posix: - strategy: - matrix: - os: [macos-latest, ubuntu-latest] - use_namespace: [false, true] - - runs-on: ${{ matrix.os }} - - env: - MAKE_ARGS: ${{ matrix.use_namespace && 'ABC_USE_NAMESPACE=xxx' || '' }} - DEMO_ARGS: ${{ matrix.use_namespace && '-DABC_NAMESPACE=xxx' || '' }} - DEMO_GCC: ${{ matrix.use_namespace && 'g++ -x c++' || 'gcc' }} - - steps: - - - name: Git Checkout - uses: actions/checkout@v2 - with: - submodules: recursive - - - name: Install brew dependencies - run: | - HOMEBREW_NO_AUTO_UPDATE=1 brew install readline - if: ${{ contains(matrix.os, 'macos') }} - - - name: Install APT dependencies - run: | - sudo apt install -y libreadline-dev - if: ${{ !contains(matrix.os, 'macos') }} - - - name: Build Executable - run: | - make -j3 ${MAKE_ARGS} abc - - - name: Test Executable - run: | - ./abc -c "r i10.aig; b; ps; b; rw -l; rw -lz; b; rw -lz; b; ps; cec" - - - name: Build Library - run: | - make -j3 ${MAKE_ARGS} libabc.a - - - name: Test Library - run: | - ${DEMO_GCC} ${DEMO_ARGS} -Wall -c src/demo.c -o demo.o - g++ -o demo demo.o libabc.a -lm -ldl -lreadline -lpthread - ./demo i10.aig - - - name: Stage Executable - run: | - mkdir staging - cp abc libabc.a staging/ - - - name: Upload pacakge artifact - uses: actions/upload-artifact@v1 - with: - name: package - path: staging/ diff --git a/.github/disabled-workflows/build-windows.yml b/.github/disabled-workflows/build-windows.yml deleted file mode 100644 index 6312780d..00000000 --- a/.github/disabled-workflows/build-windows.yml +++ /dev/null @@ -1,48 +0,0 @@ -on: [push] - -jobs: - - build-windows: - - runs-on: windows-latest - - steps: - - - name: Git Checkout - uses: actions/checkout@v2 - with: - submodules: recursive - - - name: Process project files to compile on Github Actions - run: | - sed -i 's#ABC_USE_PTHREADS\"#ABC_DONT_USE_PTHREADS\" /D \"_ALLOW_KEYWORD_MACROS=1\"#g' *.dsp - awk 'BEGIN { del=0; } /# Begin Group "uap"/ { del=1; } /# End Group/ { if( del > 0 ) {del=0; next;} } del==0 {print;} ' abclib.dsp > tmp.dsp - copy tmp.dsp abclib.dsp - del tmp.dsp - unix2dos *.dsp - - - name: Prepare MSVC - uses: bus1/cabuild/action/msdevshell@v1 - with: - architecture: x86 - - - name: Upgrade project files to latest Visual Studio, ignoring upgrade errors, and build - run: | - devenv abcspace.dsw /upgrade ; if (-not $? ) { cat UpgradeLog.htm } - msbuild abcspace.sln /m /nologo /p:Configuration=Release /p:PlatformTarget=x86 - - - name: Test Executable - run: | - _TEST\abc.exe -c "r i10.aig; b; ps; b; rw -l; rw -lz; b; rw -lz; b; ps; cec" - - - name: Stage Executable - run: | - mkdir staging - copy _TEST/abc.exe staging/ - copy UpgradeLog.htm staging/ - - - name: Upload pacakge artifact - uses: actions/upload-artifact@v1 - with: - name: package - path: staging/ diff --git a/.github/workflows/build-posix-cmake.yml b/.github/workflows/build-posix-cmake.yml index 68d325b2..ea31fe0b 100644 --- a/.github/workflows/build-posix-cmake.yml +++ b/.github/workflows/build-posix-cmake.yml @@ -11,7 +11,7 @@ jobs: runs-on: ${{ matrix.os }} env: - MAKE_ARGS: ${{ matrix.use_namespace && '-DABC_USE_NAMESPACE=ON' || '' }} + CMAKE_ARGS: ${{ matrix.use_namespace && '-DABC_USE_NAMESPACE=xxx' || '' }} DEMO_ARGS: ${{ matrix.use_namespace && '-DABC_NAMESPACE=xxx' || '' }} DEMO_GCC: ${{ matrix.use_namespace && 'g++ -x c++' || 'gcc' }} @@ -34,7 +34,7 @@ jobs: - name: Configure CMake run: | - cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -B build + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ${CMAKE_ARGS} -B build - name: Build CMake run: | @@ -53,7 +53,7 @@ jobs: - name: Stage Executable run: | mkdir staging - cp abc libabc.a staging/ + cp build/abc build/libabc.a staging/ - name: Upload pacakge artifact uses: actions/upload-artifact@v1 diff --git a/.github/workflows/build-posix.yml b/.github/workflows/build-posix.yml new file mode 100644 index 00000000..aa97aca2 --- /dev/null +++ b/.github/workflows/build-posix.yml @@ -0,0 +1,62 @@ +on: [push] + +jobs: + + build-posix: + strategy: + matrix: + os: [macos-latest, ubuntu-latest] + use_namespace: [false, true] + + runs-on: ${{ matrix.os }} + + env: + MAKE_ARGS: ${{ matrix.use_namespace && 'ABC_USE_NAMESPACE=xxx' || '' }} + DEMO_ARGS: ${{ matrix.use_namespace && '-DABC_NAMESPACE=xxx' || '' }} + DEMO_GCC: ${{ matrix.use_namespace && 'g++ -x c++' || 'gcc' }} + + steps: + + - name: Git Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Install brew dependencies + run: | + HOMEBREW_NO_AUTO_UPDATE=1 brew install readline + if: ${{ contains(matrix.os, 'macos') }} + + - name: Install APT dependencies + run: | + sudo apt install -y libreadline-dev + if: ${{ !contains(matrix.os, 'macos') }} + + - name: Build Executable + run: | + make -j3 ${MAKE_ARGS} abc + + - name: Test Executable + run: | + ./abc -c "r i10.aig; b; ps; b; rw -l; rw -lz; b; rw -lz; b; ps; cec" + + - name: Build Library + run: | + make -j3 ${MAKE_ARGS} libabc.a + + - name: Test Library + run: | + ${DEMO_GCC} ${DEMO_ARGS} -Wall -c src/demo.c -o demo.o + g++ -o demo demo.o libabc.a -lm -ldl -lreadline -lpthread + ./demo i10.aig + + - name: Stage Executable + run: | + mkdir staging + cp abc libabc.a staging/ + + - name: Upload pacakge artifact + uses: actions/upload-artifact@v1 + with: + name: package + path: staging/ diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 00000000..6312780d --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,48 @@ +on: [push] + +jobs: + + build-windows: + + runs-on: windows-latest + + steps: + + - name: Git Checkout + uses: actions/checkout@v2 + with: + submodules: recursive + + - name: Process project files to compile on Github Actions + run: | + sed -i 's#ABC_USE_PTHREADS\"#ABC_DONT_USE_PTHREADS\" /D \"_ALLOW_KEYWORD_MACROS=1\"#g' *.dsp + awk 'BEGIN { del=0; } /# Begin Group "uap"/ { del=1; } /# End Group/ { if( del > 0 ) {del=0; next;} } del==0 {print;} ' abclib.dsp > tmp.dsp + copy tmp.dsp abclib.dsp + del tmp.dsp + unix2dos *.dsp + + - name: Prepare MSVC + uses: bus1/cabuild/action/msdevshell@v1 + with: + architecture: x86 + + - name: Upgrade project files to latest Visual Studio, ignoring upgrade errors, and build + run: | + devenv abcspace.dsw /upgrade ; if (-not $? ) { cat UpgradeLog.htm } + msbuild abcspace.sln /m /nologo /p:Configuration=Release /p:PlatformTarget=x86 + + - name: Test Executable + run: | + _TEST\abc.exe -c "r i10.aig; b; ps; b; rw -l; rw -lz; b; rw -lz; b; ps; cec" + + - name: Stage Executable + run: | + mkdir staging + copy _TEST/abc.exe staging/ + copy UpgradeLog.htm staging/ + + - name: Upload pacakge artifact + uses: actions/upload-artifact@v1 + with: + name: package + path: staging/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cf6f19a..cee9bc72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,9 +47,14 @@ if(ABC_USE_NAMESPACE) set(ABC_USE_NAMESPACE_FLAGS "ABC_USE_NAMESPACE=${ABC_USE_NAMESPACE}") endif() +if( APPLE ) + set(make_env ${CMAKE_COMMAND} -E env SDKROOT=${CMAKE_OSX_SYSROOT}) +endif() + # run make to extract compiler options, linker options and list of source files execute_process( COMMAND + ${make_env} make ${ABC_READLINE_FLAGS} ${ABC_USE_NAMESPACE_FLAGS} diff --git a/README.md b/README.md index 55b9de30..358f5ce9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -[![.github/workflows/build-posix.yml](https://github.com/sterin/abc/actions/workflows/build-posix.yml/badge.svg)](https://github.com/sterin/abc/actions/workflows/build-posix.yml) -[![.github/workflows/build-windows.yml](https://github.com/sterin/abc/actions/workflows/build-windows.yml/badge.svg)](https://github.com/sterin/abc/actions/workflows/build-windows.yml) +[![.github/workflows/build-posix.yml](https://github.com/berkeley-abc/abc/actions/workflows/build-posix.yml/badge.svg)](https://github.com/berkeley-abc/abc/actions/workflows/build-posix.yml) +[![.github/workflows/build-windows.yml](https://github.com/berkeley-abc/abc/actions/workflows/build-windows.yml/badge.svg)](https://github.com/berkeley-abc/abc/actions/workflows/build-windows.yml) +[![.github/workflows/build-posix-cmake.yml](https://github.com/berkeley-abc/abc/actions/workflows/build-posix-cmake.yml/badge.svg)](https://github.com/berkeley-abc/abc/actions/workflows/build-posix-cmake.yml) # ABC: System for Sequential Logic Synthesis and Formal Verification -- cgit v1.2.3