Files
llgo/internal/crosscompile/libc.go

43 lines
1.2 KiB
Go
Raw Normal View History

2025-08-25 19:05:30 +08:00
package crosscompile
import (
"fmt"
"path/filepath"
2025-08-28 20:11:13 +08:00
2025-08-29 11:30:25 +08:00
"github.com/goplus/llgo/internal/crosscompile/compile"
"github.com/goplus/llgo/internal/crosscompile/compile/libc"
"github.com/goplus/llgo/internal/crosscompile/compile/rtlib"
2025-08-25 19:05:30 +08:00
)
2025-08-29 11:30:25 +08:00
// GetCompileConfigByName retrieves libc compilation configuration by name
2025-08-25 19:05:30 +08:00
// Returns compilation file lists and corresponding cflags
2025-09-01 14:48:54 +08:00
func getLibcCompileConfigByName(baseDir, libcName, target, mcpu string) (*compile.CompileConfig, error) {
2025-08-25 19:05:30 +08:00
if libcName == "" {
return nil, fmt.Errorf("libc name cannot be empty")
}
libcDir := filepath.Join(baseDir, libcName)
switch libcName {
case "picolibc":
2025-08-29 19:25:09 +08:00
return libc.GetPicolibcConfig(libcDir, target), nil
2025-08-28 20:11:13 +08:00
case "newlib-esp32":
2025-09-01 14:48:54 +08:00
return libc.GetNewlibESP32Config(libcDir, target, mcpu), nil
2025-08-25 19:05:30 +08:00
default:
return nil, fmt.Errorf("unsupported libc: %s", libcName)
}
}
2025-08-29 11:30:25 +08:00
2025-08-29 19:25:09 +08:00
func getRTCompileConfigByName(baseDir, rtName, target string) (*compile.CompileConfig, error) {
2025-08-29 11:30:25 +08:00
if rtName == "" {
return nil, fmt.Errorf("rt name cannot be empty")
}
rtDir := filepath.Join(baseDir, rtName)
switch rtName {
case "compiler-rt":
2025-08-29 19:25:09 +08:00
return rtlib.GetCompilerRTConfig(rtDir, target), nil
2025-08-29 11:30:25 +08:00
default:
return nil, fmt.Errorf("unsupported rt: %s", rtName)
}
}