@@ -309,28 +309,27 @@ func getDelve(ctx context.Context, platform v1.Platform) (string, error) {
309
309
cloneDir := filepath .Join (tmpInstallDir , "delve" )
310
310
err = os .MkdirAll (cloneDir , 0755 )
311
311
if err != nil {
312
- return "" , fmt .Errorf ("making dir for delve clone: %v " , err )
312
+ return "" , fmt .Errorf ("making dir for delve clone: %w " , err )
313
313
}
314
314
err = git .Clone (ctx , cloneDir , delveCloneURL )
315
315
if err != nil {
316
- return "" , fmt .Errorf ("cloning delve repo: %v " , err )
316
+ return "" , fmt .Errorf ("cloning delve repo: %w " , err )
317
317
}
318
318
osArchDir := fmt .Sprintf ("%s_%s" , platform .OS , platform .Architecture )
319
319
delveBinaryPath := filepath .Join (tmpInstallDir , "bin" , osArchDir , "dlv" )
320
320
321
321
// install delve to tmp directory
322
322
args := []string {
323
323
"build" ,
324
- "-C" ,
325
- cloneDir ,
326
- "./cmd/dlv" ,
327
324
"-o" ,
328
325
delveBinaryPath ,
326
+ "./cmd/dlv" ,
329
327
}
330
328
331
329
gobin := getGoBinary ()
332
330
cmd := exec .CommandContext (ctx , gobin , args ... )
333
331
cmd .Env = env
332
+ cmd .Dir = cloneDir
334
333
335
334
var output bytes.Buffer
336
335
cmd .Stderr = & output
@@ -924,6 +923,10 @@ func (g *gobuild) configForImportPath(ip string) Config {
924
923
return config
925
924
}
926
925
926
+ func (g gobuild ) useDebugging (platform v1.Platform ) bool {
927
+ return g .debug && doesPlatformSupportDebugging (platform )
928
+ }
929
+
927
930
func (g * gobuild ) buildOne (ctx context.Context , refStr string , base v1.Image , platform * v1.Platform ) (oci.SignedImage , error ) {
928
931
if err := g .semaphore .Acquire (ctx , 1 ); err != nil {
929
932
return nil , err
@@ -965,7 +968,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
965
968
}
966
969
}
967
970
if g .debug && ! doesPlatformSupportDebugging (* platform ) {
968
- return nil , fmt . Errorf ( " debugging is not supported for %s " , platform )
971
+ log . Printf ( "image for platform %q will be built without debugging enabled because debugging is not supported for that platform " , * platform )
969
972
}
970
973
971
974
if ! g .platformMatcher .matches (platform ) {
@@ -1078,7 +1081,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
1078
1081
})
1079
1082
1080
1083
delvePath := "" // path for delve in image
1081
- if g .debug {
1084
+ if g .useDebugging ( * platform ) {
1082
1085
// get delve locally
1083
1086
delveBinary , err := getDelve (ctx , * platform )
1084
1087
if err != nil {
@@ -1144,7 +1147,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
1144
1147
updatePath (cfg , `C:\ko-app` )
1145
1148
cfg .Config .Env = append (cfg .Config .Env , `KO_DATA_PATH=C:\var\run\ko` )
1146
1149
} else {
1147
- if g .debug {
1150
+ if g .useDebugging ( * platform ) {
1148
1151
cfg .Config .Entrypoint = append ([]string {delvePath }, delveArgs ... )
1149
1152
cfg .Config .Entrypoint = append (cfg .Config .Entrypoint , appPath )
1150
1153
}
0 commit comments