Merge pull request #19 from threeal/add-targets-input-option

Add Targets Input Option
This commit is contained in:
Alfi Maulana 2023-01-11 16:58:22 +07:00 committed by GitHub
commit dcccacb93b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 0 deletions

View File

@ -39,6 +39,21 @@ jobs:
- name: Check if the default build directory does not exist
run: test ! -d build
use-action-with-specified-targets:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3.3.0
- name: Use this action with specified targets
uses: ./
with:
source-dir: test
targets: test_c test_cpp
- name: Run build result
run: build/test_c && build/test_cpp
use-action-with-specified-compiler:
runs-on: ubuntu-latest
strategy:

View File

@ -13,6 +13,9 @@ inputs:
description: The build directory of CMake project
required: false
default: build
targets:
description: List of build targets
required: false
generator:
description: The build system generator of the CMake project
required: false
@ -33,6 +36,9 @@ runs:
run: |
ARGS="${{ inputs.source-dir }} -B ${{ inputs.build-dir }}"
BUILD_ARGS="--build ${{ inputs.build-dir }}"
if [ -n '${{ inputs.targets }}' ]; then
BUILD_ARGS="$BUILD_ARGS --target ${{ inputs.targets }}"
fi
if [ -n '${{ inputs.generator }}' ]; then
ARGS="$ARGS -G ${{ inputs.generator }}"
fi

View File

@ -11,3 +11,6 @@ endif()
if(BUILD_CXX)
add_executable(hello_world hello_world.cpp)
endif()
add_executable(test_c EXCLUDE_FROM_ALL test.c)
add_executable(test_cpp EXCLUDE_FROM_ALL test.cpp)

6
test/test.c Normal file
View File

@ -0,0 +1,6 @@
#include <stdio.h>
int main() {
printf("all ok\n");
return 0;
}

6
test/test.cpp Normal file
View File

@ -0,0 +1,6 @@
#include <iostream>
int main() {
std::cout << "all ok" << std::endl;
return 0;
}