Skip to content

Improve sandboxing setup; re-allow get/setmetatable #558

Improve sandboxing setup; re-allow get/setmetatable

Improve sandboxing setup; re-allow get/setmetatable #558

Workflow file for this run

name: CMake
on:
push:
branches: [master]
pull_request:
jobs:
unix:
# The CMake configure and build commands are platform agnostic and should work equally
# well on Windows or Mac. You can convert this to a matrix build if you need
# cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
name: ${{ matrix.os }} - ${{ matrix.build_type }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
build_type: [Debug, RelWithDebInfo, Release]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup (apt)
if: ${{ startsWith(matrix.os, 'ubuntu') }}
run: |
sudo apt update -qq
sudo apt install git build-essential cmake ninja-build zip unzip libsdl2-dev libfreetype-dev
- name: Setup (brew)
if: ${{ startsWith(matrix.os, 'macos') }}
run: brew install cmake sdl2 ninja
- name: Setup (windows)
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
$sdl_version = "2.0.16"
$sdl_link = "https://libsdl.org/release/SDL2-devel-$sdl_version-VC.zip"
$sdl_zip = "$env:GITHUB_WORKSPACE/sdl-dev.zip"
(new-object System.Net.WebClient).DownloadFile($sdl_link, $sdl_zip)
Expand-Archive -LiteralPath $sdl_zip -DestinationPath "$env:GITHUB_WORKSPACE/externals"
$sdl_config = @"
set(flavor x86)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(flavor x64)
endif()
set(_SDL2_prefix "`${CMAKE_CURRENT_LIST_DIR}/SDL2-$sdl_version")
add_library(SDL2::SDL2main STATIC IMPORTED)
set_target_properties(SDL2::SDL2main PROPERTIES
IMPORTED_LOCATION "`${_SDL2_prefix}/lib/`${flavor}/SDL2main.lib"
)
add_library(SDL2::SDL2 SHARED IMPORTED)
set_target_properties(SDL2::SDL2 PROPERTIES
IMPORTED_LOCATION "`${_SDL2_prefix}/lib/`${flavor}/SDL2.dll"
IMPORTED_IMPLIB "`${_SDL2_prefix}/lib/`${flavor}/SDL2.lib"
INTERFACE_INCLUDE_DIRECTORIES "`${_SDL2_prefix}/include"
)
target_link_libraries(SDL2::SDL2 INTERFACE SDL2::SDL2main)
"@
Set-Content -Path "$env:GITHUB_WORKSPACE/externals/sdl2-config.cmake" -Value $sdl_config
Get-Content "$env:GITHUB_WORKSPACE/externals/sdl2-config.cmake"
- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
# We'll use this as our working directory for all subsequent commands
run: cmake -E make_directory ${{runner.workspace}}/build
- name: Configure CMake (windows)
if: ${{ startsWith(matrix.os, 'windows') }}
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
working-directory: ${{runner.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $env:GITHUB_WORKSPACE -G "Visual Studio 17 2022" -A Win32 -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -DSDL2_DIR:PATH="$env:GITHUB_WORKSPACE/externals" -DWARNING_IS_ERROR=1
- name: Configure CMake (unix-like)
if: ${{ !startsWith(matrix.os, 'windows') }}
# Use a bash shell so we can use the same syntax for environment variable
# access regardless of the host operating system
shell: bash
working-directory: ${{runner.workspace}}/build
# Note the current convention is to use the -S and -B options here to specify source
# and build directories, but this is only available with CMake 3.13 and higher.
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
run: cmake $GITHUB_WORKSPACE -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DWARNING_IS_ERROR=1
- name: Build
working-directory: ${{runner.workspace}}/build
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config ${{ matrix.build_type }}