Hi all, Gabe, This commit breaks the regression quick/fs/80.netperf-stream/alpha/linux/twosys-tsunami-simple-atomic. It's the only regression that uses SysConfig() with an actual script argument, and it needs to find that script in $GEM5_ROOT/configs/boot/.
Before this commit, this would be found because script.path was initialized with [joinpath(config_root, 'boot')]. Now it is initialized with PathSearchFunc('boot'), a (nonexistent) sibling to $M5_PATH/{disks,binaries}. Thanks, Curtis -----Original Message----- From: gem5-dev [mailto:gem5-dev-boun...@gem5.org] On Behalf Of Gabe Black (Gerrit) Sent: Tuesday, October 31, 2017 5:18 PM Subject: [gem5-dev] Change in public/gem5[master]: config: Rework the SysPaths functions into functors. Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/5341 ) Change subject: config: Rework the SysPaths functions into functors. ...................................................................... config: Rework the SysPaths functions into functors. These functions were already being treated as psuedo objects and had properties assigned to them setting what their paths were. That's a bit unusual and made it less obvious what the code was doing, but also forced the "system" function to know what all the possible path searching functions were so that they'd have their "path" property initialized properly in a central location. This change introduces a PathSearcFunc class which encapsulates the mechanisms of the old code and makes it implicitly extensible so that other path searching functions which might look in other directories can be added in other places. Change-Id: I7be28e51481a06ec83997677af99927709b18003 Reviewed-on: https://gem5-review.googlesource.com/5341 Reviewed-by: Andreas Sandberg <andreas.sandb...@arm.com> Maintainer: Andreas Sandberg <andreas.sandb...@arm.com> --- M configs/common/SysPaths.py 1 file changed, 28 insertions(+), 42 deletions(-) Approvals: Andreas Sandberg: Looks good to me, approved; Looks good to me, approved diff --git a/configs/common/SysPaths.py b/configs/common/SysPaths.py index 316fd03..c012846 100644 --- a/configs/common/SysPaths.py +++ b/configs/common/SysPaths.py @@ -27,55 +27,41 @@ # Authors: Ali Saidi import os, sys -from os.path import join as joinpath -from os import environ as env config_path = os.path.dirname(os.path.abspath(__file__)) config_root = os.path.dirname(config_path) -def searchpath(path, filename): - for p in path: - f = joinpath(p, filename) - if os.path.exists(f): - return f - raise IOError, "Can't find file '%s' on path." % filename +class PathSearchFunc(object): + _sys_paths = None -def disk(filename): - system() - return searchpath(disk.path, filename) + def __init__(self, *subdirs): + self._subdir = os.path.join(*subdirs) -def binary(filename): - system() - return searchpath(binary.path, filename) + def __call__(self, filename): + if self._sys_paths is None: + try: + paths = os.environ['M5_PATH'].split(':') + except KeyError: + paths = [ '/dist/m5/system', + '/n/poolfs/z/dist/m5/system' ] -def script(filename): - system() - return searchpath(script.path, filename) + # expand '~' and '~user' in paths + paths = map(os.path.expanduser, paths) -def system(): - if not system.path: + # filter out non-existent directories + paths = filter(os.path.isdir, paths) + + if not paths: + raise IOError, "Can't find a path to system files." + + self._sys_paths = paths + + filepath = os.path.join(self._subdir, filename) + paths = (os.path.join(p, filepath) for p in self._sys_paths) try: - path = env['M5_PATH'].split(':') - except KeyError: - path = [ '/dist/m5/system', '/n/poolfs/z/dist/m5/system' ] + return next(p for p in paths if os.path.exists(p)) + except StopIteration: + raise IOError, "Can't find file '%s' on path." % filename - # expand '~' and '~user' in paths - path = map(os.path.expanduser, path) - - # filter out non-existent directories - system.path = filter(os.path.isdir, path) - - if not system.path: - raise IOError, "Can't find a path to system files." - - if not binary.path: - binary.path = [joinpath(p, 'binaries') for p in system.path] - if not disk.path: - disk.path = [joinpath(p, 'disks') for p in system.path] - if not script.path: - script.path = [joinpath(config_root, 'boot')] - -system.path = None -binary.path = None -disk.path = None -script.path = None +disk = PathSearchFunc('disks') +binary = PathSearchFunc('binaries') +script = PathSearchFunc('boot') -- To view, visit https://gem5-review.googlesource.com/5341 To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings Gerrit-Project: public/gem5 Gerrit-Branch: master Gerrit-MessageType: merged Gerrit-Change-Id: I7be28e51481a06ec83997677af99927709b18003 Gerrit-Change-Number: 5341 Gerrit-PatchSet: 2 Gerrit-Owner: Gabe Black <gabebl...@google.com> Gerrit-Assignee: Andreas Sandberg <andreas.sandb...@arm.com> Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com> Gerrit-Reviewer: Gabe Black <gabebl...@google.com> _______________________________________________ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. _______________________________________________ gem5-dev mailing list gem5-dev@gem5.org http://m5sim.org/mailman/listinfo/gem5-dev