summaryrefslogtreecommitdiffstats
path: root/vendor/modernc.org/ccgo/v3/lib/ccgo.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2022-03-12 23:02:04 +0100
committerWim <wim@42.be>2022-03-20 14:57:48 +0100
commitaefa70891cfd489fccb8a9567b5bdafb0f863ede (patch)
tree90fe7c91d7b33b2a1ed08ea3a94840860adc6fc1 /vendor/modernc.org/ccgo/v3/lib/ccgo.go
parent1b9877fda45be021ea6a5677c78648cecc19dcd5 (diff)
downloadmatterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.tar.gz
matterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.tar.bz2
matterbridge-msglm-aefa70891cfd489fccb8a9567b5bdafb0f863ede.zip
Update vendor (whatsapp)
Diffstat (limited to 'vendor/modernc.org/ccgo/v3/lib/ccgo.go')
-rw-r--r--vendor/modernc.org/ccgo/v3/lib/ccgo.go97
1 files changed, 90 insertions, 7 deletions
diff --git a/vendor/modernc.org/ccgo/v3/lib/ccgo.go b/vendor/modernc.org/ccgo/v3/lib/ccgo.go
index a5ed804f..38882b7a 100644
--- a/vendor/modernc.org/ccgo/v3/lib/ccgo.go
+++ b/vendor/modernc.org/ccgo/v3/lib/ccgo.go
@@ -904,10 +904,10 @@ func (t *Task) Main() (err error) {
}
abi, err := cc.NewABI(t.goos, t.goarch)
- abi.Types[cc.LongDouble] = abi.Types[cc.Double]
if err != nil {
return err
}
+ abi.Types[cc.LongDouble] = abi.Types[cc.Double]
var re *regexp.Regexp
if t.ignoredIncludes != "" {
@@ -1474,7 +1474,7 @@ func (t *Task) createCompileDB(command []string) (rerr error) {
var parser func(s string) ([]string, error)
out:
switch t.goos {
- case "darwin", "freebsd", "netbsd", "openbsd":
+ case "darwin", "freebsd", "netbsd":
switch command[0] {
case "make", "gmake":
// ok
@@ -1490,6 +1490,22 @@ out:
command = append([]string{sh, "-c"}, join(" ", command[0], "SHELL='sh -x'", command[1:]))
cmd = exec.Command(command[0], command[1:]...)
parser = makeXParser
+ case "openbsd":
+ switch command[0] {
+ case "make", "gmake":
+ // ok
+ default:
+ return fmt.Errorf("usupported build command: %s", command[0])
+ }
+
+ sh, err := exec.LookPath("sh")
+ if err != nil {
+ return err
+ }
+
+ command = append([]string{sh, "-c"}, join(" ", command[0], "SHELL='sh -x'", command[1:]))
+ cmd = exec.Command(command[0], command[1:]...)
+ parser = makeXParser2
case "windows":
if command[0] != "make" {
return fmt.Errorf("usupported build command: %s", command[0])
@@ -1580,7 +1596,7 @@ func isCreateArchive(s string) bool {
b := []byte(s)
sort.Slice(b, func(i, j int) bool { return b[i] < b[j] })
switch string(b) {
- case "cq", "cr", "crs", "cru":
+ case "cq", "cr", "crs", "cru", "r":
return true
}
return false
@@ -1615,7 +1631,48 @@ func makeXParser(s string) (r []string, err error) {
}
s = s[1:]
+ if dmesgs {
+ dmesg("%v: source line `%s`, caller %v:", origin(1), s, origin(2))
+ }
+ r, err = shellquote.Split(s)
+ if dmesgs {
+ dmesg("%v: shellquote.Split -> %v %[2]q, %v", origin(1), r, err)
+ }
+ if err != nil {
+ if strings.Contains(err.Error(), "Unterminated single-quoted string") {
+ return nil, nil // ignore
+ }
+ }
+ if len(r) != 0 && filepath.Base(r[0]) == "libtool" {
+ r[0] = "libtool"
+ }
+ return r, err
+}
+
+func makeXParser2(s string) (r []string, err error) {
+ s = strings.TrimSpace(s)
+ switch {
+ case strings.HasPrefix(s, "libtool: link: ar "):
+ s = s[len("libtool: link:"):]
+ case strings.HasPrefix(s, "libtool: compile: "):
+ s = s[len("libtool: compile:"):]
+ for strings.HasPrefix(s, " ") {
+ s = s[1:]
+ }
+ default:
+ var n int
+ if n, s = hasPlusPrefix(s); n != 0 {
+ return nil, nil
+ }
+ }
+
+ if dmesgs {
+ dmesg("%v: source line `%s`, caller %v:", origin(1), s, origin(2))
+ }
r, err = shellquote.Split(s)
+ if dmesgs {
+ dmesg("%v: shellquote.Split -> %v %[2]q, %v", origin(1), r, err)
+ }
if err != nil {
if strings.Contains(err.Error(), "Unterminated single-quoted string") {
return nil, nil // ignore
@@ -1809,26 +1866,29 @@ func (it *cdbItem) sources(cc, ar string) (r []string) {
}
type cdbMakeWriter struct {
- b bytes.Buffer
- cc string
ar string
arBase string
+ b bytes.Buffer
+ cc string
dir string
err error
it cdbItem
parser func(s string) ([]string, error)
+ prefix string
sc *bufio.Scanner
+ t *Task
w *cdbWriter
}
func (t *Task) newCdbMakeWriter(w *cdbWriter, dir string, parser func(s string) ([]string, error)) *cdbMakeWriter {
const sz = 1 << 16
r := &cdbMakeWriter{
- cc: t.ccLookPath,
ar: t.arLookPath,
arBase: filepath.Base(t.arLookPath),
+ cc: t.ccLookPath,
dir: dir,
parser: parser,
+ t: t,
w: w,
}
r.sc = bufio.NewScanner(&r.b)
@@ -1849,7 +1909,15 @@ func (w *cdbMakeWriter) Write(b []byte) (int, error) {
panic(todo("internal error"))
}
- s := strings.TrimSpace(w.sc.Text())
+ s := w.sc.Text()
+ if strings.HasSuffix(s, "\\") {
+ w.prefix += s[:len(s)-1]
+ continue
+ }
+
+ s = w.prefix + s
+ w.prefix = ""
+ s = strings.TrimSpace(s)
if edx := strings.Index(s, "Entering directory"); edx >= 0 {
s = s[edx+len("Entering directory"):]
s = strings.TrimSpace(s)
@@ -1882,7 +1950,13 @@ func (w *cdbMakeWriter) Write(b []byte) (int, error) {
continue
}
+ if dmesgs {
+ dmesg("%v: source line `%s`", origin(1), s)
+ }
args, err := w.parser(s)
+ if dmesgs {
+ dmesg("%v: parser -> %v %[2]q, %v", origin(1), args, err)
+ }
if err != nil {
w.fail(err)
continue
@@ -1899,16 +1973,25 @@ func (w *cdbMakeWriter) Write(b []byte) (int, error) {
err = nil
switch args[0] {
case w.cc:
+ if w.t.verboseCompiledb {
+ fmt.Printf("source line: %q\n", s)
+ }
fmt.Printf("CCGO CC: %q\n", args)
err = w.handleGCC(args)
case w.ar:
fallthrough
case w.arBase:
if isCreateArchive(args[1]) {
+ if w.t.verboseCompiledb {
+ fmt.Printf("source line: %q\n", s)
+ }
fmt.Printf("CCGO AR: %q\n", args)
err = w.handleAR(args)
}
case "libtool":
+ if w.t.verboseCompiledb {
+ fmt.Printf("source line: %q\n", s)
+ }
fmt.Printf("CCGO LIBTOOL: %q\n", args)
err = w.handleLibtool(args)
}