From c6b7bbe3c08963d6d2632e0794e2f6b11151e330 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:01:20 +0200 Subject: [PATCH 01/11] Support shared library build Signed-off-by: Uilian Ries --- .github/workflows/build_library.yml | 90 +++++++++++++++++++++++++++++ CMakeLists.txt | 18 +++--- 2 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/build_library.yml diff --git a/.github/workflows/build_library.yml b/.github/workflows/build_library.yml new file mode 100644 index 000000000..ab27de606 --- /dev/null +++ b/.github/workflows/build_library.yml @@ -0,0 +1,90 @@ +--- +name: Build Unity library + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + name: ${{ matrix.config.name }} + runs-on: ${{ matrix.config.os }} + strategy: + fail-fast: true + matrix: + config: + - { + name: "Windows: MSVC", + os: windows-latest, + build_type: "Release", + cc: "cl", + cxx: "cl", + environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat", + generators: "Ninja", + shared_build: "OFF" + } + - { + name: "Ubuntu: GCC", + os: ubuntu-latest, + build_type: "Release", + cc: "gcc", + cxx: "g++", + generators: "Ninja", + shared_build: "OFF" + } + - { + name: "Apple OSX: Clang", + os: macos-latest, + build_type: "Release", + cc: "clang", + cxx: "clang++", + generators: "Ninja", + shared_build: "OFF" + } + + steps: + - uses: actions/checkout@v3 + + - name: Install dependencies on Windows + if: startsWith(matrix.config.os, 'windows') + run: | + choco install ninja cmake + ninja --version + cmake --version + + - name: Install dependencies on Ubuntu + if: startsWith(matrix.config.os, 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install ninja-build cmake + ninja --version + cmake --version + gcc --version + - name: Install dependencies on OSX + if: startsWith(matrix.config.os, 'macos') + run: | + brew install cmake ninja + ninja --version + cmake --version + clang --version + + - name: CMake configure + shell: bash + run: | + cmake \ + -S . \ + -B build \ + -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \ + -G "${{ matrix.config.generators }}" \ + -DCMAKE_INSTALL_PREFIX:PATH=install \ + -DBUIlD_SHARED_LIBS=${{ matrix.config.shared_build }} + + - name: CMake build + shell: bash + run: cmake --build build --config ${{ matrix.config.build_type }} + + - name: CMake install + shell: bash + run: cmake --build build --config ${{ matrix.config.build_type }} --target install diff --git a/CMakeLists.txt b/CMakeLists.txt index 348266d53..08437e5f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ cmake_minimum_required(VERSION 3.12) # Read src/unity.h file and get project version from it set(UNITY_HEADER "src/unity.h") -file(STRINGS "${UNITY_HEADER}" UNITY_HEADER_CONTENT +file(STRINGS "${UNITY_HEADER}" UNITY_HEADER_CONTENT REGEX "^#define UNITY_VERSION_(MAJOR|MINOR|BUILD) +[0-9]+$" ) @@ -24,8 +24,8 @@ set(UNITY_HEADER_VERSION_BUILD 0) foreach(VERSION_LINE IN LISTS UNITY_HEADER_CONTENT) foreach(VERSION_PART MAJOR MINOR BUILD) - string(CONCAT REGEX_STRING "#define UNITY_VERSION_" - "${VERSION_PART}" + string(CONCAT REGEX_STRING "#define UNITY_VERSION_" + "${VERSION_PART}" " +([0-9]+)" ) @@ -57,7 +57,7 @@ if(${UNITY_EXTENSION_MEMORY}) endif() # Main target ------------------------------------------------------------------ -add_library(${PROJECT_NAME} STATIC) +add_library(${PROJECT_NAME}) add_library(${PROJECT_NAME}::framework ALIAS ${PROJECT_NAME}) # Includes --------------------------------------------------------------------- @@ -89,12 +89,13 @@ set(${PROJECT_NAME}_PUBLIC_HEADERS ) set_target_properties(${PROJECT_NAME} - PROPERTIES + PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON C_EXTENSIONS OFF PUBLIC_HEADER "${${PROJECT_NAME}_PUBLIC_HEADERS}" EXPORT_NAME framework + WINDOWS_EXPORT_ALL_SYMBOLS ON ) target_compile_options(${PROJECT_NAME} @@ -104,7 +105,7 @@ target_compile_options(${PROJECT_NAME} -Wcast-align -Wcast-qual -Wconversion - -Wexit-time-destructors + -Wexit-time-destructors -Wglobal-constructors -Wmissing-noreturn -Wmissing-prototypes @@ -116,7 +117,7 @@ target_compile_options(${PROJECT_NAME} -Wall $<$,8.0.0>:-Wextra-semi-stmt> > - + # GCC $<$: -Waddress @@ -146,7 +147,7 @@ target_compile_options(${PROJECT_NAME} write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake VERSION ${PROJECT_VERSION} - COMPATIBILITY SameMajorVersion + COMPATIBILITY SameMajorVersion ) ## Target installation @@ -154,6 +155,7 @@ install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} COMPONENT library ) From 4ca66a29c2e85d4d65a8b99ca027b8ba5fd0c517 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:02:20 +0200 Subject: [PATCH 02/11] build for any branch Signed-off-by: Uilian Ries --- .github/workflows/build_library.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build_library.yml b/.github/workflows/build_library.yml index ab27de606..9f10985cc 100644 --- a/.github/workflows/build_library.yml +++ b/.github/workflows/build_library.yml @@ -3,9 +3,7 @@ name: Build Unity library on: push: - branches: [ master ] pull_request: - branches: [ master ] jobs: build: From b05426f73c0eca14a7db4b370af41e48e1fd186b Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:05:01 +0200 Subject: [PATCH 03/11] Use python to install deps Signed-off-by: Uilian Ries --- .github/workflows/build_library.yml | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build_library.yml b/.github/workflows/build_library.yml index 9f10985cc..6b3328ea5 100644 --- a/.github/workflows/build_library.yml +++ b/.github/workflows/build_library.yml @@ -44,29 +44,12 @@ jobs: steps: - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: 3.8 - - name: Install dependencies on Windows - if: startsWith(matrix.config.os, 'windows') - run: | - choco install ninja cmake - ninja --version - cmake --version - - - name: Install dependencies on Ubuntu - if: startsWith(matrix.config.os, 'ubuntu') - run: | - sudo apt-get update - sudo apt-get install ninja-build cmake - ninja --version - cmake --version - gcc --version - - name: Install dependencies on OSX - if: startsWith(matrix.config.os, 'macos') - run: | - brew install cmake ninja - ninja --version - cmake --version - clang --version + - name: Install dependencies + run: pip install cmake ninja - name: CMake configure shell: bash @@ -77,7 +60,7 @@ jobs: -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \ -G "${{ matrix.config.generators }}" \ -DCMAKE_INSTALL_PREFIX:PATH=install \ - -DBUIlD_SHARED_LIBS=${{ matrix.config.shared_build }} + -DBUILD_SHARED_LIBS=${{ matrix.config.shared_build }} - name: CMake build shell: bash From 70c3c7194f216551ad09a5c7f2d0caf2e4b915b1 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:07:24 +0200 Subject: [PATCH 04/11] Add shared build Signed-off-by: Uilian Ries --- .github/workflows/build_library.yml | 37 +++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_library.yml b/.github/workflows/build_library.yml index 6b3328ea5..a0836d659 100644 --- a/.github/workflows/build_library.yml +++ b/.github/workflows/build_library.yml @@ -14,7 +14,7 @@ jobs: matrix: config: - { - name: "Windows: MSVC", + name: "Windows: MSVC - Release Static", os: windows-latest, build_type: "Release", cc: "cl", @@ -24,7 +24,7 @@ jobs: shared_build: "OFF" } - { - name: "Ubuntu: GCC", + name: "Ubuntu: GCC - Release Static", os: ubuntu-latest, build_type: "Release", cc: "gcc", @@ -33,7 +33,7 @@ jobs: shared_build: "OFF" } - { - name: "Apple OSX: Clang", + name: "Apple OSX: Clang - Release Static", os: macos-latest, build_type: "Release", cc: "clang", @@ -41,6 +41,34 @@ jobs: generators: "Ninja", shared_build: "OFF" } + - { + name: "Windows: MSVC - Release Shared", + os: windows-latest, + build_type: "Release", + cc: "cl", + cxx: "cl", + environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat", + generators: "Ninja", + shared_build: "ON" + } + - { + name: "Ubuntu: GCC - Release Shared", + os: ubuntu-latest, + build_type: "Release", + cc: "gcc", + cxx: "g++", + generators: "Ninja", + shared_build: "ON" + } + - { + name: "Apple OSX: Clang - Release Shared", + os: macos-latest, + build_type: "Release", + cc: "clang", + cxx: "clang++", + generators: "Ninja", + shared_build: "ON" + } steps: - uses: actions/checkout@v3 @@ -60,7 +88,8 @@ jobs: -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \ -G "${{ matrix.config.generators }}" \ -DCMAKE_INSTALL_PREFIX:PATH=install \ - -DBUILD_SHARED_LIBS=${{ matrix.config.shared_build }} + -DBUILD_SHARED_LIBS=${{ matrix.config.shared_build }} \ + -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON - name: CMake build shell: bash From 856ac8ad5e38dd05a56acd9d44f81d82ec2bb527 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:09:54 +0200 Subject: [PATCH 05/11] Use real bool Signed-off-by: Uilian Ries --- .github/workflows/build_library.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_library.yml b/.github/workflows/build_library.yml index a0836d659..f9a72b9f8 100644 --- a/.github/workflows/build_library.yml +++ b/.github/workflows/build_library.yml @@ -10,7 +10,7 @@ jobs: name: ${{ matrix.config.name }} runs-on: ${{ matrix.config.os }} strategy: - fail-fast: true + fail-fast: false matrix: config: - { @@ -21,7 +21,7 @@ jobs: cxx: "cl", environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat", generators: "Ninja", - shared_build: "OFF" + shared_build: false } - { name: "Ubuntu: GCC - Release Static", @@ -30,7 +30,7 @@ jobs: cc: "gcc", cxx: "g++", generators: "Ninja", - shared_build: "OFF" + shared_build: false } - { name: "Apple OSX: Clang - Release Static", @@ -39,7 +39,7 @@ jobs: cc: "clang", cxx: "clang++", generators: "Ninja", - shared_build: "OFF" + shared_build: false } - { name: "Windows: MSVC - Release Shared", @@ -49,7 +49,7 @@ jobs: cxx: "cl", environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat", generators: "Ninja", - shared_build: "ON" + shared_build: true } - { name: "Ubuntu: GCC - Release Shared", @@ -58,7 +58,7 @@ jobs: cc: "gcc", cxx: "g++", generators: "Ninja", - shared_build: "ON" + shared_build: true } - { name: "Apple OSX: Clang - Release Shared", @@ -67,7 +67,7 @@ jobs: cc: "clang", cxx: "clang++", generators: "Ninja", - shared_build: "ON" + shared_build: true } steps: @@ -88,7 +88,7 @@ jobs: -DCMAKE_BUILD_TYPE=${{ matrix.config.build_type }} \ -G "${{ matrix.config.generators }}" \ -DCMAKE_INSTALL_PREFIX:PATH=install \ - -DBUILD_SHARED_LIBS=${{ matrix.config.shared_build }} \ + -DBUILD_SHARED_LIBS:BOOL=${{ matrix.config.shared_build }} \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON - name: CMake build From ab52acb3107260b934efd68e5443f13caff9f548 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:15:31 +0200 Subject: [PATCH 06/11] Prepare Windows environment Signed-off-by: Uilian Ries --- .github/workflows/build_library.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_library.yml b/.github/workflows/build_library.yml index f9a72b9f8..1cbc3d60a 100644 --- a/.github/workflows/build_library.yml +++ b/.github/workflows/build_library.yml @@ -19,7 +19,7 @@ jobs: build_type: "Release", cc: "cl", cxx: "cl", - environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat", + environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", generators: "Ninja", shared_build: false } @@ -47,7 +47,7 @@ jobs: build_type: "Release", cc: "cl", cxx: "cl", - environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat", + environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", generators: "Ninja", shared_build: true } @@ -79,6 +79,10 @@ jobs: - name: Install dependencies run: pip install cmake ninja + - name: Prepare Visual Studio environment + if: startsWith(matrix.config.os, 'windows') + run: cmd "${{ matrix.config.environment_script }}" + - name: CMake configure shell: bash run: | From 747d0ab91dee0809509efc58501b68bf9e1992ea Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:16:54 +0200 Subject: [PATCH 07/11] enable extensions Signed-off-by: Uilian Ries --- .github/workflows/build_library.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_library.yml b/.github/workflows/build_library.yml index 1cbc3d60a..6d2ef8c00 100644 --- a/.github/workflows/build_library.yml +++ b/.github/workflows/build_library.yml @@ -93,7 +93,9 @@ jobs: -G "${{ matrix.config.generators }}" \ -DCMAKE_INSTALL_PREFIX:PATH=install \ -DBUILD_SHARED_LIBS:BOOL=${{ matrix.config.shared_build }} \ - -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON + -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ + -DUNITY_EXTENSION_FIXTURES:BOOL=ON \ + -DUNITY_EXTENSION_MEMORY:BOOL=ON - name: CMake build shell: bash From 3f1d5699176dc608746e78630acbe9aed37dd027 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:17:43 +0200 Subject: [PATCH 08/11] use msvc generator for windows Signed-off-by: Uilian Ries --- .github/workflows/build_library.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_library.yml b/.github/workflows/build_library.yml index 6d2ef8c00..5e06e9d97 100644 --- a/.github/workflows/build_library.yml +++ b/.github/workflows/build_library.yml @@ -20,7 +20,7 @@ jobs: cc: "cl", cxx: "cl", environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", - generators: "Ninja", + generators: "Visual Studio 17 2022", shared_build: false } - { @@ -48,7 +48,7 @@ jobs: cc: "cl", cxx: "cl", environment_script: "C:/Program Files (x86)/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat", - generators: "Ninja", + generators: "Visual Studio 17 2022", shared_build: true } - { From 63cfdd15daeb95d81f7434a5614c74be6adfca38 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:22:27 +0200 Subject: [PATCH 09/11] skip default runner Signed-off-by: Uilian Ries --- .github/workflows/build_library.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_library.yml b/.github/workflows/build_library.yml index 5e06e9d97..6b081951e 100644 --- a/.github/workflows/build_library.yml +++ b/.github/workflows/build_library.yml @@ -95,7 +95,8 @@ jobs: -DBUILD_SHARED_LIBS:BOOL=${{ matrix.config.shared_build }} \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -DUNITY_EXTENSION_FIXTURES:BOOL=ON \ - -DUNITY_EXTENSION_MEMORY:BOOL=ON + -DUNITY_EXTENSION_MEMORY:BOOL=ON \ + -DCMAKE_C_FLAGS="-DUNITY_SKIP_DEFAULT_RUNNER" - name: CMake build shell: bash From e38bce4a061906dfb45390f95eea7db05380720a Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:37:13 +0200 Subject: [PATCH 10/11] manage skip defult runner Signed-off-by: Uilian Ries --- .github/workflows/build_library.yml | 3 +-- CMakeLists.txt | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_library.yml b/.github/workflows/build_library.yml index 6b081951e..5e06e9d97 100644 --- a/.github/workflows/build_library.yml +++ b/.github/workflows/build_library.yml @@ -95,8 +95,7 @@ jobs: -DBUILD_SHARED_LIBS:BOOL=${{ matrix.config.shared_build }} \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -DUNITY_EXTENSION_FIXTURES:BOOL=ON \ - -DUNITY_EXTENSION_MEMORY:BOOL=ON \ - -DCMAKE_C_FLAGS="-DUNITY_SKIP_DEFAULT_RUNNER" + -DUNITY_EXTENSION_MEMORY:BOOL=ON - name: CMake build shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 08437e5f1..8a6546a6e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,6 +143,9 @@ target_compile_options(${PROJECT_NAME} $<$: /Wall > + + # Enable shared library + $<$:UNITY_SKIP_DEFAULT_RUNNER> ) write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake From 11e95e2ed3c4c8e42b3a663d972e3398e9b83a64 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Fri, 14 Jul 2023 12:38:57 +0200 Subject: [PATCH 11/11] manage skip defult runner Signed-off-by: Uilian Ries --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a6546a6e..a3583e2a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,7 +143,10 @@ target_compile_options(${PROJECT_NAME} $<$: /Wall > +) +target_compile_definitions(${PROJECT_NAME} + PRIVATE # Enable shared library $<$:UNITY_SKIP_DEFAULT_RUNNER> )