Skip to content

Commit

Permalink
Various minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mfep committed Sep 14, 2023
1 parent b9db62b commit fff80fe
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 232 deletions.
311 changes: 159 additions & 152 deletions .github/workflows/presubmit.yml

Large diffs are not rendered by default.

20 changes: 7 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,29 @@ name: Release
on:
push:
tags:
- "*"
- "v*"
env:
distroseries: jammy

jobs:
release:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Install prerequisites
shell: bash
run: sudo apt-get update -qq && sudo apt-get install -y cmake devscripts debhelper-compat=13

- name: Import GPG signing key
shell: bash
run: echo "${{ secrets.DEB_SIGNING_KEY }}" | gpg --import

- name: Download and extract source code
shell: bash
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
shell: bash
run: cmake
-S $GITHUB_WORKSPACE/OpenCL-Headers*
-B $GITHUB_WORKSPACE/../build
Expand All @@ -38,7 +37,6 @@ jobs:
-D DEBIAN_VERSION_SUFFIX=${{ vars.DEB_VERSION_SUFFIX }}

- name: Generate packaging scripts
shell: bash
run: cmake
-D CMAKE_CACHE_PATH=$GITHUB_WORKSPACE/../build/CMakeCache.txt
-D ORIG_ARCHIVE=$GITHUB_WORKSPACE/source.orig.tar.gz
Expand All @@ -48,26 +46,22 @@ jobs:
-D DEBIAN_VERSION_SUFFIX=${{ vars.DEB_VERSION_SUFFIX }}
-P $GITHUB_WORKSPACE/OpenCL-Headers*/cmake/DebSourcePkg.cmake

- name: List packaging scripts
shell: bash
run: cat $GITHUB_WORKSPACE/OpenCL-Headers*/debian/*

- name: Build source package
shell: bash
run: |
cd $GITHUB_WORKSPACE/OpenCL-Headers*/
debuild -S -sa
- name: Build binary package
shell: bash
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
shell: bash
run: dput ppa:${{ vars.PPA }} $GITHUB_WORKSPACE/*source.changes

- name: Create GitHub release
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,5 @@
# Test dir
[Tt]esting/

# CMake
CMakeCache.txt
CMakeFiles/

# Visual Studio Code
.vscode
7 changes: 6 additions & 1 deletion cmake/DebSourcePkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ if(NOT DEFINED DEBIAN_DISTROSERIES)
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")
Expand All @@ -55,9 +57,12 @@ set(PROJECT_VERSION "${CMAKE_MATCH_1}")

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
# Package.cmake contains all details for packaging
include(Package)
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"
Expand Down
61 changes: 1 addition & 60 deletions cmake/Package.cmake
Original file line number Diff line number Diff line change
@@ -1,61 +1,4 @@
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:
# <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
set(CPACK_DEBIAN_FILE_NAME "${DEBIAN_PACKAGE_NAME}_${PACKAGE_VERSION_REVISION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")

if (NOT CMAKE_SCRIPT_MODE_FILE) # Don't run in script mode
include("${CMAKE_CURRENT_LIST_DIR}/PackageSetup.cmake")

# Configuring pkgconfig

Expand Down Expand Up @@ -102,5 +45,3 @@ set(CPACK_COMPONENTS_ALL "Unspecified;pkgconfig_package")
set(CPACK_DEBIAN_PACKAGE_DEBUG ON)

include(CPack)

endif()
56 changes: 56 additions & 0 deletions cmake/PackageSetup.cmake
Original file line number Diff line number Diff line change
@@ -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:
# <PackageName>_<VersionNumber>-<DebianRevisionNumber>_<DebianArchitecture>.deb
set(CPACK_DEBIAN_FILE_NAME "${DEBIAN_PACKAGE_NAME}_${PACKAGE_VERSION_REVISION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
9 changes: 8 additions & 1 deletion tests/pkgconfig/bare/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.16)

project(PkgConfigTest
LANGUAGES C
Expand All @@ -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}
)
9 changes: 8 additions & 1 deletion tests/pkgconfig/sdk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.16)

project(PkgConfigTest
LANGUAGES C
Expand All @@ -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}
)

0 comments on commit fff80fe

Please sign in to comment.