mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 04:22:22 +00:00
35 lines
752 B
Go
35 lines
752 B
Go
// Copyright © 2017 ChaiShushan <chaishushan{AT}gmail.com>.
|
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
|
|
// +build ignore
|
|
// +build darwin
|
|
|
|
// fix python3-config for cgo build
|
|
|
|
package main
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
|
|
func main() {
|
|
for _, s := range os.Args {
|
|
if s == "--cflags" {
|
|
out, _ := exec.Command("python3-config", "--cflags").CombinedOutput()
|
|
out = bytes.Replace(out, []byte("-arch"), []byte{}, -1)
|
|
out = bytes.Replace(out, []byte("i386"), []byte{}, -1)
|
|
out = bytes.Replace(out, []byte("x86_64"), []byte{}, -1)
|
|
fmt.Print(string(out))
|
|
return
|
|
}
|
|
if s == "--libs" {
|
|
out, _ := exec.Command("python3-config", "--ldflags").CombinedOutput()
|
|
fmt.Print(string(out))
|
|
return
|
|
}
|
|
}
|
|
}
|