Skip to content

Commit

Permalink
add expandCfgByName
Browse files Browse the repository at this point in the history
  • Loading branch information
tsingbx committed Dec 11, 2024
1 parent a5ec323 commit efb61e3
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions cmd/llcppcfg/llcppgcfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ func doExpandCflags(str string, fn func(s string) bool) ([]string, string) {
}
_, ok := contains[path]
if !ok {
relPath, err := filepath.Rel(trimStr, path)
if err == nil {
relPath, errRel := filepath.Rel(trimStr, path)
if errRel == nil {
contains[path] = relPath
} else {
panic(err)
return errRel
}
}
return nil
Expand Down Expand Up @@ -138,6 +138,15 @@ func ExpandCFlagsName(name string) ([]string, string) {
return ExpandCflags(originCFlags)
}

func expandCFlagsAndLibs(name string, cfg *LLCppConfig) {
cfg.Include, cfg.CFlags = ExpandCFlagsName(name)
cfg.Libs = ExpandLibsName(name)
}

func fillCfgInclude(name string, cfg *LLCppConfig) {
cfg.Include, _ = ExpandCFlagsName(name)
}

func NewLLCppConfig(name string, isCpp bool, expand bool) *LLCppConfig {
cfg := &LLCppConfig{
Name: name,
Expand All @@ -147,12 +156,12 @@ func NewLLCppConfig(name string, isCpp bool, expand bool) *LLCppConfig {
cfg.TrimPrefixes = []string{}
cfg.Cplusplus = isCpp
cfg.Include = []string{}
cfg.Include, _ = ExpandCFlagsName(name)
if expand {
cfg.Include, cfg.CFlags = ExpandCFlagsName(name)
cfg.Libs = ExpandLibsName(name)
return cfg
expandCFlagsAndLibs(name, cfg)
} else {
fillCfgInclude(name, cfg)
}
cfg.Include, _ = ExpandCFlagsName(name)
return cfg
}

Expand Down

0 comments on commit efb61e3

Please sign in to comment.