feat: replace targets input with the more general build-args input

This commit is contained in:
Alfi Maulana 2023-06-29 19:32:21 +07:00
parent 3430da8dad
commit f1910e1a56
No known key found for this signature in database
GPG Key ID: 2242A64C2A8DF5A4
3 changed files with 23 additions and 33 deletions

View File

@ -56,11 +56,11 @@ jobs:
uses: ./
with:
source-dir: test
targets: test_c test_cpp
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
run-build: true
build-args: --target test_c --target test_cpp
run-test: true
test-args: -R test ${{ matrix.compiler == 'msvc' && '-C Debug' || '' }}
@ -77,12 +77,12 @@ jobs:
uses: ./
with:
source-dir: test
targets: test_c test_cpp
generator: Ninja
c-compiler: clang
cxx-compiler: clang++
args: -D CHECK_USING_CLANG=ON
run-build: true
build-args: --target test_c --target test_cpp
run-test: true
test-args: -R test

View File

@ -8,9 +8,9 @@ Configure, build, and test your [CMake](https://cmake.org/) project using [GitHu
## Features
- Configures a project using the [cmake](https://cmake.org/cmake/help/latest/manual/cmake.1.html) command.
- Configures a project using the [`cmake`](https://cmake.org/cmake/help/latest/manual/cmake.1.html) command.
- Option to build a project using the `cmake --build` command.
- Option to test a project using the [ctest](https://cmake.org/cmake/help/latest/manual/ctest.1.html) command.
- Option to test a project using the [`ctest`](https://cmake.org/cmake/help/latest/manual/ctest.1.html) command.
- Auto-detects and installs required dependencies.
- Supports specifying multiple CMake options directly from the Action inputs.
@ -22,18 +22,18 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
| Name | Value Type | Description |
| --- | --- | --- |
| `source-dir` | Path | The source directory of the CMake project. Defaults to the current directory. |
| `build-dir` | Path | The source directory of the CMake project.. Defaults to the `build` directory inside the source directory. |
| `targets` | Multiple strings | A list of build targets. |
| `source-dir` | Path | The source directory of the CMake project. It defaults to the current directory. |
| `build-dir` | Path | The build directory of the CMake project. It defaults to the `build` directory inside the source directory. |
| `generator` | String | The build system generator for the CMake project. |
| `c-compiler` | String | The preferred executable for compiling C language files. |
| `cxx-compiler` | String | The preferred executable for compiling C++ language files. |
| `c-flags` | Multiple strings | Additional flags passed when compiling C language files. |
| `cxx-flags` | Multiple strings | Additional flags passed when compiling C++ language files. |
| `args` | Multiple strings | Additional arguments passed 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). Defaults to `false`. |
| `run-test` | `true` or `false` | If enabled, it runs testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). Defaults to `false`. |
| `test-args` | Multiple strings | Additional arguments passed during the CTest run. |
| `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. |
| `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. |
| `run-test` | `true` or `false` | If enabled, it runs testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). It defaults to `false`. |
| `test-args` | Multiple strings | Additional arguments to pass during the CTest run. |
> Note: Multiple strings mean that the input can be specified with more than one value. Separate each value with a space or a new line.
@ -79,16 +79,6 @@ jobs:
run-test: true
```
#### Specify the Build Targets
```yaml
- name: Configure and build this project
uses: threeal/cmake-action@latest
with:
run-build: true
targets: hello_mars hello_sun
```
#### Using Ninja as the Generator and Clang as the Compiler
```yaml

View File

@ -9,10 +9,7 @@ inputs:
description: The source directory of the CMake project
required: false
build-dir:
description: The source directory of the CMake project.
required: false
targets:
description: A list of build targets
description: The build directory of the CMake project
required: false
generator:
description: The build system generator for the CMake project
@ -24,24 +21,27 @@ inputs:
description: The preferred executable for compiling C++ language files
required: false
c-flags:
description: Additional flags passed when compiling C language files
description: Additional flags to pass when compiling C language files
required: false
cxx-flags:
description: Additional flags passed when compiling C++ language files
description: Additional flags to pass when compiling C++ language files
required: false
args:
description: Additional arguments passed during the CMake configuration
description: Additional arguments to pass during the CMake configuration
required: false
run-build:
description: If enabled, it builds the project using CMake (true/false)
required: false
default: false
build-args:
description: Additional arguments to pass during the CMake build
required: false
run-test:
description: If enabled, it runs testing using CTest (true/false)
required: false
default: false
test-args:
description: Additional arguments passed during the CTest run
description: Additional arguments to pass during the CTest run
required: false
runs:
using: composite
@ -86,8 +86,8 @@ runs:
if [ '${{ inputs.run-build }}' == 'true' ]; then
BUILD_ARGS="--build '$BUILD_DIR'"
fi
if [ -n '${{ inputs.targets }}' ]; then
BUILD_ARGS="$BUILD_ARGS --target ${{ inputs.targets }}"
if [ -n '${{ inputs.build-args }}' ]; then
BUILD_ARGS="$BUILD_ARGS ${{ inputs.build-args }}"
fi
TEST_ARGS=""