feat: add options input

This commit is contained in:
Alfi Maulana 2023-06-30 12:29:27 +07:00
parent e774bd0f0d
commit f599e74b36
No known key found for this signature in database
GPG Key ID: 2242A64C2A8DF5A4
3 changed files with 10 additions and 3 deletions

View File

@ -101,7 +101,7 @@ jobs:
source-dir: test
c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
args: -D CHECK_SURPASS_WARNING=ON
options: CHECK_SURPASS_WARNING=ON
run-build: true
build-args: --target test_c --target test_cpp
run-test: true
@ -124,7 +124,7 @@ jobs:
generator: Ninja
c-compiler: clang
cxx-compiler: clang++
args: -D CHECK_USING_CLANG=ON
options: CHECK_USING_CLANG=ON
run-build: true
build-args: --target test_c --target test_cpp
run-test: true

View File

@ -29,6 +29,7 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
| `cxx-compiler` | String | The preferred executable for compiling C++ language files. |
| `c-flags` | Multiple strings | Additional flags to pass when compiling C language files. |
| `cxx-flags` | Multiple strings | Additional flags to pass when compiling C++ language files. |
| `options` | Multiple strings | Additional options to pass during the CMake configuration. |
| `args` | Multiple strings | Additional arguments to pass during the CMake configuration. |
| `run-build` | `true` or `false` | If enabled, it builds the project using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). It defaults to `false`. |
| `build-args` | Multiple strings | Additional arguments to pass during the CMake build. |
@ -80,7 +81,7 @@ jobs:
- name: Configure, build, and test the project
uses: threeal/cmake-action@latest
with:
args: -DBUILD_TESTING=ON
options: BUILD_TESTING=ON
run-build: true
run-test: true
```

View File

@ -26,6 +26,9 @@ inputs:
cxx-flags:
description: Additional flags to pass when compiling C++ language files
required: false
options:
description: Additional options to pass during the CMake configuration
required: false
args:
description: Additional arguments to pass during the CMake configuration
required: false
@ -78,6 +81,9 @@ runs:
if [ -n '${{ inputs.cxx-flags }}' ]; then
ARGS="$ARGS -D CMAKE_CXX_FLAGS='${{ inputs.cxx-flags }}'"
fi
for OPT in ${{ inputs.options }}; do
ARGS="$ARGS -D $OPT"
done
if [ -n '${{ inputs.args }}' ]; then
ARGS="$ARGS ${{ inputs.args }}"
fi