From 8f19190db2060f70f42d9413c0ebd78a5b13faf1 Mon Sep 17 00:00:00 2001 From: bebbo Date: Wed, 22 Mar 2017 16:07:34 +0100 Subject: [PATCH] @N added xbuild - to build without updateing, also build checks now for changes and rebuilds submodules --- common.py | 52 +++++++++++++++++++++++++++++--------------------- toolchain-m68k | 41 ++++++++++++++++++++++++++++++++++----- 2 files changed, 66 insertions(+), 27 deletions(-) diff --git a/common.py b/common.py index 395f3fd..ee5fbfc 100644 --- a/common.py +++ b/common.py @@ -345,37 +345,16 @@ def recipe(name, nargs=0): def wrapper(*args, **kwargs): target = [str(arg) for arg in args[:min(nargs, len(args))]] if len(target) > 0: - mtarget = target[0] target = [target[0], fill_in(name)] + target[1:] target = '-'.join(target) else: target = fill_in(name) - mtarget = target target = target.replace('_', '-') target = target.replace('/', '-') stamp = path.join('{stamps}', target) if not path.exists('{stamps}'): mkdir('{stamps}') - - if name == 'make' and path.exists(stamp): - mfile = '' - mmax = 0 - for root, dirs, files in os.walk('submodules/' + mtarget): - for filename in files: - mf = os.path.join(root, filename) - mt = os.stat(mf).st_mtime - if mt > mmax: - mfile = mf - mmax = mt - if mmax > os.stat(stamp).st_mtime: - mstamp = path.join('{stamps}', mtarget + '-make*') - info('removing stamp for "%s"\n\tcaused by "%s" %s' - '\n\tstamp is "%s" %s', mstamp, mfile, datetime.datetime.fromtimestamp(mmax), - stamp, datetime.datetime.fromtimestamp(os.stat(stamp).st_mtime)) - for f in glob(mstamp): - remove(f) - if not path.exists(stamp): fn(*args, **kwargs) touch(stamp) @@ -443,6 +422,34 @@ def unpack(name, work_dir='{sources}', top_dir=None, dst_dir=None): copytree(path.join(tmpdir, top_dir or name), dst) rmtree(tmpdir) +def removemodule(name): + mbuild = path.join('{build}', name) + info('removing build for module %s : "%s"', name, mbuild) + + mstamp = path.join('{stamps}', name + '-*') + for f in glob(mstamp): + remove(f) + + rmtree(mbuild) + +def checkstamps(name): + target = fill_in(name) + target = target.replace('_', '-') + target = target.replace('/', '-') + "-make" + stamp = path.join('{stamps}', target) + info('checking %s with %s', name, stamp) + mtime = 0 + if path.exists(stamp): + mtime = os.stat(stamp).st_mtime + + submodule = path.join('submodules/', name) + for root, dirs, files in os.walk(submodule): + for filename in files: + mf = os.path.join(root, filename) + mt = os.stat(mf).st_mtime + if mt > mtime: + return True + return False @recipe('patch', 1) def patch(name, work_dir='{sources}'): @@ -523,4 +530,5 @@ __all__ = ['setvar', 'panic', 'cmpver', 'find_executable', 'chmod', 'execute', 'rmtree', 'mkdir', 'copy', 'copytree', 'unarc', 'fetch', 'cwd', 'symlink', 'remove', 'move', 'find', 'textfile', 'env', 'path', 'add_site_dir', 'find_site_dir', 'python_setup', 'recipe', - 'unpack', 'patch', 'configure', 'make', 'require_header', 'touch'] + 'unpack', 'patch', 'configure', 'make', 'require_header', 'touch', + 'checkstamps', 'removemodule'] diff --git a/toolchain-m68k b/toolchain-m68k index a04d613..30d523a 100755 --- a/toolchain-m68k +++ b/toolchain-m68k @@ -232,6 +232,12 @@ def update(): execute('git', 'submodule', 'update'); def build(): + _build(True) + +def xbuild(): + _build(False) + +def _build(pull): for var in environ.keys(): if var not in ['_', 'LOGNAME', 'HOME', 'SHELL', 'TMPDIR', 'PWD']: del environ[var] @@ -245,8 +251,9 @@ def build(): environ['LANG'] = 'C' environ['TERM'] = 'xterm' - download() - update() + if pull: + download() + update() add_site_dir('{host}') @@ -275,6 +282,29 @@ def build(): required programs, headers and libraries are present. """ + if checkstamps('{binutils}'): + checkstamps('{binutils}') + + if checkstamps('{gcc}'): + removemodule('{libnix}') + removemodule('{clib2}') + removemodule('{libdebug}') + removemodule('{libm}') + + if checkstamps('{libnix}'): + checkstamps('{libnix}') + + if checkstamps('{clib2}'): + checkstamps('{clib2}') + + if checkstamps('{libdebug}'): + checkstamps('{libdebug}') + + if checkstamps('{libm}'): + checkstamps('{libm}') + + + find_executable('perl') find_executable('pod2text') find_executable('pod2man') @@ -381,7 +411,7 @@ def build(): config.guess script knows nothing about x86-64 or darwin. """ - with env(CC=CC, CXX=CXX, CFLAGS='-g -Wall', CXXFLAGS='-g -Wall'): + with env(CC=CC, CXX=CXX, CFLAGS='-g -Os -Wall', CXXFLAGS='-g -Os -Wall'): configure('{binutils}', '--prefix={target}', '--host=i686-linux-gnu', @@ -664,7 +694,8 @@ def test(): def help(): print ('\n' - 'build: build the tool chain (use --threads n to speed up the build)\n' + 'build: download, update and build the tool chain (use --threads n to speed up the build)\n' + 'xbuild: build the tool chain (use --threads n to speed up the build)\n' 'clean: remove the build artifacts\n' 'update: updates the submodules using git\n' 'download: download the archives\n' @@ -688,7 +719,7 @@ if __name__ == "__main__": parser = argparse.ArgumentParser(description='Build cross toolchain.') parser.add_argument('action', - choices=['help', 'build', 'list-sdk', 'install-sdk', 'clean', + choices=['help', 'build', 'xbuild', 'list-sdk', 'install-sdk', 'clean', 'test', 'update', 'download'], default='build', help='perform an action') parser.add_argument('args', metavar='ARGS', type=str, nargs='*',