compiler: build separation runtime with clite

This commit is contained in:
Li Jie
2025-01-07 22:16:31 +08:00
parent 1172e5bdce
commit 6170973b48
316 changed files with 71331 additions and 178 deletions

View File

@@ -7,9 +7,19 @@ import (
)
const (
LLGoCompilerPkg = "github.com/goplus/llgo"
LLGoCompilerPkg = "github.com/goplus/llgo"
LLGoRuntimePkgName = "runtime"
LLGoRuntimePkg = LLGoCompilerPkg + "/" + LLGoRuntimePkgName
)
func LLGoRuntimeDir() string {
root := LLGoROOT()
if root != "" {
return filepath.Join(root, LLGoRuntimePkgName)
}
return ""
}
func LLGoROOT() string {
if root, ok := isLLGoRoot(os.Getenv("LLGO_ROOT")); ok {
return root
@@ -46,12 +56,12 @@ func isLLGoRoot(root string) (string, bool) {
return "", false
}
// Check for go.mod
data, err := os.ReadFile(filepath.Join(root, "go.mod"))
data, err := os.ReadFile(filepath.Join(root, LLGoRuntimePkgName, "go.mod"))
if err != nil {
return "", false
}
// Check module name
if !strings.Contains(string(data), "module "+LLGoCompilerPkg+"\n") {
if !strings.Contains(string(data), "module "+LLGoRuntimePkg+"\n") {
return "", false
}
return root, true