Target Accessor#

class TargetAccessor#

Build, run, or edit targets ad-hoc.

run(args)#

Build and run an executable target.

Parameters:
  • args – An array of arguments to pass to the executable.

run_thread(args)#

Same as run, but runs the executable on a separate thread.

Parameters:
  • args – An array of arguments to pass to the executable.

Return type:

Thread.

build()#

Build the target (if it needs recompiling).

add_dependency(dependency)#

Add a dependency to the target.

set_pkgconfig(name)#

Set the name of the pkgconfig file, or the path to the pkgconfig file for a Meson target

artifacts()#

Returns the artifacts that this target outputs.

Return type:

Hash where the key is an artifact type and the value is the path to the artifact

Example

project("SomeProject").target("SomeTarget").artifacts
#=> {
#     staticlib: "build/aarch64-apple-darwin/debug/SomeTarget/artifacts/libSomeTarget.a",
#     dynlib: "build/aarch64-apple-darwin/debug/SomeTarget/artifacts/libSomeTarget.dylib"
#   }
dep(artifact_type)#

Returns a dependency to the artifact_type of this target.

Parameters:
  • artifact_type – The type of artifact to get the dependency to (e.g. :staticlib, :dynlib, …)

Return type:

Dependency

Example

some_target = project("SomeProject").target("SomeTarget")

C::Library(
  # ...
  dependencies: [
    some_target.dep(:staticlib)
  ]
)