From 1e958b2371f8677215cea877f0abf552efda3723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc=20Serf=C5=91z=C5=91?= Date: Tue, 14 May 2024 18:54:40 +0200 Subject: [PATCH] Updated CI, added CD (#239) * Added .gitignore * Added formatting * Fixed warnings * Updated CMakeLists to produce binary deb package * Updated CI * Added release and debian source package generation * Updated readme --- .clang-format | 123 ++++++ .github/workflows/linux.yml | 221 ---------- .github/workflows/macos.yml | 73 ---- .github/workflows/presubmit.yml | 618 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 70 ++++ .github/workflows/windows.yml | 253 ------------ .gitignore | 14 + CL/cl_platform.h | 2 +- CMakeLists.txt | 16 +- OpenCL-Headers.pc.in | 2 +- README.md | 5 + cmake/DebSourcePkg.cmake | 125 ++++++ cmake/Package.cmake | 47 +++ cmake/PackageSetup.cmake | 56 +++ scripts/check-format.sh | 55 +++ tests/pkgconfig/bare/CMakeLists.txt | 9 +- tests/pkgconfig/pkgconfig.c | 5 +- tests/pkgconfig/sdk/CMakeLists.txt | 9 +- tests/test_headers.c | 20 +- 19 files changed, 1146 insertions(+), 577 deletions(-) create mode 100644 .clang-format delete mode 100644 .github/workflows/linux.yml delete mode 100644 .github/workflows/macos.yml create mode 100644 .github/workflows/presubmit.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/windows.yml create mode 100644 .gitignore create mode 100644 cmake/DebSourcePkg.cmake create mode 100644 cmake/Package.cmake create mode 100644 cmake/PackageSetup.cmake create mode 100755 scripts/check-format.sh diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..d563a411 --- /dev/null +++ b/.clang-format @@ -0,0 +1,123 @@ +--- +Language: Cpp +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: false +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: true +AllowAllConstructorInitializersOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortLambdasOnASingleLine: All +AllowShortIfStatementsOnASingleLine: WithoutElse +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: true + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Custom +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|gmock|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 2 +NamespaceIndentation: Inner +ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: false +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 4 +UseTab: Never diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml deleted file mode 100644 index 3db0d2ca..00000000 --- a/.github/workflows/linux.yml +++ /dev/null @@ -1,221 +0,0 @@ -name: Linux - -on: - push: - paths-ignore: - - '**/*.md' - pull_request: - paths-ignore: - - '**/*.md' - -jobs: - compatibility: - runs-on: ubuntu-20.04 - container: streamhpc/opencl-sdk-base:ubuntu-18.04-20220127 - strategy: - matrix: - # TODO: CMake 3.0.2 is Headers minimum (and ubuntu 18.04 canonical apt repo ver), not this repo's min - # Replace once backport to C++14 happened - include: - # Unix Makefiles - # One CMake version - # For all compilers - # For all configurations - # For all target architectures - - C_COMPILER: gcc-7 - CXX_COMPILER: g++-7 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Debug - BIN: 64 - - C_COMPILER: gcc-7 - CXX_COMPILER: g++-7 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Release - BIN: 64 - - C_COMPILER: gcc-7 - CXX_COMPILER: g++-7 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Debug - BIN: 32 - - C_COMPILER: gcc-7 - CXX_COMPILER: g++-7 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Release - BIN: 32 - - C_COMPILER: gcc-11 - CXX_COMPILER: g++-11 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Debug - BIN: 64 - - C_COMPILER: gcc-11 - CXX_COMPILER: g++-11 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Release - BIN: 64 - - C_COMPILER: gcc-11 - CXX_COMPILER: g++-11 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Debug - BIN: 32 - - C_COMPILER: gcc-11 - CXX_COMPILER: g++-11 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Release - BIN: 32 - - C_COMPILER: clang-8 - CXX_COMPILER: clang++-8 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Debug - BIN: 64 - - C_COMPILER: clang-8 - CXX_COMPILER: clang++-8 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Release - BIN: 64 - - C_COMPILER: clang-8 - CXX_COMPILER: clang++-8 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Debug - BIN: 32 - - C_COMPILER: clang-8 - CXX_COMPILER: clang++-8 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Release - BIN: 32 - - C_COMPILER: clang-13 - CXX_COMPILER: clang++-13 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Debug - BIN: 64 - - C_COMPILER: clang-13 - CXX_COMPILER: clang++-13 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Release - BIN: 64 - - C_COMPILER: clang-13 - CXX_COMPILER: clang++-13 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Debug - BIN: 32 - - C_COMPILER: clang-13 - CXX_COMPILER: clang++-13 - CMAKE: 3.0.2 - GEN: Unix Makefiles - CONFIG: Release - BIN: 32 - # Multi-config generators - # One CMake version - # For all compilers - # For all architectures - - C_COMPILER: gcc-7 - CXX_COMPILER: g++-7 - CMAKE: 3.22.1 - GEN: Ninja Multi-Config - BIN: 64 - - C_COMPILER: gcc-7 - CXX_COMPILER: g++-7 - CMAKE: 3.22.1 - GEN: Ninja Multi-Config - BIN: 32 - - C_COMPILER: gcc-11 - CXX_COMPILER: g++-11 - CMAKE: 3.22.1 - GEN: Ninja Multi-Config - BIN: 64 - - C_COMPILER: gcc-11 - CXX_COMPILER: g++-11 - CMAKE: 3.22.1 - GEN: Ninja Multi-Config - BIN: 32 - - C_COMPILER: clang-8 - CXX_COMPILER: clang++-8 - CMAKE: 3.22.1 - GEN: Ninja Multi-Config - BIN: 64 - - C_COMPILER: clang-8 - CXX_COMPILER: clang++-8 - CMAKE: 3.22.1 - GEN: Ninja Multi-Config - BIN: 32 - - C_COMPILER: clang-13 - CXX_COMPILER: clang++-13 - CMAKE: 3.22.1 - GEN: Ninja Multi-Config - BIN: 64 - - C_COMPILER: clang-13 - CXX_COMPILER: clang++-13 - CMAKE: 3.22.1 - GEN: Ninja Multi-Config - BIN: 32 - env: - CMAKE_EXE: /opt/Kitware/CMake/${{ matrix.CMAKE }}/bin/cmake - CTEST_EXE: /opt/Kitware/CMake/${{ matrix.CMAKE }}/bin/ctest - - steps: - - name: Checkout OpenCL-Headers - uses: actions/checkout@v3 - - - name: Configure - shell: bash - run: $CMAKE_EXE - -G "${{matrix.GEN}}" - -D BUILD_TESTING=ON - `if [[ "${{matrix.GEN}}" == "Unix Makefiles" ]]; then echo -D CMAKE_BUILD_TYPE=${{matrix.CONFIG}}; fi;` - -D CMAKE_C_FLAGS="-Wall -Wextra -pedantic -Werror -m${{matrix.BIN}}" - -D CMAKE_C_COMPILER=${{matrix.C_COMPILER}} - -D CMAKE_C_EXTENSIONS=OFF - -D CMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror -m${{matrix.BIN}}" - -D CMAKE_CXX_COMPILER=${{matrix.CXX_COMPILER}} - -D CMAKE_CXX_EXTENSIONS=OFF - -D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install - -B$GITHUB_WORKSPACE/build - -H$GITHUB_WORKSPACE - - - name: Build - shell: bash - run: if [[ "${{matrix.GEN}}" == "Unix Makefiles" ]]; - then - $CMAKE_EXE --build $GITHUB_WORKSPACE/build -- -j`nproc`; - else - $CMAKE_EXE --build $GITHUB_WORKSPACE/build --config Debug -- -j`nproc`; - $CMAKE_EXE --build $GITHUB_WORKSPACE/build --config Release -- -j`nproc`; - fi; - - - name: Test - shell: bash - working-directory: ${{runner.workspace}}/OpenCL-Headers/build - run: if [[ "${{matrix.GEN}}" == "Unix Makefiles" ]]; - then - $CTEST_EXE --output-on-failure --parallel `nproc`; - else - $CTEST_EXE --output-on-failure -C Debug --parallel `nproc`; - $CTEST_EXE --output-on-failure -C Release --parallel `nproc`; - fi; - - - name: Test install - shell: bash - run: if [[ "${{matrix.GEN}}" == "Unix Makefiles" ]]; - then - $CMAKE_EXE --build $GITHUB_WORKSPACE/build --target install -- -j`nproc`; - else - $CMAKE_EXE --build $GITHUB_WORKSPACE/build --target install --config Release -- -j`nproc`; - fi; - - - name: Test pkg-config - shell: bash - run: PKG_CONFIG_PATH="$GITHUB_WORKSPACE/install/share/pkgconfig" pkg-config OpenCL-Headers --cflags | grep -q "\-I$GITHUB_WORKSPACE/install/include" diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml deleted file mode 100644 index c1b2972e..00000000 --- a/.github/workflows/macos.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: MacOS - -on: - push: - paths-ignore: - - '**/*.md' - pull_request: - paths-ignore: - - '**/*.md' - -jobs: - compatibility: - runs-on: macos-11 - strategy: - matrix: - VER: [9, 11] - GEN: [Xcode, Ninja Multi-Config] - STD: [11, 17] - - steps: - - name: Checkout OpenCL-Headers - uses: actions/checkout@v3 - - - name: Create Build Environment - shell: bash - run: | - cmake -E make_directory $GITHUB_WORKSPACE/build; - cmake -E make_directory $GITHUB_WORKSPACE/install; - if [[ "${{matrix.GEN}}" == "Ninja Multi-Config" && ! `which ninja` ]]; then brew install ninja; fi; - # Install Ninja only if it's the selected generator and it's not available. - cmake --version - - - name: Install gcc if required - run: | - if [[ ! `which /usr/local/bin/gcc-${{matrix.VER}}` ]]; then brew install gcc@${{matrix.VER}}; fi; - - - name: Configure CMake - shell: bash - run: cmake - -G "${{matrix.GEN}}" - -D BUILD_TESTING=ON - -D CMAKE_C_FLAGS="-Wall -Wextra -pedantic -Werror" - -D CMAKE_C_COMPILER=/usr/local/bin/gcc-${{matrix.VER}} - -D CMAKE_C_EXTENSIONS=OFF - -D CMAKE_CXX_FLAGS="-Wall -Wextra -pedantic -Werror" - -D CMAKE_CXX_COMPILER=/usr/local/bin/g++-${{matrix.VER}} - -D CMAKE_CXX_EXTENSIONS=OFF - -D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install - -S $GITHUB_WORKSPACE - -B $GITHUB_WORKSPACE/build - - - name: Build - shell: bash - run: | - cmake --build $GITHUB_WORKSPACE/build --config Release --parallel `sysctl -n hw.logicalcpu` `if [[ "${{matrix.GEN}}" == "Xcode" ]]; then echo "-- -quiet"; fi;` - cmake --build $GITHUB_WORKSPACE/build --config Debug --parallel `sysctl -n hw.logicalcpu` `if [[ "${{matrix.GEN}}" == "Xcode" ]]; then echo "-- -quiet"; fi;` - - - name: Test - working-directory: ${{runner.workspace}}/OpenCL-Headers/build - shell: bash - run: | - ctest -C Release --output-on-failure --parallel `sysctl -n hw.logicalcpu` - ctest -C Debug --output-on-failure --parallel `sysctl -n hw.logicalcpu` - - - name: Test install - shell: bash - run: cmake --build $GITHUB_WORKSPACE/build --target install --config Release - - - name: Test pkg-config - shell: bash - run: | - if [[ ! `which pkg-config` ]]; then brew install pkg-config; fi; - PKG_CONFIG_PATH="$GITHUB_WORKSPACE/install/share/pkgconfig" pkg-config OpenCL-Headers --cflags | grep -q "\-I$GITHUB_WORKSPACE/install/include" diff --git a/.github/workflows/presubmit.yml b/.github/workflows/presubmit.yml new file mode 100644 index 00000000..b560a18e --- /dev/null +++ b/.github/workflows/presubmit.yml @@ -0,0 +1,618 @@ +name: Presubmit + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + format: + name: Code formatting + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v3 + with: + # repository: ${{github.repository}} (default) + fetch-depth: 0 + - name: Install clang-format + run: sudo apt-get install clang-format + - name: Check format + run: $GITHUB_WORKSPACE/scripts/check-format.sh + origin/`if [[ "${{github.event_name}}" == "push" ]]; then echo "main"; else echo "${{github.base_ref}}"; fi` + --binary clang-format + + linux: + runs-on: ubuntu-latest + needs: format + defaults: + run: + shell: bash + strategy: + matrix: + CMAKE: [3.26.4] + C_COMPILER: + - gcc-11 + - gcc-13 + - clang-14 + - clang-16 + BIN: [64] + STD: [99, 11, 17] + CONF: + - GEN: Unix Makefiles + CONFIG: Debug + - GEN: Unix Makefiles + CONFIG: Release + - GEN: Ninja Multi-Config + CONFIG: Release + IMAGE: + - streamhpc/opencl-sdk-intelcpu:ubuntu-22.04-20230717 + include: + - CMAKE: system + C_COMPILER: gcc-9 + BIN: 64 + STD: 99 + CONF: + GEN: Unix Makefiles + CONFIG: Debug + IMAGE: streamhpc/opencl-sdk-intelcpu:ubuntu-20.04-20230717 + - CMAKE: system + C_COMPILER: gcc-9 + BIN: 64 + STD: 99 + CONF: + GEN: Unix Makefiles + CONFIG: Release + IMAGE: streamhpc/opencl-sdk-intelcpu:ubuntu-20.04-20230717 + - CMAKE: system + C_COMPILER: gcc-9 + BIN: 32 + STD: 99 + CONF: + GEN: Unix Makefiles + CONFIG: Debug + IMAGE: streamhpc/opencl-sdk-intelcpu:ubuntu-20.04-20230717 + - CMAKE: system + C_COMPILER: gcc-9 + BIN: 32 + STD: 99 + CONF: + GEN: Unix Makefiles + CONFIG: Release + IMAGE: streamhpc/opencl-sdk-intelcpu:ubuntu-20.04-20230717 + - CMAKE: system + C_COMPILER: gcc-11 + BIN: 64 + STD: 99 + CONF: + GEN: Unix Makefiles + CONFIG: Debug + IMAGE: streamhpc/opencl-sdk-intelcpu:ubuntu-22.04-20230717 + - CMAKE: system + C_COMPILER: gcc-11 + BIN: 64 + STD: 99 + CONF: + GEN: Unix Makefiles + CONFIG: Release + IMAGE: streamhpc/opencl-sdk-intelcpu:ubuntu-22.04-20230717 + container: ${{matrix.IMAGE}} + env: + CMAKE_EXE: /opt/Kitware/CMake/${{matrix.CMAKE}}/bin/cmake + CPACK_EXE: /opt/Kitware/CMake/${{matrix.CMAKE}}/bin/cpack + CTEST_EXE: /opt/Kitware/CMake/${{matrix.CMAKE}}/bin/ctest + CC: ${{matrix.C_COMPILER}} + CFLAGS: -Wall -Wextra -pedantic -Werror -m${{matrix.BIN}} + + steps: + - name: Install system CMake + if: ${{matrix.CMAKE}} == 'system' + run: apt-get update -qq && apt-get install -y cmake && + echo "CMAKE_EXE=cmake" >> "$GITHUB_ENV" && + echo "CPACK_EXE=cpack" >> "$GITHUB_ENV" && + echo "CTEST_EXE=ctest" >> "$GITHUB_ENV" + + - name: Checkout OpenCL-Headers + uses: actions/checkout@v3 + + - name: Configure + run: $CMAKE_EXE + -G "${{matrix.CONF.GEN}}" + -D BUILD_TESTING=ON + `if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; then echo "-D CMAKE_BUILD_TYPE=${{matrix.CONF.CONFIG}}"; fi` + -D CMAKE_C_STANDARD=${{matrix.STD}} + -D CMAKE_C_EXTENSIONS=OFF + -D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install + -D CPACK_PACKAGING_INSTALL_PREFIX=/usr + -S $GITHUB_WORKSPACE + -B $GITHUB_WORKSPACE/build + + - name: Build + run: if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CMAKE_EXE --build $GITHUB_WORKSPACE/build --parallel `nproc`; + else + $CMAKE_EXE --build $GITHUB_WORKSPACE/build --config Debug; + $CMAKE_EXE --build $GITHUB_WORKSPACE/build --config Release; + fi; + + - name: Test + working-directory: ${{runner.workspace}}/OpenCL-Headers/build + run: if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CTEST_EXE --output-on-failure --no-tests=error --parallel `nproc`; + else + $CTEST_EXE --output-on-failure --no-tests=error -C Debug --parallel `nproc`; + $CTEST_EXE --output-on-failure --no-tests=error -C Release --parallel `nproc`; + fi; + + - name: Package DEB + run: $CPACK_EXE + --config "$GITHUB_WORKSPACE/build/CPackConfig.cmake" + -G DEB + -C Release + -B "$GITHUB_WORKSPACE/package-deb" + + - name: Consume (DEB) + run: dpkg -i $GITHUB_WORKSPACE/package-deb/*.deb && + $CMAKE_EXE + -G "${{matrix.CONF.GEN}}" + `if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; then echo "-D CMAKE_BUILD_TYPE=${{matrix.CONF.CONFIG}}"; fi` + -D CMAKE_C_STANDARD=${{matrix.STD}} + -D CMAKE_C_EXTENSIONS=OFF + -S $GITHUB_WORKSPACE/tests/pkgconfig/bare + -B $GITHUB_WORKSPACE/build_package && + if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_package --parallel `nproc`; + else + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_package --config Debug; + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_package --config Release; + fi + + - name: Run consume test (DEB) + if: matrix.BIN != 32 + working-directory: ${{runner.workspace}}/OpenCL-Headers/build_package + run: if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CTEST_EXE -C ${{matrix.CONF.CONFIG}} --output-on-failure --no-tests=error --parallel `nproc`; + else + $CTEST_EXE -C Debug --output-on-failure --no-tests=error --parallel `nproc`; + $CTEST_EXE -C Release --output-on-failure --no-tests=error --parallel `nproc`; + fi + + - name: Test pkg-config (DEB) + run: | + # First check if OpenCL-Headers is locatable + pkg-config OpenCL-Headers --cflags + # /usr/include is already on the include search path, + # we expect no output + if [[ "$(pkg-config OpenCL-Headers --cflags)" ]]; + then + exit 1; + fi; + + - name: Uninstall (DEB) + run: apt-get remove -y opencl-c-headers + + - name: Test install + run: $CMAKE_EXE --build $GITHUB_WORKSPACE/build --target install --config ${{matrix.CONF.CONFIG}} --parallel `nproc` + + - name: Consume (install) + run: $CMAKE_EXE + -G "${{matrix.CONF.GEN}}" + `if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; then echo "-D CMAKE_BUILD_TYPE=${{matrix.CONF.CONFIG}}"; fi` + -D CMAKE_C_STANDARD=${{matrix.STD}} + -D CMAKE_C_EXTENSIONS=OFF + -D CMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/install + -S $GITHUB_WORKSPACE/tests/pkgconfig/bare + -B $GITHUB_WORKSPACE/build_install && + if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_install --parallel `nproc`; + else + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_install --config Debug; + $CMAKE_EXE --build $GITHUB_WORKSPACE/build_install --config Release; + fi; + + - name: Run consume test (DEB) + if: matrix.BIN != 32 + working-directory: ${{runner.workspace}}/OpenCL-Headers/build_install + run: if [[ "${{matrix.CONF.GEN}}" == "Unix Makefiles" ]]; + then + $CTEST_EXE -C ${{matrix.CONF.CONFIG}} --output-on-failure --no-tests=error --parallel `nproc`; + else + $CTEST_EXE -C Debug --output-on-failure --no-tests=error --parallel `nproc`; + $CTEST_EXE -C Release --output-on-failure --no-tests=error --parallel `nproc`; + fi + + - name: Test pkg-config (install) + run: PKG_CONFIG_PATH=$GITHUB_WORKSPACE/install/share/pkgconfig + pkg-config OpenCL-Headers --cflags | grep -q "\-I$GITHUB_WORKSPACE/install/include" + + windows: + runs-on: windows-latest + needs: format + defaults: + run: + shell: pwsh + strategy: + matrix: + VER: [v141, v142, v143, clangcl] + GEN: [Visual Studio 17 2022, Ninja Multi-Config] + BIN: [x64] + STD: [99, 11, 17] + exclude: + - VER: clangcl + GEN: Ninja Multi-Config + include: + - VER: v142 + GEN: Visual Studio 17 2022 + BIN: x86 + STD: 99 + env: + NINJA_URL: https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip + NINJA_ROOT: C:\Tools\Ninja + VS_ROOT: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' + UseMultiToolTask: true # Better parallel MSBuild execution + EnforceProcessCountAcrossBuilds: 'true' # -=- + MultiProcMaxCount: '3' # -=- + CFLAGS: /W4 /WX + + steps: + - name: Cache Ninja install + if: matrix.GEN == 'Ninja Multi-Config' + id: ninja-install + uses: actions/cache@v3 + with: + path: | + C:\Tools\Ninja + key: ${{runner.os}}-ninja-${{env.NINJA_URL}} + + - name: Install Ninja + if: matrix.GEN == 'Ninja Multi-Config' && steps.ninja-install.outputs.cache-hit != 'true' + run: | + Invoke-WebRequest ${env:NINJA_URL} -OutFile ~\Downloads\ninja-win.zip + Expand-Archive ~\Downloads\ninja-win.zip -DestinationPath ${env:NINJA_ROOT}\ + Remove-Item ~\Downloads\* + + - name: Checkout OpenCL-Headers + uses: actions/checkout@v3 + + - name: Configure (MSBuild) + if: matrix.GEN == 'Visual Studio 17 2022' + run: | + $BIN = if('${{matrix.BIN}}' -eq 'x86') {'Win32'} else {'x64'} + & cmake ` + -G '${{matrix.GEN}}' ` + -A ${BIN} ` + -T ${{matrix.VER}} ` + -D BUILD_TESTING=ON ` + -D CMAKE_C_STANDARD=${{matrix.STD}} ` + -D CMAKE_C_EXTENSIONS=OFF ` + -D CMAKE_C_STANDARD_REQUIRED=ON ` + -S "${env:GITHUB_WORKSPACE}" ` + -B "${env:GITHUB_WORKSPACE}\build" + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-Headers failed." } + + - name: Configure (Ninja Multi-Config) + if: matrix.GEN == 'Ninja Multi-Config' + run: | + $VER = switch ('${{matrix.VER}}') { ` + 'v141' {'14.1'} ` + 'v142' {'14.2'} ` + 'v143' {'14.3'} } + Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=${VER}" + & cmake ` + -G '${{matrix.GEN}}' ` + -D CMAKE_MAKE_PROGRAM="${env:NINJA_ROOT}\ninja.exe" ` + -D BUILD_TESTING=ON ` + -D CMAKE_C_STANDARD=${{matrix.STD}} ` + -D CMAKE_C_EXTENSIONS=OFF ` + -D CMAKE_C_STANDARD_REQUIRED=ON ` + -D CMAKE_EXE_LINKER_FLAGS='/INCREMENTAL' ` + -S "${env:GITHUB_WORKSPACE}" ` + -B "${env:GITHUB_WORKSPACE}\build" + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-Headers failed." } + + - name: Build (MSBuild) + if: matrix.GEN == 'Visual Studio 17 2022' + run: | + foreach ($Config in 'Release','Debug') { + & cmake ` + --build "${env:GITHUB_WORKSPACE}\build" ` + --config ${Config} ` + -- ` + /verbosity:minimal ` + /maxCpuCount ` + /noLogo + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-Headers in $Config failed." } + } + + - name: Build (Ninja Multi-Config) + if: matrix.GEN == 'Ninja Multi-Config' + run: | + $VER = switch ('${{matrix.VER}}') { ` + 'v141' {'14.1'} ` + 'v142' {'14.2'} ` + 'v143' {'14.3'} } + Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=${VER}" + foreach ($Config in 'Release','Debug') { + & cmake ` + --build "${env:GITHUB_WORKSPACE}\build" ` + --config ${Config} ` + -- ` + -j ${env:NUMBER_OF_PROCESSORS} + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-Headers in $Config failed." } + } + + - name: Test + run: | + foreach ($Config in 'Release','Debug') { + & ctest ` + --test-dir "${env:GITHUB_WORKSPACE}\build" ` + --build-config ${Config} ` + --output-on-failure ` + --no-tests=error ` + --parallel ${env:NUMBER_OF_PROCESSORS} + if ($LASTEXITCODE -ne 0) { throw "OpenCL-Headers tests in $Config failed." } + } + + - name: Install + run: | + & cmake ` + --install "${env:GITHUB_WORKSPACE}\build" ` + --prefix "${env:GITHUB_WORKSPACE}\install" ` + --config Release + if ($LASTEXITCODE -ne 0) { throw "OpenCL-Headers install failed." } + + - name: "Consume (MSBuild standalone): Configure/Build/Test" + if: matrix.GEN == 'Visual Studio 17 2022' + run: | + $BIN = if('${{matrix.BIN}}' -eq 'x86') {'Win32'} else {'x64'} + & cmake ` + -G '${{matrix.GEN}}' ` + -A ${BIN} ` + -T ${{matrix.VER}} ` + -D CMAKE_C_STANDARD=${{matrix.STD}} ` + -D CMAKE_C_EXTENSIONS=OFF ` + -D CMAKE_C_STANDARD_REQUIRED=ON ` + -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\install" ` + -S "${env:GITHUB_WORKSPACE}\tests\pkgconfig\bare" ` + -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-Headers standalone consume test failed." } + foreach ($Config in 'Release','Debug') { + & cmake ` + --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" ` + --config ${Config} ` + -- ` + /verbosity:minimal ` + /maxCpuCount ` + /noLogo + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-Headers standalone consume test in $Config failed." } + & cd ${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare + & ctest --output-on-failure --no-tests=error -C $Config + if ($LASTEXITCODE -ne 0) { throw "Running OpenCL-Headers standalone consume test in $Config failed." } + } + + - name: "Consume (Ninja Multi-Config standalone): Configure/Build/Test" + if: matrix.GEN == 'Ninja Multi-Config' + run: | + $VER = switch ('${{matrix.VER}}') { ` + 'v141' {'14.1'} ` + 'v142' {'14.2'} ` + 'v143' {'14.3'} } + Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=${VER}" + & cmake ` + -G '${{matrix.GEN}}' ` + -D CMAKE_MAKE_PROGRAM="${env:NINJA_ROOT}\ninja.exe" ` + -D BUILD_TESTING=ON ` + -D CMAKE_C_STANDARD=${{matrix.STD}} ` + -D CMAKE_C_EXTENSIONS=OFF ` + -D CMAKE_C_STANDARD_REQUIRED=ON ` + -D CMAKE_EXE_LINKER_FLAGS='/INCREMENTAL' ` + -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\install" ` + -S "${env:GITHUB_WORKSPACE}\tests\pkgconfig\bare" ` + -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-Headers standalone consume test failed." } + foreach ($Config in 'Release','Debug') { + & cmake ` + --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" ` + --config ${Config} + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-Headers standalone consume test in $Config failed." } + & cd ${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare + & ctest --output-on-failure --no-tests=error -C $Config + if ($LASTEXITCODE -ne 0) { throw "Running OpenCL-Headers standalone consume test in $Config failed." } + } + + - name: Consume (Emulate SDK presence) + run: | + New-Item -Type Directory -Path ${env:GITHUB_WORKSPACE}\install\share\cmake\OpenCL + New-Item -Type File -Path ${env:GITHUB_WORKSPACE}\install\share\cmake\OpenCL\OpenCLConfig.cmake -Value 'include("${CMAKE_CURRENT_LIST_DIR}/../OpenCLHeaders/OpenCLHeadersTargets.cmake")' + + - name: "Consume (MSBuild SDK): Configure/Build/Test" + if: matrix.GEN == 'Visual Studio 17 2022' + run: | + $BIN = if('${{matrix.BIN}}' -eq 'x86') {'Win32'} else {'x64'} + & cmake ` + -G '${{matrix.GEN}}' ` + -A ${BIN} ` + -T ${{matrix.VER}} ` + -D CMAKE_C_STANDARD=${{matrix.STD}} ` + -D CMAKE_C_EXTENSIONS=OFF ` + -D CMAKE_C_STANDARD_REQUIRED=ON ` + -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\install" ` + -S "${env:GITHUB_WORKSPACE}\tests\pkgconfig\sdk" ` + -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" + if ($LASTEXITCODE -ne 0) { throw "Configuring OpenCL-Headers in-SDK consume test failed." } + foreach ($Config in 'Release','Debug') { + cmake ` + --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" ` + --config ${Config} ` + -- ` + /verbosity:minimal ` + /maxCpuCount ` + /noLogo + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-Headers in-SDK consume test in $Config failed." } + & cd ${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk + & ctest --output-on-failure --no-tests=error -C $Config + if ($LASTEXITCODE -ne 0) { throw "Running OpenCL-Headers in-SDK consume test in $Config failed." } + } + + - name: "Consume (Ninja-Multi-Config SDK): Configure/Build/Test" + if: matrix.GEN == 'Ninja Multi-Config' + run: | + $VER = switch ('${{matrix.VER}}') { ` + 'v141' {'14.1'} ` + 'v142' {'14.2'} ` + 'v143' {'14.3'} } + Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" + Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=${VER}" + & cmake ` + -G '${{matrix.GEN}}' ` + -D CMAKE_MAKE_PROGRAM="${env:NINJA_ROOT}\ninja.exe" ` + -D BUILD_TESTING=ON ` + -D CMAKE_C_STANDARD=${{matrix.STD}} ` + -D CMAKE_C_EXTENSIONS=OFF ` + -D CMAKE_C_STANDARD_REQUIRED=ON ` + -D CMAKE_EXE_LINKER_FLAGS='/INCREMENTAL' ` + -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\install" ` + -S "${env:GITHUB_WORKSPACE}\tests\pkgconfig\sdk" ` + -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" + foreach ($Config in 'Release','Debug') { ` + & cmake ` + --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" ` + --config ${Config} + if ($LASTEXITCODE -ne 0) { throw "Building OpenCL-Headers in-SDK consume test in $Config failed." } + & cd ${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk + & ctest --output-on-failure --no-tests=error -C $Config + if ($LASTEXITCODE -ne 0) { throw "Running OpenCL-Headers in-SDK consume test in $Config failed." } + } + + macos: + runs-on: macos-latest + needs: format + defaults: + run: + shell: bash + strategy: + matrix: + C_COMPILER: + - /usr/bin/clang + - /usr/local/bin/gcc-11 + - /usr/local/bin/gcc-13 + GEN: + - Xcode + - Ninja Multi-Config + STD: [99, 11, 17] + exclude: + # These entries are excluded, since XCode selects its own compiler + - C_COMPILER: /usr/local/bin/gcc-11 + GEN: Xcode + - C_COMPILER: /usr/local/bin/gcc-13 + GEN: Xcode + env: + CFLAGS: -Wall -Wextra -pedantic -Werror + CC: ${{matrix.C_COMPILER}} + steps: + - name: Checkout OpenCL-Headers + uses: actions/checkout@v3 + + - name: Create Build Environment + run: | + # Install Ninja only if it's the selected generator and it's not available. + if [[ "${{matrix.GEN}}" == "Ninja Multi-Config" && ! `which ninja` ]]; then brew install ninja; fi; + if [[ ! `which pkg-config` ]]; then brew install pkg-config; fi && + cmake --version + + - name: Configure + run: cmake + -G "${{matrix.GEN}}" + -D BUILD_TESTING=ON + -D CMAKE_C_STANDARD=${{matrix.STD}} + -D CMAKE_C_EXTENSIONS=OFF + -D CMAKE_C_STANDARD_REQUIRED=ON + -D CMAKE_INSTALL_PREFIX=$GITHUB_WORKSPACE/install + -S $GITHUB_WORKSPACE + -B $GITHUB_WORKSPACE/build + + - name: Build + run: | + cmake --build $GITHUB_WORKSPACE/build --config Release --parallel `sysctl -n hw.logicalcpu` + cmake --build $GITHUB_WORKSPACE/build --config Debug --parallel `sysctl -n hw.logicalcpu` + + - name: Test + working-directory: ${{runner.workspace}}/OpenCL-Headers/build + run: | + ctest -C Release --output-on-failure --no-tests=error --parallel `sysctl -n hw.logicalcpu` + ctest -C Debug --output-on-failure --no-tests=error --parallel `sysctl -n hw.logicalcpu` + + - name: Test install + run: cmake --build $GITHUB_WORKSPACE/build --target install --config Release + + - name: Consume (install) + run: cmake + -G "${{matrix.GEN}}" + -D CMAKE_C_STANDARD=${{matrix.STD}} + -D CMAKE_C_EXTENSIONS=OFF + -D CMAKE_C_STANDARD_REQUIRED=ON + -D CMAKE_PREFIX_PATH="$GITHUB_WORKSPACE/install" + -S $GITHUB_WORKSPACE/tests/pkgconfig/bare + -B $GITHUB_WORKSPACE/build_install && + cmake --build $GITHUB_WORKSPACE/build_install --config Release --parallel `sysctl -n hw.logicalcpu` && + cmake --build $GITHUB_WORKSPACE/build_install --config Debug --parallel `sysctl -n hw.logicalcpu` + + - name: Run consume test (install) + working-directory: ${{runner.workspace}}/OpenCL-Headers/build_install + run: | + ctest -C Release --output-on-failure --no-tests=error --parallel `sysctl -n hw.logicalcpu` + ctest -C Debug --output-on-failure --no-tests=error --parallel `sysctl -n hw.logicalcpu` + + - name: Test pkg-config + run: export PKG_CONFIG_PATH="$GITHUB_WORKSPACE/install/share/pkgconfig" && + pkg-config OpenCL-Headers --cflags | grep -q "\-I$GITHUB_WORKSPACE/install/include" + + android: + runs-on: ubuntu-latest + needs: format + defaults: + run: + shell: bash + strategy: + matrix: + ABI: + - arm64-v8a + - x86_64 + API_LEVEL: + - android-19 + - android-33 + CONFIG: + - Debug + - Release + env: + CFLAGS: -Wall -Wextra -pedantic -Werror + steps: + - name: Checkout OpenCL-Headers + uses: actions/checkout@v3 + + - name: Configure + run: cmake + -G "Unix Makefiles" + -D BUILD_TESTING=ON + -D CMAKE_BUILD_TYPE=${{matrix.CONFIG}} + -D CMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake + -D ANDROID_ABI=${{matrix.ABI}} + -D ANDROID_PLATFORM=${{matrix.API_LEVEL}} + -S $GITHUB_WORKSPACE + -B $GITHUB_WORKSPACE/build + + - name: Build + run: cmake --build $GITHUB_WORKSPACE/build --parallel `nproc` diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..d95d31ea --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,70 @@ +name: Release + +on: + push: + tags: + - "v*" +env: + distroseries: jammy + +jobs: + release: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - name: Install prerequisites + run: sudo apt-get update -qq && sudo apt-get install -y cmake devscripts debhelper-compat=13 + + - name: Import GPG signing key + run: echo "${{ secrets.DEB_SIGNING_KEY }}" | gpg --import + + - name: Download and extract source code + run: | + wget -O $GITHUB_WORKSPACE/source.orig.tar.gz https://github.com/$GITHUB_REPOSITORY/archive/refs/tags/$GITHUB_REF_NAME.tar.gz + tar -xvf $GITHUB_WORKSPACE/source.orig.tar.gz + + - name: Configure project out-of-tree + run: cmake + -S $GITHUB_WORKSPACE/OpenCL-Headers* + -B $GITHUB_WORKSPACE/../build + -D CMAKE_BUILD_TYPE=Release + -D CMAKE_INSTALL_PREFIX=/usr + -D BUILD_TESTING=OFF + -D LATEST_RELEASE_VERSION=$GITHUB_REF_NAME + -D CPACK_DEBIAN_PACKAGE_MAINTAINER="${{ vars.DEB_MAINTAINER }}" + -D DEBIAN_VERSION_SUFFIX=${{ vars.DEB_VERSION_SUFFIX }} + + - name: Generate packaging scripts + run: cmake + -D CMAKE_CACHE_PATH=$GITHUB_WORKSPACE/../build/CMakeCache.txt + -D ORIG_ARCHIVE=$GITHUB_WORKSPACE/source.orig.tar.gz + -D LATEST_RELEASE_VERSION=$GITHUB_REF_NAME + -D DEBIAN_DISTROSERIES=${{ env.distroseries }} + -D DEBIAN_PACKAGE_MAINTAINER="${{ vars.DEB_MAINTAINER }}" + -D DEBIAN_VERSION_SUFFIX=${{ vars.DEB_VERSION_SUFFIX }} + -P $GITHUB_WORKSPACE/OpenCL-Headers*/cmake/DebSourcePkg.cmake + + - name: Build source package + run: | + cd $GITHUB_WORKSPACE/OpenCL-Headers*/ + debuild -S -sa + + - name: Build binary package + run: cpack + -G DEB + -C Release + -B $GITHUB_WORKSPACE/../build + --config $GITHUB_WORKSPACE/../build/CPackConfig.cmake + + # The following step does not depend on the previous step "Build binary package", + # but if the binary package build is unsuccessful, it is better not to push the + # source packages to the PPA + - name: Push source package to the PPA + run: dput ppa:${{ vars.PPA }} $GITHUB_WORKSPACE/*source.changes + + - name: Create GitHub release + uses: softprops/action-gh-release@v1 + with: + files: ${{ github.workspace }}/../build/*.deb diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml deleted file mode 100644 index 4def21de..00000000 --- a/.github/workflows/windows.yml +++ /dev/null @@ -1,253 +0,0 @@ -name: Windows - -on: - push: - paths-ignore: - - '**/*.md' - pull_request: - paths-ignore: - - '**/*.md' - -jobs: - compatibility: - runs-on: windows-latest - strategy: - matrix: - VER: [v142, v143] - EXT: [ON, OFF] - GEN: [Visual Studio 17 2022] - BIN: [x64, x86] - STD: [99, 11, 17] - include: - - VER: v141 - EXT: OFF - GEN: Ninja Multi-Config - BIN: x64 - STD: 89 # /Za - env: - NINJA_URL: https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-win.zip - NINJA_ROOT: C:\Tools\Ninja - VS_ROOT: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' - UseMultiToolTask: true # Better parallel MSBuild execution - - steps: - - uses: actions/checkout@v3 - - - name: Cache Ninja install - if: matrix.GEN == 'Ninja Multi-Config' - id: ninja-install - uses: actions/cache@v2 - with: - path: | - C:\Tools\Ninja - key: ${{runner.os}}-ninja-${{env.NINJA_URL}} - - - name: Install Ninja - if: matrix.GEN == 'Ninja Multi-Config' && steps.ninja-install.outputs.cache-hit != 'true' - shell: pwsh - run: | - Invoke-WebRequest ${env:NINJA_URL} -OutFile ~\Downloads\ninja-win.zip - Expand-Archive ~\Downloads\ninja-win.zip -DestinationPath ${env:NINJA_ROOT}\ - Remove-Item ~\Downloads\* - - - name: Configure (MSBuild) - if: matrix.GEN == 'Visual Studio 17 2022' - shell: pwsh - run: | - $BIN = if('${{matrix.BIN}}' -eq 'x86') {'Win32'} else {'x64'} - $C_FLAGS = '/W4 /WX' - & cmake ` - -G '${{matrix.GEN}}' ` - -A $BIN ` - -T ${{matrix.VER}} ` - -D BUILD_TESTING=ON ` - -D CMAKE_C_FLAGS="${C_FLAGS}" ` - -D CMAKE_C_EXTENSIONS='${{matrix.EXT}}' ` - -S "${env:GITHUB_WORKSPACE}" ` - -B "${env:GITHUB_WORKSPACE}\build" - - - name: Configure (Ninja Multi-Config) - if: matrix.GEN == 'Ninja Multi-Config' - shell: pwsh - run: | - $VER = switch ('${{matrix.VER}}') { ` - 'v141' {'14.1'} ` - 'v142' {'14.2'} ` - 'v143' {'14.3'} } - Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=${VER}" - $C_FLAGS = '/W4 /WX' - & cmake ` - -G '${{matrix.GEN}}' ` - -D CMAKE_MAKE_PROGRAM="${env:NINJA_ROOT}\ninja.exe" ` - -D BUILD_TESTING=ON ` - -D CMAKE_C_FLAGS="${C_FLAGS}" ` - -D CMAKE_C_EXTENSIONS='${{matrix.EXT}}' ` - -D CMAKE_EXE_LINKER_FLAGS='/INCREMENTAL' ` - -S "${env:GITHUB_WORKSPACE}" ` - -B "${env:GITHUB_WORKSPACE}\build" - - - name: Build (MSBuild) - if: matrix.GEN == 'Visual Studio 17 2022' - shell: pwsh - run: | - foreach ($Config in 'Release','Debug') { ` - & cmake ` - --build "${env:GITHUB_WORKSPACE}\build" ` - --config ${Config} ` - -- ` - /verbosity:minimal ` - /maxCpuCount ` - /noLogo - } - - - name: Build (Ninja) - if: matrix.GEN == 'Ninja Multi-Config' - shell: pwsh - run: | - $VER = switch ('${{matrix.VER}}') { ` - 'v141' {'14.1'} ` - 'v142' {'14.2'} ` - 'v143' {'14.3'} } - Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=${VER}" - foreach ($Config in 'Release','Debug') { ` - & cmake ` - --build "${env:GITHUB_WORKSPACE}\build" ` - --config ${Config} ` - -- ` - -j ${env:NUMBER_OF_PROCESSORS} - } - - - name: Test - shell: pwsh - run: | - foreach ($Config in 'Release','Debug') { ` - & ctest ` - --test-dir "${env:GITHUB_WORKSPACE}\build" ` - --build-config ${Config} ` - --output-on-failure ` - --parallel ${env:NUMBER_OF_PROCESSORS} - } - - - name: Install - shell: pwsh - run: | - & cmake ` - --install "${env:GITHUB_WORKSPACE}\build" ` - --prefix "${env:GITHUB_WORKSPACE}\install" ` - --config Release - - - name: Consume (PkgConfig - bare MSBuild) - if: matrix.GEN == 'Visual Studio 17 2022' - shell: pwsh - run: | - $BIN = if('${{matrix.BIN}}' -eq 'x86') {'Win32'} else {'x64'} - $C_FLAGS = '/W4 /WX' - & cmake ` - -G '${{matrix.GEN}}' ` - -A $BIN ` - -T ${{matrix.VER}} ` - -D CMAKE_C_FLAGS="${C_FLAGS}" ` - -D CMAKE_C_EXTENSIONS='${{matrix.EXT}}' ` - -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\install" ` - -S "${env:GITHUB_WORKSPACE}\tests\pkgconfig\bare" ` - -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" - foreach ($Config in 'Release','Debug') { ` - & cmake ` - --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" ` - --config ${Config} ` - -- ` - /verbosity:minimal ` - /maxCpuCount ` - /noLogo ` - } - - - name: Consume (PkgConfig - bare Ninja) - if: matrix.GEN == 'Ninja Multi-Config' - shell: pwsh - run: | - $VER = switch ('${{matrix.VER}}') { ` - 'v141' {'14.1'} ` - 'v142' {'14.2'} ` - 'v143' {'14.3'} } - Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=${VER}" - $C_FLAGS = '/W4 /WX' - & cmake ` - -G '${{matrix.GEN}}' ` - -D CMAKE_MAKE_PROGRAM="${env:NINJA_ROOT}\ninja.exe" ` - -D BUILD_TESTING=ON ` - -D CMAKE_C_FLAGS="${C_FLAGS}" ` - -D CMAKE_C_EXTENSIONS='${{matrix.EXT}}' ` - -D CMAKE_EXE_LINKER_FLAGS='/INCREMENTAL' ` - -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\install" ` - -S "${env:GITHUB_WORKSPACE}\tests\pkgconfig\bare" ` - -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" - foreach ($Config in 'Release','Debug') { ` - & cmake ` - --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\bare" ` - --config ${Config} ` - -- ` - -j ${env:NUMBER_OF_PROCESSORS} ` - } - - - name: Consume (Emulate SDK presence) - shell: pwsh - run: | - New-Item -Type Directory -Path ${env:GITHUB_WORKSPACE}\install\share\cmake\OpenCL - New-Item -Type File -Path ${env:GITHUB_WORKSPACE}\install\share\cmake\OpenCL\OpenCLConfig.cmake -Value 'include("${CMAKE_CURRENT_LIST_DIR}/../OpenCLHeaders/OpenCLHeadersTargets.cmake")' - - - name: Consume (PkgConfig - SDK MSBuild) - if: matrix.GEN == 'Visual Studio 17 2022' - shell: pwsh - run: | - $BIN = if('${{matrix.BIN}}' -eq 'x86') {'Win32'} else {'x64'} - $C_FLAGS = '/W4 /WX' - & cmake ` - -G '${{matrix.GEN}}' ` - -A $BIN ` - -T ${{matrix.VER}} ` - -D CMAKE_C_FLAGS="${C_FLAGS}" ` - -D CMAKE_C_EXTENSIONS='${{matrix.EXT}}' ` - -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\install" ` - -S "${env:GITHUB_WORKSPACE}\tests\pkgconfig\sdk" ` - -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" - foreach ($Config in 'Release','Debug') { ` - & cmake ` - --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" ` - --config ${Config} ` - -- ` - /verbosity:minimal ` - /maxCpuCount ` - /noLogo ` - } - - - name: Consume (PkgConfig - SDK Ninja) - if: matrix.GEN == 'Ninja Multi-Config' - shell: pwsh - run: | - $VER = switch ('${{matrix.VER}}') { ` - 'v141' {'14.1'} ` - 'v142' {'14.2'} ` - 'v143' {'14.3'} } - Import-Module "${env:VS_ROOT}\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" - Enter-VsDevShell -VsInstallPath ${env:VS_ROOT} -SkipAutomaticLocation -DevCmdArguments "-host_arch=x64 -arch=${{matrix.BIN}} -vcvars_ver=${VER}" - $C_FLAGS = '/W4 /WX' - & cmake ` - -G '${{matrix.GEN}}' ` - -D CMAKE_MAKE_PROGRAM="${env:NINJA_ROOT}\ninja.exe" ` - -D BUILD_TESTING=ON ` - -D CMAKE_C_FLAGS="${C_FLAGS}" ` - -D CMAKE_C_EXTENSIONS='${{matrix.EXT}}' ` - -D CMAKE_EXE_LINKER_FLAGS='/INCREMENTAL' ` - -D CMAKE_PREFIX_PATH="${env:GITHUB_WORKSPACE}\install" ` - -S "${env:GITHUB_WORKSPACE}\tests\pkgconfig\sdk" ` - -B "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" - foreach ($Config in 'Release','Debug') { ` - & cmake ` - --build "${env:GITHUB_WORKSPACE}\downstream\pkgconfig\sdk" ` - --config ${Config} ` - -- ` - -j ${env:NUMBER_OF_PROCESSORS} ` - } \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..c591e64c --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +# Build dir +[Bb]uild/ + +# Install dir +[Ii]nstall/ + +# Package dir +[Pp]ackage[-_\s\d]*/ + +# Test dir +[Tt]esting/ + +# Visual Studio Code +.vscode diff --git a/CL/cl_platform.h b/CL/cl_platform.h index e7a0d6f4..2d890769 100644 --- a/CL/cl_platform.h +++ b/CL/cl_platform.h @@ -77,7 +77,7 @@ extern "C" { #ifdef __GNUC__ #define CL_API_SUFFIX_DEPRECATED __attribute__((deprecated)) #define CL_API_PREFIX_DEPRECATED -#elif defined(_WIN32) +#elif defined(_MSC_VER) && !defined(__clang__) #define CL_API_SUFFIX_DEPRECATED #define CL_API_PREFIX_DEPRECATED __declspec(deprecated) #else diff --git a/CMakeLists.txt b/CMakeLists.txt index 04f77726..1b207749 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0...3.22) +cmake_minimum_required(VERSION 3.16...3.26) # Include guard for including this project multiple times if(TARGET Headers) @@ -6,7 +6,7 @@ if(TARGET Headers) endif() project(OpenCLHeaders - VERSION 2.2 + VERSION 3.0 LANGUAGES C # Ideally should be NONE, but GNUInstallDirs detects platform arch using try_compile # https://stackoverflow.com/questions/43379311/why-does-project-affect-cmakes-opinion-on-cmake-sizeof-void-p ) @@ -15,9 +15,9 @@ option(OPENCL_HEADERS_BUILD_TESTING "Enable support for OpenCL C headers testing option(OPENCL_HEADERS_BUILD_CXX_TESTS "Enable support for OpenCL C headers testing in C++ mode." ON) set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include(JoinPaths) - include(GNUInstallDirs) +include(JoinPaths) +include(Package) add_library(Headers INTERFACE) add_library(OpenCL::Headers ALIAS Headers) @@ -139,11 +139,3 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) set_target_properties(headers_generate PROPERTIES FOLDER "Generation") set_target_properties(headers_copy PROPERTIES FOLDER "Generation") endif() - -join_paths(OPENCL_INCLUDEDIR_PC "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") - -configure_file(OpenCL-Headers.pc.in OpenCL-Headers.pc @ONLY) -set(pkg_config_location ${CMAKE_INSTALL_DATADIR}/pkgconfig) -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenCL-Headers.pc - DESTINATION ${pkg_config_location}) diff --git a/OpenCL-Headers.pc.in b/OpenCL-Headers.pc.in index 92d241c4..5cc13fba 100644 --- a/OpenCL-Headers.pc.in +++ b/OpenCL-Headers.pc.in @@ -1,4 +1,4 @@ -prefix=@CMAKE_INSTALL_PREFIX@ +prefix=@PKGCONFIG_PREFIX@ includedir=@OPENCL_INCLUDEDIR_PC@ Name: OpenCL-Headers diff --git a/README.md b/README.md index 1a491896..93756c81 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,11 @@ LICENSE Source license for the OpenCL API headers CL/ Unified OpenCL API headers tree ``` +## Packaging + +For packaging instructions, see [RELEASE.md](https://github.com/KhronosGroup/OpenCL-SDK/blob/main/docs/RELEASE.md) +in the OpenCL SDK repository. + ## License See [LICENSE](LICENSE). diff --git a/cmake/DebSourcePkg.cmake b/cmake/DebSourcePkg.cmake new file mode 100644 index 00000000..9199a8cd --- /dev/null +++ b/cmake/DebSourcePkg.cmake @@ -0,0 +1,125 @@ +# This script produces the changelog, control and rules file in the debian +# directory. These files are needed to build a Debian source package from the repository. +# Run this in CMake script mode, e.g. +# $ cd OpenCL-Headers +# $ cmake -S . -B ../build -D BUILD_TESTING=OFF +# $ cmake +# -DCMAKE_CACHE_PATH=../build/CMakeCache.txt +# -DCPACK_DEBIAN_PACKAGE_MAINTAINER="Example Name " +# -DDEBIAN_DISTROSERIES=jammy +# -DORIG_ARCHIVE=../OpenCL-Headers.tar.gz +# -DLATEST_RELEASE_VERSION=v2023.08.29 +# -P cmake/DebSourcePkg.cmake +# $ debuild -S -sa + +cmake_minimum_required(VERSION 3.21) # file(COPY_FILE) is added in CMake 3.21 + +set(DEB_SOURCE_PKG_NAME "khronos-opencl-headers") +set(DEB_CLHPP_PKG_NAME "opencl-clhpp-headers") +set(DEB_META_PKG_NAME "opencl-headers") +set(DEB_META_PKG_DESCRIPTION "OpenCL (Open Computing Language) header files + OpenCL (Open Computing Language) is a multi-vendor open standard for + general-purpose parallel programming of heterogeneous systems that include + CPUs, GPUs and other processors. + . + This metapackage depends on packages providing the C and C++ headers files + for the OpenCL API as published by The Khronos Group Inc. The corresponding + specification and documentation can be found on the Khronos website.") + +if(NOT EXISTS "${CMAKE_CACHE_PATH}") + message(FATAL_ERROR "CMAKE_CACHE_PATH is not set or does not exist") +endif() +if(NOT DEFINED DEBIAN_PACKAGE_MAINTAINER) + message(FATAL_ERROR "DEBIAN_PACKAGE_MAINTAINER is not set") +endif() +if(NOT DEFINED DEBIAN_DISTROSERIES) + message(FATAL_ERROR "DEBIAN_DISTROSERIES is not set") +endif() +if(NOT DEFINED ORIG_ARCHIVE) + message(WARNING "ORIG_ARCHIVE is not set") +elseif(NOT EXISTS "${ORIG_ARCHIVE}") + message(FATAL_ERROR "ORIG_ARCHIVE is defined, but the file does not exist at \"${ORIG_ARCHIVE}\"") +endif() +if(NOT DEFINED LATEST_RELEASE_VERSION) + message(WARNING "LATEST_RELEASE_VERSION is not set") +endif() +if(NOT DEFINED DEBIAN_VERSION_SUFFIX) + message(WARNING "DEBIAN_VERSION_SUFFIX is not set") +endif() + +# Extracting the project version from the main CMakeLists.txt via regex +file(READ "${CMAKE_CACHE_PATH}" CMAKE_CACHE) +string(REGEX MATCH "CMAKE_PROJECT_VERSION[^=]*=([^\n]*)" REGEX_MATCH "${CMAKE_CACHE}") +if(NOT REGEX_MATCH) + message(FATAL_ERROR "Could not extract project version from CMakeLists.txt") +endif() +set(PROJECT_VERSION "${CMAKE_MATCH_1}") + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") +# Package.cmake contains all details for packaging +include(PackageSetup) + +# Append a space after every newline in the description. This format is required +# in the control file. +string(REPLACE "\n" "\n " CPACK_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}") + +set(DEB_SOURCE_PKG_DIR "${CMAKE_CURRENT_LIST_DIR}/../debian") +# Write debian/control +file(WRITE "${DEB_SOURCE_PKG_DIR}/control" +"Source: ${DEB_SOURCE_PKG_NAME} +Section: ${CPACK_DEBIAN_PACKAGE_SECTION} +Priority: optional +Maintainer: ${DEBIAN_PACKAGE_MAINTAINER} +Build-Depends: cmake, debhelper-compat (=13) +Rules-Requires-Root: no +Homepage: ${CPACK_DEBIAN_PACKAGE_HOMEPAGE} +Standards-Version: 4.6.2 + +Package: ${DEBIAN_PACKAGE_NAME} +Architecture: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE} +Multi-Arch: foreign +Breaks: ${CPACK_DEBIAN_PACKAGE_BREAKS} +Replaces: ${CPACK_DEBIAN_PACKAGE_REPLACES} +Description: ${CPACK_PACKAGE_DESCRIPTION} + +Package: ${DEB_META_PKG_NAME} +Architecture: ${CPACK_DEBIAN_PACKAGE_ARCHITECTURE} +Multi-Arch: foreign +Depends: ${DEBIAN_PACKAGE_NAME} (= ${PACKAGE_VERSION_REVISION}), ${DEB_CLHPP_PKG_NAME} (= ${PACKAGE_VERSION_REVISION}) +Description: ${DEB_META_PKG_DESCRIPTION} +" +) +# Write debian/changelog +string(TIMESTAMP CURRENT_TIMESTAMP "%a, %d %b %Y %H:%M:%S +0000" UTC) +file(WRITE "${DEB_SOURCE_PKG_DIR}/changelog" +"${DEB_SOURCE_PKG_NAME} (${PACKAGE_VERSION_REVISION}) ${DEBIAN_DISTROSERIES}; urgency=medium + + * Released version ${PACKAGE_VERSION_REVISION} + + -- ${DEBIAN_PACKAGE_MAINTAINER} ${CURRENT_TIMESTAMP} +") +# Write debian/rules +file(WRITE "${DEB_SOURCE_PKG_DIR}/rules" +"#!/usr/bin/make -f +%: +\tdh $@ + +override_dh_auto_configure: +\tdh_auto_configure -- -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF + +override_dh_auto_install: +\tdh_auto_install --destdir=debian/${DEBIAN_PACKAGE_NAME}/ +") + +if(DEFINED ORIG_ARCHIVE) + # Copy the passed orig.tar.gz file. The target filename is deduced from the version number, as expected by debuild + cmake_path(IS_ABSOLUTE ORIG_ARCHIVE IS_ORIG_ARCHIVE_ABSOLUTE) + if (NOT IS_ORIG_ARCHIVE_ABSOLUTE) + message(FATAL_ERROR "ORIG_ARCHIVE must be an absolute path (passed: \"${ORIG_ARCHIVE}\")") + endif() + cmake_path(GET ORIG_ARCHIVE EXTENSION ORIG_ARCHIVE_EXT) + cmake_path(GET ORIG_ARCHIVE PARENT_PATH ORIG_ARCHIVE_PARENT) + set(TARGET_PATH "${ORIG_ARCHIVE_PARENT}/${DEB_SOURCE_PKG_NAME}_${CPACK_DEBIAN_PACKAGE_VERSION}${ORIG_ARCHIVE_EXT}") + message(STATUS "Copying \"${ORIG_ARCHIVE}\" to \"${TARGET_PATH}\"") + file(COPY_FILE "${ORIG_ARCHIVE}" "${TARGET_PATH}") +endif() diff --git a/cmake/Package.cmake b/cmake/Package.cmake new file mode 100644 index 00000000..6e207c1d --- /dev/null +++ b/cmake/Package.cmake @@ -0,0 +1,47 @@ +include("${CMAKE_CURRENT_LIST_DIR}/PackageSetup.cmake") + +# Configuring pkgconfig + +# We need two different instances of OpenCL-Headers.pc +# One for installing (cmake --install), which contains CMAKE_INSTALL_PREFIX as prefix +# And another for the Debian package, which contains CPACK_PACKAGING_INSTALL_PREFIX as prefix + +join_paths(OPENCL_INCLUDEDIR_PC "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") + +set(pkg_config_location ${CMAKE_INSTALL_DATADIR}/pkgconfig) +set(PKGCONFIG_PREFIX "${CMAKE_INSTALL_PREFIX}") +configure_file( + OpenCL-Headers.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_install/OpenCL-Headers.pc + @ONLY) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_install/OpenCL-Headers.pc + DESTINATION ${pkg_config_location} + COMPONENT pkgconfig_install) + +set(PKGCONFIG_PREFIX "${CPACK_PACKAGING_INSTALL_PREFIX}") +configure_file( + OpenCL-Headers.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_package/OpenCL-Headers.pc + @ONLY) +# This install component is only needed in the Debian package +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/pkgconfig_package/OpenCL-Headers.pc + DESTINATION ${pkg_config_location} + COMPONENT pkgconfig_package + EXCLUDE_FROM_ALL) + +# By using component based packaging, component pkgconfig_install +# can be excluded from the package, and component pkgconfig_package +# can be included. +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE") + +include(CPackComponent) +cpack_add_component(pkgconfig_install) +cpack_add_component(pkgconfig_package) +set(CPACK_COMPONENTS_ALL "Unspecified;pkgconfig_package") + +set(CPACK_DEBIAN_PACKAGE_DEBUG ON) + +include(CPack) diff --git a/cmake/PackageSetup.cmake b/cmake/PackageSetup.cmake new file mode 100644 index 00000000..92075a0c --- /dev/null +++ b/cmake/PackageSetup.cmake @@ -0,0 +1,56 @@ +set(CPACK_PACKAGE_VENDOR "khronos") + +set(CPACK_PACKAGE_DESCRIPTION "OpenCL (Open Computing Language) C header files +OpenCL (Open Computing Language) is a multi-vendor open standard for +general-purpose parallel programming of heterogeneous systems that include +CPUs, GPUs and other processors. +. +This package provides the C development header files for the OpenCL API +as published by The Khronos Group Inc. The corresponding specification and +documentation can be found on the Khronos website.") + +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") + +set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") + +if(NOT CPACK_PACKAGING_INSTALL_PREFIX) + set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") +endif() + +# DEB packaging configuration +if(NOT DEFINED CPACK_DEBIAN_PACKAGE_MAINTAINER) + set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_VENDOR}) +endif() + +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE + "https://github.com/KhronosGroup/OpenCL-Headers") + +# Version number [epoch:]upstream_version[-debian_revision] +set(CPACK_DEBIAN_PACKAGE_VERSION "${PROJECT_VERSION}") # upstream_version +if(DEFINED LATEST_RELEASE_VERSION) + # Remove leading "v", if exists + string(LENGTH "${LATEST_RELEASE_VERSION}" LATEST_RELEASE_VERSION_LENGTH) + string(SUBSTRING "${LATEST_RELEASE_VERSION}" 0 1 LATEST_RELEASE_VERSION_FRONT) + if(LATEST_RELEASE_VERSION_FRONT STREQUAL "v") + string(SUBSTRING "${LATEST_RELEASE_VERSION}" 1 ${LATEST_RELEASE_VERSION_LENGTH} LATEST_RELEASE_VERSION) + endif() + + string(APPEND CPACK_DEBIAN_PACKAGE_VERSION "~${LATEST_RELEASE_VERSION}") +endif() +set(CPACK_DEBIAN_PACKAGE_RELEASE "1") # debian_revision (because this is a + # non-native pkg) +set(PACKAGE_VERSION_REVISION "${CPACK_DEBIAN_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}${DEBIAN_VERSION_SUFFIX}") + +set(DEBIAN_PACKAGE_NAME "opencl-c-headers") +set(CPACK_DEBIAN_PACKAGE_NAME + "${DEBIAN_PACKAGE_NAME}" + CACHE STRING "Package name" FORCE) + +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "all") +set(CPACK_DEBIAN_PACKAGE_SECTION "libdevel") +set(CPACK_DEBIAN_PACKAGE_BREAKS "opencl-headers (<< ${CPACK_DEBIAN_PACKAGE_VERSION}), opencl-clhpp-headers (<< ${CPACK_DEBIAN_PACKAGE_VERSION})") +set(CPACK_DEBIAN_PACKAGE_REPLACES "opencl-headers (<< ${CPACK_DEBIAN_PACKAGE_VERSION})") + +# Package file name in deb format: +# _-_.deb +set(CPACK_DEBIAN_FILE_NAME "${DEBIAN_PACKAGE_NAME}_${PACKAGE_VERSION_REVISION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb") diff --git a/scripts/check-format.sh b/scripts/check-format.sh new file mode 100755 index 00000000..24c61662 --- /dev/null +++ b/scripts/check-format.sh @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +SOURCE_COMMIT="$1" +if [ "$#" -gt 0 ]; then + shift +fi + +# If no source commit is given target the default branch +if [ "x$SOURCE_COMMIT" = "x" ]; then + # If remote is not set use the remote of the current branch or fallback to "origin" + if [ "x$REMOTE" = "x" ]; then + BRANCH="$(git rev-parse --abbrev-ref HEAD)" + REMOTE="$(git config --local --get "branch.$BRANCH.remote" || echo 'origin')" + fi + SOURCE_COMMIT="remotes/$REMOTE/HEAD" +fi + +# Force colored diff output +DIFF_COLOR_SAVED="$(git config --local --get color.diff)" +if [ "x$DIFF_COLOR_SAVED" != "x" ]; then + git config --local --replace-all "color.diff" "always" +else + git config --local --add "color.diff" "always" +fi + +scratch="$(mktemp -t check-format.XXXXXXXXXX)" +finish () { + # Remove temporary file + rm -rf "$scratch" + # Restore setting + if [ "x$DIFF_COLOR_SAVED" != "x" ]; then + git config --local --replace-all "color.diff" "$DIFF_COLOR_SAVED" + else + git config --local --unset "color.diff" + fi +} +# The trap will be invoked whenever the script exits, even due to a signal, this is a bash only +# feature +trap finish EXIT + +GIT_CLANG_FORMAT="${GIT_CLANG_FORMAT:-git-clang-format}" +"$GIT_CLANG_FORMAT" --style=file --extensions=cc,cp,cpp,c++,cxx,cu,cuh,hh,hpp,hxx,hip,vert,frag --diff "$@" "$SOURCE_COMMIT" > "$scratch" + +# Check for no-ops +grep '^no modified files to format$\|^clang-format did not modify any files$' \ + "$scratch" > /dev/null && exit 0 + +# Dump formatting diff and signal failure +printf \ +"\033[31m==== FORMATTING VIOLATIONS DETECTED ====\033[0m +run '\033[33m%s --style=file %s %s\033[0m' to apply these formating changes\n\n" \ +"$GIT_CLANG_FORMAT" "$*" "$SOURCE_COMMIT" + +cat "$scratch" +exit 1 diff --git a/tests/pkgconfig/bare/CMakeLists.txt b/tests/pkgconfig/bare/CMakeLists.txt index 866831a7..f3e8466e 100644 --- a/tests/pkgconfig/bare/CMakeLists.txt +++ b/tests/pkgconfig/bare/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.16) project(PkgConfigTest LANGUAGES C @@ -21,3 +21,10 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE CL_TARGET_OPENCL_VERSION=120 ) + +include(CTest) + +add_test( + NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} +) diff --git a/tests/pkgconfig/pkgconfig.c b/tests/pkgconfig/pkgconfig.c index d4c1f013..a520a130 100644 --- a/tests/pkgconfig/pkgconfig.c +++ b/tests/pkgconfig/pkgconfig.c @@ -1,6 +1,3 @@ #include -int main() -{ - return sizeof(cl_platform_id) - sizeof(cl_context); -} +int main(void) { return sizeof(cl_platform_id) - sizeof(cl_context); } diff --git a/tests/pkgconfig/sdk/CMakeLists.txt b/tests/pkgconfig/sdk/CMakeLists.txt index 75f56049..aa36d168 100644 --- a/tests/pkgconfig/sdk/CMakeLists.txt +++ b/tests/pkgconfig/sdk/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.16) project(PkgConfigTest LANGUAGES C @@ -22,3 +22,10 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE CL_TARGET_OPENCL_VERSION=120 ) + +include(CTest) + +add_test( + NAME ${PROJECT_NAME} + COMMAND ${PROJECT_NAME} +) diff --git a/tests/test_headers.c b/tests/test_headers.c index 460a182d..65e5f5d0 100644 --- a/tests/test_headers.c +++ b/tests/test_headers.c @@ -29,7 +29,7 @@ will use inttypes.h for C compiles and cinttypes for C++ compiles. #include "CL/cl.h" -int test_char() +int test_char(void) { /* char */ /* Constructor */ @@ -89,7 +89,7 @@ int test_char() return 0; } -int test_uchar() +int test_uchar(void) { /* uchar */ /* Constructor */ @@ -149,7 +149,7 @@ int test_uchar() return 0; } -int test_short() +int test_short(void) { /* short */ /* Constructor */ @@ -209,7 +209,7 @@ int test_short() return 0; } -int test_ushort() +int test_ushort(void) { /* ushort */ /* Constructor */ @@ -269,7 +269,7 @@ int test_ushort() return 0; } -int test_int() +int test_int(void) { /* int */ /* Constructor */ @@ -329,7 +329,7 @@ int test_int() return 0; } -int test_uint() +int test_uint(void) { /* uint */ /* Constructor */ @@ -389,7 +389,7 @@ int test_uint() return 0; } -int test_long() +int test_long(void) { /* long */ /* Constructor */ @@ -449,7 +449,7 @@ int test_long() return 0; } -int test_ulong() +int test_ulong(void) { /* ulong */ /* Constructor */ @@ -509,7 +509,7 @@ int test_ulong() return 0; } -int test_float() +int test_float(void) { /* float */ /* Constructor */ @@ -571,7 +571,7 @@ int test_float() return 0; } -int test_double() +int test_double(void) { /* double */ /* Constructor */