forked from mesonbuild/meson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
101 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
## Build and run the project | ||
|
||
[`Meson run`](Commands.md#run) compiles and runs a target inside Meson's | ||
[`devenv`](Commands.md#devenv). | ||
|
||
In the case the project installs more than one executable, `--bin <target>` | ||
argument can be used to specify which one to run. See [`compile`](#compile) | ||
command for `target` syntax. | ||
|
||
The remainder of the command line are arguments passed to the target executable: | ||
``` | ||
meson run -C builddir --bin gst-launch-1.0 videotestsrc ! glimagesink | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from __future__ import annotations | ||
|
||
import argparse | ||
import typing as T | ||
|
||
from pathlib import Path | ||
from . import build | ||
from .mesonlib import setup_vsenv, MesonException | ||
from .options import OptionKey | ||
from .mcompile import compile_single_executable | ||
from .mdevenv import run_cmd | ||
|
||
|
||
# Note: when adding arguments, please also add them to the completion | ||
# scripts in $MESONSRC/data/shell-completions/ | ||
def add_arguments(parser: argparse.ArgumentParser) -> None: | ||
parser.add_argument('-C', dest='builddir', type=Path, default='.', | ||
help='Path to build directory') | ||
parser.add_argument('--bin', default=None, | ||
help='Executable target to build and run') | ||
parser.add_argument('arguments', nargs=argparse.REMAINDER, | ||
help='Arguments to pass to the executable') | ||
|
||
|
||
def run(options: argparse.Namespace) -> int: | ||
buildfile = Path(options.builddir, 'meson-private', 'build.dat') | ||
if not buildfile.is_file(): | ||
raise MesonException(f'Directory {options.builddir!r} does not seem to be a Meson build directory.') | ||
b = build.load(options.builddir) | ||
|
||
need_vsenv = T.cast('bool', b.environment.coredata.get_option(OptionKey('vsenv'))) | ||
setup_vsenv(need_vsenv) | ||
|
||
path, returncode = compile_single_executable(b.environment, options.bin) | ||
if returncode != 0: | ||
return returncode | ||
|
||
cmd = [path] + options.arguments | ||
return run_cmd(b, cmd) |