Merge pull request #14 from threeal/add-generator-input

Add Generator Input Option
This commit is contained in:
Alfi Maulana 2023-01-08 14:36:32 +07:00 committed by GitHub
commit b861f34750
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -72,3 +72,21 @@ jobs:
- name: Run build result
run: build/${{ matrix.lang == 'C' && 'hello_world_c' || 'hello_world' }}
use-action-with-specified-generator:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3.3.0
- name: Install Ninja
run: sudo apt install -y ninja-build
- name: Use this action with specified generator
uses: ./
with:
source-dir: test
generator: Ninja
- name: Run build result
run: build/hello_world

View File

@ -13,6 +13,9 @@ inputs:
description: The build directory of CMake project
required: false
default: build
generator:
description: The build system generator of the CMake project
required: false
c-compiler:
description: The preferred executable for compiling C language files
required: false
@ -30,6 +33,9 @@ runs:
run: |
CONFIGURE_ARGS="${{ inputs.source-dir }} -B ${{ inputs.build-dir }}"
BUILD_ARGS="--build ${{ inputs.build-dir }}"
if [ -n '${{ inputs.generator }}' ]; then
CONFIGURE_ARGS="$CONFIGURE_ARGS -G ${{ inputs.generator }}"
fi
if [ -n '${{ inputs.c-compiler }}' ]; then
CONFIGURE_ARGS="$CONFIGURE_ARGS -D CMAKE_C_COMPILER=${{ inputs.c-compiler }}"
fi