From: Eurogiciel-BOT Date: Tue, 12 Aug 2014 09:09:06 +0000 (+0000) Subject: Upstream version 9.37.190.0 X-Git-Tag: submit/tizen_common/20140821.160842~8 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fframework%2Fweb%2Fcrosswalk.git;a=commitdiff_plain;h=b916acaef8009aa82e713aa9c24bcfc3c14a9bc2 Upstream version 9.37.190.0 Upstream commit-id 32f878d8009095f9fcdbeb1cb325443d834cff7c Change-Id: Iadc8893d5718b81117a32e8375a495598ed8fc9a Signed-off-by: Eurogiciel-BOT --- diff --git a/packaging/crosswalk.spec b/packaging/crosswalk.spec index 8e47581..83c35df 100644 --- a/packaging/crosswalk.spec +++ b/packaging/crosswalk.spec @@ -16,7 +16,7 @@ %endif Name: crosswalk -Version: 8.37.187.0 +Version: 9.37.190.0 Release: 0 Summary: Crosswalk is an app runtime based on Chromium License: (BSD-3-Clause and LGPL-2.1+) diff --git a/src/xwalk/VERSION b/src/xwalk/VERSION index d589d87..cf0da9d 100644 --- a/src/xwalk/VERSION +++ b/src/xwalk/VERSION @@ -1,4 +1,4 @@ -MAJOR=8 +MAJOR=9 MINOR=37 -BUILD=187 +BUILD=190 PATCH=0 diff --git a/src/xwalk/app/tools/android/compress_js_and_css.py b/src/xwalk/app/tools/android/compress_js_and_css.py index 4f70cd4..a9c77b5 100755 --- a/src/xwalk/app/tools/android/compress_js_and_css.py +++ b/src/xwalk/app/tools/android/compress_js_and_css.py @@ -14,7 +14,7 @@ def GetJARFilename(): # yuicompressor-*.jar was gotten from http://yui.github.io/yuicompressor/. file_name = "yuicompressor-%s.jar" % version cur_dir = os.path.realpath(os.path.dirname(__file__)) - return os.path.join(cur_dir, "libs", file_name) + return os.path.join(cur_dir, file_name) def ExecuteCmd(file_list, ext): diff --git a/src/xwalk/app/tools/android/customize.py b/src/xwalk/app/tools/android/customize.py index 984101f..510dd63 100755 --- a/src/xwalk/app/tools/android/customize.py +++ b/src/xwalk/app/tools/android/customize.py @@ -116,9 +116,9 @@ def Prepare(app_info, compressor): app_root = app_info.app_root if os.path.exists(name): shutil.rmtree(name) - shutil.copytree('app_src', name) + shutil.copytree('template', name) shutil.rmtree(os.path.join(name, 'src')) - src_root = os.path.join('app_src', 'src', 'org', 'xwalk', 'app', 'template') + src_root = os.path.join('template', 'src', 'org', 'xwalk', 'app', 'template') src_activity = os.path.join(src_root, 'AppTemplateActivity.java') if not os.path.isfile(src_activity): print ('Please make sure that the java file' @@ -130,20 +130,19 @@ def Prepare(app_info, compressor): dest_activity = name + 'Activity.java' shutil.copyfile(src_activity, os.path.join(root_path, dest_activity)) if app_root: - assets_path = os.path.join(name, 'assets') - shutil.rmtree(assets_path) - os.makedirs(assets_path) - app_src_path = os.path.join(assets_path, 'www') - shutil.copytree(app_root, app_src_path) + assets_path = os.path.join(name, 'assets', 'www') + if os.path.isdir(assets_path): + shutil.rmtree(assets_path) + shutil.copytree(app_root, assets_path) if compressor: - CompressSourceFiles(app_src_path, compressor) + CompressSourceFiles(assets_path, compressor) def CustomizeStringXML(name, description): strings_path = os.path.join(name, 'res', 'values', 'strings.xml') if not os.path.isfile(strings_path): print ('Please make sure strings_xml' - ' exists under app_src folder.') + ' exists under template folder.') sys.exit(6) if description: @@ -185,7 +184,7 @@ def CustomizeXML(app_info, description, icon_dict, manifest, permissions): manifest_path = os.path.join(name, 'AndroidManifest.xml') if not os.path.isfile(manifest_path): print ('Please make sure AndroidManifest.xml' - ' exists under app_src folder.') + ' exists under template folder.') sys.exit(6) CustomizeStringXML(name, description) diff --git a/src/xwalk/app/tools/android/gyp/ant.py b/src/xwalk/app/tools/android/gyp/ant.py deleted file mode 100755 index 6eca4fc..0000000 --- a/src/xwalk/app/tools/android/gyp/ant.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# pylint: disable=F0401 - -"""An Ant wrapper that suppresses useless Ant output. - -Ant build scripts output "BUILD SUCCESSFUL" and build timing at the end of -every build. In the Android build, this just adds a lot of useless noise to the -build output. This script forwards its arguments to ant, and prints Ant's -output up until the BUILD SUCCESSFUL line. -""" - -import sys - -from util import build_utils - - -def main(argv): - stdout = build_utils.CheckCallDie(['ant'] + argv[1:], suppress_output=True) - stdout = stdout.decode("utf-8").strip().split('\n') - for line in stdout: - if line.strip() == 'BUILD SUCCESSFUL': - break - print(line) - - -if __name__ == '__main__': - sys.exit(main(sys.argv)) diff --git a/src/xwalk/app/tools/android/gyp/dex.py b/src/xwalk/app/tools/android/gyp/dex.py deleted file mode 100755 index ca8ad32..0000000 --- a/src/xwalk/app/tools/android/gyp/dex.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# pylint: disable=F0401 - -import optparse -import os -import sys - -from util import build_utils -from util import md5_check - -def Find(name, path): - for root, _, files in os.walk(path): - if name in files: - return os.path.join(root, name) - - -def AddExeExtensions(name): - exts_str = os.environ.get('PATHEXT', '').lower() - exts = [_f for _f in exts_str.split(os.pathsep) if _f] - result = [] - result.append(name) - for e in exts: - result.append(name + e) - return result - - -def DoDex(options, paths): - dx_binary = '' - for dx_str in AddExeExtensions('dx'): - dx_binary = Find(dx_str, options.android_sdk_root) - if dx_binary: - break - dex_cmd = [dx_binary, '--dex', '--output', options.dex_path] + paths - - record_path = '%s.md5.stamp' % options.dex_path - md5_check.CallAndRecordIfStale( - lambda: build_utils.CheckCallDie(dex_cmd, suppress_output=True), - record_path=record_path, - input_paths=paths, - input_strings=dex_cmd) - - build_utils.Touch(options.dex_path) - - -def main(): - parser = optparse.OptionParser() - parser.add_option('--android-sdk-root', help='Android sdk root directory.') - parser.add_option('--dex-path', help='Dex output path.') - parser.add_option('--stamp', help='Path to touch on success.') - - # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. - parser.add_option('--ignore', help='Ignored.') - - options, paths = parser.parse_args() - - DoDex(options, paths) - - if options.stamp: - build_utils.Touch(options.stamp) - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/src/xwalk/app/tools/android/gyp/finalize_apk.py b/src/xwalk/app/tools/android/gyp/finalize_apk.py deleted file mode 100755 index 39eba2b..0000000 --- a/src/xwalk/app/tools/android/gyp/finalize_apk.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# pylint: disable=F0401 -"""Signs and zipaligns APK. -""" - -import optparse -import shutil -import sys - -from util import build_utils - -def SignApk(keystore_path, unsigned_path, signed_path, alias, code, alias_code): - intermediate_path = unsigned_path + '.copy' - shutil.copy(unsigned_path, intermediate_path) - sign_cmd = [ - 'jarsigner', - '-sigalg', 'MD5withRSA', - '-digestalg', 'SHA1', - '-keystore', keystore_path, - '-storepass', code, - '-keypass', alias_code, - intermediate_path, alias - ] - build_utils.CheckCallDie(sign_cmd) - shutil.move(intermediate_path, signed_path) - - -def AlignApk(zipalign_path, unaligned_path, final_path): - align_cmd = [ - zipalign_path, - '-f', '4', # 4 bytes - unaligned_path, - final_path - ] - build_utils.CheckCallDie(align_cmd) - - -def main(): - parser = optparse.OptionParser() - - parser.add_option('--zipalign-path', help='Path to the zipalign tool.') - parser.add_option('--unsigned-apk-path', help='Path to input unsigned APK.') - parser.add_option('--final-apk-path', - help='Path to output signed and aligned APK.') - parser.add_option('--keystore-path', help='Path to keystore for signing.') - parser.add_option('--keystore-alias', help='Alias name of keystore.') - parser.add_option('--keystore-passcode', help='Passcode of keystore.') - parser.add_option('--keystore-alias-passcode', - help='Passcode for alias\'s private key in the keystore.') - parser.add_option('--stamp', help='Path to touch on success.') - options, _ = parser.parse_args() - - signed_apk_path = options.unsigned_apk_path + '.signed.apk' - SignApk(options.keystore_path, options.unsigned_apk_path, - signed_apk_path, options.keystore_alias, options.keystore_passcode, - options.keystore_alias_passcode) - AlignApk(options.zipalign_path, signed_apk_path, options.final_apk_path) - - if options.stamp: - build_utils.Touch(options.stamp) - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/src/xwalk/app/tools/android/gyp/jar.py b/src/xwalk/app/tools/android/gyp/jar.py deleted file mode 100755 index 8cb3749..0000000 --- a/src/xwalk/app/tools/android/gyp/jar.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# pylint: disable=F0401 - -import fnmatch -import optparse -import os -import sys - -from util import build_utils -from util import md5_check - - -def DoJar(options): - class_files = build_utils.FindInDirectory(options.classes_dir, '*.class') - for exclude in options.excluded_classes.split(): - class_files = [f for f in class_files if not fnmatch.fnmatch(f, exclude)] - - jar_path = os.path.abspath(options.jar_path) - - # The paths of the files in the jar will be the same as they are passed in to - # the command. Because of this, the command should be run in - # options.classes_dir so the .class file paths in the jar are correct. - jar_cwd = options.classes_dir - class_files_rel = [os.path.relpath(f, jar_cwd) for f in class_files] - jar_cmd = ['jar', 'cf0', jar_path] + class_files_rel - - record_path = '%s.md5.stamp' % options.jar_path - md5_check.CallAndRecordIfStale( - lambda: build_utils.CheckCallDie(jar_cmd, cwd=jar_cwd), - record_path=record_path, - input_paths=class_files, - input_strings=jar_cmd) - - build_utils.Touch(options.jar_path) - - -def main(): - parser = optparse.OptionParser() - parser.add_option('--classes-dir', help='Directory containing .class files.') - parser.add_option('--jar-path', help='Jar output path.') - parser.add_option('--excluded-classes', - help='List of .class file patterns to exclude from the jar.') - parser.add_option('--stamp', help='Path to touch on success.') - - options, _ = parser.parse_args() - - DoJar(options) - - if options.stamp: - build_utils.Touch(options.stamp) - - -if __name__ == '__main__': - sys.exit(main()) - diff --git a/src/xwalk/app/tools/android/gyp/javac.py b/src/xwalk/app/tools/android/gyp/javac.py deleted file mode 100755 index 7584e62..0000000 --- a/src/xwalk/app/tools/android/gyp/javac.py +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. -# pylint: disable=F0401 - -import fnmatch -import optparse -import os -import sys - -from util import build_utils -from util import md5_check - - -def DoJavac(options): - output_dir = options.output_dir - - java_files = build_utils.FindInDirectories(options.src_dirs, '*.java') - if options.javac_includes: - filtered_java_files = [] - for f in java_files: - for include in options.javac_includes: - if fnmatch.fnmatch(f, include): - filtered_java_files.append(f) - break - java_files = filtered_java_files - - # Compiling guava with certain orderings of input files causes a compiler - # crash... Sorted order works, so use that. - # See https://code.google.com/p/guava-libraries/issues/detail?id=950 - java_files.sort() - - jar_inputs = [] - for path in options.classpath: - if os.path.exists(path + '.TOC'): - jar_inputs.append(path + '.TOC') - else: - jar_inputs.append(path) - - javac_cmd = [ - 'javac', - '-g', - '-source', '1.5', - '-target', '1.5', - '-classpath', os.pathsep.join(options.classpath), - '-d', output_dir, - '-Xlint:unchecked', - '-Xlint:deprecation', - ] + java_files - - def Compile(): - # Delete the classes directory. This ensures that all .class files in the - # output are actually from the input .java files. For example, if a .java - # file is deleted or an inner class is removed, the classes directory should - # not contain the corresponding old .class file after running this action. - build_utils.DeleteDirectory(output_dir) - build_utils.MakeDirectory(output_dir) - suppress_output = not options.chromium_code - build_utils.CheckCallDie(javac_cmd, suppress_output=suppress_output) - - record_path = '%s/javac.md5.stamp' % options.output_dir - md5_check.CallAndRecordIfStale( - Compile, - record_path=record_path, - input_paths=java_files + jar_inputs, - input_strings=javac_cmd) - - -def main(): - parser = optparse.OptionParser() - parser.add_option('--src-dirs', action='append', - help='Directories containing java files.') - parser.add_option('--javac-includes', action='append', - help='A list of file patterns. If provided, only java files that match' + - 'one of the patterns will be compiled.') - parser.add_option('--classpath', action='append', - help='Classpaths for javac.') - parser.add_option('--output-dir', help='Directory for javac output.') - parser.add_option('--stamp', help='Path to touch on success.') - parser.add_option('--chromium-code', type='int', help='Whether code being ' - 'compiled should be built with stricter warnings for ' - 'chromium code.') - - options, _ = parser.parse_args() - - DoJavac(options) - - if options.stamp: - build_utils.Touch(options.stamp) - - -if __name__ == '__main__': - sys.exit(main()) - - diff --git a/src/xwalk/app/tools/android/gyp/util/build_utils.py b/src/xwalk/app/tools/android/gyp/util/build_utils.py deleted file mode 100755 index 1252efc..0000000 --- a/src/xwalk/app/tools/android/gyp/util/build_utils.py +++ /dev/null @@ -1,91 +0,0 @@ -# Copyright 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -from __future__ import print_function -import fnmatch -import os -import pipes -import shutil -import subprocess -import sys -import traceback - - -def MakeDirectory(dir_path): - try: - os.makedirs(dir_path) - except OSError: - pass - - -def DeleteDirectory(dir_path): - if os.path.exists(dir_path): - shutil.rmtree(dir_path) - - -def Touch(path): - MakeDirectory(os.path.dirname(path)) - with open(path, 'a'): - os.utime(path, None) - - -def FindInDirectory(directory, filter_string): - files = [] - for root, _, filenames in os.walk(directory): - matched_files = fnmatch.filter(filenames, filter_string) - files.extend((os.path.join(root, f) for f in matched_files)) - return files - - -def FindInDirectories(directories, filter_string): - all_files = [] - for directory in directories: - all_files.extend(FindInDirectory(directory, filter_string)) - return all_files - - -# This can be used in most cases like subprocess.check_call. The output, -# particularly when the command fails, better highlights the command's failure. -# This call will directly exit on a failure in the subprocess so that no python -# stacktrace is printed after the output of the failed command (and will -# instead print a python stack trace before the output of the failed command) -def CheckCallDie(args, suppress_output=False, cwd=None): - if not cwd: - cwd = os.getcwd() - - if os.name == 'posix': - child = subprocess.Popen(args, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd) - else: - child = subprocess.Popen(args, - stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd, shell=True) - - stdout, _ = child.communicate() - - if child.returncode: - stacktrace = traceback.extract_stack() - print(''.join(traceback.format_list(stacktrace)), file=sys.stderr) - # A user should be able to simply copy and paste the command that failed - # into their shell. - copyable_command = ' '.join(map(pipes.quote, args)) - copyable_command = ('( cd ' + os.path.abspath(cwd) + '; ' - + copyable_command + ' )') - print('Command failed:', copyable_command, '\n', file=sys.stderr) - - if stdout: - print(stdout) - - # Directly exit to avoid printing stacktrace. - sys.exit(child.returncode) - - else: - if stdout and not suppress_output: - print(stdout) - return stdout - - -def GetModifiedTime(path): - # For a symlink, the modified time should be the greater of the link's - # modified time and the modified time of the target. - return max(os.lstat(path).st_mtime, os.stat(path).st_mtime) diff --git a/src/xwalk/app/tools/android/gyp/util/md5_check.py b/src/xwalk/app/tools/android/gyp/util/md5_check.py deleted file mode 100755 index aaffde2..0000000 --- a/src/xwalk/app/tools/android/gyp/util/md5_check.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2013 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -import hashlib -import os - - -def CallAndRecordIfStale( - function, record_path=None, input_paths=None, - input_strings=None, force=False): - """Calls function if the md5sum of the input paths/strings has changed. - - The md5sum of the inputs is compared with the one stored in record_path. If - this has changed (or the record doesn't exist), function will be called and - the new md5sum will be recorded. - - If force is True, the function will be called regardless of whether the - md5sum is out of date. - """ - input_paths = input_paths or [] - input_strings = input_strings or [] - md5_checker = _Md5Checker( - record_path=record_path, - input_paths=input_paths, - input_strings=input_strings) - if force or md5_checker.IsStale(): - function() - md5_checker.Write() - - -def _UpdateMd5ForFile(md5, path, block_size=2**16): - with open(path, 'rb') as infile: - while True: - data = infile.read(block_size) - if not data: - break - md5.update(data) - - -def _UpdateMd5ForDirectory(md5, dir_path): - for root, _, files in os.walk(dir_path): - for f in files: - _UpdateMd5ForFile(md5, os.path.join(root, f)) - - -def _UpdateMd5ForPath(md5, path): - if os.path.isdir(path): - _UpdateMd5ForDirectory(md5, path) - else: - _UpdateMd5ForFile(md5, path) - - -class _Md5Checker(object): - def __init__(self, record_path=None, input_paths=None, input_strings=None): - assert record_path.endswith('.stamp'), ( - 'record paths must end in \'.stamp\' so that they are easy to find ' - 'and delete') - - input_paths = input_paths or [] - input_strings = input_strings or [] - self.record_path = record_path - - md5 = hashlib.md5() - for i in sorted(input_paths): - _UpdateMd5ForPath(md5, i) - for s in input_strings: - md5.update(s.encode('utf-8')) - self.new_digest = md5.hexdigest() - - self.old_digest = '' - if os.path.exists(self.record_path): - with open(self.record_path, 'r') as old_record: - self.old_digest = old_record.read() - - def IsStale(self): - return self.old_digest != self.new_digest - - def Write(self): - with open(self.record_path, 'w') as new_record: - new_record.write(self.new_digest) diff --git a/src/xwalk/app/tools/android/make_apk.py b/src/xwalk/app/tools/android/make_apk.py index c0f3611..ebed389 100755 --- a/src/xwalk/app/tools/android/make_apk.py +++ b/src/xwalk/app/tools/android/make_apk.py @@ -5,7 +5,6 @@ # found in the LICENSE file. # pylint: disable=F0401 -import operator import optparse import os import re @@ -13,17 +12,17 @@ import shutil import subprocess import sys -sys.path.append('scripts/gyp') - from app_info import AppInfo from customize import VerifyAppName, CustomizeAll, \ ParseParameterForCompressor, ReplaceSpaceWithUnderscore -from dex import AddExeExtensions from handle_permissions import permission_mapping_table from manifest_json_parser import HandlePermissionList from manifest_json_parser import ManifestJsonParser +NATIVE_LIBRARY = 'libxwalkcore.so' + + def CleanDir(path): if os.path.exists(path): shutil.rmtree(path) @@ -33,6 +32,24 @@ def AllArchitectures(): return ("x86", "arm") +def ConvertArchNameToArchFolder(arch): + arch_dict = { + 'x86': 'x86', + 'arm': 'armeabi-v7a' + } + return arch_dict.get(arch, None) + + +def AddExeExtensions(name): + exts_str = os.environ.get('PATHEXT', '').lower() + exts = [_f for _f in exts_str.split(os.pathsep) if _f] + result = [] + result.append(name) + for e in exts: + result.append(name + e) + return result + + def RunCommand(command, verbose=False, shell=False): """Runs the command list, print the output, and propagate its result.""" proc = subprocess.Popen(command, stdout=subprocess.PIPE, @@ -46,6 +63,7 @@ def RunCommand(command, verbose=False, shell=False): print ('Command "%s" exited with non-zero exit code %d' % (' '.join(command), result)) sys.exit(result) + return output def Which(name): @@ -60,22 +78,15 @@ def Which(name): return None -def Find(name, path): - """Find executable file with the given name - and maximum API level under specific path.""" - result = {} - for root, _, files in os.walk(path): - if name in files: - key = os.path.join(root, name) - sdk_version = os.path.basename(os.path.dirname(key)) - str_num = re.search(r'\d+', sdk_version) - if str_num: - result[key] = int(str_num.group()) - else: - result[key] = 0 - if not result: - raise Exception() - return max(iter(result.items()), key=operator.itemgetter(1))[0] +def GetAndroidApiLevel(): + """Get Highest Android target level installed. + return -1 if no targets have been found. + """ + target_output = RunCommand(['android', 'list', 'target', '-c']) + target_regex = re.compile(r'android-(\d+)') + targets = map(int, target_regex.findall(target_output)) + targets.extend([-1]) + return max(targets) def GetVersion(path): @@ -89,6 +100,10 @@ def GetVersion(path): return version_str +def ContainsNativeLibrary(path): + return os.path.isfile(os.path.join(path, NATIVE_LIBRARY)) + + def ParseManifest(options): parser = ManifestJsonParser(os.path.expanduser(options.manifest)) if not options.name: @@ -209,20 +224,11 @@ def Execution(options, name): 'installation and your PATH environment variable.') sys.exit(1) - sdk_root_path = os.path.dirname(os.path.dirname(android_path)) - - try: - sdk_jar_path = Find('android.jar', - os.path.join(sdk_root_path, 'platforms')) - except Exception: - print('Your Android SDK may be ruined, please reinstall it.') - sys.exit(2) - - level_string = os.path.basename(os.path.dirname(sdk_jar_path)) - api_level = int(re.search(r'\d+', level_string).group()) + api_level = GetAndroidApiLevel() if api_level < 14: print('Please install Android API level (>=14) first.') sys.exit(3) + target_string = 'android-%d' % api_level if options.keystore_path: key_store = os.path.expanduser(options.keystore_path) @@ -234,46 +240,19 @@ def Execution(options, name): if options.keystore_passcode: key_code = options.keystore_passcode else: - print('Please provide the passcode of the developer key.') - sys.exit(6) + key_code = None if options.keystore_alias_passcode: key_alias_code = options.keystore_alias_passcode else: - print('--keystore-alias-passcode was not specified, ' - 'using the keystore\'s passcode as the alias keystore passcode.') - key_alias_code = key_code + key_alias_code = None else: print ('Use xwalk\'s keystore by default for debugging. ' 'Please switch to your keystore when distributing it to app market.') - key_store = 'scripts/ant/xwalk-debug.keystore' + key_store = 'xwalk-debug.keystore' key_alias = 'xwalkdebugkey' key_code = 'xwalkdebug' key_alias_code = 'xwalkdebug' - if not os.path.exists('out'): - os.mkdir('out') - - # Make sure to use ant-tasks.jar correctly. - # Default Android SDK names it as ant-tasks.jar - # Chrome third party Android SDk names it as anttasks.jar - ant_tasks_jar_path = os.path.join(sdk_root_path, - 'tools', 'lib', 'ant-tasks.jar') - if not os.path.exists(ant_tasks_jar_path): - ant_tasks_jar_path = os.path.join(sdk_root_path, - 'tools', 'lib', 'anttasks.jar') - - aapt_path = '' - for aapt_str in AddExeExtensions('aapt'): - try: - aapt_path = Find(aapt_str, sdk_root_path) - print('Use %s in %s.' % (aapt_str, sdk_root_path)) - break - except Exception: - pass - if not aapt_path: - print('Your Android SDK may be ruined, please reinstall it.') - sys.exit(2) - # Check whether ant is installed. try: cmd = ['ant', '-version'] @@ -282,197 +261,68 @@ def Execution(options, name): print('Please install ant first.') sys.exit(4) - res_dirs = '-DADDITIONAL_RES_DIRS=\'\'' - res_packages = '-DADDITIONAL_RES_PACKAGES=\'\'' - res_r_text_files = '-DADDITIONAL_R_TEXT_FILES=\'\'' + # Update android project for app and xwalk_core_library. + update_project_cmd = ['android', 'update', 'project', + '--path', name, '--target', target_string, + '--name', name] if options.mode == 'embedded': - # Prepare the .pak file for embedded mode. - pak_src_path = os.path.join('native_libs_res', 'xwalk.pak') - pak_des_path = os.path.join(name, 'assets', 'xwalk.pak') - shutil.copy(pak_src_path, pak_des_path) - - # Prepare the icudtl.dat for embedded mode. - icudtl_src_path = os.path.join('native_libs_res', 'icudtl.dat') - icudtl_des_path = os.path.join(name, 'assets', 'icudtl.dat') - shutil.copy(icudtl_src_path, icudtl_des_path) - - js_src_dir = os.path.join('native_libs_res', 'jsapi') - js_des_dir = os.path.join(name, 'assets', 'jsapi') - if os.path.exists(js_des_dir): - shutil.rmtree(js_des_dir) - shutil.copytree(js_src_dir, js_des_dir) - - res_ui_java = os.path.join('gen', 'ui_java') - res_content_java = os.path.join('gen', 'content_java') - res_xwalk_java = os.path.join('gen', 'xwalk_core_internal_java') - res_dir = os.path.join('libs_res', 'xwalk_core_library') - res_dirs = ('-DADDITIONAL_RES_DIRS=' + res_dir) - res_packages = ('-DADDITIONAL_RES_PACKAGES=org.chromium.ui ' - 'org.xwalk.core.internal org.chromium.content') - res_r_text_files = ('-DADDITIONAL_R_TEXT_FILES=' - + os.path.join(res_ui_java, 'java_R', 'R.txt') + ' ' - + os.path.join(res_xwalk_java, 'java_R', 'R.txt') + ' ' - + os.path.join(res_content_java, 'java_R', 'R.txt')) - - resource_dir = '-DRESOURCE_DIR=' + os.path.join(name, 'res') - manifest_path = os.path.join(name, 'AndroidManifest.xml') - cmd = ['python', os.path.join('scripts', 'gyp', 'ant.py'), - '-DAAPT_PATH=%s' % aapt_path, - res_dirs, - res_packages, - res_r_text_files, - '-DANDROID_MANIFEST=%s' % manifest_path, - '-DANDROID_SDK_JAR=%s' % sdk_jar_path, - '-DANDROID_SDK_ROOT=%s' % sdk_root_path, - '-DANDROID_SDK_VERSION=%d' % api_level, - '-DANT_TASKS_JAR=%s' % ant_tasks_jar_path, - '-DLIBRARY_MANIFEST_PATHS= ', - '-DOUT_DIR=out', - resource_dir, - '-DSTAMP=codegen.stamp', - '-Dbasedir=.', - '-buildfile', - os.path.join('scripts', 'ant', 'apk-codegen.xml')] - RunCommand(cmd, options.verbose) - - # Check whether java is installed. - try: - cmd = ['java', '-version'] - RunCommand(cmd, shell=True) - except EnvironmentError: - print('Please install Oracle JDK first.') - sys.exit(5) - - # Compile App source code with app runtime code. - cmd = ['python', os.path.join('scripts', 'gyp', 'javac.py'), - '--output-dir=%s' % os.path.join('out', 'classes'), - '--classpath', - os.path.join(os.getcwd(), 'libs', 'xwalk_app_runtime_java.jar'), - '--classpath', - sdk_jar_path, - '--src-dirs', - os.path.join(os.getcwd(), name, 'src'), - '--src-dirs', - os.path.join(os.getcwd(), 'out', 'gen'), - '--chromium-code=0', - '--stamp=compile.stam'] - RunCommand(cmd, options.verbose) - - # Package resources. - asset_dir = '-DASSET_DIR=%s' % os.path.join(name, 'assets') - xml_path = os.path.join('scripts', 'ant', 'apk-package-resources.xml') - cmd = ['python', os.path.join('scripts', 'gyp', 'ant.py'), - '-DAAPT_PATH=%s' % aapt_path, - res_dirs, - res_packages, - res_r_text_files, - '-DANDROID_SDK_JAR=%s' % sdk_jar_path, - '-DANDROID_SDK_ROOT=%s' % sdk_root_path, - '-DANT_TASKS_JAR=%s' % ant_tasks_jar_path, - '-DAPK_NAME=%s' % name, - '-DAPP_MANIFEST_VERSION_CODE=0', - '-DAPP_MANIFEST_VERSION_NAME=Developer Build', - asset_dir, - '-DCONFIGURATION_NAME=Release', - '-DOUT_DIR=out', - resource_dir, - '-DSTAMP=package_resources.stamp', - '-Dbasedir=.', - '-buildfile', - xml_path] - RunCommand(cmd, options.verbose) - - dex_path = '--dex-path=' + os.path.join(os.getcwd(), 'out', 'classes.dex') - app_runtime_jar = os.path.join(os.getcwd(), - 'libs', 'xwalk_app_runtime_java.jar') + RunCommand(['android', 'update', 'lib-project', + '--path', os.path.join(name, 'xwalk_core_library'), + '--target', target_string]) + update_project_cmd.extend(['-l', 'xwalk_core_library']) + else: + # Shared mode doesn't need xwalk_runtime_java.jar. + os.remove(os.path.join(name, 'libs', 'xwalk_runtime_java.jar')) + + RunCommand(update_project_cmd) # Check whether external extensions are included. extensions_string = 'xwalk-extensions' extensions_dir = os.path.join(os.getcwd(), name, extensions_string) external_extension_jars = FindExtensionJars(extensions_dir) - input_jars = [] - if options.mode == 'embedded': - input_jars.append(os.path.join(os.getcwd(), 'libs', - 'xwalk_runtime_embedded.dex.jar')) - dex_command_list = ['python', os.path.join('scripts', 'gyp', 'dex.py'), - dex_path, - '--android-sdk-root=%s' % sdk_root_path, - app_runtime_jar, - os.path.join(os.getcwd(), 'out', 'classes')] - dex_command_list.extend(external_extension_jars) - dex_command_list.extend(input_jars) - RunCommand(dex_command_list) - - src_dir = '-DSOURCE_DIR=' + os.path.join(name, 'src') - apk_path = '-DUNSIGNED_APK_PATH=' + os.path.join('out', 'app-unsigned.apk') - native_lib_path = '-DNATIVE_LIBS_DIR=' - if options.mode == 'embedded': - if options.arch == 'x86': - x86_native_lib_path = os.path.join('native_libs', 'x86', 'libs', - 'x86', 'libxwalkcore.so') - if os.path.isfile(x86_native_lib_path): - native_lib_path += os.path.join('native_libs', 'x86', 'libs') - else: - print('No x86 native library has been found for creating a Crosswalk ' - 'embedded APK.') - sys.exit(10) - elif options.arch == 'arm': - arm_native_lib_path = os.path.join('native_libs', 'armeabi-v7a', 'libs', - 'armeabi-v7a', 'libxwalkcore.so') - if os.path.isfile(arm_native_lib_path): - native_lib_path += os.path.join('native_libs', 'armeabi-v7a', 'libs') - else: - print('No ARM native library has been found for creating a Crosswalk ' - 'embedded APK.') - sys.exit(10) - # A space is needed for Windows. - native_lib_path += ' ' - cmd = ['python', 'scripts/gyp/ant.py', - '-DANDROID_SDK_ROOT=%s' % sdk_root_path, - '-DANT_TASKS_JAR=%s' % ant_tasks_jar_path, - '-DAPK_NAME=%s' % name, - '-DCONFIGURATION_NAME=Release', - native_lib_path, - '-DOUT_DIR=out', - src_dir, - apk_path, - '-Dbasedir=.', - '-buildfile', - 'scripts/ant/apk-package.xml'] - RunCommand(cmd, options.verbose) - - # Find the path of zipalign. - # XWALK-2033: zipalign can be in different locations depending on Android - # SDK version that used ((eg. /tools, /build-tools/android-4.4W etc),). - # So looking up the location of zipalign here instead of hard coding. - # Refer to: https://codereview.chromium.org/238253015 - zipalign_path = '' - for zipalign_str in AddExeExtensions('zipalign'): - try: - zipalign_path = Find(zipalign_str, sdk_root_path) - if options.verbose: - print('Use %s in %s.' % (zipalign_str, sdk_root_path)) - break - except Exception: - pass - if not zipalign_path: - print('zipalign could not be found in your Android SDK.' - ' Make sure it is installed.') - sys.exit(10) - apk_path = '--unsigned-apk-path=' + os.path.join('out', 'app-unsigned.apk') - final_apk_path = '--final-apk-path=' + \ - os.path.join('out', name + '.apk') - cmd = ['python', 'scripts/gyp/finalize_apk.py', - '--zipalign-path=%s' % zipalign_path, - apk_path, - final_apk_path, - '--keystore-path=%s' % key_store, - '--keystore-alias=%s' % key_alias, - '--keystore-passcode=%s' % key_code, - '--keystore-alias-passcode=%s' % key_alias_code] - RunCommand(cmd) + for external_extension_jar in external_extension_jars: + shutil.copyfile(external_extension_jar, + os.path.join(name, 'libs', + os.path.basename(external_extension_jar))) - src_file = os.path.join('out', name + '.apk') + if options.mode == 'embedded': + # Remove existing native libraries in xwalk_core_library, they are probably + # for the last execution to make apk for another CPU arch. + # And then copy the native libraries for the specified arch into + # xwalk_core_library. + arch = ConvertArchNameToArchFolder(options.arch) + if not arch: + print ('Invalid CPU arch: %s.' % arch) + sys.exit(10) + library_lib_path = os.path.join(name, 'xwalk_core_library', 'libs') + for dir_name in os.listdir(library_lib_path): + lib_dir = os.path.join(library_lib_path, dir_name) + if ContainsNativeLibrary(lib_dir): + shutil.rmtree(lib_dir) + native_lib_path = os.path.join(name, 'native_libs', arch) + if ContainsNativeLibrary(native_lib_path): + shutil.copytree(native_lib_path, os.path.join(library_lib_path, arch)) + else: + print('No %s native library has been found for creating a Crosswalk ' + 'embedded APK.' % arch) + sys.exit(10) + + ant_cmd = ['ant', 'release', '-f', os.path.join(name, 'build.xml')] + if not options.verbose: + ant_cmd.extend(['-quiet']) + ant_cmd.extend(['-Dkey.store="%s"' % os.path.abspath(key_store)]) + ant_cmd.extend(['-Dkey.alias="%s"' % key_alias]) + if key_code: + ant_cmd.extend(['-Dkey.store.password="%s"' % key_code]) + if key_alias_code: + ant_cmd.extend(['-Dkey.alias.password="%s"' % key_alias_code]) + ant_result = subprocess.call(ant_cmd) + if ant_result != 0: + print('Command "%s" exited with non-zero exit code %d' + % (' '.join(ant_cmd), ant_result)) + sys.exit(ant_result) + + src_file = os.path.join(name, 'bin', '%s-release.apk' % name) package_name = name if options.app_version: package_name += ('_' + options.app_version) @@ -482,9 +332,6 @@ def Execution(options, name): dst_file = os.path.join(options.target_dir, '%s_%s.apk' % (package_name, options.arch)) shutil.copyfile(src_file, dst_file) - CleanDir('out') - if options.mode == 'embedded': - os.remove(pak_des_path) def PrintPackageInfo(options, name, packaged_archs): @@ -531,6 +378,21 @@ def MakeApk(options, app_info, manifest): if options.mode == 'shared': Execution(options, name) elif options.mode == 'embedded': + # Copy xwalk_core_library into app folder and move the native libraries + # out. + # When making apk for specified CPU arch, will only include the + # corresponding native library by copying it back into xwalk_core_library. + target_library_path = os.path.join(name, 'xwalk_core_library') + shutil.copytree('xwalk_core_library', target_library_path) + library_lib_path = os.path.join(target_library_path, 'libs') + native_lib_path = os.path.join(name, 'native_libs') + os.makedirs(native_lib_path) + available_archs = [] + for dir_name in os.listdir(library_lib_path): + lib_dir = os.path.join(library_lib_path, dir_name) + if ContainsNativeLibrary(lib_dir): + shutil.move(lib_dir, os.path.join(native_lib_path, dir_name)) + available_archs.append(dir_name) if options.arch: Execution(options, name) packaged_archs.append(options.arch) @@ -539,9 +401,7 @@ def MakeApk(options, app_info, manifest): # will be generated. valid_archs = ['x86', 'armeabi-v7a'] for arch in valid_archs: - lib_path = os.path.join('native_libs', arch, 'libs', - arch, 'libxwalkcore.so') - if os.path.isfile(lib_path): + if arch in available_archs: if arch.find('x86') != -1: options.arch = 'x86' elif arch.find('arm') != -1: @@ -550,8 +410,7 @@ def MakeApk(options, app_info, manifest): packaged_archs.append(options.arch) else: print('Warning: failed to create package for arch "%s" ' - 'due to missing library %s' % - (arch, lib_path)) + 'due to missing native library' % arch) if len(packaged_archs) == 0: print('No packages created, aborting') diff --git a/src/xwalk/app/tools/android/make_apk_test.py b/src/xwalk/app/tools/android/make_apk_test.py index 766ed0b..3f6c97c 100755 --- a/src/xwalk/app/tools/android/make_apk_test.py +++ b/src/xwalk/app/tools/android/make_apk_test.py @@ -132,7 +132,7 @@ class TestMakeApk(unittest.TestCase): # replace the original native library with an empty library. # Because it doesn't affect the result of test. if options.mode == 'embedded': - native_library_dir = 'native_libs' + native_library_dir = os.path.join('xwalk_core_library', 'libs') native_library_temp_dir = 'temp' shutil.copytree(native_library_dir, native_library_temp_dir) for root, _, files in os.walk(native_library_dir): @@ -147,17 +147,17 @@ class TestMakeApk(unittest.TestCase): def restoreNativeLibrary(): # Restore the original native library for embedded mode. if options.mode == 'embedded': - native_library_dir = 'native_libs' + native_library_dir = os.path.join('xwalk_core_library', 'libs') native_library_temp_dir = 'temp' - if os.path.exists(native_library_dir): + if os.path.isdir(native_library_dir): shutil.rmtree(native_library_dir) shutil.move(native_library_temp_dir, native_library_dir) @staticmethod def archs(): - x86_native_lib_path = os.path.join('native_libs', 'x86', 'libs', + x86_native_lib_path = os.path.join('xwalk_core_library', 'libs', 'x86', 'libxwalkcore.so') - arm_native_lib_path = os.path.join('native_libs', 'armeabi-v7a', 'libs', + arm_native_lib_path = os.path.join('xwalk_core_library', 'libs', 'armeabi-v7a', 'libxwalkcore.so') arch_list = [] if os.path.isfile(x86_native_lib_path): @@ -508,7 +508,8 @@ class TestMakeApk(unittest.TestCase): cmd = ['python', 'make_apk.py', '--name=Example', '--app-version=1.0.0', '--package=org.xwalk.example', '--app-url=http://www.intel.com', '--keystore-path=%s' % keystore_path, '--keystore-alias=xwalk-test', - '--keystore-passcode=xwalk-test', self._mode] + '--keystore-passcode=xwalk-test', + '--keystore-alias-passcode=xwalk-test', self._mode] RunCommand(cmd) self.addCleanup(Clean, 'Example', '1.0.0') self.assertTrue(os.path.exists('Example')) @@ -791,7 +792,7 @@ class TestMakeApk(unittest.TestCase): def executeCommandAndVerifyResult(self, exec_file): # Test all of supported options with empty 'mode' option. - icon_path = './app_src/res/drawable-xhdpi/crosswalk.png' + icon_path = './template/res/drawable-xhdpi/crosswalk.png' extension_path = 'test_data/extensions/myextension' arch = '' icon = '' diff --git a/src/xwalk/application/browser/linux/running_applications_manager.cc b/src/xwalk/application/browser/linux/running_applications_manager.cc index 488b54d..c8dd611 100644 --- a/src/xwalk/application/browser/linux/running_applications_manager.cc +++ b/src/xwalk/application/browser/linux/running_applications_manager.cc @@ -123,7 +123,7 @@ void RunningApplicationsManager::OnLaunch( if (GURL(app_id_or_url).spec().empty()) { application = application_service_->Launch(app_id_or_url, params); } else { - params.entry_points = Application::URLKey; + params.entry_points = Application::StartURLKey; std::string error; scoped_refptr application_data = ApplicationData::Create(GURL(app_id_or_url), &error); diff --git a/src/xwalk/application/common/application_file_util.cc b/src/xwalk/application/common/application_file_util.cc index 5bd7621..54461f9 100644 --- a/src/xwalk/application/common/application_file_util.cc +++ b/src/xwalk/application/common/application_file_util.cc @@ -33,6 +33,10 @@ #include "xwalk/application/common/manifest.h" #include "xwalk/application/common/manifest_handler.h" +#if defined(OS_TIZEN) +#include "xwalk/application/common/id_util.h" +#endif + namespace errors = xwalk::application_manifest_errors; namespace keys = xwalk::application_manifest_keys; namespace widget_keys = xwalk::application_widget_keys; @@ -158,6 +162,8 @@ inline bool IsElementSupportSpanAndDir(xmlNode* root) { return false; } +// FIXME: This function is wrong and has to be re-implemented +// further (see XWALK-2230) bool GetPackageType(const base::FilePath& path, xwalk::application::Package::Type* package_type, std::string* error) { @@ -179,6 +185,24 @@ bool GetPackageType(const base::FilePath& path, return false; } +#if defined(OS_TIZEN) +bool GetPackageType(const std::string& application_id, + xwalk::application::Package::Type* package_type, + std::string* error) { + if (xwalk::application::IsValidWGTID(application_id)) { + *package_type = xwalk::application::Package::WGT; + return true; + } else if (xwalk::application::IsValidXPKID(application_id)) { + *package_type = xwalk::application::Package::XPK; + return true; + } + + *error = base::StringPrintf("Invalid application id: %s", + application_id.c_str()); + return false; +} +#endif + bool IsSingletonElement(const std::string& name) { for (int i = 0; i < arraysize(kSingletonElements); ++i) if (kSingletonElements[i] == name) @@ -324,7 +348,11 @@ scoped_refptr LoadApplication( Manifest::SourceType source_type, std::string* error) { Package::Type package_type; +#if defined(OS_TIZEN) + if (!GetPackageType(application_id, &package_type, error)) +#else if (!GetPackageType(application_path, &package_type, error)) +#endif return NULL; return LoadApplication(application_path, application_id, diff --git a/src/xwalk/application/common/id_util.cc b/src/xwalk/application/common/id_util.cc index 4b178c2..c427304 100644 --- a/src/xwalk/application/common/id_util.cc +++ b/src/xwalk/application/common/id_util.cc @@ -62,10 +62,20 @@ std::string GenerateIdForPath(const base::FilePath& path) { return GenerateId(path_bytes); } +#if defined(OS_TIZEN) +bool IsValidWGTID(const std::string& id) { + return RE2::FullMatch(id, kWGTAppIdPattern); +} + +bool IsValidXPKID(const std::string& id) { + return RE2::FullMatch(id, kXPKAppIdPattern); +} +#endif + bool IsValidApplicationID(const std::string& id) { #if defined(OS_TIZEN) - if (RE2::FullMatch(id, kWGTAppIdPattern) || - RE2::FullMatch(id, kXPKAppIdPattern)) + if (IsValidWGTID(id) || + IsValidXPKID(id)) return true; return false; #endif diff --git a/src/xwalk/application/common/id_util.h b/src/xwalk/application/common/id_util.h index 66452d8..a3060d4 100644 --- a/src/xwalk/application/common/id_util.h +++ b/src/xwalk/application/common/id_util.h @@ -28,6 +28,8 @@ bool IsValidApplicationID(const std::string& id); #if defined(OS_TIZEN) std::string GetPackageIdFromAppId(const std::string& app_id); +bool IsValidWGTID(const std::string& id); +bool IsValidXPKID(const std::string& id); #endif } // namespace application diff --git a/src/xwalk/build/android/generate_app_packaging_tool.py b/src/xwalk/build/android/generate_app_packaging_tool.py index effaa2d..b5b7a7f 100755 --- a/src/xwalk/build/android/generate_app_packaging_tool.py +++ b/src/xwalk/build/android/generate_app_packaging_tool.py @@ -15,13 +15,6 @@ def Clean(dir_to_clean): shutil.rmtree(dir_to_clean) -def PrepareFromChromium(target_dir): - gyp_dir = os.path.join(target_dir, 'scripts', 'gyp') - if not os.path.exists(gyp_dir): - os.makedirs(gyp_dir) - shutil.copytree('../build/android/gyp/util', os.path.join(gyp_dir, 'util')) - - def PrepareFromXwalk(src_dir, target_dir): '''Prepare different files for app packaging tools. All resources are used by make_apk.py. @@ -32,77 +25,40 @@ def PrepareFromXwalk(src_dir, target_dir): # Get the dir of source code from src_dir: ../../. source_code_dir = os.path.dirname(os.path.dirname(src_dir)) - # The directories for source and target .jar files. + # The directory to copy libraries and code from. jar_src_dir = os.path.join(src_dir, 'lib.java') - jar_target_dir = os.path.join(target_dir, 'libs') + xwalk_core_library_dir = os.path.join(src_dir, 'xwalk_core_library') - # The directories for generated resources. - gen_res_src_dir = os.path.join(src_dir, 'gen') - gen_res_target_dir = os.path.join(target_dir, 'gen') - xwalk_core_library_res_dir = os.path.join( - src_dir, 'xwalk_core_library', 'res') + # The directory to copy libraries, code and resources to. + app_target_dir = os.path.join(target_dir, 'template') + jar_target_dir = os.path.join(app_target_dir, 'libs') # The directory for source packaging tools. tools_src_dir = os.path.join(source_code_dir, 'xwalk/app/tools/android') - # The directories for source and target gyp. - gyp_src_dir = os.path.join(tools_src_dir, 'gyp') - gyp_target_dir = os.path.join(target_dir, 'scripts/gyp') - # The source file/directory list to be copied and the target directory list. source_target_list = [ (os.path.join(source_code_dir, 'xwalk/VERSION'), target_dir), # This jar is needed for minifying and obfuscating the javascript and css. (os.path.join(tools_src_dir, - 'libs/yuicompressor-' + yui_compressor_version + '.jar'), - jar_target_dir), - - # This jar is needed for 'javac' compile. - (os.path.join(jar_src_dir, 'xwalk_app_runtime_java.jar'), jar_target_dir), - (os.path.join(jar_src_dir, 'xwalk_runtime_embedded.dex.jar'), - jar_target_dir), - - # Native library, like libxwalkcore.so. - (os.path.join(src_dir, 'xwalk_runtime_lib_apk/libs/x86'), - os.path.join(target_dir, 'native_libs/x86/libs/x86')), - (os.path.join(src_dir, 'xwalk_runtime_lib_apk/libs/armeabi-v7a'), - os.path.join(target_dir, 'native_libs/armeabi-v7a/libs/armeabi-v7a')), - - # Native source package(xwalk.pak) and related js files for extension. - (os.path.join(src_dir, 'xwalk_runtime_lib/assets'), - os.path.join(target_dir, 'native_libs_res')), - - # Various Java resources. - # FIXME(wang16): Copy from the xwalk_core_library first. We need to - # consider refine the whole process of make_apk. - (os.path.join(gen_res_src_dir, 'ui_java/java_R'), - os.path.join(gen_res_target_dir, 'ui_java/java_R')), - (os.path.join(gen_res_src_dir, 'content_java/java_R'), - os.path.join(gen_res_target_dir, 'content_java/java_R')), - (os.path.join(gen_res_src_dir, 'xwalk_core_internal_java/java_R'), - os.path.join(gen_res_target_dir, 'xwalk_core_internal_java/java_R')), - (xwalk_core_library_res_dir, - os.path.join(target_dir, 'libs_res/xwalk_core_library')), + 'libs/yuicompressor-%s.jar' % yui_compressor_version), + target_dir), # The app wrapper code. It's the template Java code. (os.path.join(source_code_dir, 'xwalk/app/android/app_template'), - os.path.join(target_dir, 'app_src')), - - # Copy below 7 files to overwrite the existing ones from Chromium. - (os.path.join(gyp_src_dir, 'util/build_utils.py'), - os.path.join(gyp_target_dir, 'util')), - (os.path.join(gyp_src_dir, 'util/md5_check.py'), - os.path.join(gyp_target_dir, 'util')), - (os.path.join(gyp_src_dir, 'ant.py'), gyp_target_dir), - (os.path.join(gyp_src_dir, 'dex.py'), gyp_target_dir), - (os.path.join(gyp_src_dir, 'finalize_apk.py'), gyp_target_dir), - (os.path.join(gyp_src_dir, 'jar.py'), gyp_target_dir), - (os.path.join(gyp_src_dir, 'javac.py'), gyp_target_dir), + app_target_dir), + + # Shared mode uses xwalk_app_runtime_java.jar only. + # Embedded mode needs both. + (os.path.join(jar_src_dir, 'xwalk_app_runtime_java.jar'), jar_target_dir), + (os.path.join(jar_src_dir, 'xwalk_runtime_java.jar'), jar_target_dir), + + # XWalk Core Library + (xwalk_core_library_dir, os.path.join(target_dir, 'xwalk_core_library')), # Build and python tools. - (os.path.join(tools_src_dir, 'ant'), - os.path.join(target_dir, 'scripts/ant')), + (os.path.join(tools_src_dir, 'ant', 'xwalk-debug.keystore'), target_dir), (os.path.join(tools_src_dir, 'app_info.py'), target_dir), (os.path.join(tools_src_dir, 'compress_js_and_css.py'), target_dir), (os.path.join(tools_src_dir, 'customize.py'), target_dir), @@ -127,6 +83,8 @@ def PrepareFromXwalk(src_dir, target_dir): # Process target. if source_is_file and not os.path.exists(target_path): os.makedirs(target_path) + if not source_is_file and os.path.isdir(target_path): + shutil.rmtree(target_path) # Do copy. if source_is_file: @@ -146,7 +104,6 @@ def main(args): target_dir = args[0] src_dir = os.path.dirname(target_dir) Clean(target_dir) - PrepareFromChromium(target_dir) PrepareFromXwalk(src_dir, target_dir) diff --git a/src/xwalk/build/android/generate_xwalk_core_library.py b/src/xwalk/build/android/generate_xwalk_core_library.py index e9dd1e2..810a688 100755 --- a/src/xwalk/build/android/generate_xwalk_core_library.py +++ b/src/xwalk/build/android/generate_xwalk_core_library.py @@ -75,7 +75,11 @@ def CopyJSBindingFiles(project_source, out_dir): 'xwalk/experimental/launch_screen/launch_screen_api.js', 'xwalk/experimental/presentation/presentation_api.js', 'xwalk/runtime/android/core_internal/src/org/xwalk/core/' - + 'internal/extension/api/device_capabilities/device_capabilities_api.js' + + 'internal/extension/api/contacts/contacts_api.js', + 'xwalk/runtime/android/core_internal/src/org/xwalk/core/' + + 'internal/extension/api/device_capabilities/device_capabilities_api.js', + 'xwalk/runtime/android/core_internal/src/org/xwalk/core/' + + 'internal/extension/api/messaging/messaging_api.js' ] # Copy JS binding file to assets/jsapi folder. @@ -198,7 +202,30 @@ def MoveImagesToNonMdpiFolders(res_root): shutil.move(src_file, dst_file) -def CopyResources(out_dir): +def ReplaceCrunchedImage(project_source, filename, filepath): + """Replace crunched images with source images. + """ + search_dir = [ + 'content/public/android/java/res', + 'ui/android/java/res' + ] + + pathname = os.path.basename(filepath) + #replace crunched 9-patch image resources. + for search in search_dir: + absdir = os.path.join(project_source, search) + for dirname, _, files in os.walk(absdir): + if filename in files: + relativedir = os.path.basename(dirname) + if (pathname == 'drawable' and relativedir == 'drawable-mdpi') or \ + relativedir == pathname: + source_file = os.path.abspath(os.path.join(dirname, filename)) + target_file = os.path.join(filepath, filename) + shutil.copyfile(source_file, target_file) + return + + +def CopyResources(project_source, out_dir): print 'Copying resources...' res_dir = os.path.join(out_dir, LIBRARY_PROJECT_NAME, 'res') temp_dir = os.path.join(out_dir, LIBRARY_PROJECT_NAME, 'temp') @@ -238,6 +265,12 @@ def CopyResources(out_dir): if os.path.isdir(temp_dir): shutil.rmtree(temp_dir) + #search 9-patch, then replace it with uncrunch image. + for dirname, _, files in os.walk(res_dir): + for filename in files: + if filename.endswith('.9.png'): + ReplaceCrunchedImage(project_source, filename, dirname) + def PostCopyLibraryProject(out_dir): print 'Post Copy Library Project...' @@ -272,7 +305,7 @@ def main(argv): # Copy Eclipse project files of library project. CopyProjectFiles(options.source, out_dir) # Copy binaries and resuorces. - CopyResources(out_dir) + CopyResources(options.source, out_dir) CopyBinaries(out_dir) # Copy JS API binding files. CopyJSBindingFiles(options.source, out_dir) diff --git a/src/xwalk/build/android/generate_xwalk_core_library_aar.py b/src/xwalk/build/android/generate_xwalk_core_library_aar.py new file mode 100755 index 0000000..bba14f8 --- /dev/null +++ b/src/xwalk/build/android/generate_xwalk_core_library_aar.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014 Intel Corporation. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# pylint: disable=F0401 + +import optparse +import os +import shutil +import sys +import zipfile + +LIBRARY_PROJECT_NAME = 'xwalk_core_library' +AAR_LIBRARY_NAME = 'xwalk_core_library_aar' + +def AddGeneratorOptions(option_parser): + option_parser.add_option('-s', dest='source', + help='Source directory of project root.', + type='string') + option_parser.add_option('-t', dest='target', + help='Product out target directory.', + type='string') + + +def CopyProjectFiles(out_dir): + """cp out/Release/xwalk_core_library/AndroidManifest + out/Release/xwalk_core_library_aar/ + """ + + print 'Copying library project files...' + files_to_copy = [ + # AndroidManifest.xml from template. + 'AndroidManifest.xml', + ] + for f in files_to_copy: + source_file = os.path.join(out_dir, LIBRARY_PROJECT_NAME, f) + target_file = os.path.join(out_dir, AAR_LIBRARY_NAME, f) + shutil.copy2(source_file, target_file) + + +def CopyBinaries(out_dir): + """cp out/Release/xwalk_core_library/libs/* + out/Release/xwalk_core_library_aar/jni/ + """ + + print 'Copying binaries...' + # Copy jar files to classes.jar. + libs_dir = os.path.join(out_dir, LIBRARY_PROJECT_NAME, 'libs') + + source_file = os.path.join(libs_dir, 'xwalk_core_library_java.jar') + target_file = os.path.join(out_dir, AAR_LIBRARY_NAME, 'classes.jar') + shutil.copyfile(source_file, target_file) + + # Copy native libraries. + source_dir = os.path.join(out_dir, LIBRARY_PROJECT_NAME, 'libs') + target_dir = os.path.join(out_dir, AAR_LIBRARY_NAME, 'jni') + if not os.path.exists(target_dir): + os.makedirs(target_dir) + + if os.path.exists(source_dir): + for item in os.listdir(source_dir): + sub_path = os.path.join(source_dir, item) + target_dir = os.path.join(target_dir, item) + if os.path.isdir(sub_path): + shutil.copytree(sub_path, target_dir) + + # Copy R.txt. + r_source_dir = os.path.join(out_dir, 'gen', 'xwalk_core_internal_java') + r_source_file = os.path.join(r_source_dir, 'java_R', 'R.txt') + r_target_file = os.path.join(out_dir, AAR_LIBRARY_NAME, 'R.txt') + shutil.copyfile(r_source_file, r_target_file) + + +def CopyResources(out_dir): + print 'Copying resources...' + source_dir = os.path.join(out_dir, LIBRARY_PROJECT_NAME, 'res') + target_dir = os.path.join(out_dir, AAR_LIBRARY_NAME, 'res') + shutil.copytree(source_dir, target_dir) + + +def GenerateAAR(aar_path, aar_dir): + zfile = zipfile.ZipFile(aar_path, 'w') + abs_src = os.path.abspath(aar_dir) + for dirname, _, files in os.walk(aar_dir): + for filename in files: + absname = os.path.abspath(os.path.join(dirname, filename)) + relativename = absname[len(abs_src) + 1:] + zfile.write(absname, relativename) + zfile.close() + #delete the AAR dir. + shutil.rmtree(aar_dir) + + +def main(argv): + print 'Generating XWalkCore AAR Library...' + option_parser = optparse.OptionParser() + AddGeneratorOptions(option_parser) + options, _ = option_parser.parse_args(argv) + + if not os.path.exists(options.source): + print 'Source project does not exist, please provide correct directory.' + sys.exit(1) + out_dir = options.target + + # Clean the aar library. + aar_path = os.path.join(out_dir, 'xwalk_core_library.aar') + if os.path.exists(aar_path): + os.remove(aar_path) + + aar_dir = os.path.join(out_dir, AAR_LIBRARY_NAME) + if os.path.exists(aar_dir): + shutil.rmtree(aar_dir) + os.mkdir(aar_dir) + + # Copy Eclipse project files of library project. + CopyProjectFiles(out_dir) + # Copy binaries and resuorces. + CopyResources(out_dir) + CopyBinaries(out_dir) + GenerateAAR(aar_path, aar_dir) + + +if __name__ == '__main__': + sys.exit(main(sys.argv)) diff --git a/src/xwalk/extensions/external_extension_sample.gyp b/src/xwalk/extensions/external_extension_sample.gyp index a9bd960..e0758a6 100644 --- a/src/xwalk/extensions/external_extension_sample.gyp +++ b/src/xwalk/extensions/external_extension_sample.gyp @@ -93,5 +93,22 @@ }], ], }, + { + 'target_name': 'bulk_data_transmission', + 'type': 'loadable_module', + 'variables': { + 'mac_strip': 0, + }, + 'sources': [ + 'test/bulk_data_transmission.c', + ], + 'conditions': [ + ['OS=="win"', { + 'product_dir': '<(PRODUCT_DIR)\\tests\\extension\\bulk_data_transmission\\' + }, { + 'product_dir': '<(PRODUCT_DIR)/tests/extension/bulk_data_transmission/' + }], + ], + }, ], } diff --git a/src/xwalk/extensions/test/bulk_data_transmission.c b/src/xwalk/extensions/test/bulk_data_transmission.c new file mode 100644 index 0000000..3ca8c46 --- /dev/null +++ b/src/xwalk/extensions/test/bulk_data_transmission.c @@ -0,0 +1,68 @@ +// Bulk data transmission example for Crosswalk +// Copyright (c) 2014 Intel Corporation. All rights reserved. +// Use of this source code is governed by a BSD-style license +// that can be found in the LICENSE file. + +#include +#include +#include +#include "xwalk/extensions/public/XW_Extension.h" + +static const char* kSource_bulk_data_api = "var bulkDataListener = null;" +"" +"extension.setMessageListener(function(msg) {" +" if (bulkDataListener instanceof Function) {" +" bulkDataListener(msg);" +" };" +"});" +"" +"exports.requestBulkDataAsync = function(power, callback) {" +" bulkDataListener = callback;" +" extension.postMessage(power.toString());" +"};" +; + +static XW_Extension g_extension = 0; +static const XW_CoreInterface* g_core = NULL; +static const XW_MessagingInterface* g_messaging = NULL; + +static void instance_created(XW_Instance instance) { + printf("Instance %d created!\n", instance); +} + +static void instance_destroyed(XW_Instance instance) { + printf("Instance %d destroyed!\n", instance); +} + +static void handle_message(XW_Instance instance, const char* message) { + int size = atoi(message); + char* data = malloc(size + 1); + memset(data, 'p', size); + data[size] = '\0'; + printf("Instance %d created %d bytes of data chunk from native.\n", instance, size); + g_messaging->PostMessage(instance, data); + free(data); +} + +static void shutdown(XW_Extension extension) { + printf("Shutdown\n"); +} + +// this is the only function which needs to be public +int32_t XW_Initialize(XW_Extension extension, XW_GetInterface get_interface) { + // set up the extension + g_extension = extension; + g_core = get_interface(XW_CORE_INTERFACE); + g_core->SetExtensionName(extension, "bulkData"); + + g_core->SetJavaScriptAPI(extension, kSource_bulk_data_api); + + g_core->RegisterInstanceCallbacks( + extension, instance_created, instance_destroyed); + g_core->RegisterShutdownCallback(extension, shutdown); + + g_messaging = get_interface(XW_MESSAGING_INTERFACE); + g_messaging->Register(extension, handle_message); + + return XW_OK; +} diff --git a/src/xwalk/extensions/test/data/bulk_data_transmission.html b/src/xwalk/extensions/test/data/bulk_data_transmission.html new file mode 100644 index 0000000..bd29b10 --- /dev/null +++ b/src/xwalk/extensions/test/data/bulk_data_transmission.html @@ -0,0 +1,86 @@ + + + +Bulk Data Transmission demo + + + +

This uses the bulk data transmission extension defined in +bulk_data_transmission.c (compiled to libbulk_data_transmission.so) to +extend Crosswalk.

+ +
+
+
+ + + + diff --git a/src/xwalk/extensions/test/xwalk_extensions_browsertest.cc b/src/xwalk/extensions/test/xwalk_extensions_browsertest.cc index e9c782c..0feb263 100644 --- a/src/xwalk/extensions/test/xwalk_extensions_browsertest.cc +++ b/src/xwalk/extensions/test/xwalk_extensions_browsertest.cc @@ -108,6 +108,45 @@ class ExtensionWithInvalidName : public XWalkExtension { bool ExtensionWithInvalidName::s_instance_was_created = false; +static const char* kBulkDataAPI = "var bulkDataListener = null;" +"" +"extension.setMessageListener(function(msg) {" +" if (bulkDataListener instanceof Function) {" +" bulkDataListener(msg);" +" };" +"});" +"" +"exports.requestBulkDataAsync = function(power, callback) {" +" bulkDataListener = callback;" +" extension.postMessage(power.toString());" +"};"; + +class BulkDataContext : public XWalkExtensionInstance { + public: + BulkDataContext() { + } + virtual void HandleMessage(scoped_ptr msg) OVERRIDE { + std::string message; + msg->GetAsString(&message); + int size = atoi(message.c_str()); + std::string data_chunk(size, 'p'); + scoped_ptr data(new base::StringValue(data_chunk)); + PostMessageToJS(data.Pass()); + } +}; + +class BulkDataExtension : public XWalkExtension { + public: + BulkDataExtension() : XWalkExtension() { + set_name("bulkData"); + set_javascript_api(kBulkDataAPI); + } + + virtual XWalkExtensionInstance* CreateInstance() OVERRIDE { + return new BulkDataContext(); + } +}; + } // namespace class XWalkExtensionsTest : public XWalkExtensionsTestBase { @@ -116,6 +155,7 @@ class XWalkExtensionsTest : public XWalkExtensionsTestBase { XWalkExtensionVector* extensions) OVERRIDE { extensions->push_back(new EchoExtension); extensions->push_back(new ExtensionWithInvalidName); + extensions->push_back(new BulkDataExtension); } }; @@ -171,3 +211,13 @@ IN_PROC_BROWSER_TEST_F(XWalkExtensionsDelayedTest, EchoExtensionSync) { xwalk_test_utils::NavigateToURL(runtime(), url); EXPECT_EQ(kPassString, title_watcher.WaitAndGetTitle()); } + +IN_PROC_BROWSER_TEST_F(XWalkExtensionsTest, BulkDataExtension) { + content::RunAllPendingInMessageLoop(); + GURL url = GetExtensionsTestURL(base::FilePath(), + base::FilePath().AppendASCII("bulk_data_transmission.html")); + content::TitleWatcher title_watcher(runtime()->web_contents(), kPassString); + title_watcher.AlsoWaitForTitle(kFailString); + xwalk_test_utils::NavigateToURL(runtime(), url); + EXPECT_EQ(kPassString, title_watcher.WaitAndGetTitle()); +} diff --git a/src/xwalk/packaging/crosswalk.spec b/src/xwalk/packaging/crosswalk.spec index 8e47581..83c35df 100644 --- a/src/xwalk/packaging/crosswalk.spec +++ b/src/xwalk/packaging/crosswalk.spec @@ -16,7 +16,7 @@ %endif Name: crosswalk -Version: 8.37.187.0 +Version: 9.37.190.0 Release: 0 Summary: Crosswalk is an app runtime based on Chromium License: (BSD-3-Clause and LGPL-2.1+) diff --git a/src/xwalk/tools/build/linux/FILES.cfg b/src/xwalk/tools/build/linux/FILES.cfg index eb26985..b93bbb5 100644 --- a/src/xwalk/tools/build/linux/FILES.cfg +++ b/src/xwalk/tools/build/linux/FILES.cfg @@ -39,17 +39,4 @@ FILES = [ 'filename': 'libffmpegsumo.so', 'buildtype': ['dev'], }, -# installer creation scripts - { - 'filename': 'create_linux_installer.sh', - 'buildtype': ['dev', 'official'], - }, - { - 'filename': 'app.desktop.templ', - 'buildtype': ['dev', 'official'], - }, - { - 'filename': 'Makefile.templ', - 'buildtype': ['dev', 'official'], - }, ] diff --git a/src/xwalk/tools/build/win/FILES.cfg b/src/xwalk/tools/build/win/FILES.cfg index 3d07eaf..ec420ad 100644 --- a/src/xwalk/tools/build/win/FILES.cfg +++ b/src/xwalk/tools/build/win/FILES.cfg @@ -57,19 +57,6 @@ FILES = [ 'filename': 'libGLESv2.dll', 'buildtype': ['dev', 'official'], }, -# installer creation scripts - { - 'filename': 'create_windows_installer.bat', - 'buildtype': ['dev', 'official'], - }, - { - 'filename': 'app.wxs.templ', - 'buildtype': ['dev', 'official'], - }, - { - 'filename': 'guid.vbs', - 'buildtype': ['dev', 'official'], - }, # syms files { 'filename': 'xwalk.exe.pdb', diff --git a/src/xwalk/tools/packaging/bootstrapped/linux/Makefile.templ b/src/xwalk/tools/packaging/bootstrapped/linux/Makefile.templ deleted file mode 100644 index 8d7a2c1..0000000 --- a/src/xwalk/tools/packaging/bootstrapped/linux/Makefile.templ +++ /dev/null @@ -1,3 +0,0 @@ -install: - mkdir ${INSTALL_DIR} -p && rm Makefile && cp -r * ${INSTALL_DIR} - cp *.desktop /usr/share/applications diff --git a/src/xwalk/tools/packaging/bootstrapped/linux/app.desktop.templ b/src/xwalk/tools/packaging/bootstrapped/linux/app.desktop.templ deleted file mode 100644 index 1e0784a..0000000 --- a/src/xwalk/tools/packaging/bootstrapped/linux/app.desktop.templ +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Version=1.0 -Type=Application -Terminal=false -Comment=$COMMENT -Name=$APP_NAME -StartupNotify=true -NoDisplay=false -Icon= -Exec=$INSTALL_DIR/xwalk $APP_ARGUMENTS file://$INSTALL_DIR/$APP_INDEX diff --git a/src/xwalk/tools/packaging/bootstrapped/linux/create_linux_installer.sh b/src/xwalk/tools/packaging/bootstrapped/linux/create_linux_installer.sh deleted file mode 100755 index 109dc37..0000000 --- a/src/xwalk/tools/packaging/bootstrapped/linux/create_linux_installer.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/sh -absolute_path () { - echo `cd $1 && pwd` -} -THIS_SCRIPT=$0 -SCRIPT_DIR=`dirname $THIS_SCRIPT` -SCRIPT_DIR=`absolute_path $SCRIPT_DIR` -TEMP_DIR=/tmp/xwalk_build -while [ "$1" != "" ]; do - DASHED_PARAM=$1 - PARAM=`echo ${DASHED_PARAM}|sed 's/--//'` - if [ "$PARAM" = "$DASHED_PARAM" ]; then - APP_PATH=$PARAM - else - if ! echo $PARAM |grep = ; then - PARAM=`echo $PARAM |sed 's/^\(.*\)/\U\1/'` - eval $PARAM=true - else - PARAM=`echo $PARAM |sed 's/^\(.*=\)/\U\1/'` - eval $PARAM - fi - fi - shift -done - -if [ "x$HELP" != "x" ]; then - echo - echo usage: $THIS_SCRIPT [options] [app_path] - echo - echo This script is used to create a standalone installer for Crosswalk applications. It - echo depends on checkinstall and Crosswalk to function properly. - echo The following options are supported: - echo " - app_path Path to the Crosswalk application. If not specified, the - current directory is used. - --xwalk_path= Path to Crosswalk binaries. If not specified, the script - will try to find them through PATH, the app path, or - the current directory. - --app_name= Name of the application. If not specified, the name - of the application directory is used. - --version= The version of the application, defaults to 1.0.0 - --app_index= Path of app index file, relative to app_path. If not - specified, index.html is used. - --app_arguments= Arugments to be passed into Crosswalk executable - Example: --app_arguments=--allow-file-access-from-files - --out= Path of the output package file, defaults to - $TEMP_DIR/ - --publisher= The manufacturer of this application, defaults to "Me" - --shadow_install= Enable/disable installing app to a temporary directory - for testing purposed. Defaults to yes - --help Print this message " - exit 1 -fi - -if [ "x`which checkinstall`" = "x" ]; then - echo - echo "checkinstall is required to create an application package. You can install it by: - sudo apt-get install checkinstall" - exit 1 -fi -if [ "x$APP_PATH" = "x" ]; then - APP_PATH=`pwd` -fi -if [ "x$APP_INDEX" = "x" ]; then - APP_INDEX=index.html -fi -if [ "x$VERSION" = "x" ]; then - VERSION=1.0.0 -fi -if [ "x$XWALK_PATH" = "x" ]; then - XWALK_PATH=`which xwalk` - if [ "x$XWALK_PATH" != "x" ]; then - XWALK_PATH=`dirname $XWALK_PATH` - fi - if [ "x$XWALK_PATH" = "x" ]; then - XWALK_PATH=$APP_PATH - if ! test -f "$XWALK_PATH/xwalk"; then - XWALK_PATH=`pwd` - if ! test -f "$XWALK_PATH/xwalk"; then - echo Please make sure you have installed xwalk and setup the PATH enviroment variable - echo on your system properly. Or you can specify the Crosswalk path through --xwalk_path - echo command line parameter. - exit 1 - fi - fi - fi -fi -if [ "x$APP_NAME" = "x" ]; then - APP_NAME=`basename $APP_PATH` -fi -if [ "x$PUBLISHER" = "x" ]; then - PUBLISHER=Me -fi - -if [ "x$OUT" != "x" ]; then - OUT_OPT="--pakdir=$OUT" -fi - -if [ "x$SHADOW_INSTALL" = "x" ]; then - SHADOW_INSTALL=yes -fi - -XWALK_PATH=`absolute_path $XWALK_PATH` -APP_PATH=`absolute_path $APP_PATH` -BUILD_DIR=$TEMP_DIR/`basename $APP_PATH` -#export some variables so that Makefile can use them -export INSTALL_DIR=/opt/${PUBLISHER}/${APP_NAME} - -#Prepare for the build dir -mkdir -p $TEMP_DIR -cp -r $APP_PATH $TEMP_DIR -if ! test -f $APP_PATH/Makefile; then - cp $SCRIPT_DIR/Makefile.templ $BUILD_DIR/Makefile -fi -if ! ls *.desktop > /dev/null 2>&1; then - while read line; do eval echo $line; done < $SCRIPT_DIR/app.desktop.templ > $BUILD_DIR/$APP_NAME.desktop -fi -cd $XWALK_PATH && cp xwalk xwalk.pak libffmpegsumo.so $BUILD_DIR - -#build the package -cd $BUILD_DIR && checkinstall --pkgname=$APP_NAME --pkgversion=$VERSION \ - --backup=no --install=no --exclude=Makefile --fstrans=$SHADOW_INSTALL $OUT_OPT -if [ $? != 0 -a -f $APP_PATH/Makefile ]; then - echo "Warning: Packaging failed. Maybe there are some unsupported operations in your app's Makefile? Please try re-run the script with --shadow_install=no using sudo" - echo -fi diff --git a/src/xwalk/tools/packaging/bootstrapped/linux/test.sh b/src/xwalk/tools/packaging/bootstrapped/linux/test.sh deleted file mode 100755 index b8a0f1f..0000000 --- a/src/xwalk/tools/packaging/bootstrapped/linux/test.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -init_env() { - APP_NAME=$1 - VERSION=$2 - if [ "x$VERSION" = "x" ]; then - VERSION=1.0.0 - fi - DEB_FILE=${APP_NAME}_$VERSION-*.deb - DEB_PATH=$BUILD_DIR/$DEB_FILE - DESKTOP_FILE=$APP_NAME.desktop - DESKTOP_PATH=$BUILD_DIR/$DESKTOP_FILE - DESKTOP_PATH_IN_DEB=/usr/share/applications/$DESKTOP_FILE - if test -f $DEB_PATH; then - rm $DEB_PATH - fi -} - -file_exist_in_deb() { - run_test "Check file $1 existence in deb" "dpkg --contents $DEB_PATH |grep $1" -} - -run_test () { - if ! eval $2; then - echo $1 failed! - exit 1 - fi -} - -APP_NAME=test-app -TMP_DIR=/tmp -XWALK_PATH=--xwalk_path=../../../../../../out/Release -BUILD_DIR=$TMP_DIR/xwalk_build/$APP_NAME -if test -e $BUILD_DIR; then - rm -r $BUILD_DIR -fi - -mkdir -p $APP_NAME -cd $APP_NAME -echo hello > index.html - -init_env $APP_NAME - -run_test "Check app_arguments help message" "../create_linux_installer.sh --help |grep app_arguments" - -case $1 in - 1) - init_env test-app 1.0.1 - DEB_PATH=$TMP_DIR/$DEB_FILE - run_test "Create package" "../create_linux_installer.sh $XWALK_PATH --version=$VERSION --out=$TMP_DIR" - - #test if the version argument works - run_test "Check DEB existence" "test -e $DEB_PATH" - #test if files installed successfully - file_exist_in_deb index.html - file_exist_in_deb xwalk - file_exist_in_deb xwalk.pak - file_exist_in_deb libffmpegsumo.so - file_exist_in_deb $DESKTOP_PATH_IN_DEB - ;; - - 2) - init_env custom-app-name - run_test "Create package with customized app name" "../create_linux_installer.sh $XWALK_PATH --app_name=$APP_NAME && test -e $DEB_PATH" - file_exist_in_deb $DESKTOP_PATH_IN_DEB - run_test "Check desktop file" "grep $APP_NAME $DESKTOP_PATH" -;; - 3) - CUSTOM_INDEX=src/custom_index.html - APP_ARGUMENTS=--allow-file-access-from-files - run_test "Test app_index" "../create_linux_installer.sh $XWALK_PATH --app_arguments=$APP_ARGUMENTS --app_index=$CUSTOM_INDEX && grep $CUSTOM_INDEX $DESKTOP_PATH && grep -- $APP_ARGUMENTS $DESKTOP_PATH" -;; -esac diff --git a/src/xwalk/tools/packaging/bootstrapped/win/app.wxs.templ b/src/xwalk/tools/packaging/bootstrapped/win/app.wxs.templ deleted file mode 100644 index b53b19d9..0000000 --- a/src/xwalk/tools/packaging/bootstrapped/win/app.wxs.templ +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/xwalk/tools/packaging/bootstrapped/win/create_windows_installer.bat b/src/xwalk/tools/packaging/bootstrapped/win/create_windows_installer.bat deleted file mode 100755 index 27d6317..0000000 --- a/src/xwalk/tools/packaging/bootstrapped/win/create_windows_installer.bat +++ /dev/null @@ -1,147 +0,0 @@ -@echo off -setlocal enabledelayedexpansion -set THIS_SCRIPT=%0 -set WXS_TEMPL_FILE="%~dp0\app.wxs.templ" -set GUID_GEN="%~dp0\guid.vbs" -:loop -set DASHED_PARAM=%1 -set PARAM=!DASHED_PARAM:--=! -if "!PARAM!" == "!DASHED_PARAM!" ( - set APP_PATH=!PARAM! -) else ( - if x%2==x (set !PARAM!=true) else (set !PARAM!=%2) - shift -) -@shift - -@if not "%~1"=="" goto loop - -if not x%HELP%==x ( - echo. - echo usage: %THIS_SCRIPT% [options] [app_path] - echo. - echo This script is used to create a standalone installer for Crosswalk applications. It - echo depends on Wix toolset and Crosswalk to function properly. - echo The following options are supported: - echo. - echo app_path Path to the Crosswalk application. If not specified, the - echo current directory is used. - echo --wix_bin_path=^ Path to Wix toolset binaries. If not specified, the - echo script will try to find them through PATH - echo --xwalk_path=^ Path to Crosswalk binaries. If not specified, the script - echo will try to find them through PATH, the app path, or - echo the current directory. - echo --app_name=^ Name of the application. If not specified, the name - echo of the application directory is used. - echo --version=^ The version of the application, defaults to 1.0.0 - echo --app_index=^ Path of app index file, relative to app_path. If not - echo specified, "index.html" is used. - echo --app_arguments=^ Arguments to be passed into Crosswalk executable. - echo Example: --app_arguments=--allow-file-access-from-files - echo --out=^ File Path of the output installer file, defaults to the - echo current directory with %%app_name%%.msi as its name. - echo --publisher=^ The manufacturer of this application, defaults to "Me" - echo --help Print this message - exit /b - -) -if x%WIX_BIN_PATH%==x ( - FOR /F "tokens=*" %%A IN ('where candle') DO SET WIX_BIN_PATH="%%A" -) -if not x%WIX_BIN_PATH%==x set WIX_BIN_PATH=!WIX_BIN_PATH:\candle.exe=! -if x%WIX_BIN_PATH%==x ( - set WIX_BIN_PATH="C:\Program Files (x86)\WiX Toolset v3.7\bin" - if not exist "!WIX_BIN_PATH!\candle.exe" ( - echo Please make sure you have installed Wix and setup the PATH enviroment variable on - echo your system properly. Or you can specify the wix path through --wix_bin_path - echo command line parameter. You can download Wix from http://wixtoolset.org - exit /b - ) -) -if x%APP_PATH%==x set APP_PATH=%CD% -if x%APP_INDEX%==x set APP_INDEX=index.html -if x%VERSION%==x set VERSION=1.0.0 -if x%XWALK_PATH%==x ( - FOR /F "tokens=*" %%A IN ('where xwalk') DO SET XWALK_PATH="%%A" - if x%XWALK_PATH%==x ( - set XWALK_PATH=%APP_PATH% - if not exist "!XWALK_PATH!\xwalk.exe" ( - set XWALK_PATH=%CD% - if not exist "!XWALK_PATH!\xwalk.exe" ( - echo Please make sure you have installed Crosswalk and setup the PATH enviroment variable - echo on your system properly. Or you can specify the Crosswalk path through --xwalk_path - echo command line parameter. - - exit /b - ) - ) - ) -) -if x%APP_NAME%==x ( - for %%F in (%APP_PATH%) do set APP_NAME=%%~nF -) -if x%PUBLISHER%==x set PUBLISHER=Me - -set MAIN_OBJ_FILE=%TEMP%\%APP_NAME%.wixobj - -pushd %XWALK_PATH% -set XWALK_PATH=%CD% -popd -pushd %APP_PATH% -set APP_PATH=%CD% -popd -set PACKAGING_INI="%APP_PATH%\_packaging.ini" - -if not "x!APP_PATH:%XWALK_PATH%=!"=="x%APP_PATH%" ( - set __DIRS.1="%APP_PATH%" - set __HARV_FILES.1=appFiles -) else ( - if not "x!XWALK_PATH:%APP_PATH%=!"=="x%XWALK_PATH%" ( - set __DIRS.1="%XWALK_PATH%" - set __HARV_FILES.1=xwalkFiles - ) else ( - set __DIRS.1="%APP_PATH%" - set __HARV_FILES.1=appFiles - set __DIRS.2="%XWALK_PATH%" - set __HARV_FILES.2=xwalkFiles - ) -) -set WXS_FILES= -set OBJ_FILES= -if not exist %GUID_GEN% ( - echo. - echo File not found: %GUID_GEN% - echo Please make sure all the supporting files are in the script folder! - exit /b -) -if x%OUT%==x ( - set OUT=%APP_NAME%.msi - if exist !OUT! ( - set /p CONFIRM_DEL="The output file !OUT! already exists, replace it(Y/N)?" %=% - if /I Y==!CONFIRM_DEL! goto :yes - if /I YES==!CONFIRM_DEL! goto :yes - echo. - echo Installer not created! - exit /b - :yes - del !OUT! - ) -) -for /f "tokens=2* delims=.=" %%A IN ('"SET __HARV_FILES."') do ( - set WXS_FILE=%TEMP%\%%B.wxs - set OBJ_FILE=%TEMP%\%%B.wixobj - %WIX_BIN_PATH%\heat dir !__DIRS.%%A! -gg -cg %%BGroup -srd -dr INSTALLDIR -var var.%%BDir -o !WXS_FILE! - %WIX_BIN_PATH%\candle -dappFilesDir="%APP_PATH%" -dxwalkFilesDir="%XWALK_PATH%" !WXS_FILE! -o !OBJ_FILE! - set "WXS_FILES=!WXS_FILES! !WXS_FILE!" - set "OBJ_FILES=!OBJ_FILES! !OBJ_FILE!" -) - -if exist %PACKAGING_INI% ( - for /f "delims=" %%x in ( 'type %PACKAGING_INI%') do (set "%%x") -) -FOR /F "tokens=*" %%A IN ('cscript //nologo %GUID_GEN% %UPGRADE_CODE%') DO ( - SET UPGRADE_CODE=%%A - echo UPGRADE_CODE=!UPGRADE_CODE!>%PACKAGING_INI% -) -%WIX_BIN_PATH%\candle -dappFilesDir="%APP_PATH%" -dxwalkFilesDir="%XWALK_PATH%" %WXS_TEMPL_FILE% -o %MAIN_OBJ_FILE% -%WIX_BIN_PATH%\light -spdb %MAIN_OBJ_FILE% %OBJ_FILES% -o %OUT% diff --git a/src/xwalk/tools/packaging/bootstrapped/win/guid.vbs b/src/xwalk/tools/packaging/bootstrapped/win/guid.vbs deleted file mode 100644 index 2bb87fe..0000000 --- a/src/xwalk/tools/packaging/bootstrapped/win/guid.vbs +++ /dev/null @@ -1,6 +0,0 @@ -if WScript.Arguments.length <> 1 then - set obj = CreateObject("Scriptlet.TypeLib") - WScript.StdOut.WriteLine MID(obj.GUID, 2, len(obj.GUID) - 4) -else - WScript.StdOut.WriteLine WScript.Arguments(0) -end if diff --git a/src/xwalk/xwalk.gyp b/src/xwalk/xwalk.gyp index 3fafee2..8029ea7 100644 --- a/src/xwalk/xwalk.gyp +++ b/src/xwalk/xwalk.gyp @@ -582,16 +582,6 @@ '../content/app/startup_helper_win.cc', # Needed by InitializedSandbox 'runtime/resources/xwalk.rc', ], - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)', - 'files': [ - 'tools/packaging/bootstrapped/win/app.wxs.templ', - 'tools/packaging/bootstrapped/win/create_windows_installer.bat', - 'tools/packaging/bootstrapped/win/guid.vbs', - ], - }, - ], 'configurations': { 'Debug_Base': { 'msvs_settings': { @@ -607,18 +597,6 @@ '../sandbox/sandbox.gyp:sandbox', ], }], # OS=="win" - ['OS == "linux"', { - 'copies': [ - { - 'destination': '<(PRODUCT_DIR)', - 'files': [ - 'tools/packaging/bootstrapped/linux/app.desktop.templ', - 'tools/packaging/bootstrapped/linux/create_linux_installer.sh', - 'tools/packaging/bootstrapped/linux/Makefile.templ', - ], - } - ], - }], ['OS=="mac"', { 'product_name': '<(xwalk_product_name)', 'dependencies!': [ @@ -719,7 +697,8 @@ 'xwalk_runtime_lib_apk', 'xwalk_app_hello_world_apk', 'xwalk_app_template', - 'xwalk_core_sample_apk' + 'xwalk_core_sample_apk', + 'xwalk_core_library_aar' ], }], ], diff --git a/src/xwalk/xwalk_core_library_android.gypi b/src/xwalk/xwalk_core_library_android.gypi index 29c3751..7519627 100644 --- a/src/xwalk/xwalk_core_library_android.gypi +++ b/src/xwalk/xwalk_core_library_android.gypi @@ -185,5 +185,30 @@ }, ], }, + { + 'target_name': 'xwalk_core_library_aar', + 'type': 'none', + 'dependencies': [ + 'xwalk_core_library', + ], + 'actions': [ + { + 'action_name': 'generate_xwalk_core_library_aar', + 'message': 'Generating XwalkCore AAR Library.', + 'inputs': [ + '<(DEPTH)/xwalk/build/android/common_function.py', + '<(DEPTH)/xwalk/build/android/generate_xwalk_core_library_aar.py', + ], + 'outputs': [ + '<(PRODUCT_DIR)/xwalk_core_library_aar_intermediate/always_run', + ], + 'action': [ + 'python', '<(DEPTH)/xwalk/build/android/generate_xwalk_core_library_aar.py', + '-s', '<(DEPTH)', + '-t', '<(PRODUCT_DIR)', + ], + }, + ], + }, ], }