change android signing + fix android-emulator docker support + update default assets

This commit is contained in:
therecipe 2018-04-30 20:45:48 +02:00
parent e929d5dd53
commit e94fc48f4a
3 changed files with 41 additions and 93 deletions

View file

@ -99,7 +99,7 @@ func android_config(target, path, depPath string) string {
jsonStruct.Targetarchitecture = "x86" jsonStruct.Targetarchitecture = "x86"
} }
if utils.QT_DOCKER() { if utils.QT_DOCKER() && target == "android" {
jsonStruct.AndroidExtraLibs += "," + filepath.Join(os.Getenv("HOME"), "openssl-1.0.2k", "libcrypto.so") + "," + filepath.Join(os.Getenv("HOME"), "openssl-1.0.2k", "libssl.so") jsonStruct.AndroidExtraLibs += "," + filepath.Join(os.Getenv("HOME"), "openssl-1.0.2k", "libcrypto.so") + "," + filepath.Join(os.Getenv("HOME"), "openssl-1.0.2k", "libssl.so")
} }
@ -110,43 +110,37 @@ func android_config(target, path, depPath string) string {
return strings.Replace(string(out), `\\`, `/`, -1) return strings.Replace(string(out), `\\`, `/`, -1)
} }
func android_gradle_wrapper() string {
return `distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip`
}
//darwin //darwin
func darwin_sh(name string) string {
return fmt.Sprintf("#!/bin/bash\ncd \"${0%%/*}\"\n./%v_app \"$@\"", name)
}
func darwin_plist(name string) string { func darwin_plist(name string) string {
return fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?> return fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>NSPrincipalClass</key> <key>CFBundleExecutable</key>
<string>NSApplication</string> <string>%[1]v</string>
<key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string>
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>%[1]v.icns</string> <string>%[1]v.icns</string>
<key>CFBundleIdentifier</key>
<string>com.yourcompany.%[1]v</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>%[1]v</string> <string>%[1]v</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleGetInfoString</key> <key>CFBundleShortVersionString</key>
<string>Created by Qt/QMake</string> <string>1.0.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleExecutable</key> <key>LSMinimumSystemVersion</key>
<string>%[1]v</string> <string>10.11</string>
<key>CFBundleIdentifier</key>
<string>com.ident.%[1]v</string>
<key>NOTE</key> <key>NOTE</key>
<string>This file was generated by Qt/QMake.</string> <string>This file was generated by Qt/QMake.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
</dict> </dict>
</plist> </plist>
`, name) `, name)
@ -177,32 +171,32 @@ func ios_plist(name string) string {
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDisplayName</key>
<string>en</string> <string>%[1]v</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>main</string> <string>main</string>
<key>CFBundleGetInfoString</key>
<string>Created by Qt/QMake</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.identifier.%[1]v</string> <string>com.yourcompany.%[1]v</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>%[1]v</string> <string>%[1]v</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.0</string> <string>1.0.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0</string> <string>1.0.0</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>MinimumOSVersion</key>
<string>${IPHONEOS_DEPLOYMENT_TARGET}</string>
<key>NOTE</key>
<string>This file was generated by Qt/QMake.</string>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
<string>LaunchScreen</string> <string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key> <key>UISupportedInterfaceOrientations</key>
<array> <array>
<string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationPortrait</string>
@ -210,20 +204,8 @@ func ios_plist(name string) string {
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>QtRunLoopIntegrationDisableSeparateStack</key> <key>QtRunLoopIntegrationDisableSeparateStack</key>
<true/> <true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict> </dict>
</plist> </plist>
`, name) `, name)
@ -231,10 +213,9 @@ func ios_plist(name string) string {
func ios_launchscreen(name string) string { func ios_launchscreen(name string) string {
return fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8" standalone="no"?> return fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES"> <document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14A343f" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies> <dependencies>
<deployment identifier="iOS"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/> <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies> </dependencies>
<objects> <objects>
@ -247,7 +228,7 @@ func ios_launchscreen(name string) string {
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="%v" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX"> <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="%v" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43"/> <rect key="frame" x="20" y="140" width="441" height="43"/>
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/> <fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/> <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/> <nil key="highlightedColor"/>
</label> </label>
</subviews> </subviews>
@ -339,7 +320,7 @@ func ios_appicon() string {
} }
func ios_xcodeproject(depPath string) string { func ios_xcodeproject(depPath string) string {
return fmt.Sprintf(`// !$*UTF8*$! return `// !$*UTF8*$!
{ {
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
@ -393,7 +374,6 @@ func ios_xcodeproject(depPath string) string {
buildConfigurationList = 254BB8611B1FD08900C56DE9 /* Build configuration list for PBXNativeTarget "main" */; buildConfigurationList = 254BB8611B1FD08900C56DE9 /* Build configuration list for PBXNativeTarget "main" */;
buildPhases = ( buildPhases = (
254BB83C1B1FD08900C56DE9 /* Resources */, 254BB83C1B1FD08900C56DE9 /* Resources */,
259BC5361CE6BA19005B5A05 /* ShellScript */,
); );
buildRules = ( buildRules = (
); );
@ -450,24 +430,6 @@ func ios_xcodeproject(depPath string) string {
}; };
/* End PBXResourcesBuildPhase section */ /* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
259BC5361CE6BA19005B5A05 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"$(TARGET_BUILD_DIR)/$(EXECUTABLE_PATH)",
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cp %v/qt.conf $CODESIGNING_FOLDER_PATH/qt.conf; test -d $CODESIGNING_FOLDER_PATH/qt_qml && rm -r $CODESIGNING_FOLDER_PATH/qt_qml; mkdir -p $CODESIGNING_FOLDER_PATH/qt_qml && for p in %v/%v/ios/qml; do rsync -r --exclude='*.a' --exclude='*.prl' --exclude='*.qmltypes' $p/ $CODESIGNING_FOLDER_PATH/qt_qml; done";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin XCBuildConfiguration section */ /* Begin XCBuildConfiguration section */
254BB8601B1FD08900C56DE9 /* Release */ = { 254BB8601B1FD08900C56DE9 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
@ -512,7 +474,6 @@ func ios_xcodeproject(depPath string) string {
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
INFOPLIST_FILE = Info.plist; INFOPLIST_FILE = Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
}; };
name = Release; name = Release;
@ -540,13 +501,6 @@ func ios_xcodeproject(depPath string) string {
}; };
rootObject = 254BB8361B1FD08900C56DE9 /* Project object */; rootObject = 254BB8361B1FD08900C56DE9 /* Project object */;
} }
`, depPath, utils.QT_DIR(), utils.QT_VERSION_MAJOR())
}
func ios_qtconf() string {
return `[Paths]
Imports = qt_qml
Qml2Imports = qt_qml
` `
} }

View file

@ -336,13 +336,6 @@ func bundle(mode, target, path, name, depPath string) {
utils.MkdirAll(assets) utils.MkdirAll(assets)
copy(assets+"/.", filepath.Join(depPath, "build")) copy(assets+"/.", filepath.Join(depPath, "build"))
//create default gradle-wrapper.properties
if target == "android-emulator" {
path := filepath.Join(depPath, "build", "gradle", "wrapper")
utils.MkdirAll(path)
utils.Save(filepath.Join(path, "gradle-wrapper.properties"), android_gradle_wrapper())
}
//wrap exported go main inside c main //wrap exported go main inside c main
env, _, _, _ := cmd.BuildEnv(target, name, depPath) env, _, _, _ := cmd.BuildEnv(target, name, depPath)
compiler := env["CXX"] compiler := env["CXX"]
@ -403,13 +396,13 @@ func bundle(mode, target, path, name, depPath string) {
"--android-platform", "android-25", "--android-platform", "android-25",
"--jdk", utils.JDK_DIR(), "--jdk", utils.JDK_DIR(),
"--gradle", "--gradle",
"--no-gdbserver",
"--verbose", "--verbose",
) )
if utils.ExistsFile(filepath.Join(path, target, name+".keystore")) { if utils.ExistsFile(filepath.Join(path, target, name+".jks")) {
dep.Args = append(dep.Args, dep.Args = append(dep.Args,
"--sign", filepath.Join(path, target, name+".keystore"), "--sign", filepath.Join(path, target, name+".jks"), strings.TrimSpace(utils.Load(filepath.Join(path, target, "jks_alias"))),
strings.TrimSpace(utils.Load(filepath.Join(path, target, "alias.txt"))), "--storepass", strings.TrimSpace(utils.Load(filepath.Join(path, target, "jks_pass"))))
"--storepass", strings.TrimSpace(utils.Load(filepath.Join(path, target, "password.txt"))))
} }
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
@ -424,13 +417,13 @@ func bundle(mode, target, path, name, depPath string) {
if utils.QT_VAGRANT() { if utils.QT_VAGRANT() {
depPathUNC := strings.Replace(depPath, "C:\\media\\sf_GOPATH", "C:\\media\\UNC\\vboxsrv\\media_sf_GOPATH", -1) depPathUNC := strings.Replace(depPath, "C:\\media\\sf_GOPATH", "C:\\media\\UNC\\vboxsrv\\media_sf_GOPATH", -1)
if utils.ExistsFile(filepath.Join(path, target, name+".keystore")) { if utils.ExistsFile(filepath.Join(path, target, name+".jks")) {
copy(filepath.Join(depPathUNC, "build", "build", "outputs", "apk", "build-release-signed.apk"), depPath) copy(filepath.Join(depPathUNC, "build", "build", "outputs", "apk", "build-release-signed.apk"), depPath)
} else { } else {
copy(filepath.Join(depPathUNC, "build", "build", "outputs", "apk", "build-debug.apk"), depPath) copy(filepath.Join(depPathUNC, "build", "build", "outputs", "apk", "build-debug.apk"), depPath)
} }
} else { } else {
if utils.ExistsFile(filepath.Join(path, target, name+".keystore")) { if utils.ExistsFile(filepath.Join(path, target, name+".jks")) {
copy(filepath.Join(depPath, "build", "build", "outputs", "apk", "build-release-signed.apk"), depPath) copy(filepath.Join(depPath, "build", "build", "outputs", "apk", "build-release-signed.apk"), depPath)
} else { } else {
copy(filepath.Join(depPath, "build", "build", "outputs", "apk", "build-debug.apk"), depPath) copy(filepath.Join(depPath, "build", "build", "outputs", "apk", "build-debug.apk"), depPath)
@ -452,13 +445,12 @@ func bundle(mode, target, path, name, depPath string) {
//copy custom assets //copy custom assets
assets := filepath.Join(path, target) assets := filepath.Join(path, target)
utils.MkdirAll(assets) utils.MkdirAll(assets)
copy(assets+"/.", depPath) copy(assets+"/.", buildPath)
//add c_main_wrappers //add c_main_wrappers
if !utils.ExistsFile(filepath.Join(depPath, target+"_qml_plugin_import.cpp")) { if !utils.ExistsFile(filepath.Join(depPath, target+"_qml_plugin_import.cpp")) {
utils.Save(filepath.Join(depPath, target+"_qml_plugin_import.cpp"), "") utils.Save(filepath.Join(depPath, target+"_qml_plugin_import.cpp"), "")
} }
utils.Save(filepath.Join(depPath, "qt.conf"), ios_qtconf())
var t string var t string
switch target { switch target {

View file

@ -20,9 +20,11 @@ func run(target, name, depPath, device string) {
exec.Command(filepath.Join(utils.ANDROID_SDK_DIR(), "platform-tools", "adb"), "install", "-r", filepath.Join(depPath, "build-release-signed.apk")).Start() exec.Command(filepath.Join(utils.ANDROID_SDK_DIR(), "platform-tools", "adb"), "install", "-r", filepath.Join(depPath, "build-release-signed.apk")).Start()
} }
//TODO: parse manifest for ident and start app (+ logcat)
case "ios-simulator": case "ios-simulator":
if device == "" { if device == "" {
out, _ := exec.Command("xcrun", "instruments", "-s", "").Output() out, _ := exec.Command("xcrun", "instruments", "-s").Output()
lines := strings.Split(string(out), "iPhone") lines := strings.Split(string(out), "iPhone")
device = strings.Split(strings.Split(string(out), "iPhone 8 ("+strings.Split(strings.Split(lines[len(lines)-1], "(")[1], ")")[0]+") [")[1], "]")[0] device = strings.Split(strings.Split(string(out), "iPhone 8 ("+strings.Split(strings.Split(lines[len(lines)-1], "(")[1], ")")[0]+") [")[1], "]")[0]
} }
@ -30,7 +32,7 @@ func run(target, name, depPath, device string) {
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
utils.RunCmdOptional(exec.Command("xcrun", "simctl", "uninstall", "booted", filepath.Join(depPath, "main.app")), "uninstall old app") utils.RunCmdOptional(exec.Command("xcrun", "simctl", "uninstall", "booted", filepath.Join(depPath, "main.app")), "uninstall old app")
utils.RunCmdOptional(exec.Command("xcrun", "simctl", "install", "booted", filepath.Join(depPath, "main.app")), "install new app") utils.RunCmdOptional(exec.Command("xcrun", "simctl", "install", "booted", filepath.Join(depPath, "main.app")), "install new app")
utils.RunCmdOptional(exec.Command("xcrun", "simctl", "launch", "booted", fmt.Sprintf("com.identifier.%v", name)), "start app") utils.RunCmdOptional(exec.Command("xcrun", "simctl", "launch", "booted", fmt.Sprintf("com.yourcompany.%v", name)), "start app") //TODO: parse ident from plist
case "darwin": case "darwin":
exec.Command("open", filepath.Join(depPath, fmt.Sprintf("%v.app", name))).Start() exec.Command("open", filepath.Join(depPath, fmt.Sprintf("%v.app", name))).Start()