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))
# 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 @@ make_symlink: $(OBJDIR)/llvm2ice $(OBJDIR)/llvm2ice.build_atts
$(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 @@ format-diff:
$(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/
......@@ -6,36 +6,26 @@ 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.
"""Run the specified command only if conditions are met.
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.
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('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('--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.')
......@@ -48,7 +38,7 @@ def main():
if not args.command:
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)
if not args.echo_cmd:
sys.stdout.write(stdout_result)
......
......@@ -39,7 +39,7 @@ import sys
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 @@ llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH'))
# 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 @@ def dbg(s):
dbg('bin_root = %s' % bin_root)
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