diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2020-07-10 18:18:39 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2020-07-10 18:18:39 +0200 |
| commit | c2664e97590849f426ef7ea92a5508034ec41abd (patch) | |
| tree | 5d6f4cdcc7383d5575803be140a5aef11e55676a | |
| parent | 7a73948c649fb4a15825677d33095f995d07c4b1 (diff) | |
| download | allocbench-c2664e97590849f426ef7ea92a5508034ec41abd.tar.gz allocbench-c2664e97590849f426ef7ea92a5508034ec41abd.zip | |
[allocator.py] only check allocator build if it has defined build_cmds
| -rw-r--r-- | allocbench/allocator.py | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/allocbench/allocator.py b/allocbench/allocator.py index 74871b6..8428580 100644 --- a/allocbench/allocator.py +++ b/allocbench/allocator.py @@ -128,44 +128,45 @@ class Allocator: def build(self): """Build the allocator if needed and produce an allocator dict""" - build_needed = not self.dir.is_dir() - buildtimestamp_path = self.dir / ".buildtime" + if self.build_cmds: + build_needed = not self.dir.is_dir() + buildtimestamp_path = self.dir / ".buildtime" - if not build_needed: - print_info2("Old build found. Comparing build time with mtime") + if not build_needed: + print_info2("Old build found. Comparing build time with mtime") - with open(buildtimestamp_path, "r") as buildtimestamp_file: - timestamp = datetime.fromtimestamp( - float(buildtimestamp_file.read())) + with open(buildtimestamp_path, "r") as buildtimestamp_file: + timestamp = datetime.fromtimestamp( + float(buildtimestamp_file.read())) - modtime = os.stat(self.class_file).st_mtime - modtime = datetime.fromtimestamp(modtime) + modtime = os.stat(self.class_file).st_mtime + modtime = datetime.fromtimestamp(modtime) - build_needed = timestamp < modtime + build_needed = timestamp < modtime - print_debug("Time of last build:", timestamp.isoformat()) - print_debug("Last modification of allocators file:", - modtime.isoformat()) - print_info2("" if build_needed else "No " + "build needed") + print_debug("Time of last build:", timestamp.isoformat()) + print_debug("Last modification of allocators file:", + modtime.isoformat()) + print_info2("" if build_needed else "No " + "build needed") - if build_needed: - self.prepare() - print_status("Building", self.name, "...") + if build_needed: + self.prepare() + print_status("Building", self.name, "...") - for cmd in self.build_cmds: - cmd = cmd.format(dir=self.dir, srcdir=self.srcdir) + for cmd in self.build_cmds: + cmd = cmd.format(dir=self.dir, srcdir=self.srcdir) - try: - run_cmd(cmd, cwd=BUILDDIR, shell=True) - except CalledProcessError as err: - print_debug(err.stderr, file=sys.stderr) - print_error(f"Builing {self.name} failed") - shutil.rmtree(self.dir, ignore_errors=True) - raise + try: + run_cmd(cmd, cwd=BUILDDIR, shell=True) + except CalledProcessError as err: + print_debug(err.stderr, file=sys.stderr) + print_error(f"Builing {self.name} failed") + shutil.rmtree(self.dir, ignore_errors=True) + raise - with open(buildtimestamp_path, "w") as buildtimestamp_file: - print_info2("Save build time to:", buildtimestamp_path) - buildtimestamp_file.write(str(datetime.now().timestamp())) + with open(buildtimestamp_path, "w") as buildtimestamp_file: + print_info2("Save build time to:", buildtimestamp_path) + buildtimestamp_file.write(str(datetime.now().timestamp())) print_info2("Create allocator dictionary") res_dict = { |
