Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 build | 5 package build |
6 | 6 |
7 import ( | 7 import ( |
8 "bytes" | 8 "bytes" |
9 "errors" | 9 "errors" |
10 "fmt" | 10 "fmt" |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 return false // this one doesn't match | 850 return false // this one doesn't match |
851 } | 851 } |
852 } | 852 } |
853 } | 853 } |
854 } | 854 } |
855 } | 855 } |
856 return true // everything matches | 856 return true // everything matches |
857 } | 857 } |
858 | 858 |
859 // saveCgo saves the information from the #cgo lines in the import "C" comment. | 859 // saveCgo saves the information from the #cgo lines in the import "C" comment. |
860 // These lines set CPP, CFLAGS, CXXFLAGS and LDFLAGS and pkg-config directives | 860 // These lines set CPPCFLAGS, CFLAGS, CXXFLAGS and LDFLAGS and pkg-config direct ives |
iant
2013/05/22 20:56:21
s/CPP/CPPFLAGS/
| |
861 // that affect the way cgo's C code is built. | 861 // that affect the way cgo's C code is built. |
862 // | 862 // |
863 // TODO(rsc): This duplicates code in cgo. | 863 // TODO(rsc): This duplicates code in cgo. |
864 // Once the dust settles, remove this code from cgo. | 864 // Once the dust settles, remove this code from cgo. |
865 func (ctxt *Context) saveCgo(filename string, di *Package, cg *ast.CommentGroup) error { | 865 func (ctxt *Context) saveCgo(filename string, di *Package, cg *ast.CommentGroup) error { |
866 text := cg.Text() | 866 text := cg.Text() |
867 for _, line := range strings.Split(text, "\n") { | 867 for _, line := range strings.Split(text, "\n") { |
868 orig := line | 868 orig := line |
869 | 869 |
870 // Line is | 870 // Line is |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
909 } | 909 } |
910 for _, arg := range args { | 910 for _, arg := range args { |
911 if !safeName(arg) { | 911 if !safeName(arg) { |
912 return fmt.Errorf("%s: malformed #cgo argument: %s", filename, arg) | 912 return fmt.Errorf("%s: malformed #cgo argument: %s", filename, arg) |
913 } | 913 } |
914 } | 914 } |
915 | 915 |
916 switch verb { | 916 switch verb { |
917 case "CFLAGS": | 917 case "CFLAGS": |
918 di.CgoCFLAGS = append(di.CgoCFLAGS, args...) | 918 di.CgoCFLAGS = append(di.CgoCFLAGS, args...) |
919 case "CPPFLAGS": | 919 case "CPPFLAGS": |
iant
2013/05/22 20:56:21
These need to be documented in cmd/cgo/doc.go.
| |
920 di.CgoCPPFLAGS = append(di.CgoCPPFLAGS, args...) | 920 di.CgoCPPFLAGS = append(di.CgoCPPFLAGS, args...) |
921 case "CXXFLAGS": | 921 case "CXXFLAGS": |
922 di.CgoCXXFLAGS = append(di.CgoCXXFLAGS, args...) | 922 di.CgoCXXFLAGS = append(di.CgoCXXFLAGS, args...) |
923 case "LDFLAGS": | 923 case "LDFLAGS": |
924 di.CgoLDFLAGS = append(di.CgoLDFLAGS, args...) | 924 di.CgoLDFLAGS = append(di.CgoLDFLAGS, args...) |
925 case "pkg-config": | 925 case "pkg-config": |
926 di.CgoPkgConfig = append(di.CgoPkgConfig, args...) | 926 di.CgoPkgConfig = append(di.CgoPkgConfig, args...) |
927 default: | 927 default: |
928 return fmt.Errorf("%s: invalid #cgo verb: %s", filename, orig) | 928 return fmt.Errorf("%s: invalid #cgo verb: %s", filename, orig) |
929 } | 929 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1124 switch goarch { | 1124 switch goarch { |
1125 case "386": | 1125 case "386": |
1126 return "8", nil | 1126 return "8", nil |
1127 case "amd64": | 1127 case "amd64": |
1128 return "6", nil | 1128 return "6", nil |
1129 case "arm": | 1129 case "arm": |
1130 return "5", nil | 1130 return "5", nil |
1131 } | 1131 } |
1132 return "", errors.New("unsupported GOARCH " + goarch) | 1132 return "", errors.New("unsupported GOARCH " + goarch) |
1133 } | 1133 } |
LEFT | RIGHT |