From 118df1d952cddea78110700bdc47123c88e79179 Mon Sep 17 00:00:00 2001 From: Keegan Date: Tue, 14 Jun 2016 16:54:48 -0700 Subject: [PATCH] Make Clay a Pebble package --- .gitignore | 30 +++++++----------------------- .npmignore | 4 ++++ gulpfile.js | 4 ++-- package.json | 24 +++++++++++++++++++----- wscript | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+), 30 deletions(-) create mode 100755 .npmignore create mode 100644 wscript diff --git a/.gitignore b/.gitignore index e47e939..d301e89 100755 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,15 @@ -# Logs -logs -*.log - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - # Coverage directory used by tools like istanbul -coverage - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt +/coverage # node-waf configuration .lock-wscript - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release +/.lock-waf_darwin_build # Dependency directory # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git -node_modules +/node_modules -tmp - -dist +/tmp/ +/src/js/index.js +/dist.zip +/build/ diff --git a/.npmignore b/.npmignore new file mode 100755 index 0000000..2c33b4e --- /dev/null +++ b/.npmignore @@ -0,0 +1,4 @@ +# We ignore everying except for what is actually used by the pebble tool. +/**/* +!/dist.zip +!/src/js/index.js diff --git a/gulpfile.js b/gulpfile.js index 3bd50d7..80cec06 100755 --- a/gulpfile.js +++ b/gulpfile.js @@ -92,13 +92,13 @@ gulp.task('clay', ['inlineHtml'], function() { .transform(autoprefixify, autoprefixerOptions) .require(require.resolve('./index'), {expose: 'pebble-clay'}) .bundle() - .pipe(source('clay.js')) + .pipe(source('index.js')) .pipe(buffer()) .pipe(uglify({ preserveComments: 'license' })) .pipe(insert.prepend(versionMessage)) - .pipe(gulp.dest('./dist/')); + .pipe(gulp.dest('./src/js')); }); gulp.task('dev-js', ['js', 'sass'], function() { diff --git a/package.json b/package.json index 85b7d38..360c332 100644 --- a/package.json +++ b/package.json @@ -2,17 +2,17 @@ "name": "pebble-clay", "version": "0.1.7", "description": "Pebble Config Framework", - "main": "dist/clay.js", - "directories": { - "example": "example" - }, + "main": "src/js/index.js", "scripts": { "test-travis": "./node_modules/.bin/gulp && ./node_modules/.bin/karma start ./test/karma.conf.js --single-run --browsers chromeTravisCI && ./node_modules/.bin/eslint ./", "test-debug": "(export DEBUG=true && ./node_modules/.bin/gulp && ./node_modules/.bin/karma start ./test/karma.conf.js --no-single-run)", "test": "./node_modules/.bin/gulp && ./node_modules/.bin/karma start ./test/karma.conf.js --single-run", "lint": "./node_modules/.bin/eslint ./", "build": "gulp", - "dev": "gulp dev" + "dev": "gulp dev", + "pebble-clean": "rm -rf tmp src/js/index.js && pebble clean", + "pebble-publish": "npm run pebble-clean && npm run build && pebble build && pebble package publish && npm run pebble-clean", + "pebble-build": "npm run build && pebble build" }, "repository": { "type": "git", @@ -27,6 +27,20 @@ "bugs": { "url": "https://github.com/pebble/clay/issues" }, + "pebble": { + "projectType": "package", + "sdkVersion": "3", + "targetPlatforms": [ + "aplite", + "basalt", + "chalk", + "diorite", + "emery" + ], + "resources": { + "media": [] + } + }, "homepage": "https://github.com/pebble/clay#readme", "devDependencies": { "autoprefixer": "^6.3.1", diff --git a/wscript b/wscript new file mode 100644 index 0000000..f5f986e --- /dev/null +++ b/wscript @@ -0,0 +1,48 @@ +# +# This file is the default set of rules to compile a Pebble project. +# +# Feel free to customize this to your needs. +# +import os +import shutil +import waflib + +top = '.' +out = 'build' + + +def distclean(ctx): + if os.path.exists('dist.zip'): + os.remove('dist.zip') + if os.path.exists('dist'): + shutil.rmtree('dist') + waflib.Scripting.distclean(ctx) + + +def options(ctx): + ctx.load('pebble_sdk_lib') + + +def configure(ctx): + ctx.load('pebble_sdk_lib') + + +def build(ctx): + ctx.load('pebble_sdk_lib') + + cached_env = ctx.env + for platform in ctx.env.TARGET_PLATFORMS: + ctx.env = ctx.all_envs[platform] + ctx.set_group(ctx.env.PLATFORM_NAME) + lib_name = '{}/{}'.format(ctx.env.BUILD_DIR, ctx.env.PROJECT_INFO['name']) + ctx.pbl_build(source=ctx.path.ant_glob('src/c/**/*.c'), target=lib_name, bin_type='lib') + ctx.env = cached_env + + ctx.set_group('bundle') + ctx.pbl_bundle(includes=ctx.path.ant_glob('include/**/*.h'), + js=ctx.path.ant_glob(['src/js/**/*.js', 'src/js/**/*.json']), + bin_type='lib') + + if ctx.cmd == 'clean': + for n in ctx.path.ant_glob(['dist/**/*', 'dist.zip'], quiet=True): + n.delete()