Remove building llvm2ice.build_atts from Subzero build.
BUG=None
R=stichnot@chromium.org
Review URL: https://codereview.chromium.org/689753002
diff --git a/Makefile.standalone b/Makefile.standalone
index feae52c..ceff1fa 100644
--- a/Makefile.standalone
+++ b/Makefile.standalone
@@ -116,10 +116,14 @@
# Keep all the first target so it's the default.
all: $(OBJDIR)/llvm2ice make_symlink
-make_symlink: $(OBJDIR)/llvm2ice $(OBJDIR)/llvm2ice.build_atts
- rm -rf llvm2ice llvm2ice.build_atts
+# Creates symbolic link so that testing is easier. Also runs
+# llvm2ice to verify that the defines flags have valid values,
+# as well as describe the corresponding build attributes.
+make_symlink: $(OBJDIR)/llvm2ice
+ rm -rf llvm2ice
ln -s $(OBJDIR)/llvm2ice
- ln -s $(OBJDIR)/llvm2ice.build_atts
+ @echo "Build Attributes:"
+ @$(OBJDIR)/llvm2ice --build-atts
.PHONY: all make_symlink
@@ -128,7 +132,6 @@
$(OBJDIR)/llvm2ice: $(OBJS)
$(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) -ldl \
-Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib)
- $@ --build-atts > $@.build_atts
# TODO: Be more precise than "*.h" here and elsewhere.
$(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def
@@ -166,7 +169,7 @@
$(CLANG_FORMAT_DIFF) -p1 -style=LLVM -i
clean:
- rm -rf llvm2ice llvm2ice.build_atts *.o $(OBJDIR)
+ rm -rf llvm2ice *.o $(OBJDIR)
clean-all: clean
rm -rf build/
diff --git a/pydir/if.py b/pydir/if.py
new file mode 100755
index 0000000..86923c6
--- /dev/null
+++ b/pydir/if.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python2
+
+import argparse
+import os
+import sys
+
+from utils import shellcmd
+
+def main():
+ """Run the specified command only if conditions are met.
+
+ Two conditions are checked. First, the CONDITION must be true.
+ Secondly, all NEED names must be in the set of HAVE names.
+ If both conditions are met, the command defined by the remaining
+ arguments is run in a shell.
+ """
+ argparser = argparse.ArgumentParser(
+ description=' ' + main.__doc__,
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+ argparser.add_argument('--cond', choices={'true', 'false'} , required=False,
+ default='true', metavar='CONDITION',
+ help='Condition to test.')
+ argparser.add_argument('--need', required=False, default=[],
+ action='append', metavar='NEED',
+ help='Needed name. May be repeated.')
+ argparser.add_argument('--have', required=False, default=[],
+ action='append', metavar='HAVE',
+ help='Name you have. May be repeated.')
+ argparser.add_argument('--echo-cmd', required=False,
+ action='store_true',
+ help='Trace the command before running.')
+ argparser.add_argument('--command', nargs=argparse.REMAINDER,
+ help='Command to run if attributes found.')
+
+ args = argparser.parse_args()
+
+ # Quit early if no command to run.
+ if not args.command:
+ raise RuntimeError("No command argument(s) specified for ifatts")
+
+ if args.cond == 'true' and set(args.need) <= set(args.have):
+ stdout_result = shellcmd(args.command, echo=args.echo_cmd)
+ if not args.echo_cmd:
+ sys.stdout.write(stdout_result)
+
+if __name__ == '__main__':
+ main()
+ sys.exit(0)
diff --git a/pydir/ifatts.py b/pydir/ifatts.py
deleted file mode 100755
index 9be7cb3..0000000
--- a/pydir/ifatts.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python2
-
-import argparse
-import os
-import sys
-
-from utils import shellcmd
-
-def GetFileAttributes(Filename):
- """Returns the set of names contained in file named Filename.
- """
- if not os.path.isfile(Filename):
- raise RuntimeError("Can't open: %s" % Filename)
- with open(Filename, 'r') as f:
- return f.read().split()
-
-def HasFileAttributes(Filename, Attributes):
- """Returns true if the set of names in Attributes also appear
- in the set of names contained in file named Filename.
- """
- return set(Attributes) <= set(GetFileAttributes(Filename))
-
-def main():
- """Run the specified command only if attributes are defined.
-
- Check if the fset of attributes (i.e. names), contained in FILE,
- contains the attributes defined by --att=ATTRIBUTE arguments. If
- so, runs in a shell the command defined by the remaining
- arguments.
- """
- argparser = argparse.ArgumentParser(
- description=' ' + main.__doc__,
- formatter_class=argparse.ArgumentDefaultsHelpFormatter)
- argparser.add_argument('file', metavar='FILE',
- help='File defining attributes to check against.')
- argparser.add_argument('--att', required=False, default=[],
- action='append', metavar='ATTRIBUTE',
- help='Attribute to check. May be repeated.')
- argparser.add_argument('--echo-cmd', required=False,
- action='store_true',
- help='Trace the command before running.')
- argparser.add_argument('--command', nargs=argparse.REMAINDER,
- help='Command to run if attributes found.')
-
- args = argparser.parse_args()
-
- # Quit early if no command to run.
- if not args.command:
- raise RuntimeError("No command argument(s) specified for ifatts")
-
- if HasFileAttributes(args.file, args.att):
- stdout_result = shellcmd(args.command, echo=args.echo_cmd)
- if not args.echo_cmd:
- sys.stdout.write(stdout_result)
-
-if __name__ == '__main__':
- main()
- sys.exit(0)
diff --git a/tests_lit/lit.cfg b/tests_lit/lit.cfg
index 1233a76..3b7bf5c 100644
--- a/tests_lit/lit.cfg
+++ b/tests_lit/lit.cfg
@@ -39,7 +39,7 @@
import lit.formats
sys.path.insert(0, 'pydir')
-from utils import FindBaseNaCl
+from utils import FindBaseNaCl, shellcmd
from ifatts import GetFileAttributes
# name: The name of this test suite.
@@ -69,18 +69,23 @@
# Define the location of the llvm2ice tool.
llvm2icetool = os.path.join(bin_root, 'llvm2ice')
-llvm2icetoolatts = os.path.join(bin_root, 'llvm2ice.build_atts')
+llvm2iceatts = shellcmd(' '.join([llvm2icetool, '--build-atts']),
+ echo=False).split()
# Add build attributes of llvm2ice tool to the set of available features.
-config.available_features.update(GetFileAttributes(llvm2icetoolatts))
+config.available_features.update(llvm2iceatts)
-# Base command for testing build attributes
-if_atts_base = [os.path.join(pydir, 'ifatts.py'), llvm2icetoolatts]
-if_atts_cmd = if_atts_base + ['--command']
-ifl2i_atts_cmd = if_atts_base + ['--att=allow_llvm_ir', '--command']
-iflc2i_atts_cmd = if_atts_base + ['--att=allow_llvm_ir',
- '--att=allow_llvm_ir_as_input',
- '--command']
+def if_cond_flag(Value):
+ return '--cond=true' if Value else '--cond=false'
+
+# shell conditional commands.
+if_atts = [os.path.join(pydir, 'if.py')]
+if_atts_cmd = if_atts + ['--have=' + att
+ for att in llvm2iceatts] + ['--command']
+ifl2i_atts_cmd = if_atts + [if_cond_flag('allow_llvm_ir' in llvm2iceatts),
+ '--command']
+iflc2i_atts_cmd = if_atts + [if_cond_flag('allow_llvm_ir_as_input'
+ in llvm2iceatts), '--command']
# Base command for running llvm2ice
llvm2ice_cmd = [os.path.join(pydir, 'run-llvm2ice.py'),
@@ -129,3 +134,4 @@
dbg('bin_root = %s' % bin_root)
dbg('llvmbinpath = %s' % llvmbinpath)
+dbg("Build attributes = %s" % llvm2iceatts)