Commit 6423a0f6 by Tobias Langer

Read template dir from experiment file.

parent 567a91ff
......@@ -5,12 +5,11 @@ This utility script helps in the creation of experiment setups. It therefore
reads experiment descriptions from json files and creates everything necessary
as a result.
It therefore performs the following actions:
* [x] Read the json file of every experiment
* [x] Create folders for every experiment
* [ ] Create the header file for every experiment
* [x] Add the make file for every experiment
* [x] Add c++ file for every experiment
* Read the json file of every experiment
* Create folders for every experiment
* Create the header file for every experiment
* Add the make file for every experiment
* Add c++ file for every experiment
"""
import sys
......@@ -96,9 +95,6 @@ def main():
parser = argparse.ArgumentParser(description='Generate experiment data.')
parser.add_argument('description', type=str, nargs='+', help='file containing the taskset description.')
parser.add_argument('--header', dest='header', type=str, nargs='?', default='./templates/normal/defines.h', help='path to optional custom header file.')
parser.add_argument('--makefile', dest='makefile', type=str, nargs='?', default='./templates/normal/Makefile', help='path to optional custom makefile.')
parser.add_argument('--cpp', dest='cpp', type=str, nargs='*', default='./templates/normal/experiment.cpp', help='path to optional custom c++ implementation.')
args = parser.parse_args()
cwd = os.getcwd()
......@@ -108,6 +104,16 @@ def main():
descr_json = experiment_description.read()
experiment = json.loads(descr_json)
try:
template_path = os.path.join(cwd, experiment['template']
except KeyError:
print('Experiment file doesn\'t specify template, aborting…',
file=sys.stderr)
sys.exit(1)
header = os.path.join(template_path, 'defines.h')
makefile = os.path.join(template_path, 'Makefile')
cpp = os.path.join(template_path, 'experiment.cpp')
print('[{}/{}] Creating experiment {}:'.format(num + 1,
len(args.description),
experiment['name']),
......@@ -124,15 +130,15 @@ def main():
# Add header
print('Create header file…', file=sys.stderr)
header_path = os.path.join(experiment_dir, 'defines.h')
create_header(args.header, experiment, header_path)
create_header(header, experiment, header_path)
# Add makefile & c++ file
print('Adding Makefile…', file=sys.stderr)
makefile_path = os.path.join(experiment_dir, 'Makefile')
shutil.copyfile(args.makefile, makefile_path)
shutil.copyfile(makefile, makefile_path)
print('Add C++ file(s)…', file=sys.stderr)
cpp_file_path = os.path.join(experiment_dir, 'experiment.cpp')
shutil.copyfile(args.cpp, cpp_file_path)
shutil.copyfile(cpp, cpp_file_path)
if __name__ == '__main__':
main()
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 sign in to comment