OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "container/heap" | 9 "container/heap" |
10 "errors" | 10 "errors" |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 if p.pkgdir != "" { // overrides p.t | 340 if p.pkgdir != "" { // overrides p.t |
341 a.pkgdir = p.pkgdir | 341 a.pkgdir = p.pkgdir |
342 } | 342 } |
343 | 343 |
344 b.actionCache[key] = a | 344 b.actionCache[key] = a |
345 | 345 |
346 for _, p1 := range p.imports { | 346 for _, p1 := range p.imports { |
347 a.deps = append(a.deps, b.action(depMode, depMode, p1)) | 347 a.deps = append(a.deps, b.action(depMode, depMode, p1)) |
348 } | 348 } |
349 | 349 |
350 » if len(p.CgoFiles) > 0 { | 350 » // If we are not doing a cross-build, then record the binary we'll |
351 » » var stk importStack | 351 » // generate for cgo as a dependency of the build of any package |
352 » » p1 := loadPackage("cmd/cgo", &stk) | 352 » // using cgo, to make sure we do not overwrite the binary while |
353 » » if p1.Error != nil { | 353 » // a package is using it. If this is a cross-build, then the cgo we |
354 » » » fatalf("load cmd/cgo: %v", p1.Error) | 354 » // are writing is not the cgo we need to use. |
| 355 » if b.goos == runtime.GOOS && b.goarch == runtime.GOARCH { |
| 356 » » if len(p.CgoFiles) > 0 || p.Standard && p.ImportPath == "runtime
/cgo" { |
| 357 » » » var stk importStack |
| 358 » » » p1 := loadPackage("cmd/cgo", &stk) |
| 359 » » » if p1.Error != nil { |
| 360 » » » » fatalf("load cmd/cgo: %v", p1.Error) |
| 361 » » » } |
| 362 » » » a.cgo = b.action(depMode, depMode, p1) |
| 363 » » » a.deps = append(a.deps, a.cgo) |
355 } | 364 } |
356 a.cgo = b.action(depMode, depMode, p1) | |
357 a.deps = append(a.deps, a.cgo) | |
358 } | 365 } |
359 | 366 |
360 if p.Standard { | 367 if p.Standard { |
361 switch p.ImportPath { | 368 switch p.ImportPath { |
362 case "builtin", "unsafe": | 369 case "builtin", "unsafe": |
363 // Fake packages - nothing to build. | 370 // Fake packages - nothing to build. |
364 return a | 371 return a |
365 } | 372 } |
366 // gccgo standard library is "fake" too. | 373 // gccgo standard library is "fake" too. |
367 if _, ok := buildToolchain.(gccgoToolchain); ok { | 374 if _, ok := buildToolchain.(gccgoToolchain); ok { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 return nongcc, gcc | 567 return nongcc, gcc |
561 } | 568 } |
562 cfiles, gccfiles = filter(cfiles, cfiles[:0], gccfiles) | 569 cfiles, gccfiles = filter(cfiles, cfiles[:0], gccfiles) |
563 sfiles, gccfiles = filter(sfiles, sfiles[:0], gccfiles) | 570 sfiles, gccfiles = filter(sfiles, sfiles[:0], gccfiles) |
564 } else { | 571 } else { |
565 gccfiles = append(cfiles, sfiles...) | 572 gccfiles = append(cfiles, sfiles...) |
566 cfiles = nil | 573 cfiles = nil |
567 sfiles = nil | 574 sfiles = nil |
568 } | 575 } |
569 | 576 |
570 » » outGo, outObj, err := b.cgo(a.p, a.cgo.target, obj, gccfiles) | 577 » » cgoExe := tool("cgo") |
| 578 » » if a.cgo != nil { |
| 579 » » » cgoExe = a.cgo.target |
| 580 » » } |
| 581 » » outGo, outObj, err := b.cgo(a.p, cgoExe, obj, gccfiles) |
571 if err != nil { | 582 if err != nil { |
572 return err | 583 return err |
573 } | 584 } |
574 cgoObjects = append(cgoObjects, outObj...) | 585 cgoObjects = append(cgoObjects, outObj...) |
575 gofiles = append(gofiles, outGo...) | 586 gofiles = append(gofiles, outGo...) |
576 } | 587 } |
577 | 588 |
578 // Prepare Go import path list. | 589 // Prepare Go import path list. |
579 inc := b.includeArgs("-I", a.deps) | 590 inc := b.includeArgs("-I", a.deps) |
580 | 591 |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 return x | 1273 return x |
1263 } | 1274 } |
1264 | 1275 |
1265 func (q *actionQueue) push(a *action) { | 1276 func (q *actionQueue) push(a *action) { |
1266 heap.Push(q, a) | 1277 heap.Push(q, a) |
1267 } | 1278 } |
1268 | 1279 |
1269 func (q *actionQueue) pop() *action { | 1280 func (q *actionQueue) pop() *action { |
1270 return heap.Pop(q).(*action) | 1281 return heap.Pop(q).(*action) |
1271 } | 1282 } |
OLD | NEW |