- integrations
- CMake
- Guides
- Run workspace tools from ocx.toml
Run workspace tools from ocx.toml
Use ocx_project to turn a committed ocx.toml and ocx.lock into command lists that run your tools in custom targets, tests and groups.
Declare tools and a group
Section titled “Declare tools and a group”Put tools in [tools] and rarely used tools in a group.
[tools]jq = "ocx.sh/jqlang/jq:latest"
[group.lint.tools]shellcheck = "ocx.sh/shellcheck/shellcheck:latest"Export the launchers
Section titled “Export the launchers”Call ocx_project with the tools you want as per-tool variables.
ocx_project(NAME TOOLS BINS jq)NAME TOOLS gives OCX_TOOLS_RUN and OCX_TOOLS_RUN_JQ.
Without NAME, the variables are OCX_PROJECT_RUN and OCX_PROJECT_RUN_JQ.
The ocx.toml is found by the upward search, the lock is verified, and nothing is fetched yet.
Use a launcher in a command
Section titled “Use a launcher in a command”OCX_TOOLS_RUN is a plain CMake command list, so generator expressions such as $<CONFIG> work and you need no wrapper script.
add_custom_target(validate ALL COMMAND ${OCX_TOOLS_RUN} jq -n -e --arg config "$<CONFIG>" [[$config | length >= 0]] VERBATIM)Keep a group lazy
Section titled “Keep a group lazy”A group costs nothing until someone builds a target that uses it.
ocx_project(NAME LINT GROUPS lint)add_custom_target(lint COMMAND ${OCX_LINT_RUN} shellcheck "${CMAKE_CURRENT_SOURCE_DIR}/hello.sh" VERBATIM)Run a tool in a test
Section titled “Run a tool in a test”Use the per-tool variable as the test command.
add_test(NAME data_valid COMMAND ${OCX_TOOLS_RUN_JQ} -e ".greeting == \"hello\"" "${CMAKE_CURRENT_SOURCE_DIR}/data.json")Build and test
Section titled “Build and test”cd examples/projectcmake -S . -B buildcmake --build buildctest --test-dir build --output-on-failureFor the full signatures, see ocx_project.
Needs addressed: problems 1 and 2 of the use-case research.