An ode to Windows 3.1 Hot Dog Stand - Pebble watchface
at master 62 lines 2.0 kB view raw
1 2 # 3# This file is the default set of rules to compile a Pebble project. 4# 5# Feel free to customize this to your needs. 6# 7 8import os.path 9try: 10 from sh import CommandNotFound, jshint, cat, ErrorReturnCode_2 11 hint = jshint 12except (ImportError, CommandNotFound): 13 hint = None 14 15top = '.' 16out = 'build' 17 18def options(ctx): 19 ctx.load('pebble_sdk') 20 21def configure(ctx): 22 ctx.load('pebble_sdk') 23 24def build(ctx): 25 if False and hint is not None: 26 try: 27 hint([node.abspath() for node in ctx.path.ant_glob("src/**/*.js")], _tty_out=False) # no tty because there are none in the cloudpebble sandbox. 28 except ErrorReturnCode_2 as e: 29 ctx.fatal("\nJavaScript linting failed (you can disable this in Project Settings):\n" + e.stdout) 30 31 # Concatenate all our JS files (but not recursively), and only if any JS exists in the first place. 32 ctx.path.make_node('src/js/').mkdir() 33 js_paths = ctx.path.ant_glob(['src/*.js', 'src/**/*.js']) 34 if js_paths: 35 ctx(rule='cat ${SRC} > ${TGT}', source=js_paths, target='pebble-js-app.js') 36 has_js = True 37 else: 38 has_js = False 39 40 ctx.load('pebble_sdk') 41 42 build_worker = os.path.exists('worker_src') 43 binaries = [] 44 45 for p in ctx.env.TARGET_PLATFORMS: 46 ctx.set_env(ctx.all_envs[p]) 47 ctx.set_group(ctx.env.PLATFORM_NAME) 48 app_elf='{}/pebble-app.elf'.format(p) 49 ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'), 50 target=app_elf) 51 52 if build_worker: 53 worker_elf='{}/pebble-worker.elf'.format(p) 54 binaries.append({'platform': p, 'app_elf': app_elf, 'worker_elf': worker_elf}) 55 ctx.pbl_worker(source=ctx.path.ant_glob('worker_src/**/*.c'), 56 target=worker_elf) 57 else: 58 binaries.append({'platform': p, 'app_elf': app_elf}) 59 60 ctx.set_group('bundle') 61 ctx.pbl_bundle(binaries=binaries, js='pebble-js-app.js' if has_js else []) 62