Skip to content

Commit

Permalink
ci: windows: add GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
adriweb committed Nov 14, 2023
1 parent 9a5fa98 commit 2d7ef7d
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.linux.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build Linux

on:
push:
branches: [ master, experimental, experimental2 ]
branches: [ master, experimental, experimental2, feature/ci-windows ]
pull_request:
branches: [ master, experimental, experimental2 ]
branches: [ master, experimental, experimental2, feature/ci-windows ]
release:
types: [published]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.mac.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Build macOS

on:
push:
branches: [ master, experimental, experimental2 ]
branches: [ master, experimental, experimental2, feature/ci-windows ]
pull_request:
branches: [ master, experimental, experimental2 ]
branches: [ master, experimental, experimental2, feature/ci-windows ]
release:
types: [published]

Expand Down
73 changes: 73 additions & 0 deletions .github/workflows/build.windows.workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build Windows

on:
push:
branches: [ master, feature/github-actions, feature/ci-windows ]
pull_request:
branches: [ master, feature/github-actions, feature/ci-windows ]
release:
types: [published]

jobs:
build:
name: "Build: ${{ matrix.arch }} - ${{ matrix.deps_type }} deps"
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
arch: [x64]
config: [Release,Release-Only] # Release-Only = try to use static deps as much as possible
include:
- arch: x64
arch_name: 64-bit
arch_suffix: "64"
- config: Release
deps_type: shared
- config: Release-Only
deps_type: static

steps:
- name: Checkout Git Repo
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Install latest CMake
uses: lukka/get-cmake@9781783c006d9d607cb391b971a1dcbed768a25a # latest as of 2023-11-12

- name: Restore artifacts, or setup vcpkg (do not install any package)
uses: lukka/run-vcpkg@6fe69898af670ac05f4a8427cc5cff4fb361cee5 # latest as of 2023-11-12
with:
vcpkgGitCommitId: '61f610845fb206298a69f708104a51d651872877' # latest as of 2023-11-12
prependedCacheKey: '${{ matrix.deps_type }}Deps'

- name: Create prefix folder
shell: cmd
run: mkdir prefix

- name: Build tilibs
uses: lukka/run-cmake@2ce8982be71b8e9a3c4d5e432135035afd1e76a7 # latest as of 2023-11-12
with:
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
configurePreset: '${{ matrix.arch }}-${{ matrix.config }}'
buildPreset: '${{ matrix.arch }}-${{ matrix.config }}'
env:
VCPKG_FORCE_SYSTEM_BINARIES: 1
CMAKE_INSTALL_PREFIX_OVERRIDE: '${{ github.workspace }}/prefix'

- name: Install tilibs
uses: lukka/run-cmake@2ce8982be71b8e9a3c4d5e432135035afd1e76a7 # latest as of 2023-11-12
with:
cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
buildPreset: '${{ matrix.arch }}-${{ matrix.config }}'
buildPresetAdditionalArgs: "['--target install']"

- name: Prepare install folder for upload
shell: cmd
run: rename prefix tilibs_windows_${{ matrix.deps_type }}Deps_${{ github.sha }}

- name: Upload install folder
uses: actions/upload-artifact@v3
with:
name: tilibs_windows_${{ matrix.deps_type }}Deps_${{ github.sha }}
path: tilibs_windows_${{ matrix.deps_type }}Deps_${{ github.sha }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Thumbs.db
.\#*
\#*\#
.idea/
.vs/
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
Expand All @@ -84,3 +85,4 @@ Session.vim

# CMake
cmake-build-*/
tilibs.build/
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,30 @@ project(tilibs C CXX)
# - probably doesn't work very well with ancient toolchains or on uncommon OSes
#
# Notes:
# - this has been succesfully tested on recent macOS and Linux.
# - this has been succesfully tested on recent macOS, Linux, and Windows (with vcpkg).
# - The TRY_STATIC_LIBS CMake option will try to build the libs (both shared and static) using as many static
# dependent libraries as possible.
# Let's note however that there is currently not much advantage in building that way, using shared libs is preferred,
# but at least you have the choice to do whatever you want should you ever really need a static build.
# but at least you have the choice to do whatever you want should you ever really need a static build (may be useful on Windows)
#
# In the future...:
# - TODO: add support to build the ROM dumpers (will end up just launching the external tools...)
# - WISH: do not hardcode the (auto-generated...) potfiles_* target names
# - WISH: better expose each lib's generated install target (NTS: look at cmake's components feature?)
# - WISH: provide Find* CMake modules for the libs themselves?
# - WISH: add support for Windows (that will probably be annoying)
#

# In case there was an env-var override...
if(DEFINED ENV{CMAKE_INSTALL_PREFIX_OVERRIDE})
set(CMAKE_INSTALL_PREFIX "$ENV{CMAKE_INSTALL_PREFIX_OVERRIDE}")
endif()
# Be sure to have the expected install prefix format
if(CMAKE_INSTALL_PREFIX)
file(TO_CMAKE_PATH "${CMAKE_INSTALL_PREFIX}" CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX} CACHE PATH "CMAKE_INSTALL_PREFIX" FORCE)
message("CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
endif()

# Our modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.cmake)
file(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/*.cmake")
Expand Down
99 changes: 99 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 1
},
"configurePresets": [
{
"name": "ninja-vcpkg",
"hidden": true,
"generator": "Ninja",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"binaryDir": "${sourceDir}/tilibs.build/${presetName}",
"installDir": "${sourceDir}/tilibs.build/${presetName}",
"cacheVariables": {
"VCPKG_MANIFEST_MODE": {
"type": "BOOL",
"value": "True"
},
"VCPKG_MANIFEST_INSTALL": {
"type": "BOOL",
"value": "True"
}
}
},
{
"name": "ninja-vcpkg-x64",
"hidden": true,
"inherits": "ninja-vcpkg",
"architecture": {
"strategy": "external",
"value": "x64"
},
"cacheVariables": {
"TRY_STATIC_LIBS": {
"type": "BOOL",
"value": "OFF"
},
"VCPKG_TARGET_TRIPLET": {
"type": "STRING",
"value": "x64-windows-release"
}
}
},
{
"name": "x64-Debug",
"inherits": "ninja-vcpkg-x64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": {
"type": "STRING",
"value": "Debug"
}
}
},
{
"name": "x64-Release",
"inherits": "ninja-vcpkg-x64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": {
"type": "STRING",
"value": "Release"
}
}
},
{
"name": "x64-Release-Only",
"inherits": "x64-Release",
"cacheVariables": {
"TRY_STATIC_LIBS": {
"type": "BOOL",
"value": "ON"
},
"VCPKG_HOST_TRIPLET": {
"type": "STRING",
"value": "x64-windows-static-release"
},
"VCPKG_TARGET_TRIPLET": {
"type": "STRING",
"value": "x64-windows-static-release"
}
}
}
],
"buildPresets": [
{
"name": "x64-Debug",
"configurePreset": "x64-Debug"
},
{
"name": "x64-Release",
"configurePreset": "x64-Release"
},
{
"name": "x64-Release-Only",
"configurePreset": "x64-Release-Only"
}
]
}
17 changes: 17 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "tilibs",
"version-string": "1.0",
"homepage": "https://github.com/debrouxl/tilibs",
"description": "libs to transfer things from/to TI graphing calculators",
"dependencies": [
"pkgconf",
{
"name": "libarchive",
"default-features": false
},
"libusb-win32",
"glib",
"gettext"
],
"builtin-baseline": "61f610845fb206298a69f708104a51d651872877"
}

0 comments on commit 2d7ef7d

Please sign in to comment.