@@ -14,7 +14,6 @@ import (
14
14
"io/ioutil"
15
15
"os"
16
16
"path/filepath"
17
- "runtime"
18
17
"strings"
19
18
"unicode"
20
19
"unicode/utf8"
@@ -47,8 +46,6 @@ func genPkg(lang string, p *types.Package, astFiles []*ast.File, allPkg []*types
47
46
Pkg : conf .Pkg ,
48
47
Files : astFiles ,
49
48
}
50
- _ , thisfile , _ , _ := runtime .Caller (0 )
51
- gomobiledir := thisfile [:strings .Index (thisfile , "/mobile/" )+ len ("/mobile/" )]
52
49
switch lang {
53
50
case "java" :
54
51
g := & bind.JavaGen {
@@ -83,13 +80,11 @@ func genPkg(lang string, p *types.Package, astFiles []*ast.File, allPkg []*types
83
80
closer ()
84
81
// Generate support files along with the universe package
85
82
if p == nil {
86
- // dir, err := packageDir("golang.org/x/mobile/bind")
87
- // if err != nil {
88
- // errorf(`"golang.org/x/mobile/bind" is not found; run go get golang.org/x/mobile/bind: %v`, err)
89
- // return
90
- // }
91
- dir := gomobiledir + "/bind"
92
- var err error
83
+ dir , err := packageDir ("golang.org/x/mobile/bind" )
84
+ if err != nil {
85
+ errorf (`"golang.org/x/mobile/bind" is not found; run go get golang.org/x/mobile/bind: %v` , err )
86
+ return
87
+ }
93
88
repo := filepath .Clean (filepath .Join (dir , ".." )) // golang.org/x/mobile directory.
94
89
for _ , javaFile := range []string {"Seq.java" , "NativeUtils.java" } {
95
90
src := filepath .Join (repo , "bind/java/" + javaFile )
@@ -110,12 +105,11 @@ func genPkg(lang string, p *types.Package, astFiles []*ast.File, allPkg []*types
110
105
errorf ("unable to import bind/java: %v" , err )
111
106
return
112
107
}
113
- // javaDir, err := packageDir("golang.org/x/mobile/bind/java")
114
- // if err != nil {
115
- // errorf("unable to import bind/java: %v", err)
116
- // return
117
- // }
118
- javaDir := gomobiledir + "/bind/java"
108
+ javaDir , err := packageDir ("golang.org/x/mobile/bind/java" )
109
+ if err != nil {
110
+ errorf ("unable to import bind/java: %v" , err )
111
+ return
112
+ }
119
113
copyFile (filepath .Join ("src" , "gobind" , "seq_java.c" ), filepath .Join (javaDir , "seq_android.c.support" ))
120
114
copyFile (filepath .Join ("src" , "gobind" , "seq_java.go" ), filepath .Join (javaDir , "seq_android.go.support" ))
121
115
copyFile (filepath .Join ("src" , "gobind" , "seq_java.h" ), filepath .Join (javaDir , "seq_android.h" ))
@@ -133,12 +127,11 @@ func genPkg(lang string, p *types.Package, astFiles []*ast.File, allPkg []*types
133
127
genPkgH (w , "seq" )
134
128
io .Copy (w , & buf )
135
129
closer ()
136
- // dir, err := packageDir("golang.org/x/mobile/bind")
137
- // if err != nil {
138
- // errorf("unable to import bind: %v", err)
139
- // return
140
- // }
141
- dir := gomobiledir + "/bind"
130
+ dir , err := packageDir ("golang.org/x/mobile/bind" )
131
+ if err != nil {
132
+ errorf ("unable to import bind: %v" , err )
133
+ return
134
+ }
142
135
copyFile (filepath .Join ("src" , "gobind" , "seq.go" ), filepath .Join (dir , "seq.go.support" ))
143
136
case "objc" :
144
137
g := & bind.ObjcGen {
@@ -163,12 +156,11 @@ func genPkg(lang string, p *types.Package, astFiles []*ast.File, allPkg []*types
163
156
closer ()
164
157
if p == nil {
165
158
// Copy support files
166
- // dir, err := packageDir("golang.org/x/mobile/bind/objc")
167
- // if err != nil {
168
- // errorf("unable to import bind/objc: %v", err)
169
- // return
170
- // }
171
- dir := gomobiledir + "/bind/objc"
159
+ dir , err := packageDir ("golang.org/x/mobile/bind/objc" )
160
+ if err != nil {
161
+ errorf ("unable to import bind/objc: %v" , err )
162
+ return
163
+ }
172
164
copyFile (filepath .Join ("src" , "gobind" , "seq_darwin.m" ), filepath .Join (dir , "seq_darwin.m.support" ))
173
165
copyFile (filepath .Join ("src" , "gobind" , "seq_darwin.go" ), filepath .Join (dir , "seq_darwin.go.support" ))
174
166
copyFile (filepath .Join ("src" , "gobind" , "ref.h" ), filepath .Join (dir , "ref.h" ))
0 commit comments