summaryrefslogtreecommitdiffstats
path: root/llvm/utils/llvm-build/llvmbuild/main.py
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-11-11 00:24:00 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-11-11 00:24:00 +0000
commitf258ad81c02daba09d99f8994b38b0e3f91ac259 (patch)
treeb3ba05c62ae421874cc256fc5ba546b32c95a4da /llvm/utils/llvm-build/llvmbuild/main.py
parent6d617b48c75f34c78c453acaa35490cb33366bcf (diff)
downloadbcm5719-llvm-f258ad81c02daba09d99f8994b38b0e3f91ac259.tar.gz
bcm5719-llvm-f258ad81c02daba09d99f8994b38b0e3f91ac259.zip
llvm-build: Add --configure-target-def-file option.
- Can be used to generate the substitution values we currently use for the various target related .def files. llvm-svn: 144345
Diffstat (limited to 'llvm/utils/llvm-build/llvmbuild/main.py')
-rw-r--r--llvm/utils/llvm-build/llvmbuild/main.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/llvm/utils/llvm-build/llvmbuild/main.py b/llvm/utils/llvm-build/llvmbuild/main.py
index 51923ebad7b..fa76aa5d8ed 100644
--- a/llvm/utils/llvm-build/llvmbuild/main.py
+++ b/llvm/utils/llvm-build/llvmbuild/main.py
@@ -2,6 +2,7 @@ import os
import sys
import componentinfo
+import configutil
from util import *
@@ -616,6 +617,9 @@ def main():
help=(
"If given, an alternate path to search for LLVMBuild.txt files"),
action="store", default=None, metavar="PATH")
+ group.add_option("", "--build-root", dest="build_root", metavar="PATH",
+ help="Path to the build directory (if needed) [%default]",
+ action="store", default=None)
parser.add_option_group(group)
group = OptionGroup(parser, "Output Options")
@@ -637,6 +641,14 @@ def main():
dest="write_make_fragment", metavar="PATH",
help="Write the Makefile project information to PATH",
action="store", default=None)
+ group.add_option("", "--configure-target-def-file",
+ dest="configure_target_def_files",
+ help="""Configure the given file at SUBPATH (relative to
+the inferred or given source root, and with a '.in' suffix) by replacing certain
+substitution variables with lists of targets that support certain features (for
+example, targets with AsmPrinters) and write the result to the build root (as
+given by --build-root) at the same SUBPATH""",
+ metavar="SUBPATH", action="append", default=None)
parser.add_option_group(group)
group = OptionGroup(parser, "Configuration Options")
@@ -701,5 +713,40 @@ def main():
if opts.write_cmake_fragment:
project_info.write_cmake_fragment(opts.write_cmake_fragment)
+ # Configure target definition files, if requested.
+ if opts.configure_target_def_files:
+ # Verify we were given a build root.
+ if not opts.build_root:
+ parser.error("must specify --build-root when using "
+ "--configure-target-def-file")
+
+ # Create the substitution list.
+ available_targets = [ci for ci in project_info.component_infos
+ if ci.type_name == 'TargetGroup']
+ substitutions = [
+ ("@LLVM_ENUM_TARGETS@",
+ ' '.join('LLVM_TARGET(%s)' % ci.name
+ for ci in available_targets)),
+ ("@LLVM_ENUM_ASM_PRINTERS@",
+ ' '.join('LLVM_ASM_PRINTER(%s)' % ci.name
+ for ci in available_targets
+ if ci.has_asmprinter)),
+ ("@LLVM_ENUM_ASM_PARSERS@",
+ ' '.join('LLVM_ASM_PARSER(%s)' % ci.name
+ for ci in available_targets
+ if ci.has_asmparser)),
+ ("@LLVM_ENUM_DISASSEMBLERS@",
+ ' '.join('LLVM_DISASSEMBLER(%s)' % ci.name
+ for ci in available_targets
+ if ci.has_disassembler))]
+
+ # Configure the given files.
+ for subpath in opts.configure_target_def_files:
+ inpath = os.path.join(source_root, subpath + '.in')
+ outpath = os.path.join(opts.build_root, subpath)
+ result = configutil.configure_file(inpath, outpath, substitutions)
+ if not result:
+ note("configured file %r hasn't changed" % outpath)
+
if __name__=='__main__':
main()
OpenPOWER on IntegriCloud