Commit 6af6336d by Karl Schimpf

Remove building llvm2ice.build_atts from Subzero build.

BUG=None R=stichnot@chromium.org Review URL: https://codereview.chromium.org/689753002
parent aff9fa2c
...@@ -116,10 +116,14 @@ OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS)) ...@@ -116,10 +116,14 @@ OBJS=$(patsubst %.cpp, $(OBJDIR)/%.o, $(SRCS))
# Keep all the first target so it's the default. # Keep all the first target so it's the default.
all: $(OBJDIR)/llvm2ice make_symlink all: $(OBJDIR)/llvm2ice make_symlink
make_symlink: $(OBJDIR)/llvm2ice $(OBJDIR)/llvm2ice.build_atts # Creates symbolic link so that testing is easier. Also runs
rm -rf llvm2ice llvm2ice.build_atts # 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
ln -s $(OBJDIR)/llvm2ice.build_atts @echo "Build Attributes:"
@$(OBJDIR)/llvm2ice --build-atts
.PHONY: all make_symlink .PHONY: all make_symlink
...@@ -128,7 +132,6 @@ make_symlink: $(OBJDIR)/llvm2ice $(OBJDIR)/llvm2ice.build_atts ...@@ -128,7 +132,6 @@ make_symlink: $(OBJDIR)/llvm2ice $(OBJDIR)/llvm2ice.build_atts
$(OBJDIR)/llvm2ice: $(OBJS) $(OBJDIR)/llvm2ice: $(OBJS)
$(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) -ldl \ $(CXX) $(LDFLAGS) -o $@ $^ $(LLVM_LDFLAGS) -ldl \
-Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib) -Wl,-rpath=$(abspath $(LIBCXX_INSTALL_PATH)/lib)
$@ --build-atts > $@.build_atts
# TODO: Be more precise than "*.h" here and elsewhere. # TODO: Be more precise than "*.h" here and elsewhere.
$(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def $(OBJS): $(OBJDIR)/%.o: src/%.cpp src/*.h src/*.def
...@@ -166,7 +169,7 @@ format-diff: ...@@ -166,7 +169,7 @@ format-diff:
$(CLANG_FORMAT_DIFF) -p1 -style=LLVM -i $(CLANG_FORMAT_DIFF) -p1 -style=LLVM -i
clean: clean:
rm -rf llvm2ice llvm2ice.build_atts *.o $(OBJDIR) rm -rf llvm2ice *.o $(OBJDIR)
clean-all: clean clean-all: clean
rm -rf build/ rm -rf build/
...@@ -6,36 +6,26 @@ import sys ...@@ -6,36 +6,26 @@ import sys
from utils import shellcmd 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(): def main():
"""Run the specified command only if attributes are defined. """Run the specified command only if conditions are met.
Check if the fset of attributes (i.e. names), contained in FILE, Two conditions are checked. First, the CONDITION must be true.
contains the attributes defined by --att=ATTRIBUTE arguments. If Secondly, all NEED names must be in the set of HAVE names.
so, runs in a shell the command defined by the remaining If both conditions are met, the command defined by the remaining
arguments. arguments is run in a shell.
""" """
argparser = argparse.ArgumentParser( argparser = argparse.ArgumentParser(
description=' ' + main.__doc__, description=' ' + main.__doc__,
formatter_class=argparse.ArgumentDefaultsHelpFormatter) formatter_class=argparse.ArgumentDefaultsHelpFormatter)
argparser.add_argument('file', metavar='FILE', argparser.add_argument('--cond', choices={'true', 'false'} , required=False,
help='File defining attributes to check against.') default='true', metavar='CONDITION',
argparser.add_argument('--att', required=False, default=[], help='Condition to test.')
action='append', metavar='ATTRIBUTE', argparser.add_argument('--need', required=False, default=[],
help='Attribute to check. May be repeated.') 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, argparser.add_argument('--echo-cmd', required=False,
action='store_true', action='store_true',
help='Trace the command before running.') help='Trace the command before running.')
...@@ -48,7 +38,7 @@ def main(): ...@@ -48,7 +38,7 @@ def main():
if not args.command: if not args.command:
raise RuntimeError("No command argument(s) specified for ifatts") raise RuntimeError("No command argument(s) specified for ifatts")
if HasFileAttributes(args.file, args.att): if args.cond == 'true' and set(args.need) <= set(args.have):
stdout_result = shellcmd(args.command, echo=args.echo_cmd) stdout_result = shellcmd(args.command, echo=args.echo_cmd)
if not args.echo_cmd: if not args.echo_cmd:
sys.stdout.write(stdout_result) sys.stdout.write(stdout_result)
......
...@@ -39,7 +39,7 @@ import sys ...@@ -39,7 +39,7 @@ import sys
import lit.formats import lit.formats
sys.path.insert(0, 'pydir') sys.path.insert(0, 'pydir')
from utils import FindBaseNaCl from utils import FindBaseNaCl, shellcmd
from ifatts import GetFileAttributes from ifatts import GetFileAttributes
# name: The name of this test suite. # name: The name of this test suite.
...@@ -69,18 +69,23 @@ llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) ...@@ -69,18 +69,23 @@ llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH'))
# Define the location of the llvm2ice tool. # Define the location of the llvm2ice tool.
llvm2icetool = os.path.join(bin_root, 'llvm2ice') 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. # 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 def if_cond_flag(Value):
if_atts_base = [os.path.join(pydir, 'ifatts.py'), llvm2icetoolatts] return '--cond=true' if Value else '--cond=false'
if_atts_cmd = if_atts_base + ['--command']
ifl2i_atts_cmd = if_atts_base + ['--att=allow_llvm_ir', '--command'] # shell conditional commands.
iflc2i_atts_cmd = if_atts_base + ['--att=allow_llvm_ir', if_atts = [os.path.join(pydir, 'if.py')]
'--att=allow_llvm_ir_as_input', if_atts_cmd = if_atts + ['--have=' + att
'--command'] 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 # Base command for running llvm2ice
llvm2ice_cmd = [os.path.join(pydir, 'run-llvm2ice.py'), llvm2ice_cmd = [os.path.join(pydir, 'run-llvm2ice.py'),
...@@ -129,3 +134,4 @@ def dbg(s): ...@@ -129,3 +134,4 @@ def dbg(s):
dbg('bin_root = %s' % bin_root) dbg('bin_root = %s' % bin_root)
dbg('llvmbinpath = %s' % llvmbinpath) dbg('llvmbinpath = %s' % llvmbinpath)
dbg("Build attributes = %s" % llvm2iceatts)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment