GitLab will be upgraded to the 12.10.14-ce.0 on 28 Sept 2020 at 2.00pm (AEDT) to 2.30pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

Commit 6f7a306b authored by John Zhang's avatar John Zhang

add command line option to specify skip compilation of tasks

parent a1f7ca15
......@@ -55,8 +55,8 @@ fib:
impl: holstein
source: targetfib.py
compiler:
flags:
- --mu-vmargs=vmLog=ERROR
vmargs:
- vmLog=ERROR
runner:
flags:
- --vmLog=ERROR
......@@ -69,3 +69,8 @@ fib:
compiler:
flags:
- -O0
mu:
language:
name: mu
impl: zebu
source: build_fib.c
\ No newline at end of file
......@@ -24,12 +24,17 @@ logger = logging.getLogger(__name__)
@click.command()
@click.argument('file', type=click.Path(exists=True))
@click.option('--skip_compile', default='none',
help="a list of tasks to skip compilation." +
"Can be 'all', 'none', or a string in the form of 'taskset1:task1,task2;taskset2'. " +
"If only a task set's name is defined, skip compilation of all its tasks. " +
"Default target in the form of 'taskset-task' is assumed to be found under output directory.")
@click.option('--comp_remote', is_flag=True, default=False)
def local(file, comp_remote):
def local(file, skip_compile, comp_remote):
logger.info("Constructing a LocalRevision")
revision = LocalRevision(file)
logger.info("Running tasks specified in file")
revision.run_tasksets()
revision.run_tasksets(skip_compile)
logger.info("Generating report, compare remote?: {}".format(comp_remote))
report = revision.generate_report()
report_pipelines = {
......
......@@ -38,6 +38,13 @@ class Language:
def check_runner(cls, rc, lc, task):
return rc
@classmethod
def get_default_target(cls, task):
target_dir = task.output_dir
target_name = '%s-%s' % (task.taskset.name, task.name)
target = target_dir / target_name
return target
@classmethod
def compile(cls, task):
raise NotImplementedError
......
......@@ -46,9 +46,7 @@ class C(Language):
cc_flags = list(map(lambda a: expandenv(a, task.env), cc.get('flags', [])))
flags.extend(cc_flags)
flags.extend(include_flags)
target_dir = task.output_dir
target_name = '%s-%s' % (task.taskset.name, task.name)
target = target_dir / target_name
target = cls.get_default_target(task)
flags.extend(['-o', str(target)])
cmd.extend(flags)
......
......@@ -132,9 +132,8 @@ class Mu(Language):
flags.extend(['-L%s' % d for d in cc['library_dirs']])
flags.append('-l%(libmu_link_name)s' % cc)
target_name = '%s-%s' % (task.taskset.name, task.name)
target_dir = task.output_dir
build_target = target_dir / target_name
target = cls.get_default_target(task)
build_target = target.with_name('build_' + target.name)
flags.extend(['-o', str(build_target)])
cmd.extend(flags)
......@@ -153,7 +152,7 @@ class Mu(Language):
assert build_target.exists()
# Then run the build program to get the boot image
target = target_dir / target_name
cmd = [build_target]
cmd.append(cc['vmarg_s'])
cmd.append(target.absolute())
......
......@@ -141,9 +141,7 @@ class RPython(Language):
flags.append("--mu-vmargs=%(vmarg_s)s" % task.compiler)
flags.extend(task.compiler['flags'])
target_dir = task.output_dir
target_name = '%s-%s' % (task.taskset.name, task.name)
target = target_dir / target_name
target = cls.get_default_target(task)
flags.append('--output=%(target)s' % locals())
cmd.extend(flags)
......
......@@ -61,12 +61,30 @@ class LocalRevision(Revision):
self.file = file
self.tasksets = load_file(self.file)
def run_tasksets(self):
def run_tasksets(self, skipcomp_s):
"""
Run tasks and store the result as attribute
"""
skipcomp_d = self.get_skipcomp_dic(skipcomp_s)
for ts in self.tasksets:
ts.run()
ts.run(skipcomp_d[ts.name])
def get_skipcomp_dic(self, skipcomp_s):
none_d = {ts.name: [] for ts in self.tasksets}
all_d = {ts.name: [t.name for t in ts.tasks] for ts in self.tasksets}
if skipcomp_s == 'none':
return none_d
elif skipcomp_s == 'all':
return all_d
else:
skipcomp_d = none_d
for sub in skipcomp_s.split(';'):
if not ':' in sub: # only the taskset name -> skip compilation of all tasks
skipcomp_d[sub] = all_d[sub]
else:
tup = sub.split(':')
skipcomp_d[tup[0]] = tup[1].split(',')
return skipcomp_d
def generate_report(self):
return Report(tasksets=self.tasksets, revision=self)
......
......@@ -119,30 +119,28 @@ class TaskSet:
return ts
def run(self, *keywords):
if keywords:
tasks = list(filter(lambda t: t.name in keywords, self.tasks))
else:
tasks = self.tasks
def run(self, skipcomp_l):
# compile first
targets = {}
for task in tasks:
if task.lang_cls.compiled:
task_print(task.name, 'compiling...')
try:
target = task.compile()
task_print(task.name, 'target %s generated' % target)
targets[task] = target
except ExecutionFailure as e:
task_print(task.name, crayons.red('FAILED'))
logger.critical(crayons.red(str(e)))
errlog_file = self.output_dir / (task.name + '.log')
e.dump(errlog_file)
task_print(task.name, crayons.red(
'error output written to %s.' % errlog_file))
else: # interpreted
for task in self.tasks:
if not task.lang_cls.compiled: # interpreted
targets[task] = task.srcfile
else: # need compilation
if task.name in skipcomp_l: # skip compilation -> assume default target
targets[task] = task.get_default_target()
else:
task_print(task.name, 'compiling...')
try:
target = task.compile()
task_print(task.name, 'target %s generated' % target)
targets[task] = target
except ExecutionFailure as e:
task_print(task.name, crayons.red('FAILED'))
logger.critical(crayons.red(str(e)))
errlog_file = self.output_dir / (task.name + '.log')
e.dump(errlog_file)
task_print(task.name, crayons.red(
'error output written to %s.' % errlog_file))
# run
data = {t: [] for t in targets} # only run tasks that have a target
......@@ -247,6 +245,9 @@ class Task:
res = self.lang_cls.run(target, self)
return res
def get_default_target(self):
return self.lang_cls.get_default_target(self)
# TODO: maybe refactor this.
# Results and data should not be part of a taskset/task,
# but rather the Result should be *about* a TaskSet
......
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