-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
101 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"path/filepath" | ||
) | ||
|
||
func buildCompiler(goroot string, output string) error { | ||
args := []string{"build"} | ||
if isDevelopment { | ||
args = append(args, "-gcflags=all=-N -l") | ||
} | ||
args = append(args, "-o", output, "./") | ||
cmd := exec.Command(filepath.Join(goroot, "bin", "go"), args...) | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
env, err := patchEnvWithGoroot(os.Environ(), goroot) | ||
if err != nil { | ||
return err | ||
} | ||
cmd.Env = env | ||
// when building the compiler, we want native | ||
// build, see https://github.com/xhd2015/xgo/issues/231 | ||
cmd.Env = appendNativeBuildEnv(cmd.Env) | ||
cmd.Dir = filepath.Join(goroot, "src", "cmd", "compile") | ||
return cmd.Run() | ||
} | ||
func buildExecTool(dir string, execToolBin string) error { | ||
// build exec tool | ||
cmd := exec.Command(getNakedGo(), "build", "-o", execToolBin, "./exec_tool") | ||
cmd.Dir = dir | ||
cmd.Stdout = os.Stdout | ||
cmd.Stderr = os.Stderr | ||
cmd.Env = appendNativeBuildEnv(os.Environ()) | ||
return cmd.Run() | ||
} | ||
|
||
func appendNativeBuildEnv(env []string) []string { | ||
return append(env, "GOOS=", "GOARCH=") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package xgo_integration | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
// go test ./test/xgo_integration/ -v -run TestCrossBuild | ||
func TestCrossBuild(t *testing.T) { | ||
// xgo test -c ./simple | ||
|
||
// _, err := exec.LookPath("xgo") | ||
// if err != nil { | ||
// t.Skipf("missing: %v", err) | ||
// } | ||
// err = cmd.Env([]string{"GOOS=windows", "GOARCH=amd64"}).Debug().Dir("./testdata/build_simple").Run("xgo", "test", "--log-debug", "-c", "-o", "/dev/null") | ||
// if err != nil { | ||
// t.Fatal(err) | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
fmt.Printf("hello xgo\n") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "testing" | ||
|
||
func TestHelloWorld(t *testing.T) { | ||
t.Logf("hello world") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters