diff --git a/android/templates/module/default/hooks/android-module.js b/android/templates/module/default/hooks/android-module.js new file mode 100644 index 00000000000..c0e4e071135 --- /dev/null +++ b/android/templates/module/default/hooks/android-module.js @@ -0,0 +1,107 @@ +/** + * @overview + * Hook that performa Android specific functions when creating an Android module. + * + * @copyright + * Copyright (c) 2014 by Appcelerator, Inc. All Rights Reserved. + * + * @license + * Licensed under the terms of the Apache Public License + * Please see the LICENSE included with this distribution for details. + */ + +var fs = require('fs'), + path = require('path'), + wrench = require('wrench'); + +exports.cliVersion = '>=3.2'; + +exports.init = function (logger, config, cli, appc) { + var __ = appc.i18n(__dirname).__; + + cli.on('create.copyFiles.platform.android', { + pre: function (data, callback) { + // create the build/.apt_generated directory + var aptgenDir = path.join(this.projectDir, 'android', 'build', '.apt_generated'); + fs.existsSync(aptgenDir) || wrench.mkdirSyncRecursive(aptgenDir); + + // determine the minimum supported Android SDK version + var packageJsonFile = (function scan(dir) { + var file = path.join(dir, 'package.json'); + if (fs.existsSync(file)) { + return file; + } + dir = path.dirname(dir); + return dir != '/' && scan(dir); + }(__dirname)), + packageJson = require(packageJsonFile), + minAndroidAPILevel = parseInt(appc.version.parseMin(packageJson.vendorDependencies['android sdk'])); + + var android = require('titanium-sdk/lib/android'); + logger.debug(__('Detecting Android environment...')); + android.detect(this.config, null, function (results) { + // find all targets that satisify the minimum supported Android SDK, prefer versions with Google APIs + var apis = {}; + Object.keys(results.targets).forEach(function (idx) { + var target = results.targets[idx], + apiLevel = target['based-on'] && target['based-on']['api-level'] ? ~~target['based-on']['api-level'] : ~~target['api-level'], + gapi = target.type == 'add-on' && /google/i.test(target.name); + + if (apiLevel >= minAndroidAPILevel && (target.type == 'platform' || gapi)) { + apis[apiLevel] || (apis[apiLevel] = {}); + if (typeof apis[apiLevel].idx == 'undefined' || gapi) { + apis[apiLevel].idx = idx; + } + + if (gapi) { + apis[apiLevel].googleAPIPath = target.path; + } else { + apis[apiLevel].platformPath = target.path; + } + } + }); + + var libs = [], + targetAPILevel = Object.keys(apis).sort().shift(), + api = targetAPILevel && apis[targetAPILevel], + target = api && results.targets[api.idx]; + + // add the android.jar + if (target && target.androidJar) { + libs.push(target.androidJar); + } + + // add the maps.jar if we have Google APIs + if (target && target.libraries && target.libraries['com.google.android.maps']) { + libs.push(path.join(target.path, 'libs', target.libraries['com.google.android.maps'].jar)); + } + + // add the Titanium specific jars + libs.push( + path.join(this.sdk.path, 'android', 'titanium.jar'), + path.join(this.sdk.path, 'android', 'kroll-common.jar'), + path.join(this.sdk.path, 'android', 'kroll-apt.jar') + ); + + // update the variables + var variables = data.args[0]; + + // build the classpath + variables.classpath = libs.map(function (lib) { + return ''; + }).join('\n\t'); + + // set the Android platform path + variables.androidPlatformPath = api && api.platformPath || ''; + + // set the Google APIs path + variables.googleAPIPath = api && api.googleAPIPath || ''; + + // set the Titanium Android platform path + variables.tisdkAndroidPath = path.join(data.args[0].tisdkPath, 'android'); + + callback(); + }.bind(this)); + } + }); +}; diff --git a/android/templates/module/default/hooks/create.js b/android/templates/module/default/hooks/create.js deleted file mode 100644 index 4a4ad89c1a7..00000000000 --- a/android/templates/module/default/hooks/create.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * @overview - * Hook that performa Android specific functions when creating an Android module. - * - * @copyright - * Copyright (c) 2014 by Appcelerator, Inc. All Rights Reserved. - * - * @license - * Licensed under the terms of the Apache Public License - * Please see the LICENSE included with this distribution for details. - */ - -var fs = require('fs'), - path = require('path'); - -exports.cliVersion = '>=3.2'; - -exports.init = function (logger, config, cli, appc) { - cli.on('create.post.module', function (creator, callback) { - var android = require('titanium-sdk/lib/android'); - android.detect(creator.config, null, function (results) { - - // do something with the results! - - callback(); - }); - }); -}; diff --git a/android/templates/module/default/template/android/.classpath.ejs b/android/templates/module/default/template/android/.classpath.ejs index 253f13f8878..6e3263e257d 100644 --- a/android/templates/module/default/template/android/.classpath.ejs +++ b/android/templates/module/default/template/android/.classpath.ejs @@ -3,6 +3,6 @@ - ___CLASSPATH_ENTRIES___ + <%- classpath %> diff --git a/android/templates/module/default/template/android/.project.ejs b/android/templates/module/default/template/android/.project.ejs index 107289ee340..6cd98dc6f8e 100644 --- a/android/templates/module/default/template/android/.project.ejs +++ b/android/templates/module/default/template/android/.project.ejs @@ -1,6 +1,6 @@ - ___PROJECTNAME___ + <%- moduleName %> diff --git a/android/templates/module/default/template/android/.settings/org.eclipse.jdt.apt.core.prefs.ejs b/android/templates/module/default/template/android/.settings/org.eclipse.jdt.apt.core.prefs.ejs new file mode 100644 index 00000000000..3747ea048ab --- /dev/null +++ b/android/templates/module/default/template/android/.settings/org.eclipse.jdt.apt.core.prefs.ejs @@ -0,0 +1,7 @@ +#Thu Sep 02 15:18:34 CDT 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.apt.aptEnabled=true +org.eclipse.jdt.apt.genSrcDir=.apt_generated +org.eclipse.jdt.apt.reconcileEnabled=true + +org.eclipse.jdt.apt.processorOptions/kroll.jsonFile=<%- moduleName %>.json diff --git a/android/templates/module/default/template/android/.settings/org.eclipse.jdt.core.prefs b/android/templates/module/default/template/android/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..2595d34c7f5 --- /dev/null +++ b/android/templates/module/default/template/android/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,3 @@ +#Thu Sep 02 15:18:34 CDT 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.processAnnotations=enabled diff --git a/android/templates/module/default/template/android/build.properties.ejs b/android/templates/module/default/template/android/build.properties.ejs index cb21fd73fe0..fee1c891430 100644 --- a/android/templates/module/default/template/android/build.properties.ejs +++ b/android/templates/module/default/template/android/build.properties.ejs @@ -1,3 +1,3 @@ -titanium.platform=__SDK_ANDROID__ -android.platform=___ANDROID_PLATFORM___ -google.apis=___GOOGLE_APIS___ \ No newline at end of file +titanium.platform=<%- tisdkAndroidPath %> +android.platform=<%- androidPlatformPath %> +google.apis=<%- googleAPIPath %> diff --git a/android/templates/module/default/template/android/build.xml.ejs b/android/templates/module/default/template/android/build.xml.ejs index 9530f8b5573..f1d3f7aa58a 100644 --- a/android/templates/module/default/template/android/build.xml.ejs +++ b/android/templates/module/default/template/android/build.xml.ejs @@ -1,10 +1,38 @@ - + - Ant build script for Titanium Android module __PROJECT_SHORT_NAME__ + Ant build script for Titanium Android module <%- moduleName %> + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android/templates/module/default/template/android/src/{{ModuleIdPaths}}/ExampleProxy.java.ejs b/android/templates/module/default/template/android/src/{{ModuleIdAsFolder}}/ExampleProxy.java.ejs similarity index 93% rename from android/templates/module/default/template/android/src/{{ModuleIdPaths}}/ExampleProxy.java.ejs rename to android/templates/module/default/template/android/src/{{ModuleIdAsFolder}}/ExampleProxy.java.ejs index 962d5e0d5b2..20ba976b394 100644 --- a/android/templates/module/default/template/android/src/{{ModuleIdPaths}}/ExampleProxy.java.ejs +++ b/android/templates/module/default/template/android/src/{{ModuleIdAsFolder}}/ExampleProxy.java.ejs @@ -6,7 +6,7 @@ * Please see the LICENSE included with this distribution for details. * */ -package __MODULE_ID__; +package <%- moduleId %>; import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollProxy; @@ -23,8 +23,8 @@ import org.appcelerator.titanium.view.TiUIView; import android.app.Activity; -// This proxy can be created by calling ___MODULE_NAME_CAMEL___.createExample({message: "hello world"}) -@Kroll.proxy(creatableInModule=___MODULE_NAME_CAMEL___Module.class) +// This proxy can be created by calling <%- moduleNameCamel %>.createExample({message: "hello world"}) +@Kroll.proxy(creatableInModule=<%- moduleNameCamel %>Module.class) public class ExampleProxy extends TiViewProxy { // Standard Debugging variables @@ -76,12 +76,12 @@ public class ExampleProxy extends TiViewProxy public void handleCreationDict(KrollDict options) { super.handleCreationDict(options); - + if (options.containsKey("message")) { Log.d(LCAT, "example created with message: " + options.get("message")); } } - + // Methods @Kroll.method public void printMessage(String message) diff --git a/android/templates/module/default/template/android/src/{{ModuleIdPaths}}/{{ModuleNameFilename}}Module.java.ejs b/android/templates/module/default/template/android/src/{{ModuleIdAsFolder}}/{{ModuleNameCamel}}Module.java.ejs similarity index 83% rename from android/templates/module/default/template/android/src/{{ModuleIdPaths}}/{{ModuleNameFilename}}Module.java.ejs rename to android/templates/module/default/template/android/src/{{ModuleIdAsFolder}}/{{ModuleNameCamel}}Module.java.ejs index 252c29de0f9..6b9ca866e5a 100644 --- a/android/templates/module/default/template/android/src/{{ModuleIdPaths}}/{{ModuleNameFilename}}Module.java.ejs +++ b/android/templates/module/default/template/android/src/{{ModuleIdAsFolder}}/{{ModuleNameCamel}}Module.java.ejs @@ -6,7 +6,7 @@ * Please see the LICENSE included with this distribution for details. * */ -package __MODULE_ID__; +package <%- moduleId %>; import org.appcelerator.kroll.KrollModule; import org.appcelerator.kroll.annotations.Kroll; @@ -16,18 +16,18 @@ import org.appcelerator.kroll.common.Log; import org.appcelerator.kroll.common.TiConfig; -@Kroll.module(name="___MODULE_NAME_CAMEL___", id="__MODULE_ID__") -public class ___MODULE_NAME_CAMEL___Module extends KrollModule +@Kroll.module(name="<%- moduleNameCamel %>", id="<%- moduleId %>") +public class <%- moduleNameCamel %>Module extends KrollModule { // Standard Debugging variables - private static final String LCAT = "___MODULE_NAME_CAMEL___Module"; + private static final String LCAT = "<%- moduleNameCamel %>Module"; private static final boolean DBG = TiConfig.LOGD; // You can define constants with @Kroll.constant, for example: // @Kroll.constant public static final String EXTERNAL_NAME = value; - - public ___MODULE_NAME_CAMEL___Module() + + public <%- moduleNameCamel %>Module() { super(); } @@ -46,7 +46,7 @@ public class ___MODULE_NAME_CAMEL___Module extends KrollModule Log.d(LCAT, "example called"); return "hello world"; } - + // Properties @Kroll.getProperty public String getExampleProp() @@ -54,8 +54,8 @@ public class ___MODULE_NAME_CAMEL___Module extends KrollModule Log.d(LCAT, "get example property"); return "hello world"; } - - + + @Kroll.setProperty public void setExampleProp(String value) { Log.d(LCAT, "set example property: " + value); diff --git a/cli/commands/create.js b/cli/commands/create.js index 64b71c21d59..8477a57abf4 100644 --- a/cli/commands/create.js +++ b/cli/commands/create.js @@ -392,7 +392,7 @@ CreateCommand.prototype.run = function run(logger, config, cli, finished) { // load the project type lib creator = new this.types[type](logger, config, cli); logger.info(__('Creating %s project', type)); -dump(cli.argv.platforms); + appc.async.series(this, [ function (next) { cli.emit([ diff --git a/cli/lib/creators/app.js b/cli/lib/creators/app.js index d39e977254a..543cd1ab6ce 100644 --- a/cli/lib/creators/app.js +++ b/cli/lib/creators/app.js @@ -170,7 +170,6 @@ AppCreator.prototype.run = function run(callback) { tasks.push(function (next) { // send the analytics - /* this.cli.addAnalyticsEvent('project.create.mobile', { dir: this.projectDir, name: this.projectName, @@ -178,15 +177,14 @@ AppCreator.prototype.run = function run(callback) { url: this.projectConfig.url, image: this.projectConfig.image, appid: this.id, - description: this.projectConfig.description, + description: '', type: 'mobile', guid: this.projectConfig.guid, version: this.projectConfig.version, copyright: this.projectConfig.copyright, - runtime: '1.0', + runtime: '1.0.0', date: (new Date()).toDateString() }); - */ next(); }); diff --git a/cli/lib/creators/module.js b/cli/lib/creators/module.js index d57151a3dda..a459e503595 100644 --- a/cli/lib/creators/module.js +++ b/cli/lib/creators/module.js @@ -84,7 +84,7 @@ ModuleCreator.prototype.run = function run(callback) { moduleName: this.projectName, // MyModule - moduleNameAsIdentifier: this.projectName.replace(/[^a-zA-Z0-9_]/g, '_').replace(/_+/g, '_').split(/[\W_]/).map(function (s) { return appc.string.capitalize(s); }).join(''), + moduleNameCamel: this.projectName.replace(/[^a-zA-Z0-9_]/g, '_').replace(/_+/g, '_').split(/[\W_]/).map(function (s) { return appc.string.capitalize(s); }).join(''), // mymodule moduleNameJSSafe: this.projectName.toLowerCase().replace(/[^a-zA-Z0-9]/g, '_').replace(/_+/g, '_'), @@ -93,10 +93,10 @@ ModuleCreator.prototype.run = function run(callback) { moduleId: this.id, // ComAppceleratorMymodule - moduleIdFilename: this.id.replace(/[\s-]/g, '_').replace(/_+/g, '_').split(/\./).map(function (s) { return s.substring(0, 1).toUpperCase() + s.substring(1); }).join(''), + moduleIdAsIdentifier: this.id.replace(/[\s-]/g, '_').replace(/_+/g, '_').split(/\./).map(function (s) { return s.substring(0, 1).toUpperCase() + s.substring(1); }).join(''), // com/appcelerator/mymodule - moduleIdPaths: this.id.replace(/\./g, path.sep) + moduleIdAsFolder: this.id.replace(/\./g, path.sep) }, tasks = [ function (next) { @@ -147,40 +147,21 @@ ModuleCreator.prototype.run = function run(callback) { }); }, this); -/* - var year = (new Date).getFullYear(); - - this.projectConfig = { - '___PROJECTNAMEASIDENTIFIER___': this.projectName.toLowerCase().split(/\./).map(function (s) { return appc.string.capitalize(s); }).join(''), - '___MODULE_NAME_CAMEL___': this.projectName.toLowerCase().split(/[\W_]/).map(function (s) { return appc.string.capitalize(s); }).join(''), - '___MODULE_ID_AS_FOLDER___': this.id.replace(/\./g, path.sep), - '___PROJECTNAME___': this.projectName.toLowerCase(), - '__MODULE_ID__': this.id, - '__PROJECT_SHORT_NAME__': this.projectName, - '__VERSION__': this.sdk.name, - '__SDK__': this.sdk.path, - '__SDK_ROOT__': this.sdk.path, - '__GUID__': - '__YEAR__': year - }; -*/ tasks.push(function (next) { // send the analytics - /* this.cli.addAnalyticsEvent('project.create.module', { dir: this.projectDir, - name: this.projectName, + name: variables.moduleName, author: variables.author, - moduleid: this.id, - description: this.projectName, + moduleid: variables.moduleId, + description: '', guid: variables.guid, - version: '1.0', - copyright: 'copyright: Copyright (c) ' + (new Date).getFullYear() + ' by ' + this.config.get('user.name', 'Your Company'), + version: '1.0.0', + copyright: 'copyright: Copyright (c) ' + variables.year + ' by ' + variables.publisher, minsdk: this.sdk.name, platforms: this.platforms.original.join(', '), date: (new Date()).toDateString() }); - */ next(); }); diff --git a/iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}Module.h.ejs b/iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}Module.h.ejs similarity index 73% rename from iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}Module.h.ejs rename to iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}Module.h.ejs index 6f4906d2c88..389ed1b13f5 100644 --- a/iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}Module.h.ejs +++ b/iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}Module.h.ejs @@ -7,7 +7,7 @@ #import "TiModule.h" -@interface <%- moduleNameAsIdentifier %>Module : TiModule +@interface <%- moduleIdAsIdentifier %>Module : TiModule { } diff --git a/iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}Module.m.ejs b/iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}Module.m.ejs similarity index 95% rename from iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}Module.m.ejs rename to iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}Module.m.ejs index 4c14ddd4d87..f4b8f4bb600 100644 --- a/iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}Module.m.ejs +++ b/iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}Module.m.ejs @@ -5,12 +5,12 @@ * Copyright (c) <%- year %> <%- publisher %>. All rights reserved. */ -#import "<%- moduleNameAsIdentifier %>Module.h" +#import "<%- moduleIdAsIdentifier %>Module.h" #import "TiBase.h" #import "TiHost.h" #import "TiUtils.h" -@implementation <%- moduleNameAsIdentifier %>Module +@implementation <%- moduleIdAsIdentifier %>Module #pragma mark Internal diff --git a/iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}ModuleAssets.h.ejs b/iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}ModuleAssets.h.ejs similarity index 71% rename from iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}ModuleAssets.h.ejs rename to iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}ModuleAssets.h.ejs index 6fd8e9d4762..187d54be08f 100644 --- a/iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}ModuleAssets.h.ejs +++ b/iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}ModuleAssets.h.ejs @@ -2,7 +2,7 @@ * This is a generated file. Do not edit or your changes will be lost */ -@interface <%- moduleNameAsIdentifier %>ModuleAssets : NSObject +@interface <%- moduleIdAsIdentifier %>ModuleAssets : NSObject { } - (NSData*) moduleAsset; diff --git a/iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}ModuleAssets.m.ejs b/iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}ModuleAssets.m.ejs similarity index 82% rename from iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}ModuleAssets.m.ejs rename to iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}ModuleAssets.m.ejs index fb69e09bd52..8c193e19e35 100644 --- a/iphone/templates/module/default/template/iphone/Classes/{{ModuleNameAsIdentifier}}ModuleAssets.m.ejs +++ b/iphone/templates/module/default/template/iphone/Classes/{{ModuleIdAsIdentifier}}ModuleAssets.m.ejs @@ -1,11 +1,11 @@ /** * This is a generated file. Do not edit or your changes will be lost */ -#import "<%- moduleNameAsIdentifier %>ModuleAssets.h" +#import "<%- moduleIdAsIdentifier %>ModuleAssets.h" extern NSData* filterDataInRange(NSData* thedata, NSRange range); -@implementation <%- moduleNameAsIdentifier %>ModuleAssets +@implementation <%- moduleIdAsIdentifier %>ModuleAssets - (NSData*) moduleAsset { diff --git a/iphone/templates/module/default/template/iphone/build.py b/iphone/templates/module/default/template/iphone/build.py index 23c48b98a9d..dcefeb2d405 100755 --- a/iphone/templates/module/default/template/iphone/build.py +++ b/iphone/templates/module/default/template/iphone/build.py @@ -49,6 +49,8 @@ def read_ti_xcconfig(): def generate_doc(config): docdir = os.path.join(cwd,'documentation') + if not os.path.exists(docdir): + docdir = os.path.join(cwd,'..','documentation') if not os.path.exists(docdir): print "Couldn't find documentation file at: %s" % docdir return None @@ -114,9 +116,13 @@ def warn(msg): print "[WARN] %s" % msg def validate_license(): - c = open(os.path.join(cwd,'LICENSE')).read() - if c.find(module_license_default)!=-1: - warn('please update the LICENSE file with your license text before distributing') + license_file = os.path.join(cwd,'LICENSE') + if not os.path.exists(license_file): + license_file = os.path.join(cwd,'..','LICENSE') + if os.path.exists(license_file): + c = open(license_file).read() + if c.find(module_license_default)!=-1: + warn('please update the LICENSE file with your license text before distributing') def validate_manifest(): path = os.path.join(cwd,'manifest') @@ -197,9 +203,15 @@ def package_module(manifest,mf,config): filename = string.replace(file,'.md','.html') zf.writestr('%s/documentation/%s'%(modulepath,filename),html) for dn in ('assets','example','platform'): - if os.path.exists(dn): - zip_dir(zf,dn,'%s/%s' % (modulepath,dn),['README']) - zf.write('LICENSE','%s/LICENSE' % modulepath) + if os.path.exists(dn): + zip_dir(zf,dn,'%s/%s' % (modulepath,dn),['README']) + + license_file = os.path.join(cwd,'LICENSE') + if not os.path.exists(license_file): + license_file = os.path.join(cwd,'..','LICENSE') + if os.path.exists(license_file): + zf.write(license_file,'%s/LICENSE' % modulepath) + zf.write('module.xcconfig','%s/module.xcconfig' % modulepath) exports_file = 'metadata.json' if os.path.exists(exports_file): diff --git a/iphone/templates/module/default/template/iphone/titanium.xcconfig.ejs b/iphone/templates/module/default/template/iphone/titanium.xcconfig.ejs index cb638451d9c..15f67771099 100644 --- a/iphone/templates/module/default/template/iphone/titanium.xcconfig.ejs +++ b/iphone/templates/module/default/template/iphone/titanium.xcconfig.ejs @@ -4,13 +4,13 @@ // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR // // -TITANIUM_SDK_VERSION = "<%- tisdkVersion %>" +TITANIUM_SDK_VERSION = <%- tisdkVersion %> // // THESE SHOULD BE OK GENERALLY AS-IS // -TITANIUM_SDK = "<%- tisdkPath %>" +TITANIUM_SDK = <%- tisdkPath %> TITANIUM_BASE_SDK = "$(TITANIUM_SDK)/iphone/include" TITANIUM_BASE_SDK2 = "$(TITANIUM_SDK)/iphone/include/TiCore" HEADER_SEARCH_PATHS= $(TITANIUM_BASE_SDK) $(TITANIUM_BASE_SDK2) diff --git a/iphone/templates/module/default/template/iphone/{{ModuleIdFilename}}_Prefix.pch b/iphone/templates/module/default/template/iphone/{{ModuleIdAsIdentifier}}_Prefix.pch similarity index 100% rename from iphone/templates/module/default/template/iphone/{{ModuleIdFilename}}_Prefix.pch rename to iphone/templates/module/default/template/iphone/{{ModuleIdAsIdentifier}}_Prefix.pch diff --git a/iphone/templates/module/default/template/iphone/{{ModuleName}}.xcodeproj/project.pbxproj.ejs b/iphone/templates/module/default/template/iphone/{{ModuleName}}.xcodeproj/project.pbxproj.ejs index b457f305d41..50d3a87265e 100644 --- a/iphone/templates/module/default/template/iphone/{{ModuleName}}.xcodeproj/project.pbxproj.ejs +++ b/iphone/templates/module/default/template/iphone/{{ModuleName}}.xcodeproj/project.pbxproj.ejs @@ -22,11 +22,11 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ - 24DD6CF91134B3F500162E58 /* <%- moduleNameAsIdentifier %>Module.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DD6CF71134B3F500162E58 /* <%- moduleNameAsIdentifier %>Module.h */; }; - 24DD6CFA1134B3F500162E58 /* <%- moduleNameAsIdentifier %>Module.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DD6CF81134B3F500162E58 /* <%- moduleNameAsIdentifier %>Module.m */; }; - 24DE9E1111C5FE74003F90F6 /* <%- moduleNameAsIdentifier %>ModuleAssets.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DE9E0F11C5FE74003F90F6 /* <%- moduleNameAsIdentifier %>ModuleAssets.h */; }; - 24DE9E1211C5FE74003F90F6 /* <%- moduleNameAsIdentifier %>ModuleAssets.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DE9E1011C5FE74003F90F6 /* <%- moduleNameAsIdentifier %>ModuleAssets.m */; }; - AA747D9F0F9514B9006C5449 /* <%- moduleNameAsIdentifier %>_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* <%- moduleNameAsIdentifier %>_Prefix.pch */; }; + 24DD6CF91134B3F500162E58 /* <%- moduleIdAsIdentifier %>Module.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DD6CF71134B3F500162E58 /* <%- moduleIdAsIdentifier %>Module.h */; }; + 24DD6CFA1134B3F500162E58 /* <%- moduleIdAsIdentifier %>Module.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DD6CF81134B3F500162E58 /* <%- moduleIdAsIdentifier %>Module.m */; }; + 24DE9E1111C5FE74003F90F6 /* <%- moduleIdAsIdentifier %>ModuleAssets.h in Headers */ = {isa = PBXBuildFile; fileRef = 24DE9E0F11C5FE74003F90F6 /* <%- moduleIdAsIdentifier %>ModuleAssets.h */; }; + 24DE9E1211C5FE74003F90F6 /* <%- moduleIdAsIdentifier %>ModuleAssets.m in Sources */ = {isa = PBXBuildFile; fileRef = 24DE9E1011C5FE74003F90F6 /* <%- moduleIdAsIdentifier %>ModuleAssets.m */; }; + AA747D9F0F9514B9006C5449 /* <%- moduleIdAsIdentifier %>_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = AA747D9E0F9514B9006C5449 /* <%- moduleIdAsIdentifier %>_Prefix.pch */; }; AACBBE4A0F95108600F1A2B1 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AACBBE490F95108600F1A2B1 /* Foundation.framework */; }; /* End PBXBuildFile section */ @@ -41,14 +41,14 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 24DD6CF71134B3F500162E58 /* <%- moduleNameAsIdentifier %>Module.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "<%- moduleNameAsIdentifier %>Module.h"; path = "Classes/<%- moduleNameAsIdentifier %>Module.h"; sourceTree = ""; }; - 24DD6CF81134B3F500162E58 /* <%- moduleNameAsIdentifier %>Module.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "<%- moduleNameAsIdentifier %>Module.m"; path = "Classes/<%- moduleNameAsIdentifier %>Module.m"; sourceTree = ""; }; + 24DD6CF71134B3F500162E58 /* <%- moduleIdAsIdentifier %>Module.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "<%- moduleIdAsIdentifier %>Module.h"; path = "Classes/<%- moduleIdAsIdentifier %>Module.h"; sourceTree = ""; }; + 24DD6CF81134B3F500162E58 /* <%- moduleIdAsIdentifier %>Module.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "<%- moduleIdAsIdentifier %>Module.m"; path = "Classes/<%- moduleIdAsIdentifier %>Module.m"; sourceTree = ""; }; 24DD6D1B1134B66800162E58 /* titanium.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = titanium.xcconfig; sourceTree = ""; }; - 24DE9E0F11C5FE74003F90F6 /* <%- moduleNameAsIdentifier %>ModuleAssets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "<%- moduleNameAsIdentifier %>ModuleAssets.h"; path = "Classes/<%- moduleNameAsIdentifier %>ModuleAssets.h"; sourceTree = ""; }; - 24DE9E1011C5FE74003F90F6 /* <%- moduleNameAsIdentifier %>ModuleAssets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "<%- moduleNameAsIdentifier %>ModuleAssets.m"; path = "Classes/<%- moduleNameAsIdentifier %>ModuleAssets.m"; sourceTree = ""; }; - AA747D9E0F9514B9006C5449 /* <%- moduleNameAsIdentifier %>_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "<%- moduleNameAsIdentifier %>_Prefix.pch"; sourceTree = SOURCE_ROOT; }; + 24DE9E0F11C5FE74003F90F6 /* <%- moduleIdAsIdentifier %>ModuleAssets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "<%- moduleIdAsIdentifier %>ModuleAssets.h"; path = "Classes/<%- moduleIdAsIdentifier %>ModuleAssets.h"; sourceTree = ""; }; + 24DE9E1011C5FE74003F90F6 /* <%- moduleIdAsIdentifier %>ModuleAssets.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "<%- moduleIdAsIdentifier %>ModuleAssets.m"; path = "Classes/<%- moduleIdAsIdentifier %>ModuleAssets.m"; sourceTree = ""; }; + AA747D9E0F9514B9006C5449 /* <%- moduleIdAsIdentifier %>_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "<%- moduleIdAsIdentifier %>_Prefix.pch"; sourceTree = SOURCE_ROOT; }; AACBBE490F95108600F1A2B1 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - D2AAC07E0554694100DB518D /* lib<%- moduleNameAsIdentifier %>.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "lib<%- moduleNameAsIdentifier %>.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + D2AAC07E0554694100DB518D /* lib<%- moduleIdAsIdentifier %>.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "lib<%- moduleIdAsIdentifier %>.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -66,7 +66,7 @@ 034768DFFF38A50411DB9C8B /* Products */ = { isa = PBXGroup; children = ( - D2AAC07E0554694100DB518D /* lib<%- moduleNameAsIdentifier %>.a */, + D2AAC07E0554694100DB518D /* lib<%- moduleIdAsIdentifier %>.a */, ); name = Products; sourceTree = ""; @@ -93,10 +93,10 @@ 08FB77AEFE84172EC02AAC07 /* Classes */ = { isa = PBXGroup; children = ( - 24DE9E0F11C5FE74003F90F6 /* <%- moduleNameAsIdentifier %>ModuleAssets.h */, - 24DE9E1011C5FE74003F90F6 /* <%- moduleNameAsIdentifier %>ModuleAssets.m */, - 24DD6CF71134B3F500162E58 /* <%- moduleNameAsIdentifier %>Module.h */, - 24DD6CF81134B3F500162E58 /* <%- moduleNameAsIdentifier %>Module.m */, + 24DE9E0F11C5FE74003F90F6 /* <%- moduleIdAsIdentifier %>ModuleAssets.h */, + 24DE9E1011C5FE74003F90F6 /* <%- moduleIdAsIdentifier %>ModuleAssets.m */, + 24DD6CF71134B3F500162E58 /* <%- moduleIdAsIdentifier %>Module.h */, + 24DD6CF81134B3F500162E58 /* <%- moduleIdAsIdentifier %>Module.m */, ); name = Classes; sourceTree = ""; @@ -104,7 +104,7 @@ 32C88DFF0371C24200C91783 /* Other Sources */ = { isa = PBXGroup; children = ( - AA747D9E0F9514B9006C5449 /* <%- moduleNameAsIdentifier %>_Prefix.pch */, + AA747D9E0F9514B9006C5449 /* <%- moduleIdAsIdentifier %>_Prefix.pch */, 24DD6D1B1134B66800162E58 /* titanium.xcconfig */, ); name = "Other Sources"; @@ -117,9 +117,9 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - AA747D9F0F9514B9006C5449 /* <%- moduleNameAsIdentifier %>_Prefix.pch in Headers */, - 24DD6CF91134B3F500162E58 /* <%- moduleNameAsIdentifier %>Module.h in Headers */, - 24DE9E1111C5FE74003F90F6 /* <%- moduleNameAsIdentifier %>ModuleAssets.h in Headers */, + AA747D9F0F9514B9006C5449 /* <%- moduleIdAsIdentifier %>_Prefix.pch in Headers */, + 24DD6CF91134B3F500162E58 /* <%- moduleIdAsIdentifier %>Module.h in Headers */, + 24DE9E1111C5FE74003F90F6 /* <%- moduleIdAsIdentifier %>ModuleAssets.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -140,7 +140,7 @@ ); name = "<%- moduleName %>"; productName = "<%- moduleName %>"; - productReference = D2AAC07E0554694100DB518D /* lib<%- moduleNameAsIdentifier %>.a */; + productReference = D2AAC07E0554694100DB518D /* lib<%- moduleIdAsIdentifier %>.a */; productType = "com.apple.product-type.library.static"; }; /* End PBXNativeTarget section */ @@ -192,8 +192,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 24DD6CFA1134B3F500162E58 /* <%- moduleNameAsIdentifier %>Module.m in Sources */, - 24DE9E1211C5FE74003F90F6 /* <%- moduleNameAsIdentifier %>ModuleAssets.m in Sources */, + 24DD6CFA1134B3F500162E58 /* <%- moduleIdAsIdentifier %>Module.m in Sources */, + 24DE9E1211C5FE74003F90F6 /* <%- moduleIdAsIdentifier %>ModuleAssets.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -214,11 +214,11 @@ buildSettings = { CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DSTROOT = "/tmp/<%- moduleNameAsIdentifier %>.dst"; + DSTROOT = "/tmp/<%- moduleIdAsIdentifier %>.dst"; GCC_C_LANGUAGE_STANDARD = c99; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "<%- moduleNameAsIdentifier %>_Prefix.pch"; + GCC_PREFIX_HEADER = "<%- moduleIdAsIdentifier %>_Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; GCC_TREAT_WARNINGS_AS_ERRORS = NO; GCC_VERSION = ""; @@ -237,7 +237,7 @@ "-DTI_POST_1_2", ); OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "<%- moduleNameAsIdentifier %>"; + PRODUCT_NAME = "<%- moduleIdAsIdentifier %>"; PROVISIONING_PROFILE = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; RUN_CLANG_STATIC_ANALYZER = NO; @@ -251,11 +251,11 @@ baseConfigurationReference = 24DD6D1B1134B66800162E58 /* titanium.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - DSTROOT = "/tmp/<%- moduleNameAsIdentifier %>.dst"; + DSTROOT = "/tmp/<%- moduleIdAsIdentifier %>.dst"; GCC_C_LANGUAGE_STANDARD = c99; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "<%- moduleNameAsIdentifier %>_Prefix.pch"; + GCC_PREFIX_HEADER = "<%- moduleIdAsIdentifier %>_Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; GCC_TREAT_WARNINGS_AS_ERRORS = NO; GCC_VERSION = ""; @@ -272,7 +272,7 @@ LIBRARY_SEARCH_PATHS = ""; OTHER_CFLAGS = "-DTI_POST_1_2"; OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "<%- moduleNameAsIdentifier %>"; + PRODUCT_NAME = "<%- moduleIdAsIdentifier %>"; RUN_CLANG_STATIC_ANALYZER = NO; SDKROOT = iphoneos; USER_HEADER_SEARCH_PATHS = ""; @@ -286,11 +286,11 @@ CLANG_CXX_LIBRARY = "libstdc++"; CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - DSTROOT = "/tmp/<%- moduleNameAsIdentifier %>.dst"; + DSTROOT = "/tmp/<%- moduleIdAsIdentifier %>.dst"; GCC_C_LANGUAGE_STANDARD = c99; GCC_OPTIMIZATION_LEVEL = 0; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "<%- moduleNameAsIdentifier %>_Prefix.pch"; + GCC_PREFIX_HEADER = "<%- moduleIdAsIdentifier %>_Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; GCC_TREAT_WARNINGS_AS_ERRORS = NO; GCC_VERSION = ""; @@ -308,7 +308,7 @@ "-DTI_POST_1_2", ); OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "<%- moduleNameAsIdentifier %>"; + PRODUCT_NAME = "<%- moduleIdAsIdentifier %>"; PROVISIONING_PROFILE = ""; "PROVISIONING_PROFILE[sdk=iphoneos*]" = ""; RUN_CLANG_STATIC_ANALYZER = NO; @@ -323,11 +323,11 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LIBRARY = "libstdc++"; - DSTROOT = "/tmp/<%- moduleNameAsIdentifier %>.dst"; + DSTROOT = "/tmp/<%- moduleIdAsIdentifier %>.dst"; GCC_C_LANGUAGE_STANDARD = c99; GCC_MODEL_TUNING = G5; GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = "<%- moduleNameAsIdentifier %>_Prefix.pch"; + GCC_PREFIX_HEADER = "<%- moduleIdAsIdentifier %>_Prefix.pch"; GCC_PREPROCESSOR_DEFINITIONS = "TI_VERSION=$(TI_VERSION)"; GCC_TREAT_WARNINGS_AS_ERRORS = NO; GCC_VERSION = ""; @@ -343,7 +343,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 4.0; OTHER_CFLAGS = "-DTI_POST_1_2"; OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "<%- moduleNameAsIdentifier %>"; + PRODUCT_NAME = "<%- moduleIdAsIdentifier %>"; RUN_CLANG_STATIC_ANALYZER = NO; SDKROOT = iphoneos; USER_HEADER_SEARCH_PATHS = ""; diff --git a/mobileweb/templates/module/default/template/mobileweb/build.py.ejs b/mobileweb/templates/module/default/template/mobileweb/build.py.ejs index e93a35cb525..d5c40ba720c 100755 --- a/mobileweb/templates/module/default/template/mobileweb/build.py.ejs +++ b/mobileweb/templates/module/default/template/mobileweb/build.py.ejs @@ -17,6 +17,9 @@ try: except ImportError: import markdown +cwd = os.path.abspath(os.path.dirname(sys._getframe(0).f_code.co_filename)) +os.chdir(cwd) + ignoreFiles = ['.DS_Store','.cvsignore','.gitignore'] ignoreDirs = ['.svn','_svn','.git','CVS','CVSROOT'] @@ -126,9 +129,13 @@ class Compiler(object): print '[WARN] Please update the manifest key: "%s" to a non-default value' % key def check_license(self): - c = open(os.path.join(self.module_path, 'LICENSE')).read() - if c.find(module_license_default) != -1: - print '[WARN] Please update the LICENSE file with your license text before distributing' + license_file = os.path.join(cwd,'LICENSE') + if not os.path.exists(license_file): + license_file = os.path.join(cwd,'..','LICENSE') + if os.path.exists(license_file): + c = open(license_file).read() + if c.find(module_license_default) != -1: + print '[WARN] Please update the LICENSE file with your license text before distributing' def load_timodule_xml(self): global_settings = {} @@ -154,7 +161,7 @@ class Compiler(object): self.timodule = dict(global_settings.items() + mobileweb_settings.items()) def check_main(self): - self.main = self.timodule['main'] if 'main' in self.timodule else self.manifest['name'] + self.main = self.timodule['main'] if 'main' in self.timodule else self.manifest['moduleid'] if not os.path.exists(os.path.join(self.src_path, self.main + '.js')): print '[ERROR] Unable to find main module "%s"' % self.main sys.exit(1) @@ -377,6 +384,8 @@ class Compiler(object): def generate_doc(self): docdir = os.path.join(self.module_path, 'documentation') + if not os.path.exists(docdir): + docdir = os.path.join(self.module_path, '..', 'documentation') if not os.path.exists(docdir): print '[WARN] Couldn\'t find documentation file at: %s' % docdir return None @@ -416,7 +425,12 @@ class Compiler(object): zf = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED) zf.write(os.path.join(self.module_path, 'manifest'), '%s/manifest' % install_path) - zf.write(os.path.join(self.module_path, 'LICENSE'), '%s/LICENSE' % install_path) + + license_file = os.path.join(self.module_path, 'LICENSE') + if not os.path.exists(license_file): + license_file = os.path.join(self.module_path, '..', 'LICENSE') + if os.path.exists(license_file): + zf.write(license_file,'%s/LICENSE' % install_path) zf.writestr('%s/package.json' % install_path, simplejson.dumps({ 'name': self.manifest['name'], diff --git a/mobileweb/templates/module/default/template/mobileweb/manifest.ejs b/mobileweb/templates/module/default/template/mobileweb/manifest.ejs index 31c768a0863..7167eb8875b 100644 --- a/mobileweb/templates/module/default/template/mobileweb/manifest.ejs +++ b/mobileweb/templates/module/default/template/mobileweb/manifest.ejs @@ -2,7 +2,7 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 1.0 +version: 1.0.0 apiversion: 2 description: <%- moduleName %> author: <%- author %> diff --git a/mobileweb/templates/module/default/template/mobileweb/timodule.xml b/mobileweb/templates/module/default/template/mobileweb/timodule.xml new file mode 100644 index 00000000000..6affb2faec1 --- /dev/null +++ b/mobileweb/templates/module/default/template/mobileweb/timodule.xml @@ -0,0 +1,13 @@ + + + + + + + + + + diff --git a/node_modules/titanium-sdk/lib/android.js b/node_modules/titanium-sdk/lib/android.js index 75adaabb638..614e143808b 100644 --- a/node_modules/titanium-sdk/lib/android.js +++ b/node_modules/titanium-sdk/lib/android.js @@ -577,8 +577,6 @@ exports.detect = function detect(config, opts, finished) { } } - info.googleApis = false; - if (info.type == 'platform') { info.path = path.join(results.sdk.path, 'platforms', info.id); info.version = (m = info.name.match(/Android (((\d\.)?\d\.)?\d)/)) && m[1];