lukka / run-cmake

GitHub Action to build C++ applications with CMake (CMakePresets.json), Ninja and vcpkg on GitHub.
MIT License
182 stars 19 forks source link

wrong parsing paths in configurePresetAdditionalArgs on Windows CI #106

Open q4a opened 1 year ago

q4a commented 1 year ago

If I want to pass

configurePresetAdditionalArgs: "[ '-DD3D9_INCLUDE_DIR=${{ github.workspace }}/cache/Include' ]"

I'll get good enough string in github gui log:

Run lukka/run-cmake@v10
  with:
    cmakeListsTxtPath: D:\a\nine-tests\nine-tests/NineTests/CMakeLists.txt
    configurePreset: default
    configurePresetAdditionalArgs: ['-DD3D9_INCLUDE_DIR=D:\a\nine-tests\nine-tests/cache/Include']

But in raw log I'll see broken/splites lines and build will fail:

2023-04-12T08:47:12.2545415Z Running command '"C:\Program Files\CMake\bin\cmake.exe"' with args '^"--preset^",^"default^",^"-DD3D9_INCLUDE_DIR=D:a
2023-04-12T08:47:12.2545798Z ine-tests
2023-04-12T08:47:12.2546177Z ine-tests/cache/Include^

Full log here: build-log.txt

I also tried different variants of quotation marks:

configurePresetAdditionalArgs: "[ '-DD3D9_INCLUDE_DIR=${{ github.workspace }}/cache/Include' ]"
configurePresetAdditionalArgs: "[ `-DD3D9_INCLUDE_DIR=${{ github.workspace }}/cache/Include` ]"
configurePresetAdditionalArgs: '[ "-DD3D9_INCLUDE_DIR=${{ github.workspace }}/cache/Include" ]`
configurePresetAdditionalArgs: '[ `-DD3D9_INCLUDE_DIR="${{ github.workspace }}/cache/Include"` ]'

But got same problem.

Here is example: https://github.com/q4a/nine-tests/blob/cc0e8b9c12031a44991c11bbb48bbd3b7b8d6d5f/.github/workflows/ci_windows.yml#L37 Gui build log: https://github.com/q4a/nine-tests/actions/runs/4676508343/jobs/8282902807 Raw build log: https://github.com/q4a/nine-tests/commit/cc0e8b9c12031a44991c11bbb48bbd3b7b8d6d5f/checks/12685199096/logs

q4a commented 1 year ago

Looks similar to: https://github.com/lukka/run-vcpkg/issues/144

lukka commented 1 year ago

@q4a I think I'd be glad to see how to solve this problem with a PR contributed from the community. The problem is that the github.workspace contains backslashes on Windows, and the backslashes are going to be interpreted as escaping characters for the arbitrary input provided by the user.

My suggestion would be to avoid its usage, e.g. would a relative path such as -DD3D9_INCLUDE_DIR=./cache/Include work?

Or you could fix up the github.workspace variable by replacing backslashes with fw slashes, such as:

- uses: actions/github-script@v6
  with:
    script: |
       core.exportVariable('wkspath', "${{ github.workspace. }}".replace('\\', '/');

and then use wkspath onward in the workflow.