From d1034b5b62d12d6dc97f5fbe70c3984828a21b04 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Sun, 8 Jan 2023 14:28:57 +0700 Subject: [PATCH 1/2] add `generator` input option --- action.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/action.yml b/action.yml index 801c3ea..ccb28c8 100644 --- a/action.yml +++ b/action.yml @@ -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 From 111de3705bf8e08c216d8ec4b3426169f9530290 Mon Sep 17 00:00:00 2001 From: Alfi Maulana Date: Sun, 8 Jan 2023 14:31:58 +0700 Subject: [PATCH 2/2] add workflow job to test this action with specified generator --- .github/workflows/test.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4f1f6cc..f789a00 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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