1+ #
2+ # This file is the default set of rules to compile a Pebble application.
3+ #
4+ # Feel free to customize this to your needs.
5+ #
6+ import os .path
7+
18top = '.'
29out = 'build'
310
@@ -7,21 +14,36 @@ def options(ctx):
714
815
916def configure (ctx ):
17+ """
18+ This method is used to configure your build.
19+ ctx.load(`pebble_sdk`) automatically configures a build for each valid platform in `targetPlatforms`.
20+ Platform-specific configuration: add your change after calling ctx.load('pebble_sdk') and make sure to set the
21+ correct environment first.
22+ Universal configuration: add your change prior to calling ctx.load('pebble_sdk').
23+ """
1024 ctx .load ('pebble_sdk' )
1125
1226
1327def build (ctx ):
1428 ctx .load ('pebble_sdk' )
1529
30+ build_worker = os .path .exists ('worker_src' )
1631 binaries = []
17- for p in ctx .env .TARGET_PLATFORMS :
18- ctx .set_env (ctx .all_envs [p ])
32+
33+ cached_env = ctx .env
34+ for platform in ctx .env .TARGET_PLATFORMS :
35+ ctx .env = ctx .all_envs [platform ]
1936 ctx .set_group (ctx .env .PLATFORM_NAME )
2037 app_elf = '{}/pebble-app.elf' .format (ctx .env .BUILD_DIR )
21- ctx .pbl_program (source = ctx .path .ant_glob ('src/**/*.c' ) + ctx .path .find_node ('..' ).ant_glob ('src/**/*.c' ),
22- includes = [ctx .path .find_node ('../include' )],
23- target = app_elf )
24- binaries .append ({'platform' : p , 'app_elf' : app_elf })
38+ ctx .pbl_program (source = ctx .path .ant_glob ('src/**/*.c' ), target = app_elf )
39+
40+ if build_worker :
41+ worker_elf = '{}/pebble-worker.elf' .format (ctx .env .BUILD_DIR )
42+ binaries .append ({'platform' : p , 'app_elf' : app_elf , 'worker_elf' : worker_elf })
43+ ctx .pbl_worker (source = ctx .path .ant_glob ('worker_src/**/*.c' ), target = worker_elf )
44+ else :
45+ binaries .append ({'platform' : platform , 'app_elf' : app_elf })
46+ ctx .env = cached_env
2547
2648 ctx .set_group ('bundle' )
27- ctx .pbl_bundle (binaries = binaries , js = ctx .path .ant_glob ('src/js/**/*.js' ) )
49+ ctx .pbl_bundle (binaries = binaries , js = ctx .path .ant_glob ([ 'src/js/**/*.js' , 'src/js/**/*.json' , 'package.json' ]), js_entry_file = 'src/js/app.js' )
0 commit comments