forked from joejulian/gio-cmd
gogio: support explicit version codes through a fourth version field
As suggested in review, explicitly specifying the version code with -version major.minor.patch.versioncode provides more flexibility than the a version code implied from the major, minor, patch fields. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -450,7 +450,7 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo, extraJars, pe
|
|||||||
`<?xml version="1.0" encoding="utf-8"?>
|
`<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="{{.AppID}}"
|
package="{{.AppID}}"
|
||||||
android:versionCode="{{.Version.Version32}}"
|
android:versionCode="{{.Version.VersionCode}}"
|
||||||
android:versionName="{{.Version}}">
|
android:versionName="{{.Version}}">
|
||||||
<uses-sdk android:minSdkVersion="{{.MinSDK}}" android:targetSdkVersion="{{.TargetSDK}}" />
|
<uses-sdk android:minSdkVersion="{{.MinSDK}}" android:targetSdkVersion="{{.TargetSDK}}" />
|
||||||
{{range .Permissions}} <uses-permission android:name="{{.}}"/>
|
{{range .Permissions}} <uses-permission android:name="{{.}}"/>
|
||||||
|
|||||||
+4
-11
@@ -33,8 +33,8 @@ type buildInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Semver struct {
|
type Semver struct {
|
||||||
Major uint16
|
Major, Minor, Patch int
|
||||||
Minor, Patch uint8
|
VersionCode uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func newBuildInfo(pkgPath string) (*buildInfo, error) {
|
func newBuildInfo(pkgPath string) (*buildInfo, error) {
|
||||||
@@ -83,19 +83,12 @@ func UppercaseName(name string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s Semver) String() string {
|
func (s Semver) String() string {
|
||||||
return fmt.Sprintf("%d.%d.%d", s.Major, s.Minor, s.Patch)
|
return fmt.Sprintf("%d.%d.%d.%d", s.Major, s.Minor, s.Patch, s.VersionCode)
|
||||||
}
|
|
||||||
|
|
||||||
// Version32 returns a 32-bit integer version packed as such:
|
|
||||||
//
|
|
||||||
// major<<16 | minor<<8 | patch
|
|
||||||
func (s Semver) Version32() uint32 {
|
|
||||||
return uint32(s.Major)<<16 | uint32(s.Minor)<<8 | uint32(s.Patch)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseSemver(v string) (Semver, error) {
|
func parseSemver(v string) (Semver, error) {
|
||||||
var sv Semver
|
var sv Semver
|
||||||
_, err := fmt.Sscanf(v, "%d.%d.%d", &sv.Major, &sv.Minor, &sv.Patch)
|
_, err := fmt.Sscanf(v, "%d.%d.%d.%d", &sv.Major, &sv.Minor, &sv.Patch, &sv.VersionCode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Semver{}, fmt.Errorf("invalid semver: %q", v)
|
return Semver{}, fmt.Errorf("invalid semver: %q", v)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -377,7 +377,7 @@ func buildInfoPlist(bi *buildInfo) string {
|
|||||||
<key>DTXcodeBuild</key>
|
<key>DTXcodeBuild</key>
|
||||||
<string>10G8</string>
|
<string>10G8</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>`, appName, bi.appID, appName, bi.version, bi.version.Version32(), platform, minIOSVersion, supportPlatform, platform)
|
</plist>`, appName, bi.appID, appName, bi.version, bi.version.VersionCode, platform, minIOSVersion, supportPlatform, platform)
|
||||||
}
|
}
|
||||||
|
|
||||||
func iosPlatformFor(target string) string {
|
func iosPlatformFor(target string) string {
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ var (
|
|||||||
destPath = flag.String("o", "", "output file or directory.\nFor -target ios or tvos, use the .app suffix to target simulators.")
|
destPath = flag.String("o", "", "output file or directory.\nFor -target ios or tvos, use the .app suffix to target simulators.")
|
||||||
appID = flag.String("appid", "", "app identifier (for -buildmode=exe)")
|
appID = flag.String("appid", "", "app identifier (for -buildmode=exe)")
|
||||||
name = flag.String("name", "", "app name (for -buildmode=exe)")
|
name = flag.String("name", "", "app name (for -buildmode=exe)")
|
||||||
version = flag.String("version", "1.0.0", "semver app version (for -buildmode=exe) on the form major.minor.patch")
|
version = flag.String("version", "1.0.0.1", "semver app version (for -buildmode=exe) on the form major.minor.patch.versioncode")
|
||||||
printCommands = flag.Bool("x", false, "print the commands")
|
printCommands = flag.Bool("x", false, "print the commands")
|
||||||
keepWorkdir = flag.Bool("work", false, "print the name of the temporary work directory and do not delete it when exiting.")
|
keepWorkdir = flag.Bool("work", false, "print the name of the temporary work directory and do not delete it when exiting.")
|
||||||
linkMode = flag.String("linkmode", "", "set the -linkmode flag of the go tool")
|
linkMode = flag.String("linkmode", "", "set the -linkmode flag of the go tool")
|
||||||
|
|||||||
Reference in New Issue
Block a user