mirror of
https://github.com/threeal/cmake-action.git
synced 2026-02-01 19:40:49 +00:00
feat: add the run-build input
This commit is contained in:
37
action.yml
37
action.yml
@@ -6,22 +6,22 @@ branding:
|
||||
icon: terminal
|
||||
inputs:
|
||||
source-dir:
|
||||
description: Source directory of the CMake project
|
||||
description: The source directory of the CMake project
|
||||
required: false
|
||||
build-dir:
|
||||
description: Build directory of the CMake project
|
||||
description: The source directory of the CMake project.
|
||||
required: false
|
||||
targets:
|
||||
description: List of build targets
|
||||
description: A list of build targets
|
||||
required: false
|
||||
generator:
|
||||
description: Build system generator of the CMake project
|
||||
description: The build system generator for the CMake project
|
||||
required: false
|
||||
c-compiler:
|
||||
description: Preferred executable for compiling C language files
|
||||
description: The preferred executable for compiling C language files
|
||||
required: false
|
||||
cxx-compiler:
|
||||
description: Preferred executable for compiling C++ language files
|
||||
description: The preferred executable for compiling C++ language files
|
||||
required: false
|
||||
c-flags:
|
||||
description: Additional flags passed when compiling C language files
|
||||
@@ -32,8 +32,12 @@ inputs:
|
||||
args:
|
||||
description: Additional arguments passed during the CMake configuration
|
||||
required: false
|
||||
run-build:
|
||||
description: If enabled, it builds the project using CMake (true/false)
|
||||
required: false
|
||||
default: false
|
||||
run-test:
|
||||
description: If enabled, run testing using CTest (true/false)
|
||||
description: If enabled, it runs testing using CTest (true/false)
|
||||
required: false
|
||||
default: false
|
||||
test-args:
|
||||
@@ -50,18 +54,15 @@ runs:
|
||||
if [ -n '${{ inputs.source-dir }}' ]; then
|
||||
SOURCE_DIR="${{ inputs.source-dir }}"
|
||||
fi
|
||||
|
||||
BUILD_DIR="build"
|
||||
if [ -n '${{ inputs.build-dir }}' ]; then
|
||||
BUILD_DIR="${{ inputs.build-dir }}"
|
||||
elif [ -n "${{ inputs.source-dir }}" ]; then
|
||||
BUILD_DIR="${{ inputs.source-dir }}/build"
|
||||
fi
|
||||
|
||||
ARGS="'$SOURCE_DIR' -B '$BUILD_DIR'"
|
||||
BUILD_ARGS="--build '$BUILD_DIR'"
|
||||
TEST_ARGS=""
|
||||
if [ -n '${{ inputs.targets }}' ]; then
|
||||
BUILD_ARGS="$BUILD_ARGS --target ${{ inputs.targets }}"
|
||||
fi
|
||||
if [ -n '${{ inputs.generator }}' ]; then
|
||||
ARGS="$ARGS -G '${{ inputs.generator }}'"
|
||||
fi
|
||||
@@ -80,12 +81,23 @@ runs:
|
||||
if [ -n '${{ inputs.args }}' ]; then
|
||||
ARGS="$ARGS ${{ inputs.args }}"
|
||||
fi
|
||||
|
||||
BUILD_ARGS=""
|
||||
if [ '${{ inputs.run-build }}' == 'true' ]; then
|
||||
BUILD_ARGS="--build '$BUILD_DIR'"
|
||||
fi
|
||||
if [ -n '${{ inputs.targets }}' ]; then
|
||||
BUILD_ARGS="$BUILD_ARGS --target ${{ inputs.targets }}"
|
||||
fi
|
||||
|
||||
TEST_ARGS=""
|
||||
if [ '${{ inputs.run-test }}' == 'true' ]; then
|
||||
TEST_ARGS="--test-dir '$BUILD_DIR' --output-on-failure --no-tests=error"
|
||||
fi
|
||||
if [ -n '${{ inputs.test-args }}' ]; then
|
||||
TEST_ARGS="$TEST_ARGS ${{ inputs.test-args }}"
|
||||
fi
|
||||
|
||||
echo "cmake_args=${ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
|
||||
echo "cmake_build_args=${BUILD_ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
|
||||
echo "cmake_test_args=${TEST_ARGS//[$'\t\r\n']}" >> $GITHUB_OUTPUT
|
||||
@@ -105,6 +117,7 @@ runs:
|
||||
run: cmake ${{ steps.process_inputs.outputs.cmake_args }}
|
||||
|
||||
- name: Build targets
|
||||
if: steps.process_inputs.outputs.cmake_build_args != ''
|
||||
shell: ${{ runner.os == 'Windows' && 'pwsh' || 'bash' }}
|
||||
run: cmake ${{ steps.process_inputs.outputs.cmake_build_args }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user