mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
cmd/ebitenmobile: Bug fix: Give environment variables to search the package name (gobind)
This commit is contained in:
parent
75c9f34374
commit
b4969cccd7
@ -51,27 +51,51 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func run() error {
|
func invokeOriginalGobind(lang string) (pkgName string, err error) {
|
||||||
cmd := exec.Command("gobind-original", os.Args[1:]...)
|
cmd := exec.Command("gobind-original", os.Args[1:]...)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
return err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgs, err := packages.Load(nil, flag.Args()[0])
|
cfgtags := strings.Join(strings.Split(*tags, ","), " ")
|
||||||
|
cfg := &packages.Config{}
|
||||||
|
switch lang {
|
||||||
|
case "java":
|
||||||
|
cfg.Env = append(os.Environ(), "GOOS=android")
|
||||||
|
case "objc":
|
||||||
|
cfg.Env = append(os.Environ(), "GOOS=darwin")
|
||||||
|
if cfgtags != "" {
|
||||||
|
cfgtags += " "
|
||||||
|
}
|
||||||
|
cfgtags += "ios"
|
||||||
|
}
|
||||||
|
cfg.BuildFlags = []string{"-tags", cfgtags}
|
||||||
|
pkgs, err := packages.Load(cfg, flag.Args()[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return "", err
|
||||||
|
}
|
||||||
|
return pkgs[0].Name, nil
|
||||||
}
|
}
|
||||||
prefixLower := *prefix + pkgs[0].Name
|
|
||||||
prefixUpper := strings.Title(*prefix) + strings.Title(pkgs[0].Name)
|
|
||||||
|
|
||||||
|
func run() error {
|
||||||
writeFile := func(filename string, content string) error {
|
writeFile := func(filename string, content string) error {
|
||||||
if err := ioutil.WriteFile(filepath.Join(*outdir, filename), []byte(content), 0644); err != nil {
|
if err := ioutil.WriteFile(filepath.Join(*outdir, filename), []byte(content), 0644); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add additional files.
|
||||||
|
langs := strings.Split(*lang, ",")
|
||||||
|
for _, lang := range langs {
|
||||||
|
pkgName, err := invokeOriginalGobind(lang)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
prefixLower := *prefix + pkgName
|
||||||
|
prefixUpper := strings.Title(*prefix) + strings.Title(pkgName)
|
||||||
replacePrefixes := func(content string) string {
|
replacePrefixes := func(content string) string {
|
||||||
content = strings.ReplaceAll(content, "{{.PrefixUpper}}", prefixUpper)
|
content = strings.ReplaceAll(content, "{{.PrefixUpper}}", prefixUpper)
|
||||||
content = strings.ReplaceAll(content, "{{.PrefixLower}}", prefixLower)
|
content = strings.ReplaceAll(content, "{{.PrefixLower}}", prefixLower)
|
||||||
@ -79,9 +103,6 @@ func run() error {
|
|||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add additional files.
|
|
||||||
langs := strings.Split(*lang, ",")
|
|
||||||
for _, lang := range langs {
|
|
||||||
switch lang {
|
switch lang {
|
||||||
case "objc":
|
case "objc":
|
||||||
// iOS
|
// iOS
|
||||||
|
File diff suppressed because one or more lines are too long
@ -144,7 +144,6 @@ func doBind(args []string, flagset *flag.FlagSet) error {
|
|||||||
tags += "ios"
|
tags += "ios"
|
||||||
}
|
}
|
||||||
cfg.BuildFlags = []string{"-tags", tags}
|
cfg.BuildFlags = []string{"-tags", tags}
|
||||||
cfg.Mode |= packages.NeedName
|
|
||||||
|
|
||||||
pkgs, err := packages.Load(cfg, flagset.Args()[0])
|
pkgs, err := packages.Load(cfg, flagset.Args()[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user