aboutsummaryrefslogtreecommitdiff
path: root/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
commitb7f3bfc559f1ed541f8293ebb519cfb898dc757a (patch)
treecb2120c875fda2e288efc214098b3528da341ca7 /utils/llvm-build/llvmbuild/main.py
parent5ed5506f18fcc0a277c863f7a21b39f58e892ca5 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144345 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/llvm-build/llvmbuild/main.py')
-rw-r--r--utils/llvm-build/llvmbuild/main.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/utils/llvm-build/llvmbuild/main.py b/utils/llvm-build/llvmbuild/main.py
index 51923ebad7..fa76aa5d8e 100644
--- a/utils/llvm-build/llvmbuild/main.py
+++ b/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()