lukka / run-cmake

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

Environment vars in command-line #5

Closed rickomax closed 4 years ago

rickomax commented 4 years ago

Hi!

I'm not sure if this issue is related to the action itself, but when I try to use an environment var on the CMAKE arguments, it's not recognized.

I've tested setting the -DCMAKE_TOOLCHAIN_FILE using the ANDROID_SDK_ROOT environment variable in two ways, but no one have worked:

Just to clarify, I've already ensured the given toolchain file is on the runner image.

https://github.com/rickomax/assimp/runs/479700678?check_suite_focus=true https://github.com/rickomax/assimp/runs/479685226?check_suite_focus=true

rickomax commented 4 years ago

Setting the path manually without the ${ANDROID_SDK_ROOT} environment var on the arguments works. Strange...

lukka commented 4 years ago

@rickomax using this in the yml file should work:

${{ env.ANDROID_SDK_ROOT }}

You could also use the env variable using a syntax that the OS understand, but would have a different syntax per platform.

rickomax commented 4 years ago

Oh, gonna try. Ty! Edit: it doesnt work

rickomax commented 4 years ago

https://github.com/rickomax/assimp/runs/481149007?check_suite_focus=true

lukka commented 4 years ago

From the log, it looks like the ANDROID_SDK_ROOT variable is not set in the environment, as it is empty, as in it has been evaluated to not being set.

-DCMAKE_TOOLCHAIN_FILE=/ndk-bundle/build/cmake/android.toolchain.cmake

I can see the evalution done by enabling verbose output on steps/actions, that is:

https://github.com/actions/toolkit/blob/master/docs/action-debugging.md#step-debug-logs

rickomax commented 4 years ago

I wonder how it's not set, if I can list it using the "run" action with bash....

lukka commented 4 years ago
rickomax commented 4 years ago

Yeah, it shows values for me

lukka commented 4 years ago

ok, can you enable step-debug-log as suggested and run the workflow again?

lukka commented 4 years ago

@rickomax i've investigate this further, and indeed the core.exec functions provided by actions/toolkit is not using a shell when launching commands. It looks like a solution would be to contribute back to actions/toolkit to add this functionality, or just do the logic in this action and use 'bash'/'cmd' according to platform and user preferences.

lukka commented 4 years ago

Running processes under the platform default shell helps indeed in being able to access to env var. With v1 release you can use env var on the inputs of the action.