diff options
-rw-r--r-- | .github/workflows/build-binaries.yml | 93 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 14 | ||||
-rw-r--r-- | CMakePresets.json | 34 |
4 files changed, 136 insertions, 6 deletions
diff --git a/.github/workflows/build-binaries.yml b/.github/workflows/build-binaries.yml new file mode 100644 index 0000000..0ecff40 --- /dev/null +++ b/.github/workflows/build-binaries.yml | |||
@@ -0,0 +1,93 @@ | |||
1 | # Copyright (c) 2021-2022-2023 Luca Cappa | ||
2 | # Released under the term specified in file LICENSE.txt | ||
3 | # SPDX short identifier: MIT | ||
4 | |||
5 | # A "pure" GitHub workflow using CMake, Ninja and vcpkg to build a C/C++ codebase. | ||
6 | # It leverages both CMakePresets.json and vcpkg.json. | ||
7 | # It is called "pure workflow" because it is an example which minimizes the usage of | ||
8 | # custom GitHub Actions, but leverages directly the tools that could be easily run on | ||
9 | # your development machines (i.e. CMake, vcpkg, Ninja) to ensure a perfectly identical | ||
10 | # and reproducible local build (on your development machine) and a remote build on | ||
11 | # build agents. | ||
12 | name: build-binaries | ||
13 | on: | ||
14 | workflow_dispatch: | ||
15 | |||
16 | jobs: | ||
17 | job: | ||
18 | name: ${{ matrix.os }}-${{ github.workflow }} | ||
19 | runs-on: ${{ matrix.os }} | ||
20 | strategy: | ||
21 | fail-fast: false | ||
22 | matrix: | ||
23 | os: [ubuntu-latest, macos-latest, windows-latest] | ||
24 | include: | ||
25 | - os: windows-latest | ||
26 | triplet: x64-windows | ||
27 | - os: ubuntu-latest | ||
28 | triplet: x64-linux | ||
29 | - os: macos-latest | ||
30 | triplet: x64-osx | ||
31 | env: | ||
32 | # Indicates the location of the vcpkg as a Git submodule of the project repository. | ||
33 | VCPKG_ROOT: ${{ github.workspace }}/vendor/vcpkg | ||
34 | # Tells vcpkg where binary packages are stored. | ||
35 | VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vendor/vcpkg/bincache | ||
36 | # Let's use GitHub Action cache as storage for the vcpkg Binary Caching feature. | ||
37 | VCPKG_BINARY_SOURCES: 'clear;x-gha,readwrite' | ||
38 | |||
39 | steps: | ||
40 | # Set env vars needed for vcpkg to leverage the GitHub Action cache as a storage | ||
41 | # for Binary Caching. | ||
42 | - uses: actions/github-script@v6 | ||
43 | with: | ||
44 | script: | | ||
45 | core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | ||
46 | core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | ||
47 | |||
48 | - uses: actions/checkout@v3 | ||
49 | with: | ||
50 | submodules: true | ||
51 | - name: "Create directory '${{ env.VCPKG_DEFAULT_BINARY_CACHE }}'" | ||
52 | run: mkdir -p $VCPKG_DEFAULT_BINARY_CACHE | ||
53 | shell: bash | ||
54 | |||
55 | # Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be | ||
56 | quickly restored from GitHub cache service. | ||
57 | - uses: lukka/get-cmake@latest | ||
58 | |||
59 | # Restore vcpkg from the GitHub Action cache service. Note that packages are restored by vcpkg's binary caching | ||
60 | # when it is being run afterwards by CMake. | ||
61 | - name: Restore vcpkg | ||
62 | uses: actions/cache@v3 | ||
63 | with: | ||
64 | # The first path is the location of vcpkg: it contains the vcpkg executable and data files, as long as the | ||
65 | # built package archives (aka binary cache) which are located by VCPKG_DEFAULT_BINARY_CACHE env var. | ||
66 | # The other paths starting with '!' are exclusions: they contain termporary files generated during the build of the installed packages. | ||
67 | path: | | ||
68 | ${{ env.VCPKG_ROOT }} | ||
69 | !${{ env.VCPKG_ROOT }}/buildtrees | ||
70 | !${{ env.VCPKG_ROOT }}/packages | ||
71 | !${{ env.VCPKG_ROOT }}/downloads | ||
72 | !${{ env.VCPKG_ROOT }}/installed | ||
73 | # The key is composed in a way that it gets properly invalidated whenever a different version of vcpkg is being used. | ||
74 | key: | | ||
75 | ${{ hashFiles( '.git/modules/vcpkg/HEAD' )}} | ||
76 | |||
77 | # On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. | ||
78 | # As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK. | ||
79 | - uses: ilammy/msvc-dev-cmd@v1 | ||
80 | |||
81 | # Run CMake to generate Ninja project files, using the vcpkg's toolchain file to resolve and install | ||
82 | # the dependencies as specified in vcpkg.json. Note that the vcpkg's toolchain is specified | ||
83 | # in the CMakePresets.json file. | ||
84 | # This step also runs vcpkg with Binary Caching leveraging GitHub Action cache to | ||
85 | # store the built packages artifacts. | ||
86 | - name: Restore from cache the dependencies and generate project files | ||
87 | run: | | ||
88 | cmake --preset lingo-ap-tracker-preset | ||
89 | |||
90 | # Build (Release configuration only) the whole project with Ninja (which is spawn by CMake). | ||
91 | - name: Build (Release configuration) | ||
92 | run: | | ||
93 | cmake --build --preset lingo-ap-tracker-preset --config Release | ||
diff --git a/.gitignore b/.gitignore index 3fac228..d008edb 100644 --- a/.gitignore +++ b/.gitignore | |||
@@ -1,3 +1,4 @@ | |||
1 | build/ | 1 | build/ |
2 | builds/ | ||
2 | assets/LL1.yaml | 3 | assets/LL1.yaml |
3 | .DS_Store | 4 | .DS_Store |
diff --git a/CMakeLists.txt b/CMakeLists.txt index 756c776..6d9a111 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -3,11 +3,9 @@ project (lingo_ap_tracker) | |||
3 | 3 | ||
4 | set(CMAKE_BUILD_TYPE Debug) | 4 | set(CMAKE_BUILD_TYPE Debug) |
5 | 5 | ||
6 | find_package(wxWidgets COMPONENTS core base) | 6 | find_package(wxWidgets CONFIG REQUIRED) |
7 | include(${wxWidgets_USE_FILE}) | 7 | find_package(OpenSSL REQUIRED) |
8 | 8 | find_package(yaml-cpp REQUIRED) | |
9 | find_package(OpenSSL) | ||
10 | find_package(yaml-cpp) | ||
11 | 9 | ||
12 | include_directories( | 10 | include_directories( |
13 | vendor/hkutil | 11 | vendor/hkutil |
@@ -18,8 +16,12 @@ include_directories( | |||
18 | vendor/websocketpp | 16 | vendor/websocketpp |
19 | vendor/wswrap/include | 17 | vendor/wswrap/include |
20 | ${yaml-cpp_INCLUDE_DIRS} | 18 | ${yaml-cpp_INCLUDE_DIRS} |
19 | ${OpenSSL_INCLUDE_DIRS} | ||
21 | ) | 20 | ) |
22 | 21 | ||
22 | find_path(SYSTEM_INCLUDE_DIR zlib.h) | ||
23 | include_directories(${SYSTEM_INCLUDE_DIR}) | ||
24 | |||
23 | link_directories(${openssl_LIBRARY_DIRS}) | 25 | link_directories(${openssl_LIBRARY_DIRS}) |
24 | 26 | ||
25 | add_executable(lingo_ap_tracker | 27 | add_executable(lingo_ap_tracker |
@@ -36,4 +38,4 @@ add_executable(lingo_ap_tracker | |||
36 | ) | 38 | ) |
37 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 17) | 39 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD 17) |
38 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON) | 40 | set_property(TARGET lingo_ap_tracker PROPERTY CXX_STANDARD_REQUIRED ON) |
39 | target_link_libraries(lingo_ap_tracker ${wxWidgets_LIBRARIES} ${yaml-cpp_LIBRARIES} ${openssl_LIBRARIES}) | 41 | target_link_libraries(lingo_ap_tracker PRIVATE OpenSSL::SSL OpenSSL::Crypto wx::core wx::base yaml-cpp) |
diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..69774f3 --- /dev/null +++ b/CMakePresets.json | |||
@@ -0,0 +1,34 @@ | |||
1 | { | ||
2 | "version": 3, | ||
3 | "cmakeMinimumRequired": { | ||
4 | "major": 3, | ||
5 | "minor": 1, | ||
6 | "patch": 0 | ||
7 | }, | ||
8 | "configurePresets": [ | ||
9 | { | ||
10 | "name": "lingo-ap-tracker-preset", | ||
11 | "displayName": "Lingo AP Tracker preset", | ||
12 | "description": "Configure with vcpkg toolchain and generate Ninja project files for all configurations", | ||
13 | "binaryDir": "${sourceDir}/builds/${presetName}", | ||
14 | "generator": "Ninja Multi-Config", | ||
15 | "cacheVariables": { | ||
16 | "CMAKE_TOOLCHAIN_FILE": { | ||
17 | "type": "FILEPATH", | ||
18 | "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" | ||
19 | } | ||
20 | }, | ||
21 | "environment": { | ||
22 | "VCPKG_ROOT": "./vendor/vcpkg" | ||
23 | } | ||
24 | } | ||
25 | ], | ||
26 | "buildPresets": [ | ||
27 | { | ||
28 | "name": "lingo-ap-tracker-preset", | ||
29 | "configurePreset": "lingo-ap-tracker-preset", | ||
30 | "displayName": "Build lingo-ap-tracker-preset", | ||
31 | "description": "Build" | ||
32 | } | ||
33 | ] | ||
34 | } | ||