def main(argv): parser = optparse.OptionParser() parser.add_option('-v', '--version', action='store_true', dest='version', default=False, help='The version of this python tool.') info = ('The packaging mode of the web application. The value \'shared\' ' 'means that the runtime is shared across multiple application ' 'instances and that the runtime needs to be distributed separately. ' 'The value \'embedded\' means that the runtime is embedded into the ' 'application itself and distributed along with it.' 'Set the default mode as \'embedded\'. For example: --mode=embedded') parser.add_option('--mode', default='embedded', help=info) info = ('The target architecture of the embedded runtime. Supported values ' 'are \'x86\' and \'arm\'. Note, if undefined, APKs for all possible ' 'architestures will be generated.') parser.add_option('--arch', help=info) group = optparse.OptionGroup(parser, 'Application Source Options', 'This packaging tool supports 3 kinds of web application source: ' '1) XPK package; 2) manifest.json; 3) various command line options, ' 'for example, \'--app-url\' for website, \'--app-root\' and ' '\'--app-local-path\' for local web application.') info = ('The path of the XPK package. For example, --xpk=/path/to/xpk/file') group.add_option('--xpk', help=info) info = ('The manifest file with the detail description of the application. ' 'For example, --manifest=/path/to/your/manifest/file') group.add_option('--manifest', help=info) info = ('The url of application. ' 'This flag allows to package website as apk. For example, ' '--app-url=http://www.intel.com') group.add_option('--app-url', help=info) info = ('The root path of the web app. ' 'This flag allows to package local web app as apk. For example, ' '--app-root=/root/path/of/the/web/app') group.add_option('--app-root', help=info) info = ('The relative path of entry file based on the value from ' '\'app_root\'. This flag should work with \'--app-root\' together. ' 'For example, --app-local-path=/relative/path/of/entry/file') group.add_option('--app-local-path', help=info) parser.add_option_group(group) group = optparse.OptionGroup(parser, 'Mandatory arguments', 'They are used for describing the APK information through ' 'command line options.') info = ('The apk name. For example, --name="Your Application Name"') group.add_option('--name', help=info) info = ('The package name. For example, ' '--package=com.example.YourPackage') group.add_option('--package', help=info) parser.add_option_group(group) group = optparse.OptionGroup(parser, 'Optional arguments', 'They are used for various settings for applications through ' 'command line options.') info = ('The version name of the application. ' 'For example, --app-version=1.0.0') group.add_option('--app-version', help=info) info = ('The version code of the application. ' 'For example, --app-versionCode=24') group.add_option('--app-versionCode', type='int', help=info) info = ('The version code base of the application. Version code will ' 'be made by adding a prefix based on architecture to the version ' 'code base. For example, --app-versionCodeBase=24') group.add_option('--app-versionCodeBase', type='int', help=info) info = ('The description of the application. For example, ' '--description=YourApplicationDescription') group.add_option('--description', help=info) group.add_option('--enable-remote-debugging', action='store_true', dest='enable_remote_debugging', default=False, help = 'Enable remote debugging.') info = ('The list of external extension paths splitted by OS separators. ' 'The separators are \':\' , \';\' and \':\' on Linux, Windows and ' 'Mac OS respectively. For example, ' '--extensions=/path/to/extension1:/path/to/extension2.') group.add_option('--extensions', help=info) group.add_option('-f', '--fullscreen', action='store_true', dest='fullscreen', default=False, help='Make application fullscreen.') info = ('The path of application icon. ' 'Such as: --icon=/path/to/your/customized/icon') group.add_option('--icon', help=info) info = ('The orientation of the web app\'s display on the device. ' 'For example, --orientation=landscape. The default value is ' '\'unspecified\'. The permitted values are from Android: ' 'http://developer.android.com/guide/topics/manifest/' 'activity-element.html#screen') group.add_option('--orientation', help=info) info = ('The list of permissions to be used by web application. For example, ' '--permissions=geolocation:webgl') group.add_option('--permissions', help=info) parser.add_option_group(group) group = optparse.OptionGroup(parser, 'Keystore Options', 'The keystore is a signature from web developer, it\'s used when ' 'developer wants to distribute the applications.') info = ('The path to the developer keystore. For example, ' '--keystore-path=/path/to/your/developer/keystore') group.add_option('--keystore-path', help=info) info = ('The alias name of keystore. For example, --keystore-alias=name') group.add_option('--keystore-alias', help=info) info = ('The passcode of keystore. For example, --keystore-passcode=code') group.add_option('--keystore-passcode', help=info) info = ('Minify and obfuscate javascript and css.' '--compressor: compress javascript and css.' '--compressor=js: compress javascript.' '--compressor=css: compress css.') group.add_option('--compressor', dest='compressor', action='callback', callback=parse_optional_arg('all'), help=info) parser.add_option_group(group) options, _ = parser.parse_args() if len(argv) == 1: parser.print_help() return 0 # This option will not export to users. # Initialize here and will be read from manifest.json. options.launch_screen_img = '' if options.version: if os.path.isfile('VERSION'): print(GetVersion('VERSION')) return 0 else: parser.error('Can\'t get version due to the VERSION file missing!') xpk_temp_dir = '' if options.xpk: xpk_name = os.path.splitext(os.path.basename(options.xpk))[0] xpk_temp_dir = xpk_name + '_xpk' ParseXPK(options, xpk_temp_dir) if options.app_root and not options.manifest: manifest_path = os.path.join(options.app_root, 'manifest.json') if os.path.exists(manifest_path): print('Using manifest.json distributed with the application.') options.manifest = manifest_path if not options.manifest: if not options.package: parser.error('The package name is required! ' 'Please use "--package" option.') if not options.name: parser.error('The APK name is required! Please use "--name" option.') if not ((options.app_url and not options.app_root and not options.app_local_path) or ((not options.app_url) and options.app_root and options.app_local_path)): parser.error('The entry is required. If the entry is a remote url, ' 'please use "--app-url" option; If the entry is local, ' 'please use "--app-root" and ' '"--app-local-path" options together!') if options.permissions: permission_list = options.permissions.split(':') else: print ('Warning: all supported permissions on Android port are added. ' 'Refer to https://github.com/crosswalk-project/' 'crosswalk-website/wiki/Crosswalk-manifest') permission_list = permission_mapping_table.keys() options.permissions = HandlePermissionList(permission_list) else: try: ParseManifest(options) except SystemExit as ec: return ec.code options.name = ReplaceInvalidChars(options.name, 'apkname') options.package = ReplaceInvalidChars(options.package) sanitized_name = ReplaceInvalidChars(options.name, 'apkname') try: compress = compress_js_and_css.CompressJsAndCss(options.app_root) if options.compressor == 'all': compress.CompressJavaScript() compress.CompressCss() elif options.compressor == 'js': compress.CompressJavaScript() elif options.compressor == 'css': compress.CompressCss() MakeApk(options, sanitized_name) except SystemExit as ec: CleanDir(sanitized_name) CleanDir('out') if os.path.exists(xpk_temp_dir): CleanDir(xpk_temp_dir) return ec.code return 0
def main(argv): parser = optparse.OptionParser() parser.add_option( "-v", "--version", action="store_true", dest="version", default=False, help="The version of this python tool." ) info = ( "The packaging mode of the web application. The value 'shared' " "means that the runtime is shared across multiple application " "instances and that the runtime needs to be distributed separately. " "The value 'embedded' means that the runtime is embedded into the " "application itself and distributed along with it." "Set the default mode as 'embedded'. For example: --mode=embedded" ) parser.add_option("--mode", default="embedded", help=info) info = ( "The target architecture of the embedded runtime. Supported values " "are 'x86' and 'arm'. Note, if undefined, APKs for all possible " "architestures will be generated." ) parser.add_option("--arch", help=info) group = optparse.OptionGroup( parser, "Application Source Options", "This packaging tool supports 3 kinds of web application source: " "1) XPK package; 2) manifest.json; 3) various command line options, " "for example, '--app-url' for website, '--app-root' and " "'--app-local-path' for local web application.", ) info = "The path of the XPK package. For example, --xpk=/path/to/xpk/file" group.add_option("--xpk", help=info) info = ( "The manifest file with the detail description of the application. " "For example, --manifest=/path/to/your/manifest/file" ) group.add_option("--manifest", help=info) info = ( "The url of application. " "This flag allows to package website as apk. For example, " "--app-url=http://www.intel.com" ) group.add_option("--app-url", help=info) info = ( "The root path of the web app. " "This flag allows to package local web app as apk. For example, " "--app-root=/root/path/of/the/web/app" ) group.add_option("--app-root", help=info) info = ( "The relative path of entry file based on the value from " "'app_root'. This flag should work with '--app-root' together. " "For example, --app-local-path=/relative/path/of/entry/file" ) group.add_option("--app-local-path", help=info) parser.add_option_group(group) group = optparse.OptionGroup( parser, "Mandatory arguments", "They are used for describing the APK information through " "command line options.", ) info = "The apk name. For example, --name=YourApplicationName" group.add_option("--name", help=info) info = "The package name. For example, " "--package=com.example.YourPackage" group.add_option("--package", help=info) parser.add_option_group(group) group = optparse.OptionGroup( parser, "Optional arguments", "They are used for various settings for applications through " "command line options.", ) info = "The version name of the application. " "For example, --app-version=1.0.0" group.add_option("--app-version", help=info) info = "The version code of the application. " "For example, --app-versionCode=24" group.add_option("--app-versionCode", type="int", help=info) info = ( "The version code base of the application. Version code will " "be made by adding a prefix based on architecture to the version " "code base. For example, --app-versionCodeBase=24" ) group.add_option("--app-versionCodeBase", type="int", help=info) info = "The description of the application. For example, " "--description=YourApplicationDescription" group.add_option("--description", help=info) group.add_option( "--enable-remote-debugging", action="store_true", dest="enable_remote_debugging", default=False, help="Enable remote debugging.", ) info = ( "The list of external extension paths splitted by OS separators. " "The separators are ':' , ';' and ':' on Linux, Windows and " "Mac OS respectively. For example, " "--extensions=/path/to/extension1:/path/to/extension2." ) group.add_option("--extensions", help=info) group.add_option( "-f", "--fullscreen", action="store_true", dest="fullscreen", default=False, help="Make application fullscreen." ) info = "The path of application icon. " "Such as: --icon=/path/to/your/customized/icon" group.add_option("--icon", help=info) info = ( "The orientation of the web app's display on the device. " "For example, --orientation=landscape. The default value is " "'unspecified'. The permitted values are from Android: " "http://developer.android.com/guide/topics/manifest/" "activity-element.html#screen" ) group.add_option("--orientation", help=info) info = "The list of permissions to be used by web application. For example, " "--permissions=geolocation:webgl" group.add_option("--permissions", help=info) parser.add_option_group(group) group = optparse.OptionGroup( parser, "Keystore Options", "The keystore is a signature from web developer, it's used when " "developer wants to distribute the applications.", ) info = "The path to the developer keystore. For example, " "--keystore-path=/path/to/your/developer/keystore" group.add_option("--keystore-path", help=info) info = "The alias name of keystore. For example, --keystore-alias=name" group.add_option("--keystore-alias", help=info) info = "The passcode of keystore. For example, --keystore-passcode=code" group.add_option("--keystore-passcode", help=info) info = ( "Minify and obfuscate javascript and css." "--compressor: compress javascript and css." "--compressor=js: compress javascript." "--compressor=css: compress css." ) group.add_option( "--compressor", dest="compressor", action="callback", callback=parse_optional_arg("all"), help=info ) parser.add_option_group(group) options, _ = parser.parse_args() if len(argv) == 1: parser.print_help() return 0 if options.version: if os.path.isfile("VERSION"): print(GetVersion("VERSION")) return 0 else: parser.error("Can't get version due to the VERSION file missing!") xpk_temp_dir = "" if options.xpk: xpk_name = os.path.splitext(os.path.basename(options.xpk))[0] xpk_temp_dir = xpk_name + "_xpk" ParseXPK(options, xpk_temp_dir) if options.app_root and not options.manifest: manifest_path = os.path.join(options.app_root, "manifest.json") if os.path.exists(manifest_path): print("Using manifest.json distributed with the application.") options.manifest = manifest_path if not options.manifest: if not options.package: parser.error("The package name is required! " 'Please use "--package" option.') if not options.name: parser.error('The APK name is required! Please use "--name" option.') if not ( (options.app_url and not options.app_root and not options.app_local_path) or ((not options.app_url) and options.app_root and options.app_local_path) ): parser.error( "The entry is required. If the entry is a remote url, " 'please use "--app-url" option; If the entry is local, ' 'please use "--app-root" and ' '"--app-local-path" options together!' ) if options.permissions: permission_list = options.permissions.split(":") else: print( "Warning: all supported permissions on Android port are added. " "Refer to https://github.com/crosswalk-project/" "crosswalk-website/wiki/Crosswalk-manifest" ) permission_list = permission_mapping_table.keys() options.permissions = HandlePermissionList(permission_list) else: try: ParseManifest(options) except SystemExit as ec: return ec.code options.name = ReplaceInvalidChars(options.name, "apkname") options.package = ReplaceInvalidChars(options.package) sanitized_name = ReplaceInvalidChars(options.name) try: compress = compress_js_and_css.CompressJsAndCss(options.app_root) if options.compressor == "all": compress.CompressJavaScript() compress.CompressCss() elif options.compressor == "js": compress.CompressJavaScript() elif options.compressor == "css": compress.CompressCss() MakeApk(options, sanitized_name) except SystemExit as ec: CleanDir(sanitized_name) CleanDir("out") if os.path.exists(xpk_temp_dir): CleanDir(xpk_temp_dir) return ec.code return 0
def main(argv): parser = optparse.OptionParser() parser.add_option('-v', '--version', action='store_true', dest='version', default=False, help='The version of this python tool.') parser.add_option('--verbose', action="store_true", dest='verbose', default=False, help='Print debug messages.') info = ('The packaging mode of the web application. The value \'shared\' ' 'means that the runtime is shared across multiple application ' 'instances and that the runtime needs to be distributed separately. ' 'The value \'embedded\' means that the runtime is embedded into the ' 'application itself and distributed along with it.' 'Set the default mode as \'embedded\'. For example: --mode=embedded') parser.add_option('--mode', choices=('embedded', 'shared'), default='embedded', help=info) info = ('The target architecture of the embedded runtime. Supported values ' 'are \'x86\' and \'arm\'. Note, if undefined, APKs for all possible ' 'architestures will be generated.') parser.add_option('--arch', choices=AllArchitectures(), help=info) group = optparse.OptionGroup(parser, 'Application Source Options', 'This packaging tool supports 3 kinds of web application source: ' '1) XPK package; 2) manifest.json; 3) various command line options, ' 'for example, \'--app-url\' for website, \'--app-root\' and ' '\'--app-local-path\' for local web application.') info = ('The path of the XPK package. For example, --xpk=/path/to/xpk/file') group.add_option('--xpk', help=info) info = ('The manifest file with the detail description of the application. ' 'For example, --manifest=/path/to/your/manifest/file') group.add_option('--manifest', help=info) info = ('The url of application. ' 'This flag allows to package website as apk. For example, ' '--app-url=http://www.intel.com') group.add_option('--app-url', help=info) info = ('The root path of the web app. ' 'This flag allows to package local web app as apk. For example, ' '--app-root=/root/path/of/the/web/app') group.add_option('--app-root', help=info) info = ('The relative path of entry file based on the value from ' '\'app_root\'. This flag should work with \'--app-root\' together. ' 'For example, --app-local-path=/relative/path/of/entry/file') group.add_option('--app-local-path', help=info) parser.add_option_group(group) group = optparse.OptionGroup(parser, 'Mandatory arguments', 'They are used for describing the APK information through ' 'command line options.') info = ('The apk name. For example, --name="Your Application Name"') group.add_option('--name', help=info) info = ('The package name. For example, ' '--package=com.example.YourPackage') group.add_option('--package', help=info) parser.add_option_group(group) group = optparse.OptionGroup(parser, 'Optional arguments', 'They are used for various settings for applications through ' 'command line options.') info = ('The version name of the application. ' 'For example, --app-version=1.0.0') group.add_option('--app-version', help=info) info = ('The version code of the application. ' 'For example, --app-versionCode=24') group.add_option('--app-versionCode', type='int', help=info) info = ('The version code base of the application. Version code will ' 'be made by adding a prefix based on architecture to the version ' 'code base. For example, --app-versionCodeBase=24') group.add_option('--app-versionCodeBase', type='int', help=info) info = ('Use command lines.' 'Crosswalk is powered by Chromium and supports Chromium command line.' 'For example, ' '--xwalk-command-line=\'--chromium-command-1 --xwalk-command-2\'') group.add_option('--xwalk-command-line', default='', help=info) info = ('The description of the application. For example, ' '--description=YourApplicationDescription') group.add_option('--description', help=info) group.add_option('--enable-remote-debugging', action='store_true', dest='enable_remote_debugging', default=False, help='Enable remote debugging.') info = ('The list of external extension paths splitted by OS separators. ' 'The separators are \':\' , \';\' and \':\' on Linux, Windows and ' 'Mac OS respectively. For example, ' '--extensions=/path/to/extension1:/path/to/extension2.') group.add_option('--extensions', help=info) group.add_option('-f', '--fullscreen', action='store_true', dest='fullscreen', default=False, help='Make application fullscreen.') group.add_option('--keep-screen-on', action='store_true', default=False, help='Support keeping screen on') info = ('The path of application icon. ' 'Such as: --icon=/path/to/your/customized/icon') group.add_option('--icon', help=info) info = ('The orientation of the web app\'s display on the device. ' 'For example, --orientation=landscape. The default value is ' '\'unspecified\'. The permitted values are from Android: ' 'http://developer.android.com/guide/topics/manifest/' 'activity-element.html#screen') group.add_option('--orientation', help=info) info = ('The list of permissions to be used by web application. For example, ' '--permissions=geolocation:webgl') group.add_option('--permissions', help=info) info = ('Packaging tool will move the output APKS to the target directory') group.add_option('--target-dir', default=os.getcwd(), help=info) parser.add_option_group(group) group = optparse.OptionGroup(parser, 'Keystore Options', 'The keystore is a signature from web developer, it\'s used when ' 'developer wants to distribute the applications.') info = ('The path to the developer keystore. For example, ' '--keystore-path=/path/to/your/developer/keystore') group.add_option('--keystore-path', help=info) info = ('The alias name of keystore. For example, --keystore-alias=name') group.add_option('--keystore-alias', help=info) info = ('The passcode of keystore. For example, --keystore-passcode=code') group.add_option('--keystore-passcode', help=info) info = ('Passcode for alias\'s private key in the keystore, ' 'For example, --keystore-alias-passcode=alias-code') group.add_option('--keystore-alias-passcode', help=info) info = ('Minify and obfuscate javascript and css.' '--compressor: compress javascript and css.' '--compressor=js: compress javascript.' '--compressor=css: compress css.') group.add_option('--compressor', dest='compressor', action='callback', callback=ParseParameterForCompressor, type='string', nargs=0, help=info) parser.add_option_group(group) options, _ = parser.parse_args() if len(argv) == 1: parser.print_help() return 0 if options.version: if os.path.isfile('VERSION'): print(GetVersion('VERSION')) return 0 else: parser.error('VERSION was not found, so Crosswalk\'s version could not ' 'be determined.') xpk_temp_dir = '' if options.xpk: xpk_name = os.path.splitext(os.path.basename(options.xpk))[0] xpk_temp_dir = xpk_name + '_xpk' ParseXPK(options, xpk_temp_dir) if options.app_root and not options.manifest: manifest_path = os.path.join(options.app_root, 'manifest.json') if os.path.exists(manifest_path): print('Using manifest.json distributed with the application.') options.manifest = manifest_path app_info = AppInfo() manifest = None if not options.manifest: # The checks here are really convoluted, but at the moment make_apk # misbehaves any of the following conditions is true. if options.app_url: # 1) --app-url must be passed without either --app-local-path or # --app-root. if options.app_root or options.app_local_path: parser.error('You must pass either "--app-url" or "--app-local-path" ' 'with "--app-root", but not all.') else: # 2) --app-url is not passed but only one of --app-local-path and # --app-root is set. if bool(options.app_root) != bool(options.app_local_path): parser.error('You must specify both "--app-local-path" and ' '"--app-root".') # 3) None of --app-url, --app-local-path and --app-root are passed. elif not options.app_root and not options.app_local_path: parser.error('You must pass either "--app-url" or "--app-local-path" ' 'with "--app-root".') if options.permissions: permission_list = options.permissions.split(':') else: print('Warning: all supported permissions on Android port are added. ' 'Refer to https://github.com/crosswalk-project/' 'crosswalk-website/wiki/Crosswalk-manifest') permission_list = permission_mapping_table.keys() options.permissions = HandlePermissionList(permission_list) options.icon_dict = {} else: try: manifest = ParseManifest(options) except SystemExit as ec: return ec.code if not options.name: parser.error('An APK name is required. Please use the "--name" option.') VerifyAppName(options.name) if not options.package: parser.error('A package name is required. Please use the "--package" ' 'option.') VerifyAppName(options.package, 'packagename') if (options.app_root and options.app_local_path and not os.path.isfile(os.path.join(options.app_root, options.app_local_path))): print('Please make sure that the local path file of launching app ' 'does exist.') sys.exit(7) if options.target_dir: target_dir = os.path.abspath(os.path.expanduser(options.target_dir)) options.target_dir = target_dir if not os.path.isdir(target_dir): os.makedirs(target_dir) try: MakeApk(options, app_info, manifest) except SystemExit as ec: CleanDir(app_info.android_name) CleanDir('out') CleanDir(xpk_temp_dir) return ec.code return 0
def main(argv): parser = optparse.OptionParser() parser.add_option( "-v", "--version", action="store_true", dest="version", default=False, help="The version of this python tool." ) parser.add_option("--verbose", action="store_true", dest="verbose", default=False, help="Print debug messages.") info = ( "The packaging mode of the web application. The value 'shared' " "means that the runtime is shared across multiple application " "instances and that the runtime needs to be distributed separately. " "The value 'embedded' means that the runtime is embedded into the " "application itself and distributed along with it." "Set the default mode as 'embedded'. For example: --mode=embedded" ) parser.add_option("--mode", choices=("embedded", "shared"), default="embedded", help=info) info = ( "The target architecture of the embedded runtime. Supported values: " "%s. If not specified, APKs for all available architectures will be " "generated." % ", ".join(ALL_ARCHITECTURES) ) parser.add_option("--arch", choices=ALL_ARCHITECTURES, help=info) group = optparse.OptionGroup( parser, "Application Source Options", "This packaging tool supports 3 kinds of web application source: " "1) XPK package; 2) manifest.json; 3) various command line options, " "for example, '--app-url' for website, '--app-root' and " "'--app-local-path' for local web application.", ) info = "The path of the XPK package. For example, --xpk=/path/to/xpk/file" group.add_option("--xpk", help=info) info = ( "The manifest file with the detail description of the application. " "For example, --manifest=/path/to/your/manifest/file" ) group.add_option("--manifest", help=info) info = ( "The url of application. " "This flag allows to package website as apk. For example, " "--app-url=http://www.intel.com" ) group.add_option("--app-url", help=info) info = ( "The root path of the web app. " "This flag allows to package local web app as apk. For example, " "--app-root=/root/path/of/the/web/app" ) group.add_option("--app-root", help=info) info = ( "The relative path of entry file based on the value from " "'app_root'. This flag should work with '--app-root' together. " "For example, --app-local-path=/relative/path/of/entry/file" ) group.add_option("--app-local-path", help=info) info = ( "The download URL of the Crosswalk runtime library APK. " "The built-in updater uses the Android download manager to fetch " "the url. " "For example, --xwalk-apk-url=http://myhost/XWalkRuntimeLib.apk" ) group.add_option("--xwalk-apk-url", help=info) parser.add_option_group(group) # Mandatory options group group = optparse.OptionGroup( parser, "Mandatory arguments", "They are used for describing the APK information through " "command line options.", ) info = 'The apk name. For example, --name="Your Application Name"' group.add_option("--name", help=info) info = "The package name. For example, " "--package=com.example.YourPackage" group.add_option("--package", help=info) parser.add_option_group(group) # Optional options group (alphabetical) group = optparse.OptionGroup( parser, "Optional arguments", "They are used for various settings for applications through " "command line options.", ) group.add_option( "--app-version", help="The application version, corresponding to the " "android:versionName attribute of the Android App " 'Manifest. If the version is in the format "ab.cd.efg", ' 'like "1", "3.45" or "12.3.976", an android:versionCode ' 'will be generated automatically if "--app-versionCode" ' 'or "--app-versionCodeBase" are not specified.', ) group.add_option( "--app-versionCode", type="int", help="An integer corresponding to the android:versionCode " "attribute of the Android App Manifest. If specified, the " 'value of the "--app-version" option is not used to set ' "the value of the android:versionCode attribute.", ) group.add_option( "--app-versionCodeBase", type="int", help="An integer with at most 7 digits used to set the " "value of the android:versionCode attribute of the Android " 'App Manifest if "--app-versionCode" is not specified. ' 'If both "--app-versionCodeBase" and "--app-version" are ' "passed, the former will be used to set the " "android:versionCode attribute.", ) info = "The description of the application. For example, " "--description=YourApplicationDescription" group.add_option("--description", help=info) info = ( "Enable proguard to shrink and obfuscate java classes of Crosswalk " "and Chromium, only works with embedded mode." ) group.add_option("--enable-proguard", action="store_true", default=False, help=info) group.add_option( "--enable-remote-debugging", action="store_true", dest="enable_remote_debugging", default=False, help="Enable remote debugging.", ) group.add_option( "--use-animatable-view", action="store_true", dest="use_animatable_view", default=False, help="Enable using animatable view (TextureView).", ) info = ( "The list of external extension paths splitted by OS separators. " "The separators are ':' , ';' and ':' on Linux, Windows and " "Mac OS respectively. For example, " "--extensions=/path/to/extension1:/path/to/extension2." ) group.add_option("--extensions", help=info) info = ( "The native external extension path. Put the architecture-specific " "library file in the corresponding architecture folder " "(armeabi-v7a/arm64-v8a/x86/x86_64) under " "the path. For example, " "--native-extensions=/path/to/native_extension, " "architecture-specific folders, which contain the library, can be " "found under the path." ) group.add_option("--native-extensions", help=info) group.add_option( "-f", "--fullscreen", action="store_true", dest="fullscreen", default=False, help="Make application fullscreen." ) group.add_option("--keep-screen-on", action="store_true", default=False, help="Support keeping screen on") info = "The path of application icon. " "Such as: --icon=/path/to/your/customized/icon" group.add_option("--icon", help=info) info = ( "The orientation of the web app's display on the device. " "For example, --orientation=landscape. The default value is " "'unspecified'. The permitted values are from Android: " "http://developer.android.com/guide/topics/manifest/" "activity-element.html#screen" ) group.add_option("--orientation", help=info) info = "The list of permissions to be used by web application. For example, " "--permissions=geolocation:webgl" group.add_option("--permissions", help=info) info = "Create an Android project directory with Crosswalk at this location." " (See project-only option below)" group.add_option("--project-dir", help=info) info = ( "Must be used with project-dir option. Create an Android project " "directory with Crosswalk but do not build the APK package" ) group.add_option("--project-only", action="store_true", default=False, dest="project_only", help=info) info = "Packaging tool will move the output APKs to the target directory" group.add_option("--target-dir", default=os.getcwd(), help=info) info = ( "Use command lines." "Crosswalk is powered by Chromium and supports Chromium command line." "For example, " "--xwalk-command-line='--chromium-command-1 --xwalk-command-2'" ) group.add_option("--xwalk-command-line", default="", help=info) parser.add_option_group(group) # Keystore options group group = optparse.OptionGroup( parser, "Keystore Options", "The keystore is a signature from web developer, it's used when " "developer wants to distribute the applications.", ) info = "The path to the developer keystore. For example, " "--keystore-path=/path/to/your/developer/keystore" group.add_option("--keystore-path", help=info) info = "The alias name of keystore. For example, --keystore-alias=name" group.add_option("--keystore-alias", help=info) info = "The passcode of keystore. For example, --keystore-passcode=code" group.add_option("--keystore-passcode", help=info) info = "Passcode for alias's private key in the keystore, " "For example, --keystore-alias-passcode=alias-code" group.add_option("--keystore-alias-passcode", help=info) info = ( "Minify and obfuscate javascript and css." "--compressor: compress javascript and css." "--compressor=js: compress javascript." "--compressor=css: compress css." ) group.add_option( "--compressor", dest="compressor", action="callback", callback=ParseParameterForCompressor, type="string", nargs=0, help=info, ) parser.add_option_group(group) parser.add_option("--enable-lzma", action="store_true", dest="enable_lzma", default=False, help="Enable LZMA.") options, _ = parser.parse_args() if len(argv) == 1: parser.print_help() return 0 if options.version: if os.path.isfile("VERSION"): print(GetVersion("VERSION")) return 0 else: parser.error("VERSION was not found, so Crosswalk's version could not " "be determined.") xpk_temp_dir = "" if options.xpk: xpk_name = os.path.splitext(os.path.basename(options.xpk))[0] xpk_temp_dir = tempfile.mkdtemp(prefix="%s-" % xpk_name + "_xpk") CleanDir(xpk_temp_dir) ParseXPK(options, xpk_temp_dir) if options.manifest: options.manifest = os.path.abspath(options.manifest) if not os.path.isfile(options.manifest): print("Error: The manifest file does not exist.") sys.exit(8) if options.app_root and not options.manifest: manifest_path = os.path.join(options.app_root, "manifest.json") if os.path.exists(manifest_path): print("Using manifest.json distributed with the application.") options.manifest = manifest_path app_info = AppInfo() manifest = None if not options.manifest: # The checks here are really convoluted, but at the moment make_apk # misbehaves any of the following conditions is true. if options.app_url: # 1) --app-url must be passed without either --app-local-path or # --app-root. if options.app_root or options.app_local_path: parser.error( 'You must pass either "--app-url" or "--app-local-path" ' 'with "--app-root", but not all.' ) else: # 2) --app-url is not passed but only one of --app-local-path and # --app-root is set. if bool(options.app_root) != bool(options.app_local_path): parser.error('You must specify both "--app-local-path" and ' '"--app-root".') # 3) None of --app-url, --app-local-path and --app-root are passed. elif not options.app_root and not options.app_local_path: parser.error('You must pass either "--app-url" or "--app-local-path" ' 'with "--app-root".') if options.permissions: permission_list = options.permissions.split(":") else: print( "Warning: all supported permissions on Android port are added. " "Refer to https://github.com/crosswalk-project/" "crosswalk-website/wiki/Crosswalk-manifest" ) permission_list = permission_mapping_table.keys() options.permissions = HandlePermissionList(permission_list) options.icon_dict = {} else: try: manifest = ParseManifest(options) except SystemExit as ec: return ec.code if not options.name: parser.error('An APK name is required. Please use the "--name" option.') if not options.package: parser.error('A package name is required. Please use the "--package" ' "option.") VerifyPackageName(options.package) if options.mode != "embedded" and options.enable_lzma: parser.error("LZMA is only available in embedded mode.") if ( options.app_root and options.app_local_path and not os.path.isfile(os.path.join(options.app_root, options.app_local_path)) ): print("Please make sure that the local path file of launching app " "does exist.") sys.exit(7) if options.target_dir: target_dir = os.path.abspath(os.path.expanduser(options.target_dir)) options.target_dir = target_dir if not os.path.isdir(target_dir): os.makedirs(target_dir) if options.project_only and not options.project_dir: print("\nmake_apk.py error: Option --project-only must be used " "with --project-dir") sys.exit(8) if options.enable_proguard and options.mode != "embedded": print("\nmake_apk.py error: Option --enable-proguard only works with " "embedded mode.") sys.exit(14) try: MakeApk(options, app_info, manifest) except SystemExit as ec: return ec.code finally: CleanDir(GetBuildDir(app_info.android_name)) CleanDir(xpk_temp_dir) return 0
def main(argv): parser = optparse.OptionParser() parser.add_option('-v', '--version', action='store_true', dest='version', default=False, help='The version of this python tool.') parser.add_option('--verbose', action="store_true", dest='verbose', default=False, help='Print debug messages.') info = ( 'The packaging mode of the web application. The value \'shared\' ' 'means that the runtime is shared across multiple application ' 'instances and that the runtime needs to be distributed separately. ' 'The value \'embedded\' means that the runtime is embedded into the ' 'application itself and distributed along with it.' 'Set the default mode as \'embedded\'. For example: --mode=embedded') parser.add_option('--mode', choices=('embedded', 'shared'), default='embedded', help=info) info = ( 'The target architecture of the embedded runtime. Supported values: ' '%s. If not specified, APKs for all available architectures will be ' 'generated.' % ', '.join(AllArchitectures())) parser.add_option('--arch', choices=AllArchitectures(), help=info) group = optparse.OptionGroup( parser, 'Application Source Options', 'This packaging tool supports 3 kinds of web application source: ' '1) XPK package; 2) manifest.json; 3) various command line options, ' 'for example, \'--app-url\' for website, \'--app-root\' and ' '\'--app-local-path\' for local web application.') info = ( 'The path of the XPK package. For example, --xpk=/path/to/xpk/file') group.add_option('--xpk', help=info) info = ( 'The manifest file with the detail description of the application. ' 'For example, --manifest=/path/to/your/manifest/file') group.add_option('--manifest', help=info) info = ('The url of application. ' 'This flag allows to package website as apk. For example, ' '--app-url=http://www.intel.com') group.add_option('--app-url', help=info) info = ('The root path of the web app. ' 'This flag allows to package local web app as apk. For example, ' '--app-root=/root/path/of/the/web/app') group.add_option('--app-root', help=info) info = ( 'The relative path of entry file based on the value from ' '\'app_root\'. This flag should work with \'--app-root\' together. ' 'For example, --app-local-path=/relative/path/of/entry/file') group.add_option('--app-local-path', help=info) parser.add_option_group(group) # Mandatory options group group = optparse.OptionGroup( parser, 'Mandatory arguments', 'They are used for describing the APK information through ' 'command line options.') info = ('The apk name. For example, --name="Your Application Name"') group.add_option('--name', help=info) info = ('The package name. For example, ' '--package=com.example.YourPackage') group.add_option('--package', help=info) parser.add_option_group(group) # Optional options group (alphabetical) group = optparse.OptionGroup( parser, 'Optional arguments', 'They are used for various settings for applications through ' 'command line options.') info = ('The version name of the application. ' 'For example, --app-version=1.0.0') group.add_option('--app-version', help=info) info = ('The version code of the application. ' 'For example, --app-versionCode=24') group.add_option('--app-versionCode', type='int', help=info) info = ('The version code base of the application. Version code will ' 'be made by adding a prefix based on architecture to the version ' 'code base. For example, --app-versionCodeBase=24') group.add_option('--app-versionCodeBase', type='int', help=info) info = ('The description of the application. For example, ' '--description=YourApplicationDescription') group.add_option('--description', help=info) group.add_option('--enable-remote-debugging', action='store_true', dest='enable_remote_debugging', default=False, help='Enable remote debugging.') group.add_option('--use-animatable-view', action='store_true', dest='use_animatable_view', default=False, help='Enable using animatable view (TextureView).') info = ('The list of external extension paths splitted by OS separators. ' 'The separators are \':\' , \';\' and \':\' on Linux, Windows and ' 'Mac OS respectively. For example, ' '--extensions=/path/to/extension1:/path/to/extension2.') group.add_option('--extensions', help=info) group.add_option('-f', '--fullscreen', action='store_true', dest='fullscreen', default=False, help='Make application fullscreen.') group.add_option('--keep-screen-on', action='store_true', default=False, help='Support keeping screen on') info = ('The path of application icon. ' 'Such as: --icon=/path/to/your/customized/icon') group.add_option('--icon', help=info) info = ('The orientation of the web app\'s display on the device. ' 'For example, --orientation=landscape. The default value is ' '\'unspecified\'. The permitted values are from Android: ' 'http://developer.android.com/guide/topics/manifest/' 'activity-element.html#screen') group.add_option('--orientation', help=info) info = ( 'The list of permissions to be used by web application. For example, ' '--permissions=geolocation:webgl') group.add_option('--permissions', help=info) info = ( 'Create an Android project directory with Crosswalk at this location.' ' (See project-only option below)') group.add_option('--project-dir', help=info) info = ('Must be used with project-dir option. Create an Android project ' 'directory with Crosswalk but do not build the APK package') group.add_option('--project-only', action='store_true', default=False, dest='project_only', help=info) info = ('Packaging tool will move the output APKs to the target directory') group.add_option('--target-dir', default=os.getcwd(), help=info) info = ( 'Use command lines.' 'Crosswalk is powered by Chromium and supports Chromium command line.' 'For example, ' '--xwalk-command-line=\'--chromium-command-1 --xwalk-command-2\'') group.add_option('--xwalk-command-line', default='', help=info) parser.add_option_group(group) # Keystore options group group = optparse.OptionGroup( parser, 'Keystore Options', 'The keystore is a signature from web developer, it\'s used when ' 'developer wants to distribute the applications.') info = ('The path to the developer keystore. For example, ' '--keystore-path=/path/to/your/developer/keystore') group.add_option('--keystore-path', help=info) info = ('The alias name of keystore. For example, --keystore-alias=name') group.add_option('--keystore-alias', help=info) info = ('The passcode of keystore. For example, --keystore-passcode=code') group.add_option('--keystore-passcode', help=info) info = ('Passcode for alias\'s private key in the keystore, ' 'For example, --keystore-alias-passcode=alias-code') group.add_option('--keystore-alias-passcode', help=info) info = ('Minify and obfuscate javascript and css.' '--compressor: compress javascript and css.' '--compressor=js: compress javascript.' '--compressor=css: compress css.') group.add_option('--compressor', dest='compressor', action='callback', callback=ParseParameterForCompressor, type='string', nargs=0, help=info) parser.add_option_group(group) options, _ = parser.parse_args() if len(argv) == 1: parser.print_help() return 0 if options.version: if os.path.isfile('VERSION'): print(GetVersion('VERSION')) return 0 else: parser.error( 'VERSION was not found, so Crosswalk\'s version could not ' 'be determined.') xpk_temp_dir = '' if options.xpk: xpk_name = os.path.splitext(os.path.basename(options.xpk))[0] xpk_temp_dir = tempfile.mkdtemp(prefix="%s-" % xpk_name + '_xpk') CleanDir(xpk_temp_dir) ParseXPK(options, xpk_temp_dir) if options.manifest: options.manifest = os.path.abspath(options.manifest) if not os.path.isfile(options.manifest): print('Error: The manifest file does not exist.') sys.exit(8) if options.app_root and not options.manifest: manifest_path = os.path.join(options.app_root, 'manifest.json') if os.path.exists(manifest_path): print('Using manifest.json distributed with the application.') options.manifest = manifest_path app_info = AppInfo() manifest = None if not options.manifest: # The checks here are really convoluted, but at the moment make_apk # misbehaves any of the following conditions is true. if options.app_url: # 1) --app-url must be passed without either --app-local-path or # --app-root. if options.app_root or options.app_local_path: parser.error( 'You must pass either "--app-url" or "--app-local-path" ' 'with "--app-root", but not all.') else: # 2) --app-url is not passed but only one of --app-local-path and # --app-root is set. if bool(options.app_root) != bool(options.app_local_path): parser.error('You must specify both "--app-local-path" and ' '"--app-root".') # 3) None of --app-url, --app-local-path and --app-root are passed. elif not options.app_root and not options.app_local_path: parser.error( 'You must pass either "--app-url" or "--app-local-path" ' 'with "--app-root".') if options.permissions: permission_list = options.permissions.split(':') else: print( 'Warning: all supported permissions on Android port are added. ' 'Refer to https://github.com/crosswalk-project/' 'crosswalk-website/wiki/Crosswalk-manifest') permission_list = permission_mapping_table.keys() options.permissions = HandlePermissionList(permission_list) options.icon_dict = {} else: try: manifest = ParseManifest(options) except SystemExit as ec: return ec.code if not options.name: parser.error( 'An APK name is required. Please use the "--name" option.') if not options.package: parser.error('A package name is required. Please use the "--package" ' 'option.') VerifyPackageName(options.package) if (options.app_root and options.app_local_path and not os.path.isfile( os.path.join(options.app_root, options.app_local_path))): print('Please make sure that the local path file of launching app ' 'does exist.') sys.exit(7) if options.target_dir: target_dir = os.path.abspath(os.path.expanduser(options.target_dir)) options.target_dir = target_dir if not os.path.isdir(target_dir): os.makedirs(target_dir) if options.project_only and not options.project_dir: print('\nmake_apk.py error: Option --project-only must be used ' 'with --project-dir') sys.exit(8) try: MakeApk(options, app_info, manifest) except SystemExit as ec: return ec.code finally: CleanDir(GetBuildDir(app_info.android_name)) CleanDir(xpk_temp_dir) return 0
def main(argv): parser = optparse.OptionParser() parser.add_option( "-v", "--version", action="store_true", dest="version", default=False, help="The version of this python tool." ) parser.add_option("--verbose", action="store_true", dest="verbose", default=False, help="Print debug messages.") info = ( "The packaging mode of the web application. The value 'shared' " "means that the runtime is shared across multiple application " "instances and that the runtime needs to be distributed separately. " "The value 'embedded' means that the runtime is embedded into the " "application itself and distributed along with it." "Set the default mode as 'embedded'. For example: --mode=embedded" ) parser.add_option("--mode", choices=("embedded", "shared"), default="embedded", help=info) info = ( "The target architecture of the embedded runtime. Supported values " "are 'x86' and 'arm'. Note, if undefined, APKs for all possible " "architestures will be generated." ) parser.add_option("--arch", choices=AllArchitectures(), help=info) group = optparse.OptionGroup( parser, "Application Source Options", "This packaging tool supports 3 kinds of web application source: " "1) XPK package; 2) manifest.json; 3) various command line options, " "for example, '--app-url' for website, '--app-root' and " "'--app-local-path' for local web application.", ) info = "The path of the XPK package. For example, --xpk=/path/to/xpk/file" group.add_option("--xpk", help=info) info = ( "The manifest file with the detail description of the application. " "For example, --manifest=/path/to/your/manifest/file" ) group.add_option("--manifest", help=info) info = ( "The url of application. " "This flag allows to package website as apk. For example, " "--app-url=http://www.intel.com" ) group.add_option("--app-url", help=info) info = ( "The root path of the web app. " "This flag allows to package local web app as apk. For example, " "--app-root=/root/path/of/the/web/app" ) group.add_option("--app-root", help=info) info = ( "The relative path of entry file based on the value from " "'app_root'. This flag should work with '--app-root' together. " "For example, --app-local-path=/relative/path/of/entry/file" ) group.add_option("--app-local-path", help=info) parser.add_option_group(group) group = optparse.OptionGroup( parser, "Mandatory arguments", "They are used for describing the APK information through " "command line options.", ) info = 'The apk name. For example, --name="Your Application Name"' group.add_option("--name", help=info) info = "The package name. For example, " "--package=com.example.YourPackage" group.add_option("--package", help=info) parser.add_option_group(group) group = optparse.OptionGroup( parser, "Optional arguments", "They are used for various settings for applications through " "command line options.", ) info = "The version name of the application. " "For example, --app-version=1.0.0" group.add_option("--app-version", help=info) info = "The version code of the application. " "For example, --app-versionCode=24" group.add_option("--app-versionCode", type="int", help=info) info = ( "The version code base of the application. Version code will " "be made by adding a prefix based on architecture to the version " "code base. For example, --app-versionCodeBase=24" ) group.add_option("--app-versionCodeBase", type="int", help=info) info = ( "Use command lines." "Crosswalk is powered by Chromium and supports Chromium command line." "For example, " "--xwalk-command-line='--chromium-command-1 --xwalk-command-2'" ) group.add_option("--xwalk-command-line", default="", help=info) info = "The description of the application. For example, " "--description=YourApplicationDescription" group.add_option("--description", help=info) group.add_option( "--enable-remote-debugging", action="store_true", dest="enable_remote_debugging", default=False, help="Enable remote debugging.", ) info = ( "The list of external extension paths splitted by OS separators. " "The separators are ':' , ';' and ':' on Linux, Windows and " "Mac OS respectively. For example, " "--extensions=/path/to/extension1:/path/to/extension2." ) group.add_option("--extensions", help=info) group.add_option( "-f", "--fullscreen", action="store_true", dest="fullscreen", default=False, help="Make application fullscreen." ) group.add_option("--keep-screen-on", action="store_true", default=False, help="Support keeping screen on") info = "The path of application icon. " "Such as: --icon=/path/to/your/customized/icon" group.add_option("--icon", help=info) info = ( "The orientation of the web app's display on the device. " "For example, --orientation=landscape. The default value is " "'unspecified'. The permitted values are from Android: " "http://developer.android.com/guide/topics/manifest/" "activity-element.html#screen" ) group.add_option("--orientation", help=info) info = "The list of permissions to be used by web application. For example, " "--permissions=geolocation:webgl" group.add_option("--permissions", help=info) info = "Packaging tool will move the output APKS to the target directory" group.add_option("--target-dir", default=os.getcwd(), help=info) parser.add_option_group(group) group = optparse.OptionGroup( parser, "Keystore Options", "The keystore is a signature from web developer, it's used when " "developer wants to distribute the applications.", ) info = "The path to the developer keystore. For example, " "--keystore-path=/path/to/your/developer/keystore" group.add_option("--keystore-path", help=info) info = "The alias name of keystore. For example, --keystore-alias=name" group.add_option("--keystore-alias", help=info) info = "The passcode of keystore. For example, --keystore-passcode=code" group.add_option("--keystore-passcode", help=info) info = ( "Minify and obfuscate javascript and css." "--compressor: compress javascript and css." "--compressor=js: compress javascript." "--compressor=css: compress css." ) group.add_option( "--compressor", dest="compressor", action="callback", callback=ParseParameterForCompressor, type="string", nargs=0, help=info, ) parser.add_option_group(group) options, _ = parser.parse_args() if len(argv) == 1: parser.print_help() return 0 if options.version: if os.path.isfile("VERSION"): print(GetVersion("VERSION")) return 0 else: parser.error("VERSION was not found, so Crosswalk's version could not " "be determined.") xpk_temp_dir = "" if options.xpk: xpk_name = os.path.splitext(os.path.basename(options.xpk))[0] xpk_temp_dir = xpk_name + "_xpk" ParseXPK(options, xpk_temp_dir) if options.app_root and not options.manifest: manifest_path = os.path.join(options.app_root, "manifest.json") if os.path.exists(manifest_path): print("Using manifest.json distributed with the application.") options.manifest = manifest_path app_info = AppInfo() if not options.manifest: if options.package: VerifyAppName(options.package, "packagename") else: parser.error('A package name is required. Please use the "--package" ' "option.") if options.name: VerifyAppName(options.name) app_info.original_name = options.name options.name = ReplaceSpaceWithUnderscore(options.name) else: parser.error('An APK name is required. Please use the "--name" option.') # The checks here are really convoluted, but at the moment make_apk # misbehaves any of the following conditions is true. if options.app_url: # 1) --app-url must be passed without either --app-local-path or # --app-root. if options.app_root or options.app_local_path: parser.error( 'You must pass either "--app-url" or "--app-local-path" ' 'with "--app-root", but not all.' ) else: # 2) --app-url is not passed but only one of --app-local-path and # --app-root is set. if bool(options.app_root) != bool(options.app_local_path): parser.error('You must specify both "--app-local-path" and ' '"--app-root".') # 3) None of --app-url, --app-local-path and --app-root are passed. elif not options.app_root and not options.app_local_path: parser.error('You must pass either "--app-url" or "--app-local-path" ' 'with "--app-root".') if options.permissions: permission_list = options.permissions.split(":") else: print( "Warning: all supported permissions on Android port are added. " "Refer to https://github.com/crosswalk-project/" "crosswalk-website/wiki/Crosswalk-manifest" ) permission_list = permission_mapping_table.keys() options.permissions = HandlePermissionList(permission_list) options.icon_dict = {} else: try: ParseManifest(options, app_info) except SystemExit as ec: return ec.code if ( options.app_root and options.app_local_path and not os.path.isfile(os.path.join(options.app_root, options.app_local_path)) ): print("Please make sure that the local path file of launching app " "does exist.") sys.exit(7) if options.target_dir: target_dir = os.path.abspath(os.path.expanduser(options.target_dir)) options.target_dir = target_dir if not os.path.isdir(target_dir): os.makedirs(target_dir) try: MakeApk(options, app_info) except SystemExit as ec: CleanDir(options.name) CleanDir("out") CleanDir(xpk_temp_dir) return ec.code return 0
def main(argv): parser = optparse.OptionParser() parser.add_option('-v', '--version', action='store_true', dest='version', default=False, help='The version of this python tool.') parser.add_option('--verbose', action="store_true", dest='verbose', default=False, help='Print debug messages.') info = ('The packaging mode of the web application. The value \'shared\' ' 'means that the runtime is shared across multiple application ' 'instances and that the runtime needs to be distributed separately. ' 'The value \'embedded\' means that the runtime is embedded into the ' 'application itself and distributed along with it.' 'Set the default mode as \'embedded\'. For example: --mode=embedded') parser.add_option('--mode', choices=('embedded', 'shared'), default='embedded', help=info) info = ('The target architecture of the embedded runtime. Supported values: ' '%s. If not specified, APKs for all available architectures will be ' 'generated.' % ', '.join(ALL_ARCHITECTURES)) parser.add_option('--arch', choices=ALL_ARCHITECTURES, help=info) group = optparse.OptionGroup(parser, 'Application Source Options', 'This packaging tool supports 3 kinds of web application source: ' '1) XPK package; 2) manifest.json; 3) various command line options, ' 'for example, \'--app-url\' for website, \'--app-root\' and ' '\'--app-local-path\' for local web application.') info = ('The path of the XPK package. For example, --xpk=/path/to/xpk/file') group.add_option('--xpk', help=info) info = ('The manifest file with the detail description of the application. ' 'For example, --manifest=/path/to/your/manifest/file') group.add_option('--manifest', help=info) info = ('The url of application. ' 'This flag allows to package website as apk. For example, ' '--app-url=http://www.intel.com') group.add_option('--app-url', help=info) info = ('The root path of the web app. ' 'This flag allows to package local web app as apk. For example, ' '--app-root=/root/path/of/the/web/app') group.add_option('--app-root', help=info) info = ('The relative path of entry file based on the value from ' '\'app_root\'. This flag should work with \'--app-root\' together. ' 'For example, --app-local-path=/relative/path/of/entry/file') group.add_option('--app-local-path', help=info) info = ('The download URL of the Crosswalk runtime library APK. ' 'The built-in updater uses the Android download manager to fetch ' 'the url. ' 'For example, --xwalk-apk-url=http://myhost/XWalkRuntimeLib.apk') group.add_option('--xwalk-apk-url', help=info) parser.add_option_group(group) # Mandatory options group group = optparse.OptionGroup(parser, 'Mandatory arguments', 'They are used for describing the APK information through ' 'command line options.') info = ('The apk name. For example, --name="Your Application Name"') group.add_option('--name', help=info) info = ('The package name. For example, ' '--package=com.example.YourPackage') group.add_option('--package', help=info) parser.add_option_group(group) # Optional options group (alphabetical) group = optparse.OptionGroup(parser, 'Optional arguments', 'They are used for various settings for applications through ' 'command line options.') group.add_option('--app-version', help='The application version, corresponding to the ' 'android:versionName attribute of the Android App ' 'Manifest. If the version is in the format "ab.cd.efg", ' 'like "1", "3.45" or "12.3.976", an android:versionCode ' 'will be generated automatically if "--app-versionCode" ' 'or "--app-versionCodeBase" are not specified.') group.add_option('--app-versionCode', type='int', help='An integer corresponding to the android:versionCode ' 'attribute of the Android App Manifest. If specified, the ' 'value of the "--app-version" option is not used to set ' 'the value of the android:versionCode attribute.') group.add_option('--app-versionCodeBase', type='int', help='An integer with at most 7 digits used to set the ' 'value of the android:versionCode attribute of the Android ' 'App Manifest if "--app-versionCode" is not specified. ' 'If both "--app-versionCodeBase" and "--app-version" are ' 'passed, the former will be used to set the ' 'android:versionCode attribute.') info = ('The description of the application. For example, ' '--description=YourApplicationDescription') group.add_option('--description', help=info) info = ('Enable proguard to shrink and obfuscate java classes of Crosswalk ' 'and Chromium, only works with embedded mode.') group.add_option('--enable-proguard', action='store_true', default=False, help=info) group.add_option('--enable-remote-debugging', action='store_true', dest='enable_remote_debugging', default=False, help='Enable remote debugging.') group.add_option('--use-animatable-view', action='store_true', dest='use_animatable_view', default=False, help='Enable using animatable view (TextureView).') info = ('The list of external extension paths splitted by OS separators. ' 'The separators are \':\' , \';\' and \':\' on Linux, Windows and ' 'Mac OS respectively. For example, ' '--extensions=/path/to/extension1:/path/to/extension2.') group.add_option('--extensions', help=info) info = ('The native external extension path. Put the architecture-specific ' 'library file in the corresponding architecture folder ' '(armeabi-v7a/arm64-v8a/x86/x86_64) under ' 'the path. For example, ' '--native-extensions=/path/to/native_extension, ' 'architecture-specific folders, which contain the library, can be ' 'found under the path.') group.add_option('--native-extensions', help=info) group.add_option('-f', '--fullscreen', action='store_true', dest='fullscreen', default=False, help='Make application fullscreen.') group.add_option('--keep-screen-on', action='store_true', default=False, help='Support keeping screen on') info = ('The path of application icon. ' 'Such as: --icon=/path/to/your/customized/icon') group.add_option('--icon', help=info) info = ('The orientation of the web app\'s display on the device. ' 'For example, --orientation=landscape. The default value is ' '\'unspecified\'. The permitted values are from Android: ' 'http://developer.android.com/guide/topics/manifest/' 'activity-element.html#screen') group.add_option('--orientation', help=info) info = ('The list of permissions to be used by web application. For example, ' '--permissions=geolocation:webgl') group.add_option('--permissions', help=info) info = ('Create an Android project directory with Crosswalk at this location.' ' (See project-only option below)') group.add_option('--project-dir', help=info) info = ('Must be used with project-dir option. Create an Android project ' 'directory with Crosswalk but do not build the APK package') group.add_option('--project-only', action='store_true', default=False, dest='project_only', help=info) info = ('Packaging tool will move the output APKs to the target directory') group.add_option('--target-dir', default=os.getcwd(), help=info) info = ('Use command lines.' 'Crosswalk is powered by Chromium and supports Chromium command line.' 'For example, ' '--xwalk-command-line=\'--chromium-command-1 --xwalk-command-2\'') group.add_option('--xwalk-command-line', default='', help=info) parser.add_option_group(group) # Keystore options group group = optparse.OptionGroup(parser, 'Keystore Options', 'The keystore is a signature from web developer, it\'s used when ' 'developer wants to distribute the applications.') info = ('The path to the developer keystore. For example, ' '--keystore-path=/path/to/your/developer/keystore') group.add_option('--keystore-path', help=info) info = ('The alias name of keystore. For example, --keystore-alias=name') group.add_option('--keystore-alias', help=info) info = ('The passcode of keystore. For example, --keystore-passcode=code') group.add_option('--keystore-passcode', help=info) info = ('Passcode for alias\'s private key in the keystore, ' 'For example, --keystore-alias-passcode=alias-code') group.add_option('--keystore-alias-passcode', help=info) info = ('Minify and obfuscate javascript and css.' '--compressor: compress javascript and css.' '--compressor=js: compress javascript.' '--compressor=css: compress css.') group.add_option('--compressor', dest='compressor', action='callback', callback=ParseParameterForCompressor, type='string', nargs=0, help=info) parser.add_option_group(group) parser.add_option('--enable-lzma', action='store_true', dest='enable_lzma', default=False, help='Enable LZMA.') options, _ = parser.parse_args() if len(argv) == 1: parser.print_help() return 0 if options.version: if os.path.isfile('VERSION'): print(GetVersion('VERSION')) return 0 else: parser.error('VERSION was not found, so Crosswalk\'s version could not ' 'be determined.') xpk_temp_dir = '' if options.xpk: xpk_name = os.path.splitext(os.path.basename(options.xpk))[0] xpk_temp_dir = tempfile.mkdtemp(prefix="%s-" % xpk_name + '_xpk') CleanDir(xpk_temp_dir) ParseXPK(options, xpk_temp_dir) if options.manifest: options.manifest = os.path.abspath(options.manifest) if not os.path.isfile(options.manifest): print('Error: The manifest file does not exist.') sys.exit(8) try: manifest = ParseManifest(options) except SystemExit as ec: return ec.code else: manifest = None # The checks here are really convoluted, but at the moment make_apk # misbehaves any of the following conditions is true. if options.app_url: # 1) --app-url must be passed without either --app-local-path or # --app-root. if options.app_root or options.app_local_path: parser.error('You must pass either "--app-url" or "--app-local-path" ' 'with "--app-root", but not all.') else: # 2) --app-url is not passed but only one of --app-local-path and # --app-root is set. if bool(options.app_root) != bool(options.app_local_path): parser.error('You must specify both "--app-local-path" and ' '"--app-root".') # 3) None of --app-url, --app-local-path and --app-root are passed. elif not options.app_root and not options.app_local_path: parser.error('You must pass either "--app-url" or "--app-local-path" ' 'with "--app-root".') if options.permissions: permission_list = options.permissions.split(':') else: print('Warning: all supported permissions on Android port are added. ' 'Refer to https://github.com/crosswalk-project/' 'crosswalk-website/wiki/Crosswalk-manifest') permission_list = permission_mapping_table.keys() options.permissions = HandlePermissionList(permission_list) options.icon_dict = {} if not options.name: parser.error('An APK name is required. Please use the "--name" option.') if not options.package: parser.error('A package name is required. Please use the "--package" ' 'option.') VerifyPackageName(options.package) if options.mode != 'embedded' and options.enable_lzma: parser.error('LZMA is only available in embedded mode.') if (options.app_root and options.app_local_path and not os.path.isfile(os.path.join(options.app_root, options.app_local_path))): print('Please make sure that the local path file of launching app ' 'does exist.') sys.exit(7) if options.target_dir: target_dir = os.path.abspath(os.path.expanduser(options.target_dir)) options.target_dir = target_dir if not os.path.isdir(target_dir): os.makedirs(target_dir) if options.project_only and not options.project_dir: print('\nmake_apk.py error: Option --project-only must be used ' 'with --project-dir') sys.exit(8) if options.enable_proguard and options.mode != 'embedded': print('\nmake_apk.py error: Option --enable-proguard only works with ' 'embedded mode.') sys.exit(14) try: app_info = AppInfo() MakeApk(options, app_info, manifest) except SystemExit as ec: return ec.code finally: CleanDir(GetBuildDir(app_info.android_name)) CleanDir(xpk_temp_dir) return 0