From 6539587ed71fa0db7503ab4c882ed7a871219781 Mon Sep 17 00:00:00 2001 From: "Maxim [maxirmx] Samsonov" Date: Fri, 8 Apr 2022 11:46:39 +0300 Subject: [PATCH 1/5] Alpine build with vcpkg and static libraries --- .github/workflows/alpine-build.yml | 56 ------------- .github/workflows/alpine-x86_64.yml | 70 ++++++++++++++++ .github/workflows/macos-arm64.yml | 25 +++--- .../{macos-build.yml => macos-x86_64.yml} | 15 ++-- .github/workflows/release.yml | 2 +- .github/workflows/ubuntu-arm64.yml | 33 ++++---- .../{ubuntu-build.yml => ubuntu-x86_64.yml} | 23 +++--- .github/workflows/windows-build.yml | 29 +++---- .gitignore | 2 + CMakeLists.txt | 80 ++++++++++--------- vcpkg.json | 2 +- 11 files changed, 177 insertions(+), 160 deletions(-) delete mode 100644 .github/workflows/alpine-build.yml create mode 100644 .github/workflows/alpine-x86_64.yml rename .github/workflows/{macos-build.yml => macos-x86_64.yml} (61%) rename .github/workflows/{ubuntu-build.yml => ubuntu-x86_64.yml} (72%) diff --git a/.github/workflows/alpine-build.yml b/.github/workflows/alpine-build.yml deleted file mode 100644 index a274c835..00000000 --- a/.github/workflows/alpine-build.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Alpine build - -on: - push: - branches: [ master ] - paths-ignore: - - '.github/workflows/macos-build.yml' - - '.github/workflows/macos-arm64.yml' - - '.github/workflows/ubuntu-build.yml' - - '.github/workflows/ubuntu-arm64.yml' - - '.github/workflows/windows-build.yml' - pull_request: - workflow_dispatch: - -env: - BUILD_TYPE: Release - -jobs: - Alpine-build: - runs-on: ubuntu-latest - container: - image: alpine:latest - - steps: - - name: Install packages - run: | - apk --no-cache --upgrade add build-base cmake libxml2-dev \ - libxml2-utils libpng-dev freetype-dev fontconfig-dev git valgrind \ - argp-standalone font-noto-hebrew font-noto-arabic -# font-noto-hebrew font-noto-arabic -- this is required for testing only -# [ tests/resources/emf/test-183.emf ] - - - uses: actions/checkout@v2 - with: - submodules: recursive - - - name: Configure CMake - env: - CC: gcc - CXX: g++ - run: cmake -B . -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - - - name: Build - run: | - cmake --build . --config ${{env.BUILD_TYPE}} - pwd - ls -l - - - name: Test well formed files - run: ./tests/resources/check_correctness.sh -r -s - - - name: Test corrupted files - run: ./tests/resources/check_correctness.sh -r -s -e tests/resources/emf-corrupted/ -xN - - - name: Test EA files - run: ./tests/resources/check_correctness.sh -r -s -e tests/resources/emf-ea/ diff --git a/.github/workflows/alpine-x86_64.yml b/.github/workflows/alpine-x86_64.yml new file mode 100644 index 00000000..a996ecae --- /dev/null +++ b/.github/workflows/alpine-x86_64.yml @@ -0,0 +1,70 @@ +name: Alpine-x86_64 + +on: + push: + paths-ignore: + - '.github/workflows/macos-x86_64.yml' + - '.github/workflows/macos-arm64.yml' + - '.github/workflows/ubuntu-x86_64.yml' + - '.github/workflows/ubuntu-arm64.yml' + - '.github/workflows/windows-build.yml' + pull_request: + workflow_dispatch: + +env: + BUILD_TYPE: Release + VCPKG_FORCE_SYSTEM_BINARIES: 1 + VCPKG_DEFAULT_BINARY_CACHE: /home/cache + CC: gcc + CXX: g++ + +jobs: + build: + runs-on: ubuntu-latest + container: + image: alpine:latest + + steps: + - name: Install packages + run: | + apk --no-cache --upgrade add build-base cmake git valgrind argp-standalone \ + gcompat gperf flex bison gettext-dev python3 ninja zip unzip curl pkgconfig \ + libxml2-utils font-noto-hebrew font-noto-arabic + +# vcpkg prerequisites (and VCPKG_FORCE_SYSTEM_BINARIES: 1) +# gcompat gperf flex bison gettext-dev python3 ninja zip unzip curl pkg-config +# testing prerequisites +# libxml2-utils +# [ tests/resources/emf/test-183.emf ] -- font-noto-hebrew font-noto-arabic + + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Create cache storage and cache key + run: | + mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + git submodule status > sm.txt + + - name: Process cache + uses: actions/cache@v2 + with: + path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} + + - name: Configure CMake + run: | + cmake -B . -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=x64-linux -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake + + - name: Build + run: | + cmake --build . --config ${{env.BUILD_TYPE}} + + - name: Test well formed files + run: ./tests/resources/check_correctness.sh -r -s + + - name: Test corrupted files + run: ./tests/resources/check_correctness.sh -r -s -e tests/resources/emf-corrupted/ -xN + + - name: Test EA files + run: ./tests/resources/check_correctness.sh -r -s -e tests/resources/emf-ea/ diff --git a/.github/workflows/macos-arm64.yml b/.github/workflows/macos-arm64.yml index 2891a5ac..b23a3177 100644 --- a/.github/workflows/macos-arm64.yml +++ b/.github/workflows/macos-arm64.yml @@ -2,44 +2,43 @@ name: MacOS-arm64 build on: push: - branches: [ master ] paths-ignore: - - '.github/workflows/alpine-build.yml' - - '.github/workflows/ubuntu-build.yml' + - '.github/workflows/alpine-x86_64.yml' + - '.github/workflows/ubuntu-x86_64.yml' - '.github/workflows/ubuntu-arm64.yml' - '.github/workflows/windows-build.yml' - - '.github/workflows/macos-build.yml' + - '.github/workflows/macos-x86_64.yml' pull_request: workflow_dispatch: env: BUILD_TYPE: Release - VCPKG_DEFAULT_BINARY_CACHE: ${{github.workspace}}/cache + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: - MacOS-build: + build: runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - name: Create cache storage and cache key run: | - mkdir ${{env.VCPKG_DEFAULT_BINARY_CACHE}} + mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} git submodule status > sm.txt - uses: actions/cache@v2 with: - path: ${{env.VCPKG_DEFAULT_BINARY_CACHE}} - key: ${{runner.os}}-vcpkg-${{ hashFiles('sm.txt') }} + path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} - name: Configure CMake run: | - cmake -B ${{github.workspace}} \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ - -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake \ + cmake -B ${{ github.workspace }} \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \ -DVCPKG_TARGET_TRIPLET=arm64-osx - name: Build diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-x86_64.yml similarity index 61% rename from .github/workflows/macos-build.yml rename to .github/workflows/macos-x86_64.yml index bf9f31f3..cc6c5c75 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-x86_64.yml @@ -1,11 +1,10 @@ -name: MacOS build +name: MacOS-x86_64 on: push: - branches: [ master ] paths-ignore: - - '.github/workflows/alpine-build.yml' - - '.github/workflows/ubuntu-build.yml' + - '.github/workflows/alpine-x86_64.yml' + - '.github/workflows/ubuntu-x86_64.yml' - '.github/workflows/ubuntu-arm64.yml' - '.github/workflows/windows-build.yml' - '.github/workflows/macos-arm64.yml' @@ -16,11 +15,11 @@ env: BUILD_TYPE: Release jobs: - MacOS-build: + build: runs-on: macos-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install packages run: | @@ -30,7 +29,7 @@ jobs: # brew install --HEAD LouisBrunner/valgrind/valgrind - name: Configure CMake - run: cmake -B ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B ${{ github.workspace }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} - name: Build - run: cmake --build ${{github.workspace}} --config ${{env.BUILD_TYPE}} + run: cmake --build ${{ github.workspace }} --config ${{ env.BUILD_TYPE }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 81554b10..8f4b89cb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: recursive diff --git a/.github/workflows/ubuntu-arm64.yml b/.github/workflows/ubuntu-arm64.yml index 3c9d3377..7001d4c7 100644 --- a/.github/workflows/ubuntu-arm64.yml +++ b/.github/workflows/ubuntu-arm64.yml @@ -2,11 +2,10 @@ name: Ubuntu-arm64 build on: push: - branches: [ master ] paths-ignore: - - '.github/workflows/alpine-build.yml' - - '.github/workflows/ubuntu-build.yml' - - '.github/workflows/macos-build.yml' + - '.github/workflows/alpine-x86_64.yml' + - '.github/workflows/ubuntu-x86_64.yml' + - '.github/workflows/macos-x86_64.yml' - '.github/workflows/macos-arm64.yml' - '.github/workflows/windows-build.yml' pull_request: @@ -14,26 +13,26 @@ on: env: BUILD_TYPE: Release - VCPKG_DEFAULT_BINARY_CACHE: ${{github.workspace}}/cache + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: - Ubuntu-build: + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - name: Create cache storage and cache key run: | - mkdir ${{env.VCPKG_DEFAULT_BINARY_CACHE}} + mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} git submodule status > sm.txt - uses: actions/cache@v2 with: - path: ${{env.VCPKG_DEFAULT_BINARY_CACHE}} - key: ${{runner.os}}-vcpkg-${{ hashFiles('sm.txt') }} + path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} - name: Install packages run: | @@ -42,17 +41,17 @@ jobs: - name: Configure CMake run: | - cmake -B ${{github.workspace}} \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ - -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake \ + cmake -B ${{ github.workspace }} \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \ -DVCPKG_TARGET_TRIPLET=arm64-linux - name: Build - run: cmake --build ${{github.workspace}} --config ${{env.BUILD_TYPE}} + run: cmake --build ${{ github.workspace }} --config ${{env.BUILD_TYPE}} - name: Smoke test run: | - qemu-aarch64 -L /usr/aarch64-linux-gnu ${{github.workspace}}/emf2svg-conv --version - qemu-aarch64 -L /usr/aarch64-linux-gnu ${{github.workspace}}/emf2svg-conv \ - -i ${{github.workspace}}/tests/resources/emf/test-000.emf -o test-000.svg + qemu-aarch64 -L /usr/aarch64-linux-gnu ${{ github.workspace }}/emf2svg-conv --version + qemu-aarch64 -L /usr/aarch64-linux-gnu ${{ github.workspace }}/emf2svg-conv \ + -i ${{ github.workspace }}/tests/resources/emf/test-000.emf -o test-000.svg ls | grep test-000.svg diff --git a/.github/workflows/ubuntu-build.yml b/.github/workflows/ubuntu-x86_64.yml similarity index 72% rename from .github/workflows/ubuntu-build.yml rename to .github/workflows/ubuntu-x86_64.yml index a44461e3..0ef2274a 100644 --- a/.github/workflows/ubuntu-build.yml +++ b/.github/workflows/ubuntu-x86_64.yml @@ -1,11 +1,10 @@ -name: Ubuntu build +name: Ubuntu-x86_64 on: push: - branches: [ master ] paths-ignore: - - '.github/workflows/alpine-build.yml' - - '.github/workflows/macos-build.yml' + - '.github/workflows/alpine-x86_64.yml' + - '.github/workflows/macos-x86_64.yml' - '.github/workflows/macos-arm64.yml' - '.github/workflows/ubuntu-arm64.yml' - '.github/workflows/windows-build.yml' @@ -16,11 +15,11 @@ env: BUILD_TYPE: Release jobs: - Ubuntu-build: + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Install packages run: | @@ -28,21 +27,21 @@ jobs: sudo apt-get install libxml2-utils valgrind - name: Configure CMake - run: cmake -B ${{github.workspace}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B ${{ github.workspace }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} - name: Build - run: cmake --build ${{github.workspace}} --config ${{env.BUILD_TYPE}} + run: cmake --build ${{ github.workspace }} --config ${{env.BUILD_TYPE }} - name: Test well formed files - working-directory: ${{github.workspace}} + working-directory: ${{ github.workspace }} run: ./tests/resources/check_correctness.sh -r -s - name: Test corrupted files - working-directory: ${{github.workspace}} + working-directory: ${{ github.workspace }} run: ./tests/resources/check_correctness.sh -r -s -e tests/resources/emf-corrupted/ -xN - name: Test EA files - working-directory: ${{github.workspace}} + working-directory: ${{ github.workspace }} run: ./tests/resources/check_correctness.sh -r -s -e tests/resources/emf-ea/ coverage: @@ -60,7 +59,7 @@ jobs: run: sudo pip install cpp-coveralls - name: Configure CMake - run: cmake -B ${{github.workspace}} -DCMAKE_BUILD_TYPE=Debug -DGCOV=ON + run: cmake -B ${{ github.workspace }} -DCMAKE_BUILD_TYPE=Debug -DGCOV=ON - name: Build run: make coverage diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 9b01fc30..c37da7a6 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -1,48 +1,45 @@ -name: Windows build +name: Windows-build on: push: - branches: [ master ] paths-ignore: - - '.github/workflows/alpine-build.yml' - - '.github/workflows/macos-build.yml' + - '.github/workflows/alpine-x86_64.yml' + - '.github/workflows/macos-x86_64.yml' - '.github/workflows/macos-arm64.yml' - '.github/workflows/ubuntu-arm64.yml' - - '.github/workflows/ubuntu-build.yml' + - '.github/workflows/ubuntu-x86_64.yml' pull_request: workflow_dispatch: env: BUILD_TYPE: Release - VCPKG_DEFAULT_BINARY_CACHE: ${{github.workspace}}/cache + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: - Windows-build: + build: runs-on: windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - name: Create cache storage and cache key run: | - mkdir ${{env.VCPKG_DEFAULT_BINARY_CACHE}} + mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} git submodule status > sm.txt -# Something like " 025e564979cc01d0fbc5c920aa8a36635efb01bb vcpkg (2020.04-3294-g025e56497)" -# to be used as cache key - uses: actions/cache@v2 with: path: ${{env.VCPKG_DEFAULT_BINARY_CACHE}} - key: ${{runner.os}}-vcpkg-${{ hashFiles('sm.txt') }} + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} - name: Configure run: > cmake - -B ${{github.workspace}} - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - -DCMAKE_TOOLCHAIN_FILE=${{github.workspace}}/vcpkg/scripts/buildsystems/vcpkg.cmake + -B ${{ github.workspace }} + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build - run: cmake --build ${{github.workspace}} --config ${{env.BUILD_TYPE}} + run: cmake --build ${{ github.workspace }} --config ${{env.BUILD_TYPE}} diff --git a/.gitignore b/.gitignore index 14da1d59..0166197b 100644 --- a/.gitignore +++ b/.gitignore @@ -56,6 +56,8 @@ emf2svg-test # external projects vcpkg +vcpkg_installed +vcpkg-manifest-install.log deps/tmp deps/src deps/include diff --git a/CMakeLists.txt b/CMakeLists.txt index fe36c69e..80e76cc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,12 +18,13 @@ include(ExternalProject) project (emf2svg) set(emf2svg_VERSION_MAJOR 1) -set(emf2svg_VERSION_MINOR 6) +set(emf2svg_VERSION_MINOR 7) set(emf2svg_VERSION_PATCH 0) set(emf2svg_VERSION ${emf2svg_VERSION_MAJOR}.${emf2svg_VERSION_MINOR}.${emf2svg_VERSION_PATCH}) if(VCPKG_TARGET_TRIPLET) set(PLATFORM_TOOLCHAIN ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${VCPKG_TARGET_TRIPLET}.cmake) + message(STATUS "Configured with platform toolchain = '${PLATFORM_TOOLCHAIN}'") if(EXISTS ${PLATFORM_TOOLCHAIN}) set(PLATFORM_TOOLCHAIN_OPTION -DCMAKE_TOOLCHAIN_FILE=${PLATFORM_TOOLCHAIN}) include(${PLATFORM_TOOLCHAIN}) @@ -32,6 +33,24 @@ endif(VCPKG_TARGET_TRIPLET) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") + +# Options +option(LONLY "build library only" OFF) +option(GCOV "compile with gcov support" OFF) +option(UNITTEST "compile unit tests" OFF) +option(INDEX "print record indexes" OFF) +option(STATIC "compile statically" OFF) +option(FORCELE "force little endian architecture" OFF) + +if(STATIC) + set(SHARED "SHARED") + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(BUILD_SHARED_LIBRARIES OFF) + set(CMAKE_EXE_LINKER_FLAGS "-static") +else(STATIC) + set(SHARED "SHARED") +endif(STATIC) + find_package(PNG REQUIRED) find_package(Freetype REQUIRED) find_package(Fontconfig REQUIRED) @@ -75,17 +94,15 @@ add_custom_target(tag set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DE2S_VERSION='\"${emf2svg_VERSION}\"'") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DE2S_VERSION=${emf2svg_VERSION}") -# Options -option(GCOV "compile with gcov support" OFF) -option(UNITTEST "compile unit tests" OFF) -option(INDEX "print record indexes" OFF) -option(STATIC "compile statically" OFF) -option(FORCELE "force little endian architecture" OFF) - +message(STATUS "Configuring argp") +list(APPEND CMAKE_MESSAGE_INDENT " ") +message(STATUS "Checking if argp is provided system libraries") CHECK_FUNCTION_EXISTS(argp_parse HAVE_BUNDLED_ARGP_PARSE_FUNCTION) +message(STATUS "Looking for standalone argp library") set(CMAKE_REQUIRED_LIBRARIES argp) CHECK_FUNCTION_EXISTS(argp_parse HAVE_EXTERNAL_ARGP_PARSE_FUNCTION) +list(POP_BACK CMAKE_MESSAGE_INDENT) if(GCOV) SET(UNITTEST ON) @@ -104,29 +121,19 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g") set(CMAKE_EXE_LINKER_FLAGS "-INCREMENTAL:NO") endif(MSVC) - set(CMAKE_BUILD_TYPE Debug) endif() -if(STATIC) - set(SHARED "") - set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") - set(BUILD_SHARED_LIBRARIES OFF) - set(CMAKE_EXE_LINKER_FLAGS "-static") -else(STATIC) - set(SHARED "SHARED") -endif(STATIC) - if(UNIX) link_libraries(m) add_compile_options(-fPIC) endif(UNIX) if(NOT FORCELE) - include(TestBigEndian) - TEST_BIG_ENDIAN(BIGENDIAN) - IF(${BIGENDIAN}) - add_definitions(-DWORDS_BIGENDIAN) - ENDIF(${BIGENDIAN}) + include(TestBigEndian) + TEST_BIG_ENDIAN(BIGENDIAN) + IF(${BIGENDIAN}) + add_definitions(-DWORDS_BIGENDIAN) + ENDIF(${BIGENDIAN}) endif(NOT FORCELE) # Build external dependancies if we are on OSX @@ -245,6 +252,7 @@ set_target_properties(emf2svg target_link_libraries(emf2svg ${PNG_LIBRARIES} + ${LIBXML2_LIBRARIES} ${EXTERNAL_ICONV} ${FREETYPE_LIBRARIES} ${FONTCONFIG_LIBRARIES} @@ -253,24 +261,25 @@ target_link_libraries(emf2svg ) add_dependencies(emf2svg ${FMEM_NAME}) -if(MSVC) - add_dependencies(emf2svg ${ARGP_NAME}) -endif(MSVC) -# Compile the executable add_executable(emf2svg-conv src/conv/emf2svg.cpp) target_link_libraries(emf2svg-conv - emf2svg - ${EXTERNAL_ARGP} - ${PNG_LIBRARIES} - ${EXTERNAL_ICONV} - ${FREETYPE_LIBRARIES} - ${FONTCONFIG_LIBRARIES} - ${EXPAT_LIBRARY_RELEASE} - ${EXTERNAL_FMEM} + emf2svg + ${EXTERNAL_ARGP} + ${PNG_LIBRARIES} + ${LIBXML2_LIBRARIES} + ${EXTERNAL_ICONV} + ${FREETYPE_LIBRARIES} + ${FONTCONFIG_LIBRARIES} + ${EXPAT_LIBRARY_RELEASE} + ${EXTERNAL_FMEM} ) +if(ARGP_NAME) + add_dependencies(emf2svg-conv ${ARGP_NAME}) +endif(ARGP_NAME) + if(GCOV) Set(COVERAGE_EXCLUDES '*conv*' '*uemf*' '*upmf*' '*tests*' '*c++*') include(CodeCoverage) @@ -311,7 +320,6 @@ if (NOT INCLUDE_INSTALL_DIR) set(INCLUDE_INSTALL_DIR include) endif () - # install binaries and library INSTALL(TARGETS emf2svg emf2svg-conv RUNTIME DESTINATION ${BIN_INSTALL_DIR} diff --git a/vcpkg.json b/vcpkg.json index 0a0f8625..fd785183 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "libemf2svg", - "version-string": "1.3.1", + "version-string": "1.7.0", "dependencies": [ "libxml2", "libpng", From 43d3b5994f04029e12e8013ca283038014910b32 Mon Sep 17 00:00:00 2001 From: "Maxim [maxirmx] Samsonov" Date: Fri, 8 Apr 2022 18:11:58 +0300 Subject: [PATCH 2/5] CMake script optimization --- .github/workflows/alpine-x86_64.yml | 71 ++++++++- .github/workflows/ubuntu-x86_64.yml | 55 ++++++- CMakeLists.txt | 224 +++++++++++++++------------- tests/resources/lcheck.sh | 86 +++++++++++ 4 files changed, 319 insertions(+), 117 deletions(-) create mode 100755 tests/resources/lcheck.sh diff --git a/.github/workflows/alpine-x86_64.yml b/.github/workflows/alpine-x86_64.yml index a996ecae..14ac9a28 100644 --- a/.github/workflows/alpine-x86_64.yml +++ b/.github/workflows/alpine-x86_64.yml @@ -14,12 +14,11 @@ on: env: BUILD_TYPE: Release VCPKG_FORCE_SYSTEM_BINARIES: 1 - VCPKG_DEFAULT_BINARY_CACHE: /home/cache CC: gcc CXX: g++ jobs: - build: + build-and-test: runs-on: ubuntu-latest container: image: alpine:latest @@ -27,8 +26,8 @@ jobs: steps: - name: Install packages run: | - apk --no-cache --upgrade add build-base cmake git valgrind argp-standalone \ - gcompat gperf flex bison gettext-dev python3 ninja zip unzip curl pkgconfig \ + apk --no-cache --upgrade add build-base cmake git valgrind tar argp-standalone \ + gcompat gperf flex bison gettext-dev python3 ninja zip unzip curl pkgconfig \ libxml2-utils font-noto-hebrew font-noto-arabic # vcpkg prerequisites (and VCPKG_FORCE_SYSTEM_BINARIES: 1) @@ -41,6 +40,12 @@ jobs: with: submodules: recursive + - name: Configure cache + run: | + echo 'VCPKG_DEFAULT_BINARY_CACHE<> $GITHUB_ENV + echo "$(pwd)/cache" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + - name: Create cache storage and cache key run: | mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} @@ -50,7 +55,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }}-2 - name: Configure CMake run: | @@ -68,3 +73,59 @@ jobs: - name: Test EA files run: ./tests/resources/check_correctness.sh -r -s -e tests/resources/emf-ea/ + + build-for-ruby: + runs-on: ubuntu-latest + container: + image: alpine:latest + + steps: + - name: Install packages + run: | + apk --no-cache --upgrade add build-base cmake git valgrind tar bash \ + gcompat gperf flex bison gettext-dev python3 ninja zip unzip curl pkgconfig + + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Configure cache + run: | + echo 'VCPKG_DEFAULT_BINARY_CACHE<> $GITHUB_ENV + echo "$(pwd)/cache" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + + - name: Create cache storage and cache key + run: | + mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + git submodule status > sm.txt + + - name: Process cache + uses: actions/cache@v2 + with: + path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }}-2 + + - name: Configure CMake + run: | + cmake -B . -DCMAKE_BUILD_TYPE=Release \ + -DVCPKG_TARGET_TRIPLET=x64-linux \ + -DLONLY=ON \ + -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake + + - name: Build + run: | + cmake --build . --config ${{env.BUILD_TYPE}} + + - name: Checkout shell test framework + uses: actions/checkout@v3 + with: + repository: kward/shunit2 + path: tests/shunit2 + fetch-depth: 1 + + - name: Run additional tests + run: | + ls -l libemf2svg* + ldd libemf2svg.so +# tests/resources/lcheck.sh diff --git a/.github/workflows/ubuntu-x86_64.yml b/.github/workflows/ubuntu-x86_64.yml index 0ef2274a..b1e74ba2 100644 --- a/.github/workflows/ubuntu-x86_64.yml +++ b/.github/workflows/ubuntu-x86_64.yml @@ -13,13 +13,14 @@ on: env: BUILD_TYPE: Release + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: - build: + build-and-test: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 - name: Install packages run: | @@ -46,9 +47,9 @@ jobs: coverage: runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v3 - name: Install packages run: | @@ -75,3 +76,47 @@ jobs: -E '.*goodies.*' \ -E '.*tests.*' \ --gcov-options '\-lp' + + build-for-ruby: + runs-on: ubuntu-latest + steps: + - name: Install packages + run: | + sudo apt-get update + sudo apt-get install gperf + + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Create cache storage and cache key + run: | + mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + git submodule status > sm.txt + + - name: Process cache + uses: actions/cache@v2 + with: + path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} + + - name: Configure CMake + run: | + cmake -B . -DCMAKE_BUILD_TYPE=Release \ + -DVCPKG_TARGET_TRIPLET=x64-linux \ + -DLONLY=ON \ + -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake + + - name: Build + run: cmake --build . --config ${{env.BUILD_TYPE}} + + - name: Checkout shell test framework + uses: actions/checkout@v3 + with: + repository: kward/shunit2 + path: tests/shunit2 + fetch-depth: 1 + + - name: Run additional tests + run: tests/resources/lcheck.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 80e76cc4..2f456c3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,14 +2,14 @@ cmake_minimum_required (VERSION 3.12) include(CheckFunctionExists) include(ExternalProject) -# Comments re MSVC build -# - We use vcpkg to install MSVC versions of the following GNU libraries +# Comments re vcpkg +# - We use vcpkg to install the following libraries # and their dependencies: # -- libpng # -- freetype # -- fontconfig # -- iconv -# - vcpkg is configured as git submodule. Some experts consider it is the best prectice +# - vcpkg is configured as git submodule. Some experts consider it is the best practice # (though other experts do not) # - The list of vcpkg modules is specified at vcpkg.json # - With this setup and when called with -DCMAKE_TOOLCHAIN_FILE={project root}/vcpkg/scripts/buildsystems/vcpkg.cmake @@ -33,8 +33,6 @@ endif(VCPKG_TARGET_TRIPLET) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") - -# Options option(LONLY "build library only" OFF) option(GCOV "compile with gcov support" OFF) option(UNITTEST "compile unit tests" OFF) @@ -51,6 +49,16 @@ else(STATIC) set(SHARED "SHARED") endif(STATIC) +if(GCOV) + SET(UNITTEST ON) + SET(CMAKE_BUILD_TYPE "Debug") +endif(GCOV) + +if(UNITTEST) + SET(LONLY OFF) + message(WARNING "LONLY cannot be used with GCOV and/or UNITTEST; ignoring") +endif(UNITTEST) + find_package(PNG REQUIRED) find_package(Freetype REQUIRED) find_package(Fontconfig REQUIRED) @@ -94,20 +102,17 @@ add_custom_target(tag set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DE2S_VERSION='\"${emf2svg_VERSION}\"'") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DE2S_VERSION=${emf2svg_VERSION}") -message(STATUS "Configuring argp") -list(APPEND CMAKE_MESSAGE_INDENT " ") -message(STATUS "Checking if argp is provided system libraries") -CHECK_FUNCTION_EXISTS(argp_parse HAVE_BUNDLED_ARGP_PARSE_FUNCTION) +if(NOT LONLY) + message(STATUS "Configuring argp") + list(APPEND CMAKE_MESSAGE_INDENT " ") + message(STATUS "Checking if argp is provided system libraries") + CHECK_FUNCTION_EXISTS(argp_parse HAVE_BUNDLED_ARGP_PARSE_FUNCTION) -message(STATUS "Looking for standalone argp library") -set(CMAKE_REQUIRED_LIBRARIES argp) -CHECK_FUNCTION_EXISTS(argp_parse HAVE_EXTERNAL_ARGP_PARSE_FUNCTION) -list(POP_BACK CMAKE_MESSAGE_INDENT) - -if(GCOV) - SET(UNITTEST ON) - SET(CMAKE_BUILD_TYPE "Debug") -endif(GCOV) + message(STATUS "Looking for standalone argp library") + set(CMAKE_REQUIRED_LIBRARIES argp) + CHECK_FUNCTION_EXISTS(argp_parse HAVE_EXTERNAL_ARGP_PARSE_FUNCTION) + list(POP_BACK CMAKE_MESSAGE_INDENT) +endif(NOT LONLY) if(INDEX) set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -DRECORD_INDEX='true'") @@ -158,34 +163,35 @@ if(MSVC) set(EXTERNAL_ICONV ${Iconv_LIBRARY}) endif(MSVC) -if(HAVE_BUNDLED_ARGP_PARSE_FUNCTION) - message(STATUS "Using bundled argp") -elseif(HAVE_EXTERNAL_ARGP_PARSE_FUNCTION) - message(STATUS "Using stand-alone argp") - set(EXTERNAL_ARGP "argp") -else() - message(STATUS "Building argp") - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +if(NOT LONLY) + if(HAVE_BUNDLED_ARGP_PARSE_FUNCTION) + message(STATUS "Using bundled argp") + elseif(HAVE_EXTERNAL_ARGP_PARSE_FUNCTION) + message(STATUS "Using stand-alone argp") + set(EXTERNAL_ARGP "argp") + else() + message(STATUS "Building argp") + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # https://www.gnu.org/software/gnulib/manual/html_node/argp_005fprogram_005fversion_005fhook.html - set(EXTERNAL_ARGP "-Wl,-force_load,${DEPS}/lib/libargp-standalone.a") - else(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(EXTERNAL_ARGP "argp-standalone") - endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - - set(ARGP_NAME argp${EXTERNAL_LIB_DIR_SUFFIX}) - ExternalProject_Add(${ARGP_NAME} - PREFIX ${DEPS} - GIT_REPOSITORY https://github.com/tom42/argp-standalone.git - GIT_TAG 238d83d6fb4fbdbb3e0893f51698d8d54696bfb0 - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${DEPS} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - ${PLATFORM_TOOLCHAIN_OPTION} - ${CMAKE_OSX_ARCHITECTURES_OPTION} - PATCH_COMMAND cd ${DEPS}/src/${ARGP_NAME} && git restore CMakeLists.txt && git apply ${PATCHES}/argp/CMakeLists.txt.patch - ) -endif(HAVE_BUNDLED_ARGP_PARSE_FUNCTION) + set(EXTERNAL_ARGP "-Wl,-force_load,${DEPS}/lib/libargp-standalone.a") + else(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(EXTERNAL_ARGP "argp-standalone") + endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + + set(ARGP_NAME argp${EXTERNAL_LIB_DIR_SUFFIX}) + ExternalProject_Add(${ARGP_NAME} + PREFIX ${DEPS} + GIT_REPOSITORY https://github.com/tom42/argp-standalone.git + GIT_TAG 238d83d6fb4fbdbb3e0893f51698d8d54696bfb0 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${DEPS} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + ${PLATFORM_TOOLCHAIN_OPTION} + ${CMAKE_OSX_ARCHITECTURES_OPTION} + PATCH_COMMAND cd ${DEPS}/src/${ARGP_NAME} && git restore CMakeLists.txt && git apply ${PATCHES}/argp/CMakeLists.txt.patch + ) + endif(HAVE_BUNDLED_ARGP_PARSE_FUNCTION) +endif(NOT LONLY) -# headers & library directories if(MSVC) include_directories( ./inc @@ -218,55 +224,38 @@ else(MSVC) ) endif(MSVC) -# Compile the library add_library(emf2svg - ${SHARED} - src/lib/pmf2svg.c - src/lib/pmf2svg_print.c - ${DEPS_UEMF}/uemf_utf.c - ${DEPS_UEMF}/uemf_endian.c - ${DEPS_UEMF}/uemf.c - ${DEPS_UEMF}/upmf.c - src/lib/emf2svg_utils.c - src/lib/emf2svg_img_utils.c - src/lib/emf2svg_clip_utils.c - src/lib/emf2svg_rec_control.c - src/lib/emf2svg_rec_object_creation.c - src/lib/emf2svg_rec_path.c - src/lib/emf2svg_rec_clipping.c - src/lib/emf2svg_rec_drawing.c - src/lib/emf2svg_rec_bitmap.c - src/lib/emf2svg_rec_object_manipulation.c - src/lib/emf2svg_rec_comment.c - src/lib/emf2svg_rec_transform.c - src/lib/emf2svg_rec_state_record.c - src/lib/emf2svg_print.c - src/lib/emf2svg.c + ${SHARED} + src/lib/pmf2svg.c + src/lib/pmf2svg_print.c + ${DEPS_UEMF}/uemf_utf.c + ${DEPS_UEMF}/uemf_endian.c + ${DEPS_UEMF}/uemf.c + ${DEPS_UEMF}/upmf.c + src/lib/emf2svg_utils.c + src/lib/emf2svg_img_utils.c + src/lib/emf2svg_clip_utils.c + src/lib/emf2svg_rec_control.c + src/lib/emf2svg_rec_object_creation.c + src/lib/emf2svg_rec_path.c + src/lib/emf2svg_rec_clipping.c + src/lib/emf2svg_rec_drawing.c + src/lib/emf2svg_rec_bitmap.c + src/lib/emf2svg_rec_object_manipulation.c + src/lib/emf2svg_rec_comment.c + src/lib/emf2svg_rec_transform.c + src/lib/emf2svg_rec_state_record.c + src/lib/emf2svg_print.c + src/lib/emf2svg.c ) set_target_properties(emf2svg - PROPERTIES - VERSION ${emf2svg_VERSION} - SOVERSION ${emf2svg_VERSION_MAJOR} + PROPERTIES + VERSION ${emf2svg_VERSION} + SOVERSION ${emf2svg_VERSION_MAJOR} ) target_link_libraries(emf2svg - ${PNG_LIBRARIES} - ${LIBXML2_LIBRARIES} - ${EXTERNAL_ICONV} - ${FREETYPE_LIBRARIES} - ${FONTCONFIG_LIBRARIES} - ${EXPAT_LIBRARY_RELEASE} - ${EXTERNAL_FMEM} -) - -add_dependencies(emf2svg ${FMEM_NAME}) - -add_executable(emf2svg-conv src/conv/emf2svg.cpp) - -target_link_libraries(emf2svg-conv - emf2svg - ${EXTERNAL_ARGP} ${PNG_LIBRARIES} ${LIBXML2_LIBRARIES} ${EXTERNAL_ICONV} @@ -276,28 +265,46 @@ target_link_libraries(emf2svg-conv ${EXTERNAL_FMEM} ) -if(ARGP_NAME) - add_dependencies(emf2svg-conv ${ARGP_NAME}) -endif(ARGP_NAME) - -if(GCOV) - Set(COVERAGE_EXCLUDES '*conv*' '*uemf*' '*upmf*' '*tests*' '*c++*') - include(CodeCoverage) - setup_target_for_coverage(NAME coverage - EXECUTABLE emf2svg-test ./tests/resources/emf*/* - DEPENDENCIES emf2svg-test - ) - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") -endif(GCOV) +add_dependencies(emf2svg ${FMEM_NAME}) -if(UNITTEST) - add_executable(emf2svg-test tests/test.c) +if(NOT LONLY) + add_executable(emf2svg-conv src/conv/emf2svg.cpp) - target_link_libraries(emf2svg-test + target_link_libraries(emf2svg-conv emf2svg + ${EXTERNAL_ARGP} + ${PNG_LIBRARIES} + ${LIBXML2_LIBRARIES} + ${EXTERNAL_ICONV} + ${FREETYPE_LIBRARIES} + ${FONTCONFIG_LIBRARIES} + ${EXPAT_LIBRARY_RELEASE} + ${EXTERNAL_FMEM} ) -endif(UNITTEST) + + if(ARGP_NAME) + add_dependencies(emf2svg-conv ${ARGP_NAME}) + endif(ARGP_NAME) + + if(GCOV) + Set(COVERAGE_EXCLUDES '*conv*' '*uemf*' '*upmf*' '*tests*' '*c++*') + include(CodeCoverage) + setup_target_for_coverage(NAME coverage + EXECUTABLE emf2svg-test ./tests/resources/emf*/* + DEPENDENCIES emf2svg-test + ) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") + endif(GCOV) + + if(UNITTEST) + add_executable(emf2svg-test tests/test.c) + + target_link_libraries(emf2svg-test + emf2svg + ) + endif(UNITTEST) +endif(NOT LONLY) if (MSVC) # x64: suppress mostly harmless warnings about 64 to 32 bit conversion (4244, 4267, 4305). @@ -320,12 +327,15 @@ if (NOT INCLUDE_INSTALL_DIR) set(INCLUDE_INSTALL_DIR include) endif () -# install binaries and library -INSTALL(TARGETS emf2svg emf2svg-conv +list(APPEND BINTARGETS emf2svg) +if(NOT LONLY) + list(APPEND BINTARGETS emf2svg-conv) +endif(NOT LONLY) + +INSTALL(TARGETS ${BINTARGETS} RUNTIME DESTINATION ${BIN_INSTALL_DIR} LIBRARY DESTINATION ${LIB_INSTALL_DIR} ARCHIVE DESTINATION ${LIB_INSTALL_DIR} ) -# install header file INSTALL(FILES inc/emf2svg.h DESTINATION ${INCLUDE_INSTALL_DIR}) diff --git a/tests/resources/lcheck.sh b/tests/resources/lcheck.sh new file mode 100755 index 00000000..9b5b8e31 --- /dev/null +++ b/tests/resources/lcheck.sh @@ -0,0 +1,86 @@ +#! /bin/bash +# +# Copyright (c) 2022 [Ribose Inc](https://www.ribose.com). +# All rights reserved. +# This file is a part of tebako +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +set -o errexit -o pipefail -o noclobber -o nounset + +# Checks referenced shared libraries +# $1 - an array of expected refs to shared libraries +# $2 - an array of actual refs to shared libraries +check_shared_libs() { + expected_size="${#expected[@]}" + actual_size="${#actual[@]}" + assertEquals "The number of references to shared libraries does not meet our expectations" "$expected_size" "$actual_size" + + for exp in "${expected[@]}"; do + for i in "${!actual[@]}"; do + if [[ "${actual[i]}" == *"$exp"* ]]; then + unset 'actual[i]' + fi + done + done + + for unexp in "${actual[@]}"; do + echo "Unxpected reference to shared library $unexp" + done + + assertEquals "Unxpected references to shared libraries" 0 "${#actual[@]}" +} + +test_linkage() { + echo "==> References to shared libraries test" + if [[ "$OSTYPE" == "linux-gnu"* ]]; then + expected=("linux-vdso.so" "libpthread.so" "libc.so" "libm.so" "ld-linux-x86-64.so") + readarray -t actual < <(ldd "$probe.so") + assertEquals "readarray -t actual < <(ldd $probe.so) failed" 0 "${PIPESTATUS[0]}" + check_shared_libs + elif [[ "$OSTYPE" == "linux-musl"* ]]; then + expected=("libgcc_s.so" "libc.musl-x86_64.so" "ld-musl-x86_64.so") + readarray -t actual < <(ldd "$probe.so") + assertEquals "readarray -t actual < <(ldd $probe.so) failed" 0 "${PIPESTATUS[0]}" + check_shared_libs + elif [[ "$OSTYPE" == "darwin"* ]]; then + expected=("libc++.1.dylib" "libSystem.B.dylib" "wr-bin") + readarray -t actual < <(otool -L "$probe.bundle") + assertEquals "readarray -t actual < <(otool -L $probe.bundle) failed" 0 "${PIPESTATUS[0]}" + check_shared_libs "${expected[@]}" + else + echo "... unknown - $OSTYPE ... skipping" + fi +} + +# ...................................................................... +# main +DIR0="$( cd "$( dirname "$0" )" && pwd )" +DIR1="${DIR_ROOT:="$DIR0/../.."}" +DIR_ROOT="$( cd "$DIR1" && pwd )" + +DIR_TESTS="$( cd "$DIR0/.." && pwd)" + +echo "Running libemf2svg linkage tests" +probe="$DIR_ROOT/libemf2svg" +# shellcheck source=/dev/null +. "$DIR_TESTS"/shunit2/shunit2 From adfd027ee737a5446a76be42082868003d23f52e Mon Sep 17 00:00:00 2001 From: "Maxim [maxirmx] Samsonov" Date: Fri, 8 Apr 2022 20:54:00 +0300 Subject: [PATCH 3/5] CMake script optimization (ubuntu) --- .github/workflows/alpine-x86_64.yml | 7 +-- .github/workflows/macos-arm64.yml | 2 +- .github/workflows/macos-x86_64.yml | 8 +-- .../{ubuntu-arm64.yml => ubuntu-aarch64.yml} | 52 +++++++++++++++++-- .github/workflows/ubuntu-x86_64.yml | 2 +- .github/workflows/windows-build.yml | 2 +- tests/resources/lcheck.sh | 2 +- 7 files changed, 59 insertions(+), 16 deletions(-) rename .github/workflows/{ubuntu-arm64.yml => ubuntu-aarch64.yml} (52%) diff --git a/.github/workflows/alpine-x86_64.yml b/.github/workflows/alpine-x86_64.yml index 14ac9a28..b72ac7c7 100644 --- a/.github/workflows/alpine-x86_64.yml +++ b/.github/workflows/alpine-x86_64.yml @@ -6,7 +6,7 @@ on: - '.github/workflows/macos-x86_64.yml' - '.github/workflows/macos-arm64.yml' - '.github/workflows/ubuntu-x86_64.yml' - - '.github/workflows/ubuntu-arm64.yml' + - '.github/workflows/ubuntu-aarch64.yml' - '.github/workflows/windows-build.yml' pull_request: workflow_dispatch: @@ -125,7 +125,4 @@ jobs: fetch-depth: 1 - name: Run additional tests - run: | - ls -l libemf2svg* - ldd libemf2svg.so -# tests/resources/lcheck.sh + run: tests/resources/lcheck.sh diff --git a/.github/workflows/macos-arm64.yml b/.github/workflows/macos-arm64.yml index b23a3177..73c02cf3 100644 --- a/.github/workflows/macos-arm64.yml +++ b/.github/workflows/macos-arm64.yml @@ -5,7 +5,7 @@ on: paths-ignore: - '.github/workflows/alpine-x86_64.yml' - '.github/workflows/ubuntu-x86_64.yml' - - '.github/workflows/ubuntu-arm64.yml' + - '.github/workflows/ubuntu-aarch64.yml' - '.github/workflows/windows-build.yml' - '.github/workflows/macos-x86_64.yml' pull_request: diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index cc6c5c75..9a10267b 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -5,7 +5,7 @@ on: paths-ignore: - '.github/workflows/alpine-x86_64.yml' - '.github/workflows/ubuntu-x86_64.yml' - - '.github/workflows/ubuntu-arm64.yml' + - '.github/workflows/ubuntu-aarch64.yml' - '.github/workflows/windows-build.yml' - '.github/workflows/macos-arm64.yml' pull_request: @@ -21,12 +21,12 @@ jobs: steps: - uses: actions/checkout@v3 +# brew install lcov - name: Install packages run: | brew install argp-standalone coreutils -# brew install lcov -# brew tap LouisBrunner/valgrind -# brew install --HEAD LouisBrunner/valgrind/valgrind + brew tap LouisBrunner/valgrind + brew install --HEAD LouisBrunner/valgrind/valgrind - name: Configure CMake run: cmake -B ${{ github.workspace }} -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} diff --git a/.github/workflows/ubuntu-arm64.yml b/.github/workflows/ubuntu-aarch64.yml similarity index 52% rename from .github/workflows/ubuntu-arm64.yml rename to .github/workflows/ubuntu-aarch64.yml index 7001d4c7..506167f3 100644 --- a/.github/workflows/ubuntu-arm64.yml +++ b/.github/workflows/ubuntu-aarch64.yml @@ -1,4 +1,4 @@ -name: Ubuntu-arm64 build +name: Ubuntu-aarch64 build on: push: @@ -16,7 +16,7 @@ env: VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: - build: + build-all: runs-on: ubuntu-latest steps: @@ -37,7 +37,8 @@ jobs: - name: Install packages run: | sudo apt-get update - sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu gperf qemu-user + sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu \ + gperf qemu-user - name: Configure CMake run: | @@ -55,3 +56,48 @@ jobs: qemu-aarch64 -L /usr/aarch64-linux-gnu ${{ github.workspace }}/emf2svg-conv \ -i ${{ github.workspace }}/tests/resources/emf/test-000.emf -o test-000.svg ls | grep test-000.svg + + build-for-ruby: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Create cache storage and cache key + run: | + mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + git submodule status > sm.txt + + - uses: actions/cache@v2 + with: + path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} + + - name: Install packages + run: | + sudo apt-get update + sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu \ + gperf + + - name: Configure CMake + run: | + cmake -B ${{ github.workspace }} \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \ + -DLONLY=ON \ + -DVCPKG_TARGET_TRIPLET=arm64-linux + + - name: Build + run: cmake --build ${{ github.workspace }} --config ${{env.BUILD_TYPE}} + + - name: Checkout shell test framework + uses: actions/checkout@v3 + with: + repository: kward/shunit2 + path: tests/shunit2 + fetch-depth: 1 + + - name: Run additional tests + run: tests/resources/lcheck.sh diff --git a/.github/workflows/ubuntu-x86_64.yml b/.github/workflows/ubuntu-x86_64.yml index b1e74ba2..99f609e4 100644 --- a/.github/workflows/ubuntu-x86_64.yml +++ b/.github/workflows/ubuntu-x86_64.yml @@ -6,7 +6,7 @@ on: - '.github/workflows/alpine-x86_64.yml' - '.github/workflows/macos-x86_64.yml' - '.github/workflows/macos-arm64.yml' - - '.github/workflows/ubuntu-arm64.yml' + - '.github/workflows/ubuntu-aarch64.yml' - '.github/workflows/windows-build.yml' pull_request: workflow_dispatch: diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index c37da7a6..0033de6b 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -6,7 +6,7 @@ on: - '.github/workflows/alpine-x86_64.yml' - '.github/workflows/macos-x86_64.yml' - '.github/workflows/macos-arm64.yml' - - '.github/workflows/ubuntu-arm64.yml' + - '.github/workflows/ubuntu-aarch64.yml' - '.github/workflows/ubuntu-x86_64.yml' pull_request: workflow_dispatch: diff --git a/tests/resources/lcheck.sh b/tests/resources/lcheck.sh index 9b5b8e31..44ab72e8 100755 --- a/tests/resources/lcheck.sh +++ b/tests/resources/lcheck.sh @@ -58,7 +58,7 @@ test_linkage() { assertEquals "readarray -t actual < <(ldd $probe.so) failed" 0 "${PIPESTATUS[0]}" check_shared_libs elif [[ "$OSTYPE" == "linux-musl"* ]]; then - expected=("libgcc_s.so" "libc.musl-x86_64.so" "ld-musl-x86_64.so") + expected=("libc.musl-x86_64.so" "ld-musl-x86_64.so") readarray -t actual < <(ldd "$probe.so") assertEquals "readarray -t actual < <(ldd $probe.so) failed" 0 "${PIPESTATUS[0]}" check_shared_libs From 50bfe8c7a84160be4d619bfc87e56bd3ae2ee89d Mon Sep 17 00:00:00 2001 From: "Maxim [maxirmx] Samsonov" Date: Fri, 8 Apr 2022 21:05:34 +0300 Subject: [PATCH 4/5] CMake script optimization (MacOS) --- .github/workflows/alpine-x86_64.yml | 14 +++--- .github/workflows/macos-arm64.yml | 38 ++++++++++++---- .github/workflows/macos-x86_64.yml | 67 +++++++++++++++++++++++++++- .github/workflows/ubuntu-aarch64.yml | 55 +++-------------------- .github/workflows/windows-build.yml | 6 ++- CMakeLists.txt | 2 +- tests/resources/lcheck.sh | 8 ++-- 7 files changed, 117 insertions(+), 73 deletions(-) diff --git a/.github/workflows/alpine-x86_64.yml b/.github/workflows/alpine-x86_64.yml index b72ac7c7..90b25118 100644 --- a/.github/workflows/alpine-x86_64.yml +++ b/.github/workflows/alpine-x86_64.yml @@ -36,7 +36,8 @@ jobs: # libxml2-utils # [ tests/resources/emf/test-183.emf ] -- font-noto-hebrew font-noto-arabic - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: submodules: recursive @@ -62,8 +63,7 @@ jobs: cmake -B . -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=x64-linux -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build - run: | - cmake --build . --config ${{env.BUILD_TYPE}} + run: cmake --build . --config ${{env.BUILD_TYPE}} - name: Test well formed files run: ./tests/resources/check_correctness.sh -r -s @@ -85,7 +85,8 @@ jobs: apk --no-cache --upgrade add build-base cmake git valgrind tar bash \ gcompat gperf flex bison gettext-dev python3 ninja zip unzip curl pkgconfig - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: submodules: recursive @@ -114,8 +115,7 @@ jobs: -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build - run: | - cmake --build . --config ${{env.BUILD_TYPE}} + run: cmake --build . --config ${{env.BUILD_TYPE}} - name: Checkout shell test framework uses: actions/checkout@v3 @@ -125,4 +125,4 @@ jobs: fetch-depth: 1 - name: Run additional tests - run: tests/resources/lcheck.sh + run: tests/resources/lcheck.sh diff --git a/.github/workflows/macos-arm64.yml b/.github/workflows/macos-arm64.yml index 73c02cf3..b5870265 100644 --- a/.github/workflows/macos-arm64.yml +++ b/.github/workflows/macos-arm64.yml @@ -1,4 +1,4 @@ -name: MacOS-arm64 build +name: MacOS-arm64 on: push: @@ -16,30 +16,52 @@ env: VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: - build: + build-for-ruby: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: submodules: recursive + - name: Setup environment + run: | + echo 'BREW_HOME<> $GITHUB_ENV + brew --prefix >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + + - name: Install packages + run: brew install bash + - name: Create cache storage and cache key run: | mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} git submodule status > sm.txt - - uses: actions/cache@v2 + - name: Process cache + uses: actions/cache@v2 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} - name: Configure CMake run: | - cmake -B ${{ github.workspace }} \ - -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ - -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \ - -DVCPKG_TARGET_TRIPLET=arm64-osx + cmake -B ${{ github.workspace }} \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ + -DVCPKG_TARGET_TRIPLET=arm64-osx \ + -DLONLY=ON \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake - name: Build run: cmake --build ${{github.workspace}} --config ${{env.BUILD_TYPE}} + + - name: Checkout shell test framework + uses: actions/checkout@v3 + with: + repository: kward/shunit2 + path: tests/shunit2 + fetch-depth: 1 + + - name: Run additional tests + run: ${{ env.BREW_HOME }}/bin/bash tests/resources/lcheck.sh diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index 9a10267b..ab776ffa 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -13,15 +13,16 @@ on: env: BUILD_TYPE: Release + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: build: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 -# brew install lcov - name: Install packages run: | brew install argp-standalone coreutils @@ -33,3 +34,65 @@ jobs: - name: Build run: cmake --build ${{ github.workspace }} --config ${{ env.BUILD_TYPE }} + + - name: Test well formed files + working-directory: ${{ github.workspace }} + run: ./tests/resources/check_correctness.sh -r -s + + - name: Test corrupted files + working-directory: ${{ github.workspace }} + run: ./tests/resources/check_correctness.sh -r -s -e tests/resources/emf-corrupted/ -xN + + - name: Test EA files + working-directory: ${{ github.workspace }} + run: ./tests/resources/check_correctness.sh -r -s -e tests/resources/emf-ea/ + + build-for-ruby: + runs-on: macos-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup environment + run: | + echo 'BREW_HOME<> $GITHUB_ENV + brew --prefix >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + + - name: Install packages + run: brew install bash + + - name: Create cache storage and cache key + run: | + mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + git submodule status > sm.txt + + - name: Process cache + uses: actions/cache@v2 + with: + path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }}-2 + + - name: Configure CMake + run: | + cmake -B ${{ github.workspace }} \ + -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ + -DVCPKG_TARGET_TRIPLET=x64-osx \ + -DLONLY=ON \ + -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake + + - name: Build + run: cmake --build ${{github.workspace}} --config ${{env.BUILD_TYPE}} + + - name: Checkout shell test framework + uses: actions/checkout@v3 + with: + repository: kward/shunit2 + path: tests/shunit2 + fetch-depth: 1 + + - name: Run additional tests + run: ${{ env.BREW_HOME }}/bin/bash tests/resources/lcheck.sh diff --git a/.github/workflows/ubuntu-aarch64.yml b/.github/workflows/ubuntu-aarch64.yml index 506167f3..4b9d3332 100644 --- a/.github/workflows/ubuntu-aarch64.yml +++ b/.github/workflows/ubuntu-aarch64.yml @@ -1,4 +1,4 @@ -name: Ubuntu-aarch64 build +name: Ubuntu-aarch64 on: push: @@ -16,11 +16,12 @@ env: VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: - build-all: + build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: submodules: recursive @@ -29,7 +30,8 @@ jobs: mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} git submodule status > sm.txt - - uses: actions/cache@v2 + - name: Process cache + uses: actions/cache@v2 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} @@ -56,48 +58,3 @@ jobs: qemu-aarch64 -L /usr/aarch64-linux-gnu ${{ github.workspace }}/emf2svg-conv \ -i ${{ github.workspace }}/tests/resources/emf/test-000.emf -o test-000.svg ls | grep test-000.svg - - build-for-ruby: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Create cache storage and cache key - run: | - mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - git submodule status > sm.txt - - - uses: actions/cache@v2 - with: - path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} - - - name: Install packages - run: | - sudo apt-get update - sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu \ - gperf - - - name: Configure CMake - run: | - cmake -B ${{ github.workspace }} \ - -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ - -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake \ - -DLONLY=ON \ - -DVCPKG_TARGET_TRIPLET=arm64-linux - - - name: Build - run: cmake --build ${{ github.workspace }} --config ${{env.BUILD_TYPE}} - - - name: Checkout shell test framework - uses: actions/checkout@v3 - with: - repository: kward/shunit2 - path: tests/shunit2 - fetch-depth: 1 - - - name: Run additional tests - run: tests/resources/lcheck.sh diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 0033de6b..0d2759ef 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -20,7 +20,8 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 with: submodules: recursive @@ -29,7 +30,8 @@ jobs: mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} git submodule status > sm.txt - - uses: actions/cache@v2 + - name: Process cache + uses: actions/cache@v2 with: path: ${{env.VCPKG_DEFAULT_BINARY_CACHE}} key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f456c3f..9fe6633f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -105,7 +105,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DE2S_VERSION=${emf2svg_VERSION}") if(NOT LONLY) message(STATUS "Configuring argp") list(APPEND CMAKE_MESSAGE_INDENT " ") - message(STATUS "Checking if argp is provided system libraries") + message(STATUS "Checking if argp is provided by system libraries") CHECK_FUNCTION_EXISTS(argp_parse HAVE_BUNDLED_ARGP_PARSE_FUNCTION) message(STATUS "Looking for standalone argp library") diff --git a/tests/resources/lcheck.sh b/tests/resources/lcheck.sh index 44ab72e8..0ee0d157 100755 --- a/tests/resources/lcheck.sh +++ b/tests/resources/lcheck.sh @@ -55,7 +55,7 @@ test_linkage() { if [[ "$OSTYPE" == "linux-gnu"* ]]; then expected=("linux-vdso.so" "libpthread.so" "libc.so" "libm.so" "ld-linux-x86-64.so") readarray -t actual < <(ldd "$probe.so") - assertEquals "readarray -t actual < <(ldd $probe.so) failed" 0 "${PIPESTATUS[0]}" + assertEquals "readarray -t actual < <(ldd "$probe.so") failed" 0 "${PIPESTATUS[0]}" check_shared_libs elif [[ "$OSTYPE" == "linux-musl"* ]]; then expected=("libc.musl-x86_64.so" "ld-musl-x86_64.so") @@ -63,9 +63,9 @@ test_linkage() { assertEquals "readarray -t actual < <(ldd $probe.so) failed" 0 "${PIPESTATUS[0]}" check_shared_libs elif [[ "$OSTYPE" == "darwin"* ]]; then - expected=("libc++.1.dylib" "libSystem.B.dylib" "wr-bin") - readarray -t actual < <(otool -L "$probe.bundle") - assertEquals "readarray -t actual < <(otool -L $probe.bundle) failed" 0 "${PIPESTATUS[0]}" + expected=("libSystem.B.dylib" "libiconv.2.dylib" "libcharset.1.dylib" "libemf2svg.1.dylib" "libemf2svg.dylib") + readarray -t actual < <(otool -L "$probe.dylib") + assertEquals "readarray -t actual < <(otool -L $probe.dylib) failed" 0 "${PIPESTATUS[0]}" check_shared_libs "${expected[@]}" else echo "... unknown - $OSTYPE ... skipping" From 98f793821eb476de3ccc1c919172cd9219f45115 Mon Sep 17 00:00:00 2001 From: "Maxim [maxirmx] Samsonov" Date: Fri, 8 Apr 2022 22:45:30 +0300 Subject: [PATCH 5/5] Workflow optimization (Windows) --- .github/workflows/alpine-x86_64.yml | 15 +- .github/workflows/macos-arm64.yml | 3 +- .github/workflows/macos-x86_64.yml | 7 +- .github/workflows/msys-x86_64.yml | 138 ++++++++++++++++++ .github/workflows/ubuntu-aarch64.yml | 5 +- .github/workflows/ubuntu-x86_64.yml | 3 +- .../{windows-build.yml => windows-x86_64.yml} | 11 +- CMakeLists.txt | 6 +- README.md | 31 ++-- tests/resources/check_correctness.sh | 4 +- tests/resources/check_truncate.sh | 2 +- tests/resources/colors.sh | 2 +- tests/resources/lcheck.sh | 10 +- 13 files changed, 194 insertions(+), 43 deletions(-) create mode 100644 .github/workflows/msys-x86_64.yml rename .github/workflows/{windows-build.yml => windows-x86_64.yml} (80%) diff --git a/.github/workflows/alpine-x86_64.yml b/.github/workflows/alpine-x86_64.yml index 90b25118..dd4a8d76 100644 --- a/.github/workflows/alpine-x86_64.yml +++ b/.github/workflows/alpine-x86_64.yml @@ -7,7 +7,8 @@ on: - '.github/workflows/macos-arm64.yml' - '.github/workflows/ubuntu-x86_64.yml' - '.github/workflows/ubuntu-aarch64.yml' - - '.github/workflows/windows-build.yml' + - '.github/workflows/windows-x86_64.yml' + - '.github/workflows/msys-x86_64.yml' pull_request: workflow_dispatch: @@ -33,8 +34,8 @@ jobs: # vcpkg prerequisites (and VCPKG_FORCE_SYSTEM_BINARIES: 1) # gcompat gperf flex bison gettext-dev python3 ninja zip unzip curl pkg-config # testing prerequisites -# libxml2-utils -# [ tests/resources/emf/test-183.emf ] -- font-noto-hebrew font-noto-arabic +# libxml2-utils +# [ tests/resources/emf/test-183.emf ] -- font-noto-hebrew font-noto-arabic - name: Checkout uses: actions/checkout@v3 @@ -56,7 +57,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }}-2 + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} - name: Configure CMake run: | @@ -82,8 +83,8 @@ jobs: steps: - name: Install packages run: | - apk --no-cache --upgrade add build-base cmake git valgrind tar bash \ - gcompat gperf flex bison gettext-dev python3 ninja zip unzip curl pkgconfig + apk --no-cache --upgrade add build-base cmake git tar bash \ + gcompat gperf flex bison gettext-dev python3 ninja zip unzip curl pkgconfig - name: Checkout uses: actions/checkout@v3 @@ -105,7 +106,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }}-2 + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} - name: Configure CMake run: | diff --git a/.github/workflows/macos-arm64.yml b/.github/workflows/macos-arm64.yml index b5870265..a96b1503 100644 --- a/.github/workflows/macos-arm64.yml +++ b/.github/workflows/macos-arm64.yml @@ -6,7 +6,8 @@ on: - '.github/workflows/alpine-x86_64.yml' - '.github/workflows/ubuntu-x86_64.yml' - '.github/workflows/ubuntu-aarch64.yml' - - '.github/workflows/windows-build.yml' + - '.github/workflows/msys-x86_64.yml' + - '.github/workflows/windows-x86_64.yml' - '.github/workflows/macos-x86_64.yml' pull_request: workflow_dispatch: diff --git a/.github/workflows/macos-x86_64.yml b/.github/workflows/macos-x86_64.yml index ab776ffa..7a170cd8 100644 --- a/.github/workflows/macos-x86_64.yml +++ b/.github/workflows/macos-x86_64.yml @@ -6,7 +6,8 @@ on: - '.github/workflows/alpine-x86_64.yml' - '.github/workflows/ubuntu-x86_64.yml' - '.github/workflows/ubuntu-aarch64.yml' - - '.github/workflows/windows-build.yml' + - '.github/workflows/msys-x86_64.yml' + - '.github/workflows/windows-x86_64.yml' - '.github/workflows/macos-arm64.yml' pull_request: workflow_dispatch: @@ -16,7 +17,7 @@ env: VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: - build: + build-and-test: runs-on: macos-latest steps: @@ -74,7 +75,7 @@ jobs: uses: actions/cache@v2 with: path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} - key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }}-2 + key: ${{ github.workflow }}-vcpkg-${{ hashFiles('sm.txt') }} - name: Configure CMake run: | diff --git a/.github/workflows/msys-x86_64.yml b/.github/workflows/msys-x86_64.yml new file mode 100644 index 00000000..bbaa5552 --- /dev/null +++ b/.github/workflows/msys-x86_64.yml @@ -0,0 +1,138 @@ +name: MSys-x86_64 + +on: + push: + paths-ignore: + - '.github/workflows/alpine-x86_64.yml' + - '.github/workflows/macos-x86_64.yml' + - '.github/workflows/macos-arm64.yml' + - '.github/workflows/ubuntu-aarch64.yml' + - '.github/workflows/ubuntu-x86_64.yml' + - '.github/workflows/windows-x86_64.yml' + pull_request: + workflow_dispatch: + +env: + BUILD_TYPE: Release + MAKEFLAGS: -j4 + +jobs: + build-and-smoke-test: + runs-on: windows-latest + + defaults: + run: + shell: msys2 {0} + steps: + - name: Setup msys + uses: msys2/setup-msys2@v2 + with: + path-type: minimal + msystem: mingw64 + install: git flex bison gettext-devel + pacboy: gperf:p cmake:p python3:p ninja:p curl:p pkgconf:p gcc:p + + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Configure cache + run: | + echo 'VCPKG_DEFAULT_BINARY_CACHE<> $GITHUB_ENV + echo "$(pwd)/cache" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + echo 'CI_CACHE<> $GITHUB_ENV + echo "$(pwd -W)/cache" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + + - name: Create cache storage and cache key + run: | + mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + git submodule status > sm.txt + + - name: Process cache + uses: actions/cache@v2 + with: + path: ${{ env.CI_CACHE }} + key: ${{ github.workflow }}-mingw64-vcpkg-${{ hashFiles('sm.txt') }} + + - name: Configure + run: | + cmake -B . -DCMAKE_BUILD_TYPE=Release \ + -DVCPKG_TARGET_TRIPLET=x64-mingw-static \ + -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake + + - name: Build + run: cmake --build . --config ${{env.BUILD_TYPE}} + + - name: Smoke test + run: | + ./emf2svg-conv.exe --version + ./emf2svg-conv.exe -i tests/resources/emf/test-000.emf -o test-000.svg + ls | grep test-000.svg + + build-for-ruby: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + sys: + - mingw64 + - ucrt64 + defaults: + run: + shell: msys2 {0} + steps: + - name: Setup msys + uses: msys2/setup-msys2@v2 + with: + path-type: minimal + msystem: ${{ matrix.sys }} + install: git flex bison gettext-devel + pacboy: gperf:p cmake:p python3:p ninja:p curl:p pkgconf:p gcc:p + + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Configure cache + run: | + echo 'VCPKG_DEFAULT_BINARY_CACHE<> $GITHUB_ENV + echo "$(pwd)/cache" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + echo 'CI_CACHE<> $GITHUB_ENV + echo "$(pwd -W)/cache" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + + - name: Create cache storage and cache key + run: | + mkdir ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + git submodule status > sm.txt + + - name: Process cache + uses: actions/cache@v2 + with: + path: ${{ env.CI_CACHE }} + key: ${{ github.workflow }}-${{ matrix.sys }}-vcpkg-${{ hashFiles('sm.txt') }} + + - name: Configure + run: | + cmake -B . -DCMAKE_BUILD_TYPE=Release \ + -DVCPKG_TARGET_TRIPLET=x64-mingw-static \ + -DLONLY=ON \ + -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake + + - name: Build + run: cmake --build . --config ${{env.BUILD_TYPE}} + + - name: Checkout shell test framework + uses: actions/checkout@v3 + with: + repository: kward/shunit2 + path: tests/shunit2 + fetch-depth: 1 + + - name: Run additional tests + run: tests/resources/lcheck.sh diff --git a/.github/workflows/ubuntu-aarch64.yml b/.github/workflows/ubuntu-aarch64.yml index 4b9d3332..a138cbb0 100644 --- a/.github/workflows/ubuntu-aarch64.yml +++ b/.github/workflows/ubuntu-aarch64.yml @@ -7,7 +7,8 @@ on: - '.github/workflows/ubuntu-x86_64.yml' - '.github/workflows/macos-x86_64.yml' - '.github/workflows/macos-arm64.yml' - - '.github/workflows/windows-build.yml' + - '.github/workflows/msys-x86_64.yml' + - '.github/workflows/windows-x86_64.yml' pull_request: workflow_dispatch: @@ -16,7 +17,7 @@ env: VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: - build: + build-and-smoke-test: runs-on: ubuntu-latest steps: diff --git a/.github/workflows/ubuntu-x86_64.yml b/.github/workflows/ubuntu-x86_64.yml index 99f609e4..2a0ee745 100644 --- a/.github/workflows/ubuntu-x86_64.yml +++ b/.github/workflows/ubuntu-x86_64.yml @@ -7,7 +7,8 @@ on: - '.github/workflows/macos-x86_64.yml' - '.github/workflows/macos-arm64.yml' - '.github/workflows/ubuntu-aarch64.yml' - - '.github/workflows/windows-build.yml' + - '.github/workflows/msys-x86_64.yml' + - '.github/workflows/windows-x86_64.yml' pull_request: workflow_dispatch: diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-x86_64.yml similarity index 80% rename from .github/workflows/windows-build.yml rename to .github/workflows/windows-x86_64.yml index 0d2759ef..b3410557 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-x86_64.yml @@ -1,4 +1,4 @@ -name: Windows-build +name: Windows-x86_64 on: push: @@ -8,6 +8,7 @@ on: - '.github/workflows/macos-arm64.yml' - '.github/workflows/ubuntu-aarch64.yml' - '.github/workflows/ubuntu-x86_64.yml' + - '.github/workflows/msys-x86_64.yml' pull_request: workflow_dispatch: @@ -16,7 +17,7 @@ env: VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/cache jobs: - build: + build-and-smoke-test: runs-on: windows-latest steps: @@ -45,3 +46,9 @@ jobs: - name: Build run: cmake --build ${{ github.workspace }} --config ${{env.BUILD_TYPE}} + + - name: Smoke test + run: | + Release/emf2svg-conv.exe --version + Release/emf2svg-conv.exe -i tests/resources/emf/test-000.emf -o test-000.svg + dir . | findstr test-000.svg diff --git a/CMakeLists.txt b/CMakeLists.txt index 9fe6633f..8f6c64af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,8 +83,8 @@ ExternalProject_Add(${FMEM_NAME} PREFIX ${DEPS} GIT_REPOSITORY https://github.com/tamatebako/fmem.git GIT_TAG bdce2760f0190253600f11984220fc0a007742c8 - CMAKE_ARGS -DBUILD_TESTING=FALSE - -DCMAKE_INSTALL_PREFIX=${DEPS} + CMAKE_ARGS -DBUILD_TESTING=FALSE + -DCMAKE_INSTALL_PREFIX=${DEPS} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${PLATFORM_TOOLCHAIN_OPTION} ${CMAKE_OSX_ARCHITECTURES_OPTION} @@ -172,7 +172,7 @@ if(NOT LONLY) else() message(STATUS "Building argp") if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - # https://www.gnu.org/software/gnulib/manual/html_node/argp_005fprogram_005fversion_005fhook.html + # https://www.gnu.org/software/gnulib/manual/html_node/argp_005fprogram_005fversion_005fhook.html set(EXTERNAL_ARGP "-Wl,-force_load,${DEPS}/lib/libargp-standalone.a") else(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(EXTERNAL_ARGP "argp-standalone") diff --git a/README.md b/README.md index f8f1acd9..a5c00633 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,8 @@ libemf2svg ========== +[![Ubuntu-x86_64](https://github.com/metanorma/libemf2svg/actions/workflows/ubuntu-x86_64.yml/badge.svg)](https://github.com/metanorma/libemf2svg/actions/workflows/ubuntu-x86_64.yml) [![Ubuntu-aarch64](https://github.com/metanorma/libemf2svg/actions/workflows/ubuntu-aarch64.yml/badge.svg)](https://github.com/metanorma/libemf2svg/actions/workflows/ubuntu-aarch64.yml) [![Alpine-x86_64](https://github.com/metanorma/libemf2svg/actions/workflows/alpine-x86_64.yml/badge.svg)](https://github.com/metanorma/libemf2svg/actions/workflows/alpine-x86_64.yml) -![Build status](https://github.com/metanorma/libemf2svg/actions/workflows/ubuntu-build.yml/badge.svg) -![Build status](https://github.com/metanorma/libemf2svg/actions/workflows/macos-build.yml/badge.svg) -![Build status](https://github.com/metanorma/libemf2svg/actions/workflows/windows-build.yml/badge.svg) -[![Alpine build](https://github.com/metanorma/libemf2svg/actions/workflows/alpine-build.yml/badge.svg)](https://github.com/metanorma/libemf2svg/actions/workflows/alpine-build.yml) - -[![Ubuntu-arm64 build](https://github.com/metanorma/libemf2svg/actions/workflows/ubuntu-arm64.yml/badge.svg)](https://github.com/metanorma/libemf2svg/actions/workflows/ubuntu-arm64.yml) -[![MacOS-arm64 build](https://github.com/metanorma/libemf2svg/actions/workflows/macos-arm64.yml/badge.svg)](https://github.com/metanorma/libemf2svg/actions/workflows/macos-arm64.yml) +[![MacOS-x86_64](https://github.com/metanorma/libemf2svg/actions/workflows/macos-x86_64.yml/badge.svg)](https://github.com/metanorma/libemf2svg/actions/workflows/macos-x86_64.yml) [![MacOS-arm64](https://github.com/metanorma/libemf2svg/actions/workflows/macos-arm64.yml/badge.svg)](https://github.com/metanorma/libemf2svg/actions/workflows/macos-arm64.yml) [![Windows-x86_64](https://github.com/metanorma/libemf2svg/actions/workflows/windows-x86_64.yml/badge.svg)](https://github.com/metanorma/libemf2svg/actions/workflows/windows-x86_64.yml) [![MSys-x86_64](https://github.com/metanorma/libemf2svg/actions/workflows/msys-x86_64.yml/badge.svg)](https://github.com/metanorma/libemf2svg/actions/workflows/msys-x86_64.yml) [![Coverage Status](https://coveralls.io/repos/github/metanorma/libemf2svg/badge.svg?branch=master)](https://coveralls.io/github/metanorma/libemf2svg?branch=master) @@ -65,12 +60,6 @@ Installing the dependencies on RHEL/CentOS/Fedora: yum install cmake libpng-devel freetype-devel fontconfig-devel gcc-c++ gcc ``` -Installing the dependencies on Alpine Linux: -```bash -apk --no-cache --upgrade add build-base clang cmake libxml2-dev \ - libxml2-utils libpng-dev freetype-dev fontconfig-dev git argp-standalone -``` - Installing the dependencies on Windows for MSVC native builds Dependencies are installed by vcpkg package manager. Installation is implemented as a step of CMake configuration procedure. @@ -97,9 +86,15 @@ $ cmake . -DCMAKE_INSTALL_PREFIX=/usr/ # Windows native (MSVC) build $ cmake . -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -# Linux cross-compilation -# (the only option tested is arm64 build on ubuntu x64) -$ cmake . -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=arm64-linux +# Cross-compilation +# This project employs vcpkg (https://github.com/microsoft/vcpkg) to setup cross-compilation environment +$ cmake . -DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET= +# The following triplets are tested in CI: +# * x64-linux (both for Ubuntu and ALpine Linux) +# * arm64-linux (Ubuntu) +# * x64-osx +# * arm64-osx +# * x64-mingw-static # compilation $ make @@ -236,6 +231,10 @@ EMF+ RECORDS: ChangeLogs ---------- +1.7.0: + +* refactor build scripts to facilitate better portability and ruby integration + 1.6.0: * add arm64 MacOS support (cross-compilation only, no tests) diff --git a/tests/resources/check_correctness.sh b/tests/resources/check_correctness.sh index 22578e56..f618c103 100755 --- a/tests/resources/check_correctness.sh +++ b/tests/resources/check_correctness.sh @@ -18,7 +18,7 @@ STOPONERROR="no" help(){ cat <] [-s] [-n] +usage: `basename $0` [-h] [-v] [-e ] [-s] [-n] Script checking memleaks, segfault and svg correctness of emf2svg-conv @@ -39,7 +39,7 @@ EOF while getopts ":hnNxrvse:" opt; do case $opt in - h) + h) help ;; n) diff --git a/tests/resources/check_truncate.sh b/tests/resources/check_truncate.sh index a9011bf4..6127caf9 100755 --- a/tests/resources/check_truncate.sh +++ b/tests/resources/check_truncate.sh @@ -13,7 +13,7 @@ burn_in_hell(){ while [ $counter1 -lt $MAX ] do tmp_emf=`mktemp -p ../out/` - cp emf/`ls emf |shuf -n 1` ${tmp_emf} + cp emf/`ls emf |shuf -n 1` ${tmp_emf} counter2=0 while [ $counter2 -lt $MAX ] do diff --git a/tests/resources/colors.sh b/tests/resources/colors.sh index 17aa9e9c..189fdfe3 100644 --- a/tests/resources/colors.sh +++ b/tests/resources/colors.sh @@ -1,5 +1,5 @@ RCol='\33[0m' # Text Reset - + # Regular Bold Underline High Intensity Bla='\33[0;30m'; BBla='\33[1;30m'; UBla='\33[4;30m'; IBla='\33[0;90m'; Red='\33[0;31m'; BRed='\33[1;31m'; URed='\33[4;31m'; IRed='\33[0;91m'; diff --git a/tests/resources/lcheck.sh b/tests/resources/lcheck.sh index 0ee0d157..b90255a1 100755 --- a/tests/resources/lcheck.sh +++ b/tests/resources/lcheck.sh @@ -28,12 +28,10 @@ set -o errexit -o pipefail -o noclobber -o nounset # Checks referenced shared libraries -# $1 - an array of expected refs to shared libraries -# $2 - an array of actual refs to shared libraries check_shared_libs() { expected_size="${#expected[@]}" actual_size="${#actual[@]}" - assertEquals "The number of references to shared libraries does not meet our expectations" "$expected_size" "$actual_size" + assertTrue "The number of references to shared libraries does not meet our expectations" "[ $expected_size -ge $actual_size ]" for exp in "${expected[@]}"; do for i in "${!actual[@]}"; do @@ -67,11 +65,15 @@ test_linkage() { readarray -t actual < <(otool -L "$probe.dylib") assertEquals "readarray -t actual < <(otool -L $probe.dylib) failed" 0 "${PIPESTATUS[0]}" check_shared_libs "${expected[@]}" + elif [[ "$OSTYPE" == "msys"* ]]; then + expected=("ntdll.dll" "KERNEL32.DLL" "KERNELBASE.dll" "msvcrt.dll" "libgcc_s_seh-1.dll" "libwinpthread-1.dll" "ucrtbase.dll") + readarray -t actual < <(ldd "$probe.dll") + assertEquals "readarray -t actual < <(ldd "$probe.dll") failed" 0 "${PIPESTATUS[0]}" + check_shared_libs else echo "... unknown - $OSTYPE ... skipping" fi } - # ...................................................................... # main DIR0="$( cd "$( dirname "$0" )" && pwd )"