summaryrefslogtreecommitdiff
path: root/ybd.py
diff options
context:
space:
mode:
authorPaul Sherwood <paul.sherwood@codethink.co.uk>2015-06-21 03:31:54 +0000
committerPaul Sherwood <paul.sherwood@codethink.co.uk>2015-06-21 03:31:54 +0000
commite1174259d75a58d0939f445d56187c90293b428a (patch)
tree4d4816096228a62d50b71d53db986ac1a7fb39c3 /ybd.py
parent5fdebbad3c6b6f0b7440aa06693c45b0abbc0f16 (diff)
downloadybd-e1174259d75a58d0939f445d56187c90293b428a.tar.gz
Re-work app.setup - sys.argv goes there, no context-manager
Diffstat (limited to 'ybd.py')
-rwxr-xr-xybd.py50
1 files changed, 17 insertions, 33 deletions
diff --git a/ybd.py b/ybd.py
index 62439eb..509d477 100755
--- a/ybd.py
+++ b/ybd.py
@@ -27,41 +27,25 @@ import app
from assembly import assemble, deploy
from definitions import Definitions
import cache
-import platform
import sandbox
print('')
-if len(sys.argv) not in [2, 3]:
- sys.stderr.write("Usage: %s DEFINITION_FILE [ARCH]\n\n" % sys.argv[0])
- sys.exit(1)
-target = sys.argv[1]
-if len(sys.argv) == 3:
- arch = sys.argv[2]
-else:
- arch = platform.machine()
- if arch in ('mips', 'mips64'):
- if arch == 'mips':
- arch = 'mips32'
- if sys.byteorder == 'big':
- arch = arch + 'b'
- else:
- arch = arch + 'l'
-
-with app.setup(target, arch):
- with app.timer('TOTAL', 'ybd starts, version %s' %
- app.settings['ybd-version']):
- app.log('TARGET', 'Target is %s' % os.path.join(app.settings['defdir'],
- target), arch)
- with app.timer('DEFINITIONS', 'Parsing %s' % app.settings['def-ver']):
- defs = Definitions()
- with app.timer('CACHE-KEYS', 'Calculating'):
- cache.get_cache(defs, app.settings['target'])
- defs.save_trees()
-
- sandbox.executor = sandboxlib.executor_for_platform()
- app.log(target, 'Using %s for sandboxing' % sandbox.executor)
-
- assemble(defs, app.settings['target'])
- deploy(defs, app.settings['target'])
+app.setup(sys.argv)
+with app.timer('TOTAL', '%s starts, version %s' % (app.settings['program'],
+ app.settings['program-version'])):
+ app.log('TARGET', 'Target is %s' % os.path.join(app.settings['defdir'],
+ app.settings['target']),
+ app.settings['arch'])
+ with app.timer('DEFINITIONS', 'Parsing %s' % app.settings['def-version']):
+ defs = Definitions()
+ with app.timer('CACHE-KEYS', 'Calculating'):
+ cache.get_cache(defs, app.settings['target'])
+ defs.save_trees()
+
+ sandbox.executor = sandboxlib.executor_for_platform()
+ app.log(app.settings['target'], 'Sandbox using %s' % sandbox.executor)
+
+ assemble(defs, app.settings['target'])
+ deploy(defs, app.settings['target'])