userland: allow selecting targets, including directories

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-03-13 00:00:02 +00:00
parent cbf6481c4b
commit 276688bb33
7 changed files with 91 additions and 71 deletions

View File

@@ -30,10 +30,12 @@ allows us to build examples that rely on it.
'targets', 'targets',
default=[], default=[],
help='''\ help='''\
Build only the given userland programs. Build only the given userland programs or all programs in the given directories.
Default: build all examples that have their package dependencies met.
For example, an OpenBLAS example can only be built if the target root filesystem Default: build all examples that have their package dependencies met, e.g.:
has the OpenBLAS libraries and headers installed. - userland/arch/ programs only build if the target arch matches
- an OpenBLAS example can only be built if the target root filesystem
has the OpenBLAS libraries and headers installed, which you must inform with --has-package
''', ''',
nargs='*', nargs='*',
) )
@@ -90,7 +92,7 @@ has the OpenBLAS libraries and headers installed.
'-o', out_path, LF, '-o', out_path, LF,
in_path, LF, in_path, LF,
] + ] +
extra_objs + self.sh.add_newlines(extra_objs) +
[ [
'-lm', LF, '-lm', LF,
'-pthread', LF, '-pthread', LF,
@@ -160,9 +162,15 @@ has the OpenBLAS libraries and headers installed.
rootdir_abs_len = len(self.env['userland_source_dir']) rootdir_abs_len = len(self.env['userland_source_dir'])
thread_limiter = threading.BoundedSemaphore(self.env['nproc']) thread_limiter = threading.BoundedSemaphore(self.env['nproc'])
self.error = False self.error = False
for path, in_dirnames, in_filenames in os.walk(self.env['userland_source_dir']): if self.env['_args_given']['targets']:
targets = self.env['targets']
else:
targets = [self.env['userland_source_dir']]
for target in targets:
for path, in_dirnames, in_filenames in self.sh.walk(target):
in_dirnames.sort() in_dirnames.sort()
dirpath_relative_root = path[rootdir_abs_len + 1:] path_abs = os.path.abspath(path)
dirpath_relative_root = path_abs[rootdir_abs_len + 1:]
dirpath_relative_root_components = dirpath_relative_root.split(os.sep) dirpath_relative_root_components = dirpath_relative_root.split(os.sep)
if ( if (
len(dirpath_relative_root_components) < 2 or len(dirpath_relative_root_components) < 2 or

View File

@@ -1169,7 +1169,10 @@ class BuildCliFunction(LkmcCliFunction):
self.add_argument( self.add_argument(
'--force-rebuild', '--force-rebuild',
default=False, default=False,
help="Force rebuild even if sources didn't chage", help='''\
Force rebuild even if sources didn't chage.
TODO: not yet implemented on all scripts.
'''
) )
self.add_argument( self.add_argument(
'-j', '-j',

View File

@@ -310,6 +310,19 @@ class ShellHelpers:
else: else:
os.unlink(path) os.unlink(path)
def walk(self, root):
'''
Extended walk that can take files or directories.
'''
if not os.path.exists(root):
raise Exception('Path does not exist: ' + root)
if os.path.isfile(root):
dirname, basename = os.path.split(root)
yield dirname, [], [basename]
else:
for path, dirnames, filenames in os.walk(root):
yield path, dirnames, filenames
def wget(self, url, download_path): def wget(self, url, download_path):
''' '''
Append extra KEY=val configs into the given config file. Append extra KEY=val configs into the given config file.

View File

@@ -1 +0,0 @@
../../Makefile

View File

@@ -1 +0,0 @@
COMMON_DIR = ../../..

View File

@@ -1 +0,0 @@
../../Makefile

View File

@@ -1 +0,0 @@
COMMON_DIR = ../../..