diff --git a/.devcontainer/Dockerfile.base b/.devcontainer/Dockerfile.base index 63abed7..b1f20ad 100644 --- a/.devcontainer/Dockerfile.base +++ b/.devcontainer/Dockerfile.base @@ -21,4 +21,7 @@ RUN apt-get install -y \ libgmp-dev \ libmpfr-dev -WORKDIR /workspace +RUN chown -R ubuntu:ubuntu /home/ubuntu + +USER ubuntu +WORKDIR /home/ubuntu/dev diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index aea4b2d..99b7fce 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,17 +2,18 @@ "name": "Tessellator", "dockerFile": "Dockerfile.base", "context": "..", - "remoteUser": "root", - "workspaceFolder": "/workspace", + "remoteUser": "ubuntu", + "workspaceFolder": "/home/ubuntu/dev", "mounts": [ - "source=${localWorkspaceFolder},target=/workspace,type=bind", + "source=${localWorkspaceFolder},target=/home/ubuntu/dev,type=bind" ], "customizations": { "vscode": { "extensions": [ "ms-vscode.cpptools", "ms-vscode.cmake-tools", - "vadimcn.vscode-lldb" + "vadimcn.vscode-lldb", + "matepek.vscode-catch2-test-adapter" ], "settings": { "cmake.configureOnOpen": false, diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index e7719cf..7c29fb8 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -5,7 +5,8 @@ on: branches: - main -env: +env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" WINDOWS_FILENAME: opensemba-tessellator-windows-x64.tar.gz LINUX_FILENAME: opensemba-tessellator-linux.tar.gz @@ -27,7 +28,7 @@ jobs: strategy: matrix: preset: [ - {"os": windows-latest, "name": "msbuild", "filename": "windows-x64"}, + {"os": windows-2022, "name": "msbuild", "filename": "windows-x64"}, {"os": ubuntu-latest, "name": "gnu", "filename": "linux"} ] build-type: ["Release"] @@ -59,8 +60,17 @@ jobs: sudo apt-get update sudo apt-get install -y libvtk9-dev + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Setup vcpkg uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: eed289f6e06a5e7a5c9e6a729671b0a56af7dd69 - name: Windows configure and build if: matrix.preset.name=='msbuild' diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 73d442b..4bf49b8 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -5,17 +5,20 @@ on: branches: - main - dev - + concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true + +env: + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" jobs: builds-and-tests: strategy: matrix: preset: [ - {"os": windows-latest, "name": "msbuild"}, + {"os": windows-2022, "name": "msbuild"}, {"os": ubuntu-latest, "name": "gnu"} ] build-type: ["Debug", "Release"] @@ -45,8 +48,17 @@ jobs: sudo apt-get update sudo apt-get install -y libvtk9-dev + - name: Export GitHub Actions cache environment variables + uses: actions/github-script@v7 + with: + script: | + core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); + core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); + - name: Setup vcpkg uses: lukka/run-vcpkg@v11 + with: + vcpkgGitCommitId: eed289f6e06a5e7a5c9e6a729671b0a56af7dd69 - name: Windows configure and build if: matrix.preset.name=='msbuild' @@ -67,6 +79,3 @@ jobs: - name: Ubuntu Run tests if: matrix.preset.name=='gnu' run: build/bin/tessellator_tests - - - \ No newline at end of file diff --git a/.vscode/settings.dev.json b/.vscode/settings.dev.json index 7214448..45347a3 100644 --- a/.vscode/settings.dev.json +++ b/.vscode/settings.dev.json @@ -1,5 +1,7 @@ { "cmake.configureOnOpen": false, "cmake.configureOnEdit": false, - "cmake.autoSelectActiveFolder": false + "cmake.autoSelectActiveFolder": false, + "testMate.cpp.test.executables": "{build,build-dbg,Build,BUILD,out,Out,OUT}/**/*{test,Test,TEST}*", + "testMate.cpp.test.workingDirectory": "${workspaceFolder}" } diff --git a/CMakePresets.json b/CMakePresets.json index 322d7c9..8c3893e 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,56 +1,75 @@ { - "version": 4, - "configurePresets": [ - { - "name": "default", - "hidden": true, - "binaryDir": "build/", - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": { - "type": "FILEPATH", - "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + "version": 4, + "configurePresets": [ + { + "name": "default", + "hidden": true, + "binaryDir": "build/", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": { + "type": "FILEPATH", + "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + } + } + }, + { + "name": "msbuild", + "displayName": "MSBuild Configure Settings", + "generator": "Visual Studio 17 2022", + "architecture": { + "strategy": "set", + "value": "x64" + }, + "inherits": "default" + }, + { + "name": "gnu", + "displayName": "GNU g++ compiler", + "generator": "Ninja", + "inherits": "default" + }, + { + "name": "docker", + "displayName": "Docker (system libraries)", + "description": "Uses system-installed libraries, skips vcpkg. Optimized for containerized builds.", + "generator": "Ninja", + "binaryDir": "build/", + "cacheVariables": { + "CMAKE_CXX_COMPILER": "g++", + "CMAKE_PREFIX_PATH": "/usr/local", + "CMAKE_FIND_ROOT_PATH": "/usr/local", + "TESSELLATOR_ENABLE_TESTS": "ON", + "TESSELLATOR_ENABLE_CGAL": "OFF" + } + }, + { + "name": "docker-dbg", + "inherits": "docker", + "displayName": "Docker-dbg (system libraries)", + "description": "Uses system-installed libraries, skips vcpkg. Optimized for containerized builds. Debug mode", + "binaryDir": "build-dbg/", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_CXX_COMPILER": "g++", + "CMAKE_PREFIX_PATH": "/usr/local", + "CMAKE_FIND_ROOT_PATH": "/usr/local", + "TESSELLATOR_ENABLE_TESTS": "ON", + "TESSELLATOR_ENABLE_CGAL": "OFF" + } } - } - }, - { - "name": "msbuild", - "displayName": "MSBuild Configure Settings", - "generator": "Visual Studio 17 2022", - "architecture": { - "strategy": "set", - "value": "x64" - }, - "inherits": "default" - }, - { - "name": "gnu", - "displayName": "GNU g++ compiler", - "generator": "Ninja", - "inherits": "default" - }, - { - "name": "docker", - "displayName": "Docker (system libraries)", - "description": "Uses system-installed libraries, skips vcpkg. Optimized for containerized builds.", - "generator": "Ninja", - "binaryDir": "build/", - "cacheVariables": { - "CMAKE_CXX_COMPILER": "g++", - "CMAKE_PREFIX_PATH": "/usr/local", - "CMAKE_FIND_ROOT_PATH": "/usr/local", - "TESSELLATOR_ENABLE_TESTS": "ON", - "TESSELLATOR_ENABLE_CGAL": "OFF" - } - } - ], - "buildPresets": [ - { - "name": "default", - "configurePreset": "default" - }, - { - "name": "docker", - "configurePreset": "docker" - } - ] + ], + "buildPresets": [ + { + "name": "default", + "configurePreset": "default" + }, + { + "name": "docker", + "configurePreset": "docker" + }, + { + "name": "docker-dbg", + "configurePreset": "docker-dbg" + } + ] } \ No newline at end of file diff --git a/overlayPorts/libaec/README.md b/overlayPorts/libaec/README.md new file mode 100644 index 0000000..ca36a07 --- /dev/null +++ b/overlayPorts/libaec/README.md @@ -0,0 +1,12 @@ +Original port: https://github.com/microsoft/vcpkg/tree/fedfb6ae868887a13f8a0ba3b29603bd7eb9f118/ports/libaec + +A different download url is used to avoid connection errors. + +libaec provides CMake targets: +``` Cmake + find_package(libaec CONFIG REQUIRED) + # libaec API + target_link_libraries(main PRIVATE libaec::aec) + # szip compatible API + target_link_libraries(main PRIVATE libaec::sz) +``` \ No newline at end of file diff --git a/overlayPorts/libaec/portfile.cmake b/overlayPorts/libaec/portfile.cmake new file mode 100644 index 0000000..cdd5c9f --- /dev/null +++ b/overlayPorts/libaec/portfile.cmake @@ -0,0 +1,44 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO Deutsches-Klimarechenzentrum/libaec + REF v${VERSION} + SHA512 76df7501d1b7d91a43b525ba828f092f18d83f8ab09a9331e5758f93942a9758ad580baca8f9316b92a98639bde2e23cacbc2f33f52d0dd98ce7efe412cf43cd + HEAD_REF master +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -DBUILD_STATIC_LIBS=${BUILD_STATIC} + -Dlibaec_INSTALL_CMAKEDIR=share/${PORT} +) +vcpkg_cmake_install() +vcpkg_copy_pdbs() +vcpkg_cmake_config_fixup() +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/libaec/libaec-config.cmake" + "if(libaec_USE_STATIC_LIBS)" + "if(\"${BUILD_STATIC}\") # forced by vcpkg" +) + +# Compatibility with user's CMake < 3.18 (vcpkg claims support for >= 3.16): +# Make imported targets global so that libaec-config.cmake can create ALIAS targets. +set(_target_file "libaec_shared-targets") +if(BUILD_STATIC) + set(_target_file "libaec_static-targets") +endif() +file(READ "${CURRENT_PACKAGES_DIR}/share/libaec/${_target_file}.cmake" libaec_targets) +string(REGEX REPLACE " (SHARED|STATIC) IMPORTED" " \\1 IMPORTED \${libaec_maybe_global}" libaec_targets "${libaec_targets}") +file(WRITE "${CURRENT_PACKAGES_DIR}/share/libaec/${_target_file}.cmake" "set(libaec_maybe_global \"\") +if(CMAKE_VERSION VERSION_LESS 3.18) + set(libaec_maybe_global \"GLOBAL\") +endif() +${libaec_targets} +" +) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +file(INSTALL "${CURRENT_PORT_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt") \ No newline at end of file diff --git a/overlayPorts/libaec/usage b/overlayPorts/libaec/usage new file mode 100644 index 0000000..26ebd09 --- /dev/null +++ b/overlayPorts/libaec/usage @@ -0,0 +1,7 @@ +libaec provides CMake targets: + + find_package(libaec CONFIG REQUIRED) + # libaec API + target_link_libraries(main PRIVATE libaec::aec) + # szip compatible API + target_link_libraries(main PRIVATE libaec::sz) \ No newline at end of file diff --git a/overlayPorts/libaec/vcpkg.json b/overlayPorts/libaec/vcpkg.json new file mode 100644 index 0000000..a4f3d55 --- /dev/null +++ b/overlayPorts/libaec/vcpkg.json @@ -0,0 +1,17 @@ +{ + "name": "libaec", + "version": "1.1.6", + "description": "Adaptive Entropy Coding library", + "homepage": "https://gitlab.dkrz.de/k202009/libaec", + "license": "BSD-2-Clause", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} \ No newline at end of file diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index 563e537..e1d933f 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -10,5 +10,8 @@ "location": "https://aka.ms/vcpkg-ce-default", "name": "microsoft" } + ], + "overlay-ports" : [ + "./overlayPorts" ] }