aboutsummaryrefslogtreecommitdiff
path: root/scripts/llvm.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/llvm.py')
-rw-r--r--scripts/llvm.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/llvm.py b/scripts/llvm.py
index d1bf29d..ff8ecb1 100644
--- a/scripts/llvm.py
+++ b/scripts/llvm.py
@@ -4,6 +4,7 @@ import os
from sys import argv
from sys import exit
+from modules.llvm import build_llvm
from modules.llvm import LLVMBuildConfig
from modules.llvm import LLVMSubproject
from modules.llvm import LLVMSourceConfig
@@ -116,6 +117,21 @@ def configure_build(args):
die("Failed to configure {} because:\n{}".format(args.build, str(exc)))
+def run_build(args):
+ """Run a build command in a given directory."""
+ build_dir = args.build
+
+ if args.dry:
+ consumer = CommandPrinter()
+ else:
+ consumer = CommandRunner()
+
+ try:
+ build_llvm(consumer, args.build, args.flags)
+ except RuntimeError as exc:
+ die("Failed to build {} because:\n{}".format(args.build, str(exc)))
+
+
##########################################################################
# Command line parsing #
##########################################################################
@@ -215,6 +231,36 @@ configure.add_argument(
help="Print the CMake command instead of executing it.")
configure.set_defaults(run_command=configure_build)
+# Subcommand for building a target
+build = subcommands.add_parser(
+ 'build',
+ help="Run a build command in the given directory."
+ "The build command can be either a 'ninja' or a 'make' command, depending "
+ "on what the build directory contains. First, we look for a 'build.ninja' "
+ "file. If that is not found, we look for a 'Makefile'. If that is not "
+ "found either, the script fails.")
+build.add_argument(
+ '--build-dir',
+ dest='build',
+ required=True,
+ help="Path to the build directory. It must have already been configured.")
+build.add_argument(
+ '-n', '--dry-run',
+ dest='dry',
+ action='store_true',
+ default=False,
+ help="Print the build command instead of executing it.")
+build.add_argument(
+ '--build-flag',
+ dest='flags',
+ metavar='FLAG',
+ default=[],
+ action='append',
+ help="Additional flags for the build command (e.g. targets to build). "
+ "May be passed several times. If your flag starts with a '-', use "
+ "'--build-flag=-FLAG' to pass it.")
+build.set_defaults(run_command=run_build)
+
args = options.parse_args()
if args.subcommand == "projects" and args.add and not args.repos:
projs.error(