Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion bind/genjava.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"strings"

"golang.org/x/mobile/internal/importers/java"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

// TODO(crawshaw): disallow basic android java type names in exported symbols.
Expand Down Expand Up @@ -1038,7 +1040,7 @@ func JavaClassName(pkg *types.Package) string {
if pkg == nil {
return "Universe"
}
return javaNameReplacer(strings.Title(pkg.Name()))
return javaNameReplacer(cases.Title(language.English).String(pkg.Name()))
}

func (g *JavaGen) genConst(o *types.Const) {
Expand Down
4 changes: 3 additions & 1 deletion bind/genobjc.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"strings"

"golang.org/x/mobile/internal/importers/objc"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

// TODO(hyangah): handle method name conflicts.
Expand Down Expand Up @@ -101,7 +103,7 @@ func (g *ObjcGen) namePrefixOf(pkg *types.Package) string {
return "Universe"
}
p := g.Prefix
return p + strings.Title(pkg.Name())
return p + cases.Title(language.English).String(pkg.Name())
}

func (g *ObjcGen) GenGoH() error {
Expand Down
6 changes: 4 additions & 2 deletions cmd/gobind/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
"golang.org/x/mobile/internal/importers"
"golang.org/x/mobile/internal/importers/java"
"golang.org/x/mobile/internal/importers/objc"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"golang.org/x/tools/go/packages"
)

Expand Down Expand Up @@ -142,12 +144,12 @@ func genPkg(lang string, p *types.Package, astFiles []*ast.File, allPkg []*types
processErr(g.GenGoH())
io.Copy(w, &buf)
closer()
hname := strings.Title(fname[:len(fname)-2]) + ".objc.h"
hname := cases.Title(language.English).String(fname[:len(fname)-2]) + ".objc.h"
w, closer = writer(filepath.Join("src", "gobind", hname))
processErr(g.GenH())
io.Copy(w, &buf)
closer()
mname := strings.Title(fname[:len(fname)-2]) + "_darwin.m"
mname := cases.Title(language.English).String(fname[:len(fname)-2]) + "_darwin.m"
w, closer = writer(filepath.Join("src", "gobind", mname))
conf.Writer = w
processErr(g.GenM())
Expand Down
8 changes: 5 additions & 3 deletions cmd/gomobile/bind_iosapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"time"

"golang.org/x/sync/errgroup"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"golang.org/x/tools/go/packages"
)

Expand All @@ -27,15 +29,15 @@ func goAppleBind(gobind string, pkgs []*packages.Package, targets []targetInfo)

if buildO == "" {
name = pkgs[0].Name
title = strings.Title(name)
title = cases.Title(language.English).String(name)
buildO = title + ".xcframework"
} else {
if !strings.HasSuffix(buildO, ".xcframework") {
return fmt.Errorf("static framework name %q missing .xcframework suffix", buildO)
}
base := filepath.Base(buildO)
name = base[:len(base)-len(".xcframework")]
title = strings.Title(name)
title = cases.Title(language.English).String(name)
}

if err := removeAll(buildO); err != nil {
Expand Down Expand Up @@ -185,7 +187,7 @@ func goAppleBind(gobind string, pkgs []*packages.Package, targets []targetInfo)

fileBases := make([]string, len(pkgs)+1)
for i, pkg := range pkgs {
fileBases[i] = bindPrefix + strings.Title(pkg.Name)
fileBases[i] = bindPrefix + cases.Title(language.English).String(pkg.Name)
}
fileBases[len(fileBases)-1] = "Universe"

Expand Down
4 changes: 3 additions & 1 deletion cmd/gomobile/build_androidapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"strings"

"golang.org/x/mobile/internal/binres"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"golang.org/x/tools/go/packages"
)

Expand Down Expand Up @@ -47,7 +49,7 @@ func goAndroidBuild(pkg *packages.Package, targets []targetInfo) (map[string]boo
err := manifestTmpl.Execute(buf, manifestTmplData{
// TODO(crawshaw): a better package path.
JavaPkgPath: "org.golang.todo." + libName,
Name: strings.Title(appName),
Name: cases.Title(language.English).String(appName),
LibName: libName,
})
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion cmd/gomobile/build_apple.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import (
"strings"
"text/template"

"golang.org/x/text/cases"
"golang.org/x/text/language"
"golang.org/x/tools/go/packages"
)

Expand All @@ -33,7 +35,7 @@ func goAppleBuild(pkg *packages.Package, bundleID string, targets []targetInfo)
infoplist := new(bytes.Buffer)
if err := infoplistTmpl.Execute(infoplist, infoplistTmplData{
BundleID: bundleID + "." + productName,
Name: strings.Title(path.Base(pkg.PkgPath)),
Name: cases.Title(language.English).String(path.Base(pkg.PkgPath)),
}); err != nil {
return nil, err
}
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ require (
golang.org/x/tools v0.33.0
)

require golang.org/x/sys v0.33.0 // indirect
require (
golang.org/x/sys v0.33.0 // indirect
golang.org/x/text v0.25.0 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ golang.org/x/sync v0.14.0 h1:woo0S4Yywslg6hp4eUFjTVOyKt0RookbpAHG4c1HmhQ=
golang.org/x/sync v0.14.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
golang.org/x/tools v0.33.0 h1:4qz2S3zmRxbGIhDIAgjxvFutSvH5EfnsYrRBj0UI0bc=
golang.org/x/tools v0.33.0/go.mod h1:CIJMaWEY88juyUfo7UbgPqbC8rU2OqfAV1h2Qp0oMYI=