From 55b4ff4e8cdd679b007a288e802bff20457dec4b Mon Sep 17 00:00:00 2001 From: "Christian A. Jacobsen" Date: Wed, 22 Jul 2020 12:23:26 +0200 Subject: [PATCH 1/5] First pipeline --- .semaphore/semaphore.yml | 38 +++++++++++++++++++ .../000-upgrade-system/upgrade-cmake.sh | 11 ++++++ .../configure-and-build.sh | 10 +++++ 3 files changed, 59 insertions(+) create mode 100644 .semaphore/semaphore.yml create mode 100644 build-tools/000-upgrade-system/upgrade-cmake.sh create mode 100644 build-tools/001-configure-and-build/configure-and-build.sh diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml new file mode 100644 index 0000000..ae7f6f8 --- /dev/null +++ b/.semaphore/semaphore.yml @@ -0,0 +1,38 @@ +version: v1.0 +name: Linux-x64 +agent: + machine: + type: e1-standard-2 + os_image: ubuntu1804 +blocks: + - name: Upgrade System + dependencies: [] + task: + prologue: + commands: + - checkout + jobs: + - name: Fetch Version 3.18 of CMake + commands: + - ./build-tools/000-upgrade-system/upgrade-cmake.sh + env_vars: + - name: CMAKE_CACHE_STRING + value: cmake-3-18-0 + - name: CMAKE_VERSION + value: 3.18.0 + - name: Build + dependencies: + - Upgrade System + task: + prologue: + commands: + - checkout + jobs: + - name: Configure & Build + commands: + - ./build-tools/001-configure-and-build/configure-and-build.sh + env_vars: + - name: CMAKE_CACHE_STRING + value: cmake-3-18-0 + - name: CMAKE_VERSION + value: 3.18.0 diff --git a/build-tools/000-upgrade-system/upgrade-cmake.sh b/build-tools/000-upgrade-system/upgrade-cmake.sh new file mode 100644 index 0000000..6b0eb3a --- /dev/null +++ b/build-tools/000-upgrade-system/upgrade-cmake.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env sh + +# Exit if CMake version is already cached +cache has_key "${CMAKE_CACHE_STRING}" && exit 0 + +# Download and extract desired version +wget -q "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz" +tar zxf "cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz" + +# Store the newly downloaded version in the cache +cache store "${CMAKE_CACHE_STRING}" "./cmake-${CMAKE_VERSION}-Linux-x86_64/bin/cmake" diff --git a/build-tools/001-configure-and-build/configure-and-build.sh b/build-tools/001-configure-and-build/configure-and-build.sh new file mode 100644 index 0000000..f3a5860 --- /dev/null +++ b/build-tools/001-configure-and-build/configure-and-build.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# Restore CMake from cache +cache restore "${CMAKE_CACHE_STRING}" + +# Configure build +"./cmake-${CMAKE_VERSION}-Linux-x86_64/bin/cmake" -B build -DCMAKE_BUILD_TYPE=Release . + +# Build +"./cmake-${CMAKE_VERSION}-Linux-x86_64/bin/cmake" --build build -j 2 From 5485f206f9409ab3c733656c84753313cacdf7e4 Mon Sep 17 00:00:00 2001 From: "Christian A. Jacobsen" Date: Wed, 22 Jul 2020 15:46:55 +0200 Subject: [PATCH 2/5] Add execute permissions to build scripts --- build-tools/000-upgrade-system/upgrade-cmake.sh | 0 build-tools/001-configure-and-build/configure-and-build.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 build-tools/000-upgrade-system/upgrade-cmake.sh mode change 100644 => 100755 build-tools/001-configure-and-build/configure-and-build.sh diff --git a/build-tools/000-upgrade-system/upgrade-cmake.sh b/build-tools/000-upgrade-system/upgrade-cmake.sh old mode 100644 new mode 100755 diff --git a/build-tools/001-configure-and-build/configure-and-build.sh b/build-tools/001-configure-and-build/configure-and-build.sh old mode 100644 new mode 100755 From 2063524453b1bd0360fa0cc77c916a134e1a0d2e Mon Sep 17 00:00:00 2001 From: "Christian A. Jacobsen" Date: Wed, 22 Jul 2020 15:50:46 +0200 Subject: [PATCH 3/5] Now stores entire CMake directory in cache --- build-tools/000-upgrade-system/upgrade-cmake.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-tools/000-upgrade-system/upgrade-cmake.sh b/build-tools/000-upgrade-system/upgrade-cmake.sh index 6b0eb3a..094b458 100755 --- a/build-tools/000-upgrade-system/upgrade-cmake.sh +++ b/build-tools/000-upgrade-system/upgrade-cmake.sh @@ -8,4 +8,4 @@ wget -q "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cm tar zxf "cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz" # Store the newly downloaded version in the cache -cache store "${CMAKE_CACHE_STRING}" "./cmake-${CMAKE_VERSION}-Linux-x86_64/bin/cmake" +cache store "${CMAKE_CACHE_STRING}" "./cmake-${CMAKE_VERSION}-Linux-x86_64/" From cc1c0ac531285348cfadeca2adb4e0d80ecfa3a7 Mon Sep 17 00:00:00 2001 From: "Christian A. Jacobsen" Date: Wed, 22 Jul 2020 17:27:45 +0200 Subject: [PATCH 4/5] Fix CMake config and add publish step for CI --- .semaphore/semaphore.yml | 11 +++++++++++ CMakeLists.txt | 8 +++++--- .../001-configure-and-build/configure-and-build.sh | 5 ++++- build-tools/002-publish/publish.sh | 10 ++++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100755 build-tools/002-publish/publish.sh diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index ae7f6f8..37dc8cd 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -26,6 +26,7 @@ blocks: task: prologue: commands: + - sem-version cpp 8 - checkout jobs: - name: Configure & Build @@ -36,3 +37,13 @@ blocks: value: cmake-3-18-0 - name: CMAKE_VERSION value: 3.18.0 + - name: Publish + dependencies: + - Build + skip: + when: branch != master + task: + jobs: + - name: Publish + commands: + - ./build-tools/002-publish/publish.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ef7a0a..f7116cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.14) project(wakeup DESCRIPTION "Wake your computer from sleep by sending a Magic Packet" LANGUAGES CXX @@ -8,12 +8,12 @@ set(Boost_NO_BOOST_CMAKE On) set(CMAKE_CXX_EXTENSIONS Off) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED On) +set(CMAKE_POSITION_INDEPENDENT_CODE On) include(./cmake/CPM.cmake) set(BOOST_VERSION 1.67.0) find_package(Boost ${BOOST_VERSION} QUIET) -get_cmake_property(_variableNames VARIABLES) if (NOT ${Boost_FOUND}) CPMAddPackage( NAME boost-cmake @@ -22,7 +22,9 @@ if (NOT ${Boost_FOUND}) ) elseif (NOT TARGET Boost::system) # Add Boost::system target for Boost packages compiled without CMake - add_library(Boost_system INTERFACE) + if (NOT TARGET Boost_system) + add_library(Boost_system INTERFACE) + endif () add_library(Boost::system ALIAS Boost_system) endif () diff --git a/build-tools/001-configure-and-build/configure-and-build.sh b/build-tools/001-configure-and-build/configure-and-build.sh index f3a5860..0ca07c9 100755 --- a/build-tools/001-configure-and-build/configure-and-build.sh +++ b/build-tools/001-configure-and-build/configure-and-build.sh @@ -7,4 +7,7 @@ cache restore "${CMAKE_CACHE_STRING}" "./cmake-${CMAKE_VERSION}-Linux-x86_64/bin/cmake" -B build -DCMAKE_BUILD_TYPE=Release . # Build -"./cmake-${CMAKE_VERSION}-Linux-x86_64/bin/cmake" --build build -j 2 +"./cmake-${CMAKE_VERSION}-Linux-x86_64/bin/cmake" --build build -j 3 + +# Store the built binary as an artifact +artifact push workflow build/wakeup diff --git a/build-tools/002-publish/publish.sh b/build-tools/002-publish/publish.sh new file mode 100755 index 0000000..6da460b --- /dev/null +++ b/build-tools/002-publish/publish.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# Fetch the current artifact +artifact pull workflow build/wakeup + +# Create a tar-ball +tar zcf "wakeup-$(build/wakeup --version).tar.gz" build/wakeup + +# Publish the final tar-balled binary +artifact push project "wakeup-$(build/wakeup --version).tar.gz" From 25d397115c871f553891bfbaf15dbf0f476d286e Mon Sep 17 00:00:00 2001 From: Jenkins Date: Wed, 22 Jul 2020 15:30:46 +0000 Subject: [PATCH 5/5] Update Semaphore configuration --- .semaphore/semaphore.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.semaphore/semaphore.yml b/.semaphore/semaphore.yml index 37dc8cd..c3ef845 100644 --- a/.semaphore/semaphore.yml +++ b/.semaphore/semaphore.yml @@ -41,7 +41,7 @@ blocks: dependencies: - Build skip: - when: branch != master + when: branch != 'master' task: jobs: - name: Publish