From 68019ea31883e3bb448f57ba5b76ef900f40ecc0 Mon Sep 17 00:00:00 2001 From: Dave Corley <73663882+magicaldave@users.noreply.github.com> Date: Mon, 16 Oct 2023 14:31:08 -0500 Subject: [PATCH 1/5] Feat(CI): Add automated builds (#1) * Feat(CI): Add automated builds --- .github/workflows/cjson.yml | 78 ++++++++ CI/get_luajit.Linux.sh | 36 ++++ CI/get_luajit.windows.sh | 52 ++++++ CMakeLists.txt | 4 +- cmake/FindLuaJit.cmake | 16 ++ cmake/LibFindMacros.cmake | 363 ++++++++++++++++++++++++++++++++++++ 6 files changed, 548 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/cjson.yml create mode 100755 CI/get_luajit.Linux.sh create mode 100755 CI/get_luajit.windows.sh create mode 100644 cmake/FindLuaJit.cmake create mode 100644 cmake/LibFindMacros.cmake diff --git a/.github/workflows/cjson.yml b/.github/workflows/cjson.yml new file mode 100644 index 00000000..37bd7fb1 --- /dev/null +++ b/.github/workflows/cjson.yml @@ -0,0 +1,78 @@ +name: CJSON-Main + +on: + workflow_dispatch: + push: + branches: + - 'master' + pull_request: + branches: [ master ] + +jobs: + CJSON_MASTER: + strategy: + matrix: + build_type: [Release, RelWithDebInfo, MinSizeRel, Debug] + target_system: [ ubuntu-22.04, windows-2022 ] + runs-on: ${{ matrix.target_system }} + env: + BUILD_EXT: ${{ matrix.target_system == 'windows-2022' && '.dll' || '.so' }} + BUILD_DIR: ${{ matrix.target_system == 'windows-2022' && 'D:/a/lua-cjson/lua-cjson' || '/home/runner/work/lua-cjson/lua-cjson' }} + + steps: + - uses: actions/checkout@v4 + + - name: Prime ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ matrix.target_system }}-${{ matrix.build_type }} + max-size: 1000M + + - name: Cache LuaJIT + id: cache-Lua + uses: actions/cache@v3 + with: + path: | + ${{ runner.os == 'Linux' && 'apt-cache' || 'LuaJIT' }} + key: ${{ runner.os }}-Lua + + - name: Get Deps (LuaJIT) + shell: bash + if: steps.cache-Lua.outputs.cache-hit != 'true' + run: | + ${{ runner.os == 'Linux' && 'sudo' || '' }} CI/get_luajit.${{runner.os}}.sh openmw-deps + + - name: Configure + shell: bash + run: | + LUA_DIR=LuaJIT/ cmake . + + - name: Build + run: | + cmake --build . --config ${{ matrix.build_type }} + + - name: Prep Windows Release + if: runner.os == 'Windows' + run: | + mv ${{ env.BUILD_DIR }}/${{ matrix.build_type }}/cjson.dll ${{ env.BUILD_DIR }}/cjson-${{ matrix.build_type }}.dll + + - name: Prep Linux Release + if: runner.os != 'Windows' + run: | + mv ${{ env.BUILD_DIR }}/cjson.so ${{ env.BUILD_DIR }}/cjson-${{ matrix.build_type }}.so + + - name: Upload Release + if: github.event_name != 'pull_request' + uses: softprops/action-gh-release@v1 + with: + tag_name: Stable-CI + files: ${{ env.BUILD_DIR }}/cjson-${{ matrix.build_type }}${{ env.BUILD_EXT }} + body: | + CI Build for Dreamweave IO2 fork + + - name: Upload Artifact + if: github.event_name == 'pull_request' + uses: actions/upload-artifact@v3 + with: + name: cjson-${{ matrix.build_type }}-${{matrix.target_system}} + path: ${{ env.BUILD_DIR }}/cjson-${{ matrix.build_type }}${{ env.BUILD_EXT }} diff --git a/CI/get_luajit.Linux.sh b/CI/get_luajit.Linux.sh new file mode 100755 index 00000000..d47813e3 --- /dev/null +++ b/CI/get_luajit.Linux.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +set -euo pipefail + +print_help() { + echo "usage: $0 [group]..." + echo + echo " available groups: "${!GROUPED_DEPS[@]}"" +} + +declare -rA GROUPED_DEPS=( + # Common dependencies for building OpenMW. + [openmw-deps]=" + libluajit-5.1-dev + " +) + +if [[ $# -eq 0 ]]; then + >&2 print_help + exit 1 +fi + +deps=() +for group in "$@"; do + if [[ ! -v GROUPED_DEPS[$group] ]]; then + >&2 echo "error: unknown group ${group}" + exit 1 + fi + deps+=(${GROUPED_DEPS[$group]}) +done + +export APT_CACHE_DIR="${PWD}/apt-cache" +set -x +mkdir -pv "$APT_CACHE_DIR" +apt-get update -yq +apt-get -q -o dir::cache::archives="$APT_CACHE_DIR" install -y --no-install-recommends "${deps[@]}" diff --git a/CI/get_luajit.windows.sh b/CI/get_luajit.windows.sh new file mode 100755 index 00000000..e56c2cb0 --- /dev/null +++ b/CI/get_luajit.windows.sh @@ -0,0 +1,52 @@ +set -e + +download() { + if [ $# -lt 3 ]; then + echo "Invalid parameters to download." + return 1 + fi + + NAME=$1 + shift + + echo "$NAME..." + + while [ $# -gt 1 ]; do + URL=$1 + FILE=$2 + shift + shift + + if ! [ -f $FILE ]; then + printf " Downloading $FILE... " + + if [ -z $VERBOSE ]; then + RET=0 + curl --silent --fail --retry 10 -Ly 5 -o $FILE $URL || RET=$? + else + RET=0 + curl --fail --retry 10 -Ly 5 -o $FILE $URL || RET=$? + fi + + if [ $RET -ne 0 ]; then + echo "Failed!" + wrappedExit $RET + else + echo "Done." + fi + else + echo " $FILE exists, skipping." + fi + done + + if [ $# -ne 0 ]; then + echo "Missing parameter." + fi +} + +download "LuaJIT v2.1.0-beta3-452-g7a0cf5fd" \ + "https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/LuaJIT-v2.1.0-beta3-452-g7a0cf5fd-msvc2019-win64.7z" \ + "LuaJIT-v2.1.0-beta3-452-g7a0cf5fd-msvc2019-win64.7z" + +echo "Extracting LuaJIT . . ." +eval 7z x -y LuaJIT-v2.1.0-beta3-452-g7a0cf5fd-msvc2019-win64.7z -o./LuaJIT diff --git a/CMakeLists.txt b/CMakeLists.txt index c17239b2..3f3741dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,9 @@ if(NOT CMAKE_BUILD_TYPE) FORCE) endif() -find_package(Lua51 REQUIRED) +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/) + +find_package(LuaJit REQUIRED) include_directories(${LUA_INCLUDE_DIR}) if(NOT USE_INTERNAL_FPCONV) diff --git a/cmake/FindLuaJit.cmake b/cmake/FindLuaJit.cmake new file mode 100644 index 00000000..213487c0 --- /dev/null +++ b/cmake/FindLuaJit.cmake @@ -0,0 +1,16 @@ +include(LibFindMacros) + +libfind_pkg_detect(LuaJit luajit + FIND_PATH luajit.h + HINTS $ENV{LUA_DIR} + PATH_SUFFIXES include include/luajit-2.1 + FIND_LIBRARY luajit-5.1 luajit lua51 + HINTS $ENV{LUA_DIR} + PATH_SUFFIXES lib +) + + +libfind_process(LuaJit) + +set(LUA_LIBRARY ${LuaJit_LIBRARY}) +set(LUA_INCLUDE_DIR ${LuaJit_INCLUDE_DIR}) diff --git a/cmake/LibFindMacros.cmake b/cmake/LibFindMacros.cmake new file mode 100644 index 00000000..2be27c5f --- /dev/null +++ b/cmake/LibFindMacros.cmake @@ -0,0 +1,363 @@ +# Version 2.2 +# Public Domain, originally written by Lasse Kärkkäinen +# Maintained at https://github.com/Tronic/cmake-modules +# Please send your improvements as pull requests on Github. + +include(CMakeParseArguments) + +# Find another package and make it a dependency of the current package. +# This also automatically forwards the "REQUIRED" argument. +# Usage: libfind_package( [extra args to find_package]) +macro (libfind_package PREFIX PKG) + set(${PREFIX}_args ${PKG} ${ARGN}) + if (${PREFIX}_FIND_REQUIRED) + set(${PREFIX}_args ${${PREFIX}_args} REQUIRED) + endif() + find_package(${${PREFIX}_args}) + set(${PREFIX}_DEPENDENCIES ${${PREFIX}_DEPENDENCIES};${PKG}) + unset(${PREFIX}_args) +endmacro() + +# A simple wrapper to make pkg-config searches a bit easier. +# Works the same as CMake's internal pkg_check_modules but is always quiet. +macro (libfind_pkg_check_modules) + find_package(PkgConfig QUIET) + if (PKG_CONFIG_FOUND) + pkg_check_modules(${ARGN} QUIET) + endif() +endmacro() + +# Avoid useless copy&pasta by doing what most simple libraries do anyway: +# pkg-config, find headers, find library. +# Usage: libfind_pkg_detect( FIND_PATH [other args] FIND_LIBRARY [other args]) +# E.g. libfind_pkg_detect(SDL2 sdl2 FIND_PATH SDL.h PATH_SUFFIXES SDL2 FIND_LIBRARY SDL2) +function (libfind_pkg_detect PREFIX) + # Parse arguments + set(argname pkgargs) + foreach (i ${ARGN}) + if ("${i}" STREQUAL "FIND_PATH") + set(argname pathargs) + elseif ("${i}" STREQUAL "FIND_LIBRARY") + set(argname libraryargs) + else() + set(${argname} ${${argname}} ${i}) + endif() + endforeach() + if (NOT pkgargs) + message(FATAL_ERROR "libfind_pkg_detect requires at least a pkg_config package name to be passed.") + endif() + # Find library + libfind_pkg_check_modules(${PREFIX}_PKGCONF ${pkgargs}) + if (pathargs) + find_path(${PREFIX}_INCLUDE_DIR NAMES ${pathargs} HINTS ${${PREFIX}_PKGCONF_INCLUDE_DIRS}) + endif() + if (libraryargs) + find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}) + endif() +endfunction() + +# libfind_header_path( [PATHS [ ...]] NAMES [name ...] VAR [QUIET]) +# Get fullpath of the first found header looking inside _INCLUDE_DIR or in the given PATHS +# Usage: libfind_header_path(Foobar NAMES foobar/version.h VAR filepath) +function (libfind_header_path PREFIX) + set(options QUIET) + set(one_value_keywords VAR PATH) + set(multi_value_keywords NAMES PATHS) + CMAKE_PARSE_ARGUMENTS(OPT "${options}" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN}) + if (NOT OPT_VAR OR NOT OPT_NAMES) + message(FATAL_ERROR "Arguments VAR, NAMES are required!") + endif() + if (OPT_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Calling function with unused arguments '${OPT_UNPARSED_ARGUMENTS}'!") + endif() + if (OPT_QUIET OR ${PREFIX}_FIND_QUIETLY) + set(quiet TRUE) + endif() + set(paths ${OPT_PATHS} ${PREFIX}_INCLUDE_DIR) + + foreach(name ${OPT_NAMES}) + foreach(path ${paths}) + set(filepath "${${path}}/${name}") + # check for existance + if (EXISTS ${filepath}) + set(${OPT_VAR} ${filepath} PARENT_SCOPE) # export path + return() + endif() + endforeach() + endforeach() + + # report error if not found + set(${OPT_VAR} NOTFOUND PARENT_SCOPE) + if (NOT quiet) + message(AUTHOR_WARNING "Unable to find '${OPT_NAMES}'") + endif() +endfunction() + +# libfind_version_n_header( +# NAMES [ ...] +# DEFINES [ ...] | CONSTANTS [ ...] +# [PATHS [ ...]] +# [QUIET] +# ) +# Collect all defines|constants from a header inside _INCLUDE_DIR or in the given PATHS +# output stored to _VERSION. +# This function does nothing if the version variable is already defined. +# Usage: libfind_version_n_header(Foobar NAMES foobar/version.h DEFINES FOOBAR_VERSION_MAJOR FOOBAR_VERSION_MINOR) +function (libfind_version_n_header PREFIX) + # Skip processing if we already have a version + if (${PREFIX}_VERSION) + return() + endif() + + set(options QUIET) + set(one_value_keywords ) + set(multi_value_keywords NAMES PATHS DEFINES CONSTANTS) + CMAKE_PARSE_ARGUMENTS(OPT "${options}" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN}) + if (NOT OPT_NAMES OR (NOT OPT_DEFINES AND NOT OPT_CONSTANTS)) + message(FATAL_ERROR "Arguments NAMES, DEFINES|CONSTANTS are required!") + endif() + if (OPT_DEFINES AND OPT_CONSTANTS) + message(FATAL_ERROR "Either DEFINES or CONSTANTS must be set!") + endif() + if (OPT_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Calling function with unused arguments '${OPT_UNPARSED_ARGUMENTS}'!") + endif() + if (OPT_QUIET OR ${PREFIX}_FIND_QUIETLY) + set(quiet TRUE) + set(force_quiet "QUIET") # to propagate argument QUIET + endif() + + # Read the header + libfind_header_path(${PREFIX} NAMES ${OPT_NAMES} PATHS ${OPT_PATHS} VAR filename ${force_quiet}) + if (NOT filename) + return() + endif() + file(READ "${filename}" header) + # Parse for version number + unset(version_parts) + foreach(define_name ${OPT_DEFINES}) + string(REGEX MATCH "# *define +${define_name} +((\"([^\n]*)\")|([^ \n]*))" match "${header}") + # No regex match? + if (NOT match OR match STREQUAL header) + if (NOT quiet) + message(AUTHOR_WARNING "Unable to find \#define ${define_name} \"\" from ${filename}") + endif() + return() + else() + list(APPEND version_parts "${CMAKE_MATCH_3}${CMAKE_MATCH_4}") + endif() + endforeach() + foreach(constant_name ${OPT_CONSTANTS}) + string(REGEX MATCH "${constant_name} *= *((\"([^\;]*)\")|([^ \;]*))" match "${header}") + # No regex match? + if (NOT match OR match STREQUAL header) + if (NOT quiet) + message(AUTHOR_WARNING "Unable to find ${constant_name} = \"\" from ${filename}") + endif() + return() + else() + list(APPEND version_parts "${CMAKE_MATCH_3}${CMAKE_MATCH_4}") + endif() + endforeach() + + # Export the version string + string(REPLACE ";" "." version "${version_parts}") + set(${PREFIX}_VERSION "${version}" PARENT_SCOPE) +endfunction() + +# libfind_version_header(
[PATHS [ ...]] [QUIET]) +# Extracts a version #define from a version.h file, output stored to _VERSION. +# This function does nothing if the version variable is already defined. +# Usage: libfind_version_header(Foobar foobar/version.h FOOBAR_VERSION_STR) +function (libfind_version_header PREFIX VERSION_H DEFINE_NAME) + # Skip processing if we already have a version + if (${PREFIX}_VERSION) + return() + endif() + + set(options QUIET) + set(one_value_keywords ) + set(multi_value_keywords PATHS) + CMAKE_PARSE_ARGUMENTS(OPT "${options}" "${one_value_keywords}" "${multi_value_keywords}" ${ARGN}) + if (OPT_UNPARSED_ARGUMENTS) + message(FATAL_ERROR "Calling function with unused arguments '${OPT_UNPARSED_ARGUMENTS}'!") + endif() + if (OPT_QUIET OR ${PREFIX}_FIND_QUIETLY) + set(force_quiet "QUIET") # to propagate argument QUIET + endif() + + libfind_version_n_header(${PREFIX} NAMES ${VERSION_H} PATHS ${OPT_PATHS} DEFINES ${DEFINE_NAME} ${force_quiet}) + set(${PREFIX}_VERSION "${${PREFIX}_VERSION}" PARENT_SCOPE) +endfunction() + +# Do the final processing once the paths have been detected. +# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain +# all the variables, each of which contain one include directory. +# Ditto for ${PREFIX}_PROCESS_LIBS and library files. +# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. +# Also handles errors in case library detection was required, etc. +function (libfind_process PREFIX) + # Skip processing if already processed during this configuration run + if (${PREFIX}_FOUND) + return() + endif() + + set(found TRUE) # Start with the assumption that the package was found + + # Did we find any files? Did we miss includes? These are for formatting better error messages. + set(some_files FALSE) + set(missing_headers FALSE) + + # Shorthands for some variables that we need often + set(quiet ${${PREFIX}_FIND_QUIETLY}) + set(required ${${PREFIX}_FIND_REQUIRED}) + set(exactver ${${PREFIX}_FIND_VERSION_EXACT}) + set(findver "${${PREFIX}_FIND_VERSION}") + set(version "${${PREFIX}_VERSION}") + + # Lists of config option names (all, includes, libs) + unset(configopts) + set(includeopts ${${PREFIX}_PROCESS_INCLUDES}) + set(libraryopts ${${PREFIX}_PROCESS_LIBS}) + + # Process deps to add to + foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES}) + if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS) + # The package seems to export option lists that we can use, woohoo! + list(APPEND includeopts ${${i}_INCLUDE_OPTS}) + list(APPEND libraryopts ${${i}_LIBRARY_OPTS}) + else() + # If plural forms don't exist or they equal singular forms + if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR + ({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES)) + # Singular forms can be used + if (DEFINED ${i}_INCLUDE_DIR) + list(APPEND includeopts ${i}_INCLUDE_DIR) + endif() + if (DEFINED ${i}_LIBRARY) + list(APPEND libraryopts ${i}_LIBRARY) + endif() + else() + # Oh no, we don't know the option names + message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!") + endif() + endif() + endforeach() + + if (includeopts) + list(REMOVE_DUPLICATES includeopts) + endif() + + if (libraryopts) + list(REMOVE_DUPLICATES libraryopts) + endif() + + string(REGEX REPLACE ".*[ ;]([^ ;]*(_INCLUDE_DIRS|_LIBRARIES))" "\\1" tmp "${includeopts} ${libraryopts}") + if (NOT tmp STREQUAL "${includeopts} ${libraryopts}") + message(AUTHOR_WARNING "Plural form ${tmp} found in config options of ${PREFIX}. This works as before but is now deprecated. Please only use singular forms INCLUDE_DIR and LIBRARY, and update your find scripts for LibFindMacros > 2.0 automatic dependency system (most often you can simply remove the PROCESS variables entirely).") + endif() + + # Include/library names separated by spaces (notice: not CMake lists) + unset(includes) + unset(libs) + + # Process all includes and set found false if any are missing + foreach (i ${includeopts}) + list(APPEND configopts ${i}) + if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND") + list(APPEND includes "${${i}}") + else() + set(found FALSE) + set(missing_headers TRUE) + endif() + endforeach() + + # Process all libraries and set found false if any are missing + foreach (i ${libraryopts}) + list(APPEND configopts ${i}) + if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND") + list(APPEND libs "${${i}}") + else() + set (found FALSE) + endif() + endforeach() + + # Version checks + if (found AND findver) + if (NOT version) + message(WARNING "The find module for ${PREFIX} does not provide version information, so we'll just assume that it is OK. Please fix the module or remove package version requirements to get rid of this warning.") + elseif (version VERSION_LESS findver OR (exactver AND NOT version VERSION_EQUAL findver)) + set(found FALSE) + set(version_unsuitable TRUE) + endif() + endif() + + # If all-OK, hide all config options, export variables, print status and exit + if (found) + foreach (i ${configopts}) + mark_as_advanced(${i}) + endforeach() + set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE) + set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE) + set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE) + set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE) + set (${PREFIX}_FOUND TRUE PARENT_SCOPE) + if (NOT quiet) + message(STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") + if (LIBFIND_DEBUG) + message(STATUS " ${PREFIX}_DEPENDENCIES=${${PREFIX}_DEPENDENCIES}") + message(STATUS " ${PREFIX}_INCLUDE_OPTS=${includeopts}") + message(STATUS " ${PREFIX}_INCLUDE_DIRS=${includes}") + message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}") + message(STATUS " ${PREFIX}_LIBRARIES=${libs}") + endif() + endif() + return() + endif() + + # Format messages for debug info and the type of error + set(vars "Relevant CMake configuration variables:\n") + foreach (i ${configopts}) + mark_as_advanced(CLEAR ${i}) + set(val ${${i}}) + if ("${val}" STREQUAL "${i}-NOTFOUND") + set (val "") + elseif (val AND NOT EXISTS "${val}") + set (val "${val} (does not exist)") + else() + set(some_files TRUE) + endif() + set(vars "${vars} ${i}=${val}\n") + endforeach() + set(vars "${vars}You may use CMake GUI, cmake -D or ccmake to modify the values. Delete CMakeCache.txt to discard all values and force full re-detection if necessary.\n") + if (version_unsuitable) + set(msg "${PREFIX} ${${PREFIX}_VERSION} was found but") + if (exactver) + set(msg "${msg} only version ${findver} is acceptable.") + else() + set(msg "${msg} version ${findver} is the minimum requirement.") + endif() + else() + if (missing_headers) + set(msg "We could not find development headers for ${PREFIX}. Do you have the necessary dev package installed?") + elseif (some_files) + set(msg "We only found some files of ${PREFIX}, not all of them. Perhaps your installation is incomplete or maybe we just didn't look in the right place?") + if(findver) + set(msg "${msg} This could also be caused by incompatible version (if it helps, at least ${PREFIX} ${findver} should work).") + endif() + else() + set(msg "We were unable to find package ${PREFIX}.") + endif() + endif() + + # Fatal error out if REQUIRED + if (required) + set(msg "REQUIRED PACKAGE NOT FOUND\n${msg} This package is REQUIRED and you need to install it or adjust CMake configuration in order to continue building ${CMAKE_PROJECT_NAME}.") + message(FATAL_ERROR "${msg}\n${vars}") + endif() + # Otherwise just print a nasty warning + if (NOT quiet) + message(WARNING "WARNING: MISSING PACKAGE\n${msg} This package is NOT REQUIRED and you may ignore this warning but by doing so you may miss some functionality of ${CMAKE_PROJECT_NAME}. \n${vars}") + endif() +endfunction() + From c6ffa11d8439a817cfbc4993cc6b0539620f967e Mon Sep 17 00:00:00 2001 From: Dave Corley <73663882+magicaldave@users.noreply.github.com> Date: Wed, 18 Oct 2023 06:20:25 -0500 Subject: [PATCH 2/5] Feat(CI): Add macOS builds & Dreamweave LuaJIT (#2) --- .github/workflows/cjson.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cjson.yml b/.github/workflows/cjson.yml index 37bd7fb1..927a5e3a 100644 --- a/.github/workflows/cjson.yml +++ b/.github/workflows/cjson.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: build_type: [Release, RelWithDebInfo, MinSizeRel, Debug] - target_system: [ ubuntu-22.04, windows-2022 ] + target_system: [ ubuntu-22.04, windows-2022, macos-11 ] runs-on: ${{ matrix.target_system }} env: BUILD_EXT: ${{ matrix.target_system == 'windows-2022' && '.dll' || '.so' }} @@ -40,7 +40,8 @@ jobs: shell: bash if: steps.cache-Lua.outputs.cache-hit != 'true' run: | - ${{ runner.os == 'Linux' && 'sudo' || '' }} CI/get_luajit.${{runner.os}}.sh openmw-deps + curl -o LuaJIT.7z -L https://github.com/DreamWeave-MP/LuaJIT/releases/download/Stable-CI/LuaJIT-${{ runner.os }}.7z + 7z x -y LuaJIT.7z -oLuaJIT/ - name: Configure shell: bash @@ -51,22 +52,22 @@ jobs: run: | cmake --build . --config ${{ matrix.build_type }} - - name: Prep Windows Release - if: runner.os == 'Windows' - run: | - mv ${{ env.BUILD_DIR }}/${{ matrix.build_type }}/cjson.dll ${{ env.BUILD_DIR }}/cjson-${{ matrix.build_type }}.dll + # - name: Prep Windows Release + # if: runner.os == 'Windows' + # run: | + # mv ${{ env.BUILD_DIR }}/${{ matrix.build_type }}/cjson.dll ${{ env.BUILD_DIR }}/cjson-${{ matrix.build_type }}.dll - name: Prep Linux Release - if: runner.os != 'Windows' + # if: runner.os != 'Windows' run: | - mv ${{ env.BUILD_DIR }}/cjson.so ${{ env.BUILD_DIR }}/cjson-${{ matrix.build_type }}.so + mv ${{ runner.os == 'Windows' && matrix.build_type || '.'}}/cjson${{ env.BUILD_EXT }} cjson-${{ matrix.build_type }}-${{ runner.os }}${{ env.BUILD_EXT }} - name: Upload Release if: github.event_name != 'pull_request' uses: softprops/action-gh-release@v1 with: tag_name: Stable-CI - files: ${{ env.BUILD_DIR }}/cjson-${{ matrix.build_type }}${{ env.BUILD_EXT }} + files: cjson-${{ matrix.build_type }}-${{ runner.os }}${{ env.BUILD_EXT }} body: | CI Build for Dreamweave IO2 fork @@ -74,5 +75,5 @@ jobs: if: github.event_name == 'pull_request' uses: actions/upload-artifact@v3 with: - name: cjson-${{ matrix.build_type }}-${{matrix.target_system}} - path: ${{ env.BUILD_DIR }}/cjson-${{ matrix.build_type }}${{ env.BUILD_EXT }} + name: cjson-${{ matrix.build_type }}-${{ runner.os }} + path: cjson-${{ matrix.build_type }}-${{ runner.os }}${{ env.BUILD_EXT }} From 5dae577de66bdf94d37f726378f11e9a9928fefa Mon Sep 17 00:00:00 2001 From: Dave Corley <73663882+magicaldave@users.noreply.github.com> Date: Fri, 20 Oct 2023 06:58:38 -0500 Subject: [PATCH 3/5] Feat(CI): Fix Windows builds by building in gcc (#3) * Fix(CI): Add gcc builds for windows environments --- .github/workflows/cjson.yml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cjson.yml b/.github/workflows/cjson.yml index 927a5e3a..6748a565 100644 --- a/.github/workflows/cjson.yml +++ b/.github/workflows/cjson.yml @@ -22,6 +22,13 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: msys2/setup-msys2@v2 + if: runner.os == 'Windows' + with: + msystem: UCRT64 + update: true + install: git mingw-w64-ucrt-x86_64-gcc + - name: Prime ccache uses: hendrikmuhs/ccache-action@v1.2 with: @@ -33,7 +40,7 @@ jobs: uses: actions/cache@v3 with: path: | - ${{ runner.os == 'Linux' && 'apt-cache' || 'LuaJIT' }} + LuaJIT key: ${{ runner.os }}-Lua - name: Get Deps (LuaJIT) @@ -44,23 +51,24 @@ jobs: 7z x -y LuaJIT.7z -oLuaJIT/ - name: Configure + if: runner.os != 'Windows' shell: bash run: | LUA_DIR=LuaJIT/ cmake . + - name: Configure + if: runner.os == 'Windows' + shell: bash + run: | + LUA_DIR=LuaJIT/ CC=$(which gcc) cmake . -G 'MinGW Makefiles' + - name: Build run: | cmake --build . --config ${{ matrix.build_type }} - # - name: Prep Windows Release - # if: runner.os == 'Windows' - # run: | - # mv ${{ env.BUILD_DIR }}/${{ matrix.build_type }}/cjson.dll ${{ env.BUILD_DIR }}/cjson-${{ matrix.build_type }}.dll - - - name: Prep Linux Release - # if: runner.os != 'Windows' + - name: Prep Release run: | - mv ${{ runner.os == 'Windows' && matrix.build_type || '.'}}/cjson${{ env.BUILD_EXT }} cjson-${{ matrix.build_type }}-${{ runner.os }}${{ env.BUILD_EXT }} + mv cjson${{ env.BUILD_EXT }} cjson-${{ matrix.build_type }}-${{ runner.os }}${{ env.BUILD_EXT }} - name: Upload Release if: github.event_name != 'pull_request' From bffdffe4a2d56e00a3b9881ee16085e3ab4f3bde Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Fri, 20 Oct 2023 17:58:53 -0500 Subject: [PATCH 4/5] Test(CI): Make phoenix build it --- .github/workflows/cjson.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cjson.yml b/.github/workflows/cjson.yml index 927a5e3a..41093b18 100644 --- a/.github/workflows/cjson.yml +++ b/.github/workflows/cjson.yml @@ -14,7 +14,7 @@ jobs: matrix: build_type: [Release, RelWithDebInfo, MinSizeRel, Debug] target_system: [ ubuntu-22.04, windows-2022, macos-11 ] - runs-on: ${{ matrix.target_system }} + runs-on: ${{ matrix.target_system == 'windows-2022' && '[self-hosted, windows, x64]' || matrix.target_system }} env: BUILD_EXT: ${{ matrix.target_system == 'windows-2022' && '.dll' || '.so' }} BUILD_DIR: ${{ matrix.target_system == 'windows-2022' && 'D:/a/lua-cjson/lua-cjson' || '/home/runner/work/lua-cjson/lua-cjson' }} From 4ca1190875582c90a21e09339f96ed432530af23 Mon Sep 17 00:00:00 2001 From: Phoenix / Hotaru Date: Tue, 24 Oct 2023 09:45:45 +0100 Subject: [PATCH 5/5] Revert "Test(CI): Make phoenix build it" This reverts commit bffdffe4a2d56e00a3b9881ee16085e3ab4f3bde. --- .github/workflows/cjson.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cjson.yml b/.github/workflows/cjson.yml index f1c60a61..6748a565 100644 --- a/.github/workflows/cjson.yml +++ b/.github/workflows/cjson.yml @@ -14,7 +14,7 @@ jobs: matrix: build_type: [Release, RelWithDebInfo, MinSizeRel, Debug] target_system: [ ubuntu-22.04, windows-2022, macos-11 ] - runs-on: ${{ matrix.target_system == 'windows-2022' && '[self-hosted, windows, x64]' || matrix.target_system }} + runs-on: ${{ matrix.target_system }} env: BUILD_EXT: ${{ matrix.target_system == 'windows-2022' && '.dll' || '.so' }} BUILD_DIR: ${{ matrix.target_system == 'windows-2022' && 'D:/a/lua-cjson/lua-cjson' || '/home/runner/work/lua-cjson/lua-cjson' }}