Skip to content

Instantly share code, notes, and snippets.

@stpe
Created January 21, 2014 09:30
Show Gist options
  • Save stpe/8537053 to your computer and use it in GitHub Desktop.
Save stpe/8537053 to your computer and use it in GitHub Desktop.
Modified Pebble wscript file. Read appinfo.json and generates appinfo.h which contain a define for VERSION_LABEL. http://forums.getpebble.com/discussion/10405/how-do-i-get-my-app-version-in-c-code
import json
top = '.'
out = 'build'
def options(ctx):
ctx.load('pebble_sdk')
def configure(ctx):
ctx.load('pebble_sdk')
def build(ctx):
ctx.load('pebble_sdk')
def generate_appinfo(task):
src = task.inputs[0].abspath()
tgt = task.outputs[0].abspath()
json_data=open(src)
data = json.load(json_data)
f = open(tgt,'w')
f.write('#ifndef appinfo_h\n')
f.write('#define appinfo_h\n')
f.write('#define VERSION_LABEL "' + data["versionLabel"] + '"\n')
f.write('#endif\n')
f.close()
ctx(
rule = generate_appinfo,
source = 'appinfo.json',
target = 'generated/appinfo.h',
)
ctx.pbl_program(source=ctx.path.ant_glob(['src/**/*.c','generated/**/*.c']),
includes='generated',
target='pebble-app.elf')
ctx.pbl_bundle(elf='pebble-app.elf',
js=ctx.path.ant_glob('src/js/**/*.js'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment