def prepareBuildRoot(): LOG.info("+Preparing build root folder ...") global BUILD_ROOT global BUILD_ROOT_SRC global BUILD_ROOT_SRC_PKG global BUILD_ROOT_SRC_PKG_APP global BUILD_ROOT_SRC_SUB_APP global BUILD_ROOT_PKG global BUILD_ROOT_PKG_APP while True: BUILD_ROOT = os.path.join("/tmp", utils.getRandomStr()) if os.path.exists(BUILD_ROOT): continue else: break BUILD_ROOT_SRC = os.path.join(BUILD_ROOT, PKG_NAME) BUILD_ROOT_SRC_PKG = os.path.join(BUILD_ROOT, "pkg") BUILD_ROOT_SRC_PKG_APP = os.path.join(BUILD_ROOT, "pkg-app") BUILD_ROOT_SRC_SUB_APP = os.path.join(BUILD_ROOT, "sub-app") BUILD_ROOT_PKG = os.path.join(BUILD_ROOT, "pkg", "opt", PKG_NAME) BUILD_ROOT_PKG_APP = os.path.join(BUILD_ROOT, "pkg-app", "opt", PKG_NAME) if not utils.doCopy(BUILD_PARAMETERS.srcdir, BUILD_ROOT_SRC): return False else: utils.replaceUserString(BUILD_ROOT_SRC, "*", "TESTER-HOME-DIR", "/home/%s" % BUILD_PARAMETERS.user) if not utils.doRemove(glob.glob(os.path.join(BUILD_ROOT_SRC, "%s*.zip" % PKG_NAME))): return False return True
def prepareBuildRoot(): LOG.info("+Preparing build root folder ...") global BUILD_ROOT global BUILD_ROOT_SRC global BUILD_ROOT_SRC_PKG global BUILD_ROOT_SRC_PKG_APP global BUILD_ROOT_SRC_SUB_APP global BUILD_ROOT_PKG global BUILD_ROOT_PKG_APP while True: BUILD_ROOT = os.path.join("/tmp", utils.getRandomStr()) if os.path.exists(BUILD_ROOT): continue else: break BUILD_ROOT_SRC = os.path.join(BUILD_ROOT, PKG_NAME) BUILD_ROOT_SRC_PKG = os.path.join(BUILD_ROOT, "pkg") BUILD_ROOT_SRC_PKG_APP = os.path.join(BUILD_ROOT, "pkg-app") BUILD_ROOT_SRC_SUB_APP = os.path.join(BUILD_ROOT, "sub-app") BUILD_ROOT_PKG = os.path.join(BUILD_ROOT, "pkg", "opt", PKG_NAME) BUILD_ROOT_PKG_APP = os.path.join(BUILD_ROOT, "pkg-app", "opt", PKG_NAME) if not utils.doCopy(BUILD_PARAMETERS.srcdir, BUILD_ROOT_SRC): return False else: utils.replaceUserString(BUILD_ROOT_SRC, '*', 'TESTER-HOME-DIR', "/home/%s" % BUILD_PARAMETERS.user) if not utils.doRemove( glob.glob(os.path.join(BUILD_ROOT_SRC, "%s*.zip" % PKG_NAME))): return False return True
def packAPP(build_json=None, app_src=None, app_dest=None, app_name=None): LOG.info("Packing %s(%s)" % (app_name, app_src)) if not os.path.exists(app_dest): try: os.makedirs(app_dest) except Exception as e: LOG.error("Fail to init package install dest dir: %s" % e) return False app_tpye = utils.safelyGetValue(build_json, "app-type") if utils.checkContains(BUILD_PARAMETERS.pkgtype, "APK") and app_tpye == "EXTENSION": if not build_extension.packExtension(build_json, app_src, app_dest, app_name): return False if not build_android.packAPK(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "APK") and app_tpye != "EMBEDDINGAPI": if not build_android.packAPK(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "CORDOVA"): if BUILD_PARAMETERS.subversion == "4.x": if not build_cordova.packCordova_cli(build_json, app_src, app_dest, app_name): return False else: if not build_cordova.packCordova(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "EMBEDDINGAPI") or app_tpye == "EMBEDDINGAPI": app_version = None if "_" in app_name: index_flag = app_name.index("_") app_version = app_name[index_flag + 1 :] if app_version: utils.replaceUserString( app_src, "AndroidManifest.xml", "org.xwalk.embedding.test", "org.xwalk.embedding.test." + app_version ) utils.replaceUserString( app_src, "AndroidManifest.xml", "EmbeddingApiTestUnit", "EmbeddingApiTestUnit" + app_version ) main_dest = os.path.join(app_src, "src/org/xwalk/embedding") utils.replaceUserString( main_dest, "MainActivity.java", "org.xwalk.embedding.test", "org.xwalk.embedding.test." + app_version ) if BUILD_PARAMETERS.packtype and utils.checkContains(BUILD_PARAMETERS.packtype, "GRADLE"): if not build_embeddingapi.packEmbeddingAPI_gradle(build_json, app_src, app_dest, app_name, app_version): return False elif BUILD_PARAMETERS.packtype and utils.checkContains(BUILD_PARAMETERS.packtype, "MAVEN"): if not build_embeddingapi.packEmbeddingAPI_maven(build_json, app_src, app_dest, app_name, app_version): return False else: if not build_embeddingapi.packEmbeddingAPI_ant(build_json, app_src, app_dest, app_name, app_version): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "DEB"): if not build_deb.packDeb(build_json, app_src, app_dest, app_name): return False else: LOG.error("Got wrong pkg type: %s" % BUILD_PARAMETERS.pkgtype) return False LOG.info("Success to pack APP: %s" % app_name) return True
def packCordova_cli( build_json=None, app_src=None, app_dest=None, app_name=None): BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS") BUILD_ROOT = varshop.getValue("BUILD_ROOT") CROSSWALK_BRANCH= varshop.getValue("CROSSWALK_BRANCH") CROSSWALK_VERSION= varshop.getValue("CROSSWALK_VERSION") DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT") app_name = app_name.replace("-", "_") project_root = os.path.join(BUILD_ROOT, app_name) output = commands.getoutput("cordova -v") output_version = int(output[0]) if output_version < 5: LOG.error( "Cordova 4.x build requires the latest Cordova CLI, and must >= 5.0.0, install with command: '$ sudo npm install cordova -g'") return False plugin_tool = os.path.join(BUILD_ROOT, "cordova_plugins") if not os.path.exists(plugin_tool): if not utils.doCopy( os.path.join(BUILD_PARAMETERS.pkgpacktools, "cordova_plugins"), plugin_tool): return False extra_plugins = os.path.join(BUILD_ROOT, "extra_plugins") if os.path.exists(extra_plugins): if not utils.doCopy(extra_plugins, plugin_tool): return False orig_dir = os.getcwd() os.chdir(BUILD_ROOT) pack_cmd = "cordova create %s org.xwalk.%s %s" % ( app_name, app_name, app_name) if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False # Set activity name as app_name utils.replaceUserString( project_root, 'config.xml', '<widget', '<widget android-activityName="%s"' % app_name) # Workaround for XWALK-3679 utils.replaceUserString( project_root, 'config.xml', '</widget>', ' <allow-navigation href="*" />\n</widget>') if not utils.doRemove([os.path.join(project_root, "www")]): return False if not utils.doCopy(app_src, os.path.join(project_root, "www")): os.chdir(orig_dir) return False os.chdir(project_root) pack_cmd = "cordova platform add android" if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False pkg_mode_tmp = "shared" if BUILD_PARAMETERS.pkgmode == "embedded": pkg_mode_tmp = "core" xwalk_version = "%s" % CROSSWALK_VERSION if CROSSWALK_BRANCH == "beta": xwalk_version = "org.xwalk:xwalk_%s_library_beta:%s" % (pkg_mode_tmp, CROSSWALK_VERSION) webview_plugin_name = "cordova-plugin-crosswalk-webview" install_variable_cmd = "" plugin_dirs = os.listdir(plugin_tool) for i_dir in plugin_dirs: i_plugin_dir = os.path.join(plugin_tool, i_dir) plugin_crosswalk_source = i_plugin_dir if i_dir == webview_plugin_name: if BUILD_PARAMETERS.packtype == "npm": plugin_crosswalk_source = webview_plugin_name install_variable_cmd = "--variable XWALK_MODE=\"%s\" --variable XWALK_VERSION=\"%s\"" \ % (BUILD_PARAMETERS.pkgmode, xwalk_version) plugin_install_cmd = "cordova plugin add %s %s" % (plugin_crosswalk_source, install_variable_cmd) if not utils.doCMD(plugin_install_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False ANDROID_HOME = "echo $(dirname $(dirname $(which android)))" os.environ['ANDROID_HOME'] = commands.getoutput(ANDROID_HOME) pack_cmd = "cordova build android" if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False outputs_dir = os.path.join( project_root, "platforms", "android", "build", "outputs", "apk") if BUILD_PARAMETERS.pkgarch == "x86": cordova_tmp_path = os.path.join( outputs_dir, "%s-x86-debug.apk" % app_name) cordova_tmp_path_spare = os.path.join( outputs_dir, "android-x86-debug.apk") else: cordova_tmp_path = os.path.join( outputs_dir, "%s-armv7-debug.apk" % app_name) cordova_tmp_path_spare = os.path.join( outputs_dir, "android-armv7-debug.apk") if not os.path.exists(cordova_tmp_path): if not utils.doCopy( cordova_tmp_path_spare, os.path.join(app_dest, "%s.apk" % app_name)): os.chdir(orig_dir) return False else: if not utils.doCopy( cordova_tmp_path, os.path.join(app_dest, "%s.apk" % app_name)): os.chdir(orig_dir) return False os.chdir(orig_dir) return True
def packAPP(build_json=None, app_src=None, app_dest=None, app_name=None): LOG.info("Packing %s(%s)" % (app_name, app_src)) if not os.path.exists(app_dest): try: os.makedirs(app_dest) except Exception as e: LOG.error("Fail to init package install dest dir: %s" % e) return False app_tpye = utils.safelyGetValue(build_json, 'app-type') if utils.checkContains(BUILD_PARAMETERS.pkgtype, "APK") and app_tpye == "EXTENSION": if not build_extension.packExtension(build_json, app_src, app_dest, app_name): return False if not build_android.packAPK(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "APK") and app_tpye != "EMBEDDINGAPI": if not build_android.packAPK(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "CORDOVA"): if BUILD_PARAMETERS.subversion == '4.x': if not build_cordova.packCordova_cli(build_json, app_src, app_dest, app_name): return False else: if not build_cordova.packCordova(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "EMBEDDINGAPI") or app_tpye == "EMBEDDINGAPI": app_version = None if "_" in app_name: index_flag = app_name.index("_") app_version = app_name[index_flag + 1:] if app_version: utils.replaceUserString(app_src, 'AndroidManifest.xml', 'org.xwalk.embedding.test', "org.xwalk.embedding.test." + app_version) utils.replaceUserString(app_src, 'AndroidManifest.xml', 'EmbeddingApiTestUnit', "EmbeddingApiTestUnit" + app_version) main_dest = os.path.join(app_src, "src/org/xwalk/embedding") utils.replaceUserString(main_dest, 'MainActivity.java', 'org.xwalk.embedding.test', "org.xwalk.embedding.test." + app_version) if BUILD_PARAMETERS.packtype and utils.checkContains( BUILD_PARAMETERS.packtype, "GRADLE"): if not build_embeddingapi.packEmbeddingAPI_gradle( build_json, app_src, app_dest, app_name, app_version): return False elif BUILD_PARAMETERS.packtype and utils.checkContains( BUILD_PARAMETERS.packtype, "MAVEN"): if not build_embeddingapi.packEmbeddingAPI_maven( build_json, app_src, app_dest, app_name, app_version): return False else: if not build_embeddingapi.packEmbeddingAPI_ant( build_json, app_src, app_dest, app_name, app_version): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "DEB"): if not build_deb.packDeb(build_json, app_src, app_dest, app_name): return False else: LOG.error("Got wrong pkg type: %s" % BUILD_PARAMETERS.pkgtype) return False LOG.info("Success to pack APP: %s" % app_name) return True
def packCordova_cli( build_json=None, app_src=None, app_dest=None, app_name=None): BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS") BUILD_ROOT = varshop.getValue("BUILD_ROOT") CROSSWALK_BRANCH= varshop.getValue("CROSSWALK_BRANCH") CROSSWALK_VERSION= varshop.getValue("CROSSWALK_VERSION") DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT") app_name = app_name.replace("-", "_") project_root = os.path.join(BUILD_ROOT, app_name) output = commands.getoutput("cordova -v") output_version = int(output[0]) if output_version < 5: LOG.error( "Cordova 4.x build requires the latest Cordova CLI, and must >= 5.0.0, install with command: '$ sudo npm install cordova -g'") return False plugin_tool = os.path.join(BUILD_ROOT, "cordova_plugins") plugin_source = os.path.join(BUILD_PARAMETERS.pkgpacktools, "cordova_plugins") if not os.path.exists(plugin_tool): if os.path.exists(plugin_source): if not utils.doCopy( os.path.join(BUILD_PARAMETERS.pkgpacktools, "cordova_plugins"), plugin_tool): return False extra_plugins = os.path.join(BUILD_ROOT, "extra_plugins") if os.path.exists(extra_plugins): if not utils.doCopy(extra_plugins, plugin_tool): return False orig_dir = os.getcwd() os.chdir(BUILD_ROOT) pack_cmd = "cordova create %s org.xwalk.%s %s" % ( app_name, app_name, app_name) if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False # Set activity name as app_name utils.replaceUserString( project_root, 'config.xml', '<widget', '<widget android-activityName="%s"' % app_name) # Workaround for XWALK-3679 utils.replaceUserString( project_root, 'config.xml', '</widget>', ' <allow-navigation href="*" />\n</widget>') if not utils.doRemove([os.path.join(project_root, "www")]): return False if not utils.doCopy(app_src, os.path.join(project_root, "www")): os.chdir(orig_dir) return False os.chdir(project_root) pack_cmd = "cordova platform add android" if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False pkg_mode_tmp = "shared" if BUILD_PARAMETERS.pkgmode == "embedded": pkg_mode_tmp = "core" xwalk_version = "%s" % CROSSWALK_VERSION if CROSSWALK_BRANCH == "beta": xwalk_version = "org.xwalk:xwalk_%s_library_beta:%s" % (pkg_mode_tmp, CROSSWALK_VERSION) webview_plugin_name = "cordova-plugin-crosswalk-webview" plugin_dirs = os.listdir(plugin_tool) for i_dir in plugin_dirs: install_variable_cmd = "" i_plugin_dir = os.path.join(plugin_tool, i_dir) plugin_crosswalk_source = i_plugin_dir if i_dir == webview_plugin_name: if BUILD_PARAMETERS.packtype == "npm": plugin_crosswalk_source = webview_plugin_name install_variable_cmd = "--variable XWALK_MODE=\"%s\" --variable XWALK_VERSION=\"%s\"" \ % (BUILD_PARAMETERS.pkgmode, xwalk_version) plugin_install_cmd = "cordova plugin add %s %s" % (plugin_crosswalk_source, install_variable_cmd) if not utils.doCMD(plugin_install_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False ANDROID_HOME = "echo $(dirname $(dirname $(which android)))" os.environ['ANDROID_HOME'] = commands.getoutput(ANDROID_HOME) apk_name_arch = "armv7" pack_arch_tmp = "arm" if BUILD_PARAMETERS.pkgarch and BUILD_PARAMETERS.pkgarch != "arm": apk_name_arch = BUILD_PARAMETERS.pkgarch if BUILD_PARAMETERS.pkgarch == "x86": pack_arch_tmp = "x86" elif BUILD_PARAMETERS.pkgarch == "x86_64": pack_arch_tmp = "x86 --xwalk64bit" elif BUILD_PARAMETERS.pkgarch == "arm64": pack_arch_tmp = "arm --xwalk64bit" pack_cmd = "cordova build android -- --gradleArg=-PcdvBuildArch=%s" % pack_arch_tmp if not utils.doCMD(pack_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False outputs_dir = os.path.join( project_root, "platforms", "android", "build", "outputs", "apk") cordova_tmp_path = os.path.join( outputs_dir, "android-%s-debug.apk" % apk_name_arch) if not os.path.exists(cordova_tmp_path): cordova_tmp_path = os.path.join( outputs_dir, "%s-%s-debug.apk" % (app_name, apk_name_arch)) if not os.path.exists(cordova_tmp_path): cordova_tmp_path = os.path.join( outputs_dir, "android-debug.apk") if not os.path.exists(cordova_tmp_path): cordova_tmp_path = os.path.join( outputs_dir, "%s-debug.apk" % app_name) if not utils.doCopy( cordova_tmp_path, os.path.join(app_dest, "%s.apk" % app_name)): os.chdir(orig_dir) return False os.chdir(orig_dir) return True
def packAPP(build_json=None, app_src=None, app_dest=None, app_name=None): LOG.info("Packing %s(%s)" % (app_name, app_src)) if not os.path.exists(app_dest): try: os.makedirs(app_dest) except Exception as e: LOG.error("Fail to init package install dest dir: %s" % e) return False app_tpye = utils.safelyGetValue(build_json, 'app-type') if utils.checkContains(BUILD_PARAMETERS.pkgtype, "APK") and app_tpye == "EXTENSION": if not build_extension.packExtension(build_json, app_src, app_dest, app_name): return False if not build_android.packAPK(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "APK") and app_tpye != "EMBEDDINGAPI": if not build_android.packAPK(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "CORDOVA"): if not build_cordova.packCordova(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "EMBEDDINGAPI") or app_tpye == "EMBEDDINGAPI": app_version = None if "_" in app_name: index_flag = app_name.index("_") app_version = app_name[index_flag + 1:] if app_version: utils.replaceUserString( app_src, 'AndroidManifest.xml', 'org.xwalk.embedding.test', "org.xwalk.embedding.test." + app_version) utils.replaceUserString( app_src, 'AndroidManifest.xml', 'org.xwalk.embedding.asynctest', "org.xwalk.embedding.asynctest." + app_version) utils.replaceUserString( app_src, 'AndroidManifest.xml', 'EmbeddingApiTestUnit', "EmbeddingApiTestUnit" + app_version) utils.replaceUserString( app_src, 'AndroidManifest.xml', 'EmbeddingApiAsynctestUnit', "EmbeddingApiAsynctestUnit" + app_version) if app_version != "v6": utils.replaceUserString( app_src, 'AndroidManifest.xml', '<provider android:name=\"org.xwalk.embedding.base.TestContentProvider\"' + ' android:authorities=\"org.xwalk.embedding.base.TestContentProvider\" />', "") main_dest = os.path.join(app_src, "src/org/xwalk/embedding") utils.replaceUserString( main_dest, 'MainActivity.java', 'org.xwalk.embedding.test', "org.xwalk.embedding.test." + app_version) utils.replaceUserString( main_dest, 'MainActivity.java', 'org.xwalk.embedding.asynctest', "org.xwalk.embedding.asynctest." + app_version) if BUILD_PARAMETERS.packtype and utils.checkContains( BUILD_PARAMETERS.packtype, "GRADLE"): if not build_embeddingapi.packEmbeddingAPI_gradle( build_json, app_src, app_dest, app_name, app_version): return False elif BUILD_PARAMETERS.packtype and utils.checkContains(BUILD_PARAMETERS.packtype, "MAVEN"): if not build_embeddingapi.packEmbeddingAPI_maven( build_json, app_src, app_dest, app_name, app_version): return False else: if not build_embeddingapi.packEmbeddingAPI_ant( build_json, app_src, app_dest, app_name, app_version): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "DEB"): if not build_deb.packDeb(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "MSI"): if not build_msi.packMsi(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "ios"): if not build_ios.packIOS(build_json, app_src, app_dest, app_name): return False elif utils.checkContains(BUILD_PARAMETERS.pkgtype, "iot"): if not build_iot.packIoT(build_json, app_src, app_dest, app_name): return False else: LOG.error("Got wrong pkg type: %s" % BUILD_PARAMETERS.pkgtype) return False LOG.info("Success to pack APP: %s" % app_name) return True
def packEmbeddingAPI_maven( build_json=None, app_src=None, app_dest=None, app_name=None, app_version=None): BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS") BUILD_ROOT = varshop.getValue("BUILD_ROOT") CROSSWALK_VERSION= varshop.getValue("CROSSWALK_VERSION") DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT") app_name = app_name.replace("-", "_") orig_dir = os.getcwd() LOG.info("app_src: %s" % app_src) LOG.info("app_dest: %s" % app_dest) os.chdir(BUILD_ROOT) utils.replaceUserString( app_src, 'pom.xml', '{crosswalk.version}', CROSSWALK_VERSION) version_parts = CROSSWALK_VERSION.split('.') if len(version_parts) < 4: LOG.error("The crosswalk version is not configured exactly!") return False versionType = version_parts[3] if versionType == '0': utils.replaceUserString( app_src, 'pom.xml', 'xwalk_core_library_beta', 'xwalk_core_library') username = commands.getoutput("echo $USER") repository_path = "/home/%s/.m2/repository/org/xwalk/xwalk_core_library/%s" % \ (username, CROSSWALK_VERSION) repository_aar_path = "/home/%s/.m2/repository/org/xwalk/xwalk_core_library/%s/" \ "xwalk_core_library-%s.aar" % \ (username, CROSSWALK_VERSION, CROSSWALK_VERSION) repository_pom_path = "/home/%s/.m2/repository/org/xwalk/xwalk_core_library/%s/" \ "xwalk_core_library-%s.pom" % \ (username, CROSSWALK_VERSION, CROSSWALK_VERSION) if not os.path.exists(repository_aar_path) or not os.path.exists(repository_pom_path): wget_cmd = "wget https://download.01.org/crosswalk/releases/crosswalk/android" \ "/canary/%s/crosswalk-%s.aar" % \ (CROSSWALK_VERSION, CROSSWALK_VERSION) if not utils.doCMD(wget_cmd, DEFAULT_CMD_TIMEOUT * 3): os.chdir(orig_dir) return False install_cmd = "mvn install:install-file -DgroupId=org.xwalk " \ "-DartifactId=xwalk_core_library -Dversion=%s -Dpackaging=aar " \ "-Dfile=crosswalk-%s.aar -DgeneratePom=true" % \ (CROSSWALK_VERSION, CROSSWALK_VERSION) if not utils.doCMD(install_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False if not utils.doCopy( repository_aar_path, os.path.join(repository_path, "xwalk_core_library-%s-x86.aar" % CROSSWALK_VERSION)): os.chdir(orig_dir) return False if not utils.doCopy( repository_aar_path, os.path.join(repository_path, "xwalk_core_library-%s-arm.aar" % CROSSWALK_VERSION)): os.chdir(orig_dir) return False utils.replaceUserString( app_src, 'pom.xml', 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2', 'file:///home/%s/.m2/repository' % username) os.chdir(app_src) utils.replaceUserString( app_src, 'AndroidManifest.xml', 'android:versionCode=\"1\"', 'android:versionCode=\"${app.version.code}\"') utils.replaceUserString( app_src, 'AndroidManifest.xml', 'android:versionName=\"1.0\"', 'android:versionName=\"${app.version.name}\"') manifest_path = os.path.join(app_src, "AndroidManifest.xml") if not utils.doCopy( manifest_path, os.path.join(app_src, "src", "main", "AndroidManifest.xml")): return False if not utils.doRemove([manifest_path]): return False res_path = os.path.join(app_src, "res") if os.path.exists(res_path): if not utils.doCopy(res_path, os.path.join(app_src, "src", "main", "res")): return False if not utils.doRemove([res_path]): return False assets_path = os.path.join(app_src, "assets") if os.path.exists(assets_path): if not utils.doCopy( assets_path, os.path.join(app_src, "src", "main", "assets")): return False if not utils.doRemove([assets_path]): return False src_org_path = os.path.join(app_src, "src", "org") if not utils.doCopy( src_org_path, os.path.join(app_src, "src", "main", "java", "org")): return False if not utils.doRemove([src_org_path]): return False libs_path = os.path.join(app_src, "libs") if os.path.exists(libs_path): if not utils.doCopy( libs_path, os.path.join(app_src, "../libs")): return False if not utils.doRemove([libs_path]): return False if BUILD_PARAMETERS.pkgarch and BUILD_PARAMETERS.pkgarch == "arm": if not utils.doCMD("mvn clean install -Parm", DEFAULT_CMD_TIMEOUT): return False if not utils.doCopy( os.path.join( app_src, "target", "embeddingapi-tests-arm.apk"), os.path.join(app_dest, "%s.apk" % app_name)): return False else: if not utils.doCMD("mvn clean install -Px86", DEFAULT_CMD_TIMEOUT): return False if not utils.doCopy( os.path.join(app_src, "target", "embeddingapi-tests-x86.apk"), os.path.join(app_dest, "%s.apk" % app_name)): return False os.chdir(orig_dir) return True
def packEmbeddingAPI_gradle( build_json=None, app_src=None, app_dest=None, app_name=None, app_version=None): BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS") BUILD_ROOT = varshop.getValue("BUILD_ROOT") CROSSWALK_VERSION= varshop.getValue("CROSSWALK_VERSION") DEFAULT_CMD_TIMEOUT= varshop.getValue("DEFAULT_CMD_TIMEOUT") app_name_origin = app_name app_name = app_name.replace("-", "_") orig_dir = os.getcwd() LOG.info("app_src: %s" % app_src) LOG.info("app_dest: %s" % app_dest) os.chdir(BUILD_ROOT) utils.replaceUserString( app_src, 'build.gradle', '{crosswalk.version}', CROSSWALK_VERSION) version_parts = CROSSWALK_VERSION.split('.') if len(version_parts) < 4: LOG.error("The crosswalk version is not configured exactly!") return False versionType = version_parts[3] if versionType == '0': utils.replaceUserString( app_src, 'build.gradle', 'xwalk_core_library_beta', 'xwalk_core_library') utils.replaceUserString( app_src, 'build.gradle', 'maven {\n url \'https://download.01.org/crosswalk/releases/crosswalk/android/maven2\'\n }', ' mavenLocal()') username = commands.getoutput("echo $USER") repository_aar_path = "/home/%s/.m2/repository/org/xwalk/xwalk_core_library/%s/" \ "xwalk_core_library-%s.aar" % \ (username, CROSSWALK_VERSION, CROSSWALK_VERSION) repository_pom_path = "/home/%s/.m2/repository/org/xwalk/xwalk_core_library/%s/" \ "xwalk_core_library-%s.pom" % \ (username, CROSSWALK_VERSION, CROSSWALK_VERSION) if not os.path.exists(repository_aar_path) or not os.path.exists(repository_pom_path): wget_cmd = "wget https://download.01.org/crosswalk/releases/crosswalk/" \ "android/canary/%s/crosswalk-%s.aar" % \ (CROSSWALK_VERSION, CROSSWALK_VERSION) if not utils.doCMD(wget_cmd, DEFAULT_CMD_TIMEOUT * 3): os.chdir(orig_dir) return False install_cmd = "mvn install:install-file -DgroupId=org.xwalk " \ "-DartifactId=xwalk_core_library -Dversion=%s -Dpackaging=aar " \ "-Dfile=crosswalk-%s.aar -DgeneratePom=true" % \ (CROSSWALK_VERSION, CROSSWALK_VERSION) if not utils.doCMD(install_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False os.chdir(app_src) if not utils.doCMD("gradle build", DEFAULT_CMD_TIMEOUT): os.chdir("..") return False if BUILD_PARAMETERS.pkgarch and BUILD_PARAMETERS.pkgarch == "arm": if not utils.doCopy( os.path.join( app_src, "build", "outputs", "apk", "%s-armv7-debug.apk" % app_name_origin), os.path.join(app_dest, "%s.apk" % app_name)): return False else: if not utils.doCopy( os.path.join( app_src, "build", "outputs", "apk", "%s-x86-debug.apk" % app_name_origin), os.path.join(app_dest, "%s.apk" % app_name)): return False os.chdir(orig_dir) return True
def packEmbeddingAPI_maven(build_json=None, app_src=None, app_dest=None, app_name=None, app_version=None): BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS") BUILD_ROOT = varshop.getValue("BUILD_ROOT") CROSSWALK_VERSION = varshop.getValue("CROSSWALK_VERSION") DEFAULT_CMD_TIMEOUT = varshop.getValue("DEFAULT_CMD_TIMEOUT") app_name = app_name.replace("-", "_") orig_dir = os.getcwd() LOG.info("app_src: %s" % app_src) LOG.info("app_dest: %s" % app_dest) os.chdir(BUILD_ROOT) utils.replaceUserString(app_src, 'pom.xml', '{crosswalk.version}', CROSSWALK_VERSION) version_parts = CROSSWALK_VERSION.split('.') if len(version_parts) < 4: LOG.error("The crosswalk version is not configured exactly!") return False versionType = version_parts[3] if versionType == '0': utils.replaceUserString(app_src, 'pom.xml', 'xwalk_core_library_beta', 'xwalk_core_library') username = commands.getoutput("echo $USER") repository_path = "/home/%s/.m2/repository/org/xwalk/xwalk_core_library/%s" % \ (username, CROSSWALK_VERSION) repository_aar_path = "/home/%s/.m2/repository/org/xwalk/xwalk_core_library/%s/" \ "xwalk_core_library-%s.aar" % \ (username, CROSSWALK_VERSION, CROSSWALK_VERSION) repository_pom_path = "/home/%s/.m2/repository/org/xwalk/xwalk_core_library/%s/" \ "xwalk_core_library-%s.pom" % \ (username, CROSSWALK_VERSION, CROSSWALK_VERSION) if not os.path.exists(repository_aar_path) or not os.path.exists( repository_pom_path): wget_cmd = "wget https://download.01.org/crosswalk/releases/crosswalk/android" \ "/canary/%s/crosswalk-%s.aar" % \ (CROSSWALK_VERSION, CROSSWALK_VERSION) if not utils.doCMD(wget_cmd, DEFAULT_CMD_TIMEOUT * 3): os.chdir(orig_dir) return False install_cmd = "mvn install:install-file -DgroupId=org.xwalk " \ "-DartifactId=xwalk_core_library -Dversion=%s -Dpackaging=aar " \ "-Dfile=crosswalk-%s.aar -DgeneratePom=true" % \ (CROSSWALK_VERSION, CROSSWALK_VERSION) if not utils.doCMD(install_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False if not utils.doCopy( repository_aar_path, os.path.join( repository_path, "xwalk_core_library-%s-x86.aar" % CROSSWALK_VERSION)): os.chdir(orig_dir) return False if not utils.doCopy( repository_aar_path, os.path.join( repository_path, "xwalk_core_library-%s-arm.aar" % CROSSWALK_VERSION)): os.chdir(orig_dir) return False utils.replaceUserString( app_src, 'pom.xml', 'https://download.01.org/crosswalk/releases/crosswalk/android/maven2', 'file:///home/%s/.m2/repository' % username) os.chdir(app_src) utils.replaceUserString(app_src, 'AndroidManifest.xml', 'android:versionCode=\"1\"', 'android:versionCode=\"${app.version.code}\"') utils.replaceUserString(app_src, 'AndroidManifest.xml', 'android:versionName=\"1.0\"', 'android:versionName=\"${app.version.name}\"') manifest_path = os.path.join(app_src, "AndroidManifest.xml") if not utils.doCopy( manifest_path, os.path.join(app_src, "src", "main", "AndroidManifest.xml")): return False if not utils.doRemove([manifest_path]): return False res_path = os.path.join(app_src, "res") if os.path.exists(res_path): if not utils.doCopy(res_path, os.path.join(app_src, "src", "main", "res")): return False if not utils.doRemove([res_path]): return False assets_path = os.path.join(app_src, "assets") if os.path.exists(assets_path): if not utils.doCopy(assets_path, os.path.join(app_src, "src", "main", "assets")): return False if not utils.doRemove([assets_path]): return False src_org_path = os.path.join(app_src, "src", "org") if not utils.doCopy(src_org_path, os.path.join(app_src, "src", "main", "java", "org")): return False if not utils.doRemove([src_org_path]): return False libs_path = os.path.join(app_src, "libs") if os.path.exists(libs_path): if not utils.doCopy(libs_path, os.path.join(app_src, "../libs")): return False if not utils.doRemove([libs_path]): return False if BUILD_PARAMETERS.pkgarch and BUILD_PARAMETERS.pkgarch == "arm": if not utils.doCMD("mvn clean install -Parm", DEFAULT_CMD_TIMEOUT): return False if not utils.doCopy( os.path.join(app_src, "target", "embeddingapi-tests-arm.apk"), os.path.join(app_dest, "%s.apk" % app_name)): return False else: if not utils.doCMD("mvn clean install -Px86", DEFAULT_CMD_TIMEOUT): return False if not utils.doCopy( os.path.join(app_src, "target", "embeddingapi-tests-x86.apk"), os.path.join(app_dest, "%s.apk" % app_name)): return False os.chdir(orig_dir) return True
def packEmbeddingAPI_gradle(build_json=None, app_src=None, app_dest=None, app_name=None, app_version=None): BUILD_PARAMETERS = varshop.getValue("BUILD_PARAMETERS") BUILD_ROOT = varshop.getValue("BUILD_ROOT") CROSSWALK_VERSION = varshop.getValue("CROSSWALK_VERSION") DEFAULT_CMD_TIMEOUT = varshop.getValue("DEFAULT_CMD_TIMEOUT") app_name_origin = app_name app_name = app_name.replace("-", "_") orig_dir = os.getcwd() LOG.info("app_src: %s" % app_src) LOG.info("app_dest: %s" % app_dest) os.chdir(BUILD_ROOT) utils.replaceUserString(app_src, 'build.gradle', '{crosswalk.version}', CROSSWALK_VERSION) version_parts = CROSSWALK_VERSION.split('.') if len(version_parts) < 4: LOG.error("The crosswalk version is not configured exactly!") return False versionType = version_parts[3] if versionType == '0': utils.replaceUserString(app_src, 'build.gradle', 'xwalk_core_library_beta', 'xwalk_core_library') utils.replaceUserString( app_src, 'build.gradle', 'maven {\n url \'https://download.01.org/crosswalk/releases/crosswalk/android/maven2\'\n }', ' mavenLocal()') username = commands.getoutput("echo $USER") repository_aar_path = "/home/%s/.m2/repository/org/xwalk/xwalk_core_library/%s/" \ "xwalk_core_library-%s.aar" % \ (username, CROSSWALK_VERSION, CROSSWALK_VERSION) repository_pom_path = "/home/%s/.m2/repository/org/xwalk/xwalk_core_library/%s/" \ "xwalk_core_library-%s.pom" % \ (username, CROSSWALK_VERSION, CROSSWALK_VERSION) if not os.path.exists(repository_aar_path) or not os.path.exists( repository_pom_path): wget_cmd = "wget https://download.01.org/crosswalk/releases/crosswalk/" \ "android/canary/%s/crosswalk-%s.aar" % \ (CROSSWALK_VERSION, CROSSWALK_VERSION) if not utils.doCMD(wget_cmd, DEFAULT_CMD_TIMEOUT * 3): os.chdir(orig_dir) return False install_cmd = "mvn install:install-file -DgroupId=org.xwalk " \ "-DartifactId=xwalk_core_library -Dversion=%s -Dpackaging=aar " \ "-Dfile=crosswalk-%s.aar -DgeneratePom=true" % \ (CROSSWALK_VERSION, CROSSWALK_VERSION) if not utils.doCMD(install_cmd, DEFAULT_CMD_TIMEOUT): os.chdir(orig_dir) return False os.chdir(app_src) if not utils.doCMD("gradle build", DEFAULT_CMD_TIMEOUT): os.chdir("..") return False if BUILD_PARAMETERS.pkgarch and BUILD_PARAMETERS.pkgarch == "arm": if not utils.doCopy( os.path.join(app_src, "build", "outputs", "apk", "%s-armv7-debug.apk" % app_name_origin), os.path.join(app_dest, "%s.apk" % app_name)): return False else: if not utils.doCopy( os.path.join(app_src, "build", "outputs", "apk", "%s-x86-debug.apk" % app_name_origin), os.path.join(app_dest, "%s.apk" % app_name)): return False os.chdir(orig_dir) return True