forked from joejulian/gio-cmd
gogio: load Android assets from module root
This commit is contained in:
+18
-3
@@ -424,7 +424,8 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo, extraJars, pe
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := copyTree(filepath.Join(bi.pkgDir, "android", "res"), resDir); err != nil {
|
||||
moduleRoot := moduleRootForDir(bi.pkgDir)
|
||||
if err := copyTree(filepath.Join(moduleRoot, "android", "res"), resDir); err != nil {
|
||||
return err
|
||||
}
|
||||
resZip := filepath.Join(tmpDir, "resources.zip")
|
||||
@@ -452,8 +453,8 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo, extraJars, pe
|
||||
AppName: appName,
|
||||
Schemes: bi.schemes,
|
||||
PackageQueries: bi.packageQueries,
|
||||
ManifestSnip: readOptionalText(filepath.Join(bi.pkgDir, "android", "manifest_snippets.xml")),
|
||||
AppSnip: readOptionalText(filepath.Join(bi.pkgDir, "android", "application_snippets.xml")),
|
||||
ManifestSnip: readOptionalText(filepath.Join(moduleRoot, "android", "manifest_snippets.xml")),
|
||||
AppSnip: readOptionalText(filepath.Join(moduleRoot, "android", "application_snippets.xml")),
|
||||
}
|
||||
manifestBuffer, err := renderAndroidManifest(manifestSrc)
|
||||
if err != nil {
|
||||
@@ -839,6 +840,20 @@ func androidExtraJars(dir string) ([]string, error) {
|
||||
return jars, nil
|
||||
}
|
||||
|
||||
func moduleRootForDir(dir string) string {
|
||||
current := dir
|
||||
for {
|
||||
if _, err := os.Stat(filepath.Join(current, "go.mod")); err == nil {
|
||||
return current
|
||||
}
|
||||
parent := filepath.Dir(current)
|
||||
if parent == current {
|
||||
return dir
|
||||
}
|
||||
current = parent
|
||||
}
|
||||
}
|
||||
|
||||
func findNDK(androidHome string) (string, error) {
|
||||
ndks, err := filepath.Glob(filepath.Join(androidHome, "ndk", "*"))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user