cmptest: regexdemo (todo)

This commit is contained in:
xushiwei
2024-07-29 11:44:49 +08:00
parent cbd891785e
commit e0e3664fdb
5 changed files with 12 additions and 4 deletions

View File

@@ -0,0 +1,11 @@
package main
import (
"fmt"
"github.com/goplus/llgo/xtool/env"
)
func main() {
fmt.Println(env.ExpandEnv("$(pkg-config --libs bdw-gc)"))
}

View File

@@ -21,7 +21,7 @@ import (
"runtime" "runtime"
"github.com/goplus/llgo/cmd/internal/base" "github.com/goplus/llgo/cmd/internal/base"
"github.com/goplus/llgo/xtool/env" "github.com/goplus/llgo/x/env"
) )
// llgo version // llgo version

3
xtool/env/env.go vendored
View File

@@ -36,11 +36,8 @@ func ExpandEnv(s string) string {
func expandEnvWithCmd(s string) string { func expandEnvWithCmd(s string) string {
expanded := reSubcmd.ReplaceAllStringFunc(s, func(m string) string { expanded := reSubcmd.ReplaceAllStringFunc(s, func(m string) string {
subcmd := strings.TrimSpace(m[2 : len(m)-1]) subcmd := strings.TrimSpace(m[2 : len(m)-1])
args := parseSubcmd(subcmd) args := parseSubcmd(subcmd)
cmd := args[0] cmd := args[0]
if cmd != "pkg-config" && cmd != "llvm-config" { if cmd != "pkg-config" && cmd != "llvm-config" {
fmt.Fprintf(os.Stderr, "expand cmd only support pkg-config and llvm-config: '%s'\n", subcmd) fmt.Fprintf(os.Stderr, "expand cmd only support pkg-config and llvm-config: '%s'\n", subcmd)
return "" return ""