Louis authored on25/07/2018 21:41:41
Showing1 changed files
1 1
new file mode 100755
... ...
@@ -0,0 +1,52 @@
1
+#
2
+# This file is the default set of rules to compile a Pebble project.
3
+#
4
+# Feel free to customize this to your needs.
5
+#
6
+
7
+import os.path
8
+try:
9
+    from sh import CommandNotFound, jshint, cat, ErrorReturnCode_2
10
+    hint = jshint
11
+except (ImportError, CommandNotFound):
12
+    hint = None
13
+
14
+top = '.'
15
+out = 'build'
16
+
17
+
18
+def options(ctx):
19
+    ctx.load('pebble_sdk')
20
+
21
+
22
+def configure(ctx):
23
+    ctx.load('pebble_sdk')
24
+
25
+
26
+def build(ctx):
27
+    if False and hint is not None:
28
+        try:
29
+            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.
30
+        except ErrorReturnCode_2 as e:
31
+            ctx.fatal("\nJavaScript linting failed (you can disable this in Project Settings):\n" + e.stdout)
32
+
33
+    ctx.load('pebble_sdk')
34
+
35
+    build_worker = os.path.exists('worker_src')
36
+    binaries = []
37
+
38
+    for p in ctx.env.TARGET_PLATFORMS:
39
+        ctx.set_env(ctx.all_envs[p])
40
+        ctx.set_group(ctx.env.PLATFORM_NAME)
41
+        app_elf = '{}/pebble-app.elf'.format(ctx.env.BUILD_DIR)
42
+        ctx.pbl_program(source=ctx.path.ant_glob('src/c/**/*.c'), target=app_elf)
43
+
44
+        if build_worker:
45
+            worker_elf = '{}/pebble-worker.elf'.format(ctx.env.BUILD_DIR)
46
+            binaries.append({'platform': p, 'app_elf': app_elf, 'worker_elf': worker_elf})
47
+            ctx.pbl_worker(source=ctx.path.ant_glob('worker_src/c/**/*.c'), target=worker_elf)
48
+        else:
49
+            binaries.append({'platform': p, 'app_elf': app_elf})
50
+
51
+    ctx.set_group('bundle')
52
+    ctx.pbl_bundle(binaries=binaries, js=ctx.path.ant_glob(['src/pkjs/**/*.js', 'src/pkjs/**/*.json']), js_entry_file='src/pkjs/app.js')