From d63330e4b046320c79859346fcf8fb5c3d2f1bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krystian=20Bac=C5=82awski?= Date: Sat, 22 Aug 2015 13:58:23 +0200 Subject: [PATCH] Some cleanups. --- build-ppc.py | 114 +++++++++++++++++++++++---------------------------- common.py | 7 ++-- 2 files changed, 54 insertions(+), 67 deletions(-) diff --git a/build-ppc.py b/build-ppc.py index 9098e2b..ca116d0 100755 --- a/build-ppc.py +++ b/build-ppc.py @@ -88,79 +88,71 @@ def doit(): name = path.basename(url) fetch(name, url) - lha = VARS['lha'] - source(lha, copy=path.join('{build}', lha)) - configure(lha, + source('{lha}', copy=path.join('{build}', '{lha}')) + configure('{lha}', '--disable-shared', '--prefix={host}') - build(lha) - install(lha) + build('{lha}') + install('{lha}') - gmp = VARS['gmp'] - source(gmp) - configure(gmp, + source('{gmp}') + configure('{gmp}', '--disable-shared', '--prefix={host}') - build(gmp) - install(gmp) + build('{gmp}') + install('{gmp}') - mpfr = VARS['mpfr'] - source(mpfr) - configure(mpfr, + source('{mpfr}') + configure('{mpfr}', '--disable-shared', '--prefix={host}', '--with-gmp={host}') - build(mpfr) - install(mpfr) + build('{mpfr}') + install('{mpfr}') - mpc = VARS['mpc'] - source(mpc) - configure(mpc, + source('{mpc}') + configure('{mpc}', '--disable-shared', '--prefix={host}', '--with-gmp={host}', '--with-mpfr={host}') - build(mpc) - install(mpc) + build('{mpc}') + install('{mpc}') - isl = VARS['isl'] - source(isl) - configure(isl, + source('{isl}') + configure('{isl}', '--disable-shared', '--prefix={host}', '--with-gmp-prefix={host}') - build(isl) - install(isl) + build('{isl}') + install('{isl}') - cloog = VARS['cloog'] - source(cloog) - configure(cloog, + source('{cloog}') + configure('{cloog}', '--disable-shared', '--prefix={host}', '--with-isl=system', '--with-gmp-prefix={host}', '--with-isl-prefix={host}') - build(cloog) - install(cloog) + build('{cloog}') + install('{cloog}') - binutils = VARS['binutils'] binutils_env = {} if cmpver('eq', '{binutils_ver}', '2.18'): binutils_env.update(CFLAGS='-Wno-error') elif cmpver('eq', '{binutils_ver}', '2.23.2'): binutils_env.update(CFLAGS='-Wno-error') - source(binutils) + source('{binutils}') with env(**binutils_env): - configure(binutils, + configure('{binutils}', '--prefix={target}', '--target=ppc-amigaos') - build(binutils) - install(binutils) + build('{binutils}') + install('{binutils}') prepare_sdk() - gcc = VARS['gcc'] gcc_env = {} if cmpver('eq', '{gcc_ver}', '4.2.4'): cflags = ['-std=gnu89'] @@ -168,9 +160,9 @@ def doit(): cflags.append('-m32') gcc_env.update(CFLAGS=' '.join(cflags)) - source(gcc) + source('{gcc}') with env(**gcc_env): - configure(gcc, + configure('{gcc}', '--with-bugurl="http://sf.net/p/adtools"', '--target=ppc-amigaos', '--with-gmp={host}', @@ -182,8 +174,8 @@ def doit(): '--enable-sjlj-exceptions' '--disable-libstdcxx-pch' '--disable-tls') - build(gcc) - install(gcc) + build('{gcc}') + install('{gcc}') def clean(): @@ -213,32 +205,28 @@ if __name__ == "__main__": if platform.machine() not in ['i386', 'i686', 'x86_64']: panic('Build on %s architecture not supported!', platform.machine()) - VARS.update({ - 'top': path.abspath('.'), - 'binutils_ver': args.binutils, - 'gcc_ver': args.gcc - }) + setvar(top=path.abspath('.'), + binutils_ver=args.binutils, + gcc_ver=args.gcc) - VARS.update({ - 'lha': 'lhasa-0.3.0', - 'gmp': 'gmp-5.1.3', - 'mpfr': 'mpfr-3.1.3', - 'mpc': 'mpc-1.0.3', - 'isl': 'isl-0.12.2', - 'cloog': 'cloog-0.18.4', - 'binutils': 'binutils-{binutils_ver}', - 'gcc': 'gcc-{gcc_ver}', - 'patches': path.join('{top}', 'patches'), - 'stamps': path.join('{top}', 'stamps'), - 'build': path.join('{top}', 'build'), - 'sources': path.join('{top}', 'sources'), - 'host': path.join('{top}', 'host'), - 'target': path.join('{top}', 'target'), - 'archives': path.join('{top}', 'archives', 'ppc'), - }) + setvar(lha='lhasa-0.3.0', + gmp='gmp-5.1.3', + mpfr='mpfr-3.1.3', + mpc='mpc-1.0.3', + isl='isl-0.12.2', + cloog='cloog-0.18.4', + binutils='binutils-{binutils_ver}', + gcc='gcc-{gcc_ver}', + patches=path.join('{top}', 'patches'), + stamps=path.join('{top}', 'stamps'), + build=path.join('{top}', 'build'), + sources=path.join('{top}', 'sources'), + host=path.join('{top}', 'host'), + target=path.join('{top}', 'target'), + archives=path.join('{top}', 'archives', 'ppc')) if args.prefix is not None: - VARS['target'] = args.prefix + setvar(target=args.prefix) if not path.exists('{target}'): mkdir('{target}') diff --git a/common.py b/common.py index 2b552ea..236d2b4 100644 --- a/common.py +++ b/common.py @@ -16,11 +16,10 @@ import zipfile VARS = {} +setvar = VARS.update def fill_in(value): - global VARS - if type(value) == str: return value.format(**VARS) return value @@ -249,7 +248,7 @@ def check_stamp(fn): def wrapper(*args, **kwargs): name = fn.func_name.replace('_', '-') if len(args) > 0: - name = name + "-" + str(args[0]) + name = name + "-" + str(fill_in(args[0])) stamp = path.join('{stamps}', name) if not path.exists('{stamps}'): mkdir('{stamps}') @@ -324,7 +323,7 @@ def install(name, *confopts): execute('make', 'install') -__all__ = ['VARS', 'panic', 'cmpver', 'find_executable', 'execute', +__all__ = ['setvar', 'panic', 'cmpver', 'find_executable', 'execute', 'rmtree', 'mkdir', 'copytree', 'unarc', 'fetch', 'cwd', 'remove', 'rename', 'find_files', 'env', 'path', 'check_stamp', 'source', 'configure', 'build', 'install']