-
Notifications
You must be signed in to change notification settings - Fork 12
tool: cfg.Files; tool test: TestCpp_LLVMSystem #878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,9 @@ import ( | |
| "go/token" | ||
| "log" | ||
| "os" | ||
| "path" | ||
| "path/filepath" | ||
| "sort" | ||
| "strings" | ||
|
|
||
| "github.com/goplus/gogen" | ||
|
|
@@ -69,7 +71,7 @@ const includeSuffix = string(os.PathSeparator) + "include" | |
|
|
||
| // NewPackage loads the source files and converts them into a Go package according to the | ||
| // configuration. | ||
| func (cfg *Config) NewPackage(pkgPath, workDir string, index clang.Index) (ret cl.Package, lang cl.Language, err error) { | ||
| func (cfg *Config) NewPackage(pkgPath, pkgName, workDir string, index clang.Index) (ret cl.Package, lang cl.Language, err error) { | ||
|
xushiwei marked this conversation as resolved.
|
||
| lang, ok := cfg.Lang() | ||
| if !ok { | ||
| err = fmt.Errorf("invalid language: %q", cfg.Language) | ||
|
|
@@ -138,9 +140,15 @@ func (cfg *Config) NewPackage(pkgPath, workDir string, index clang.Index) (ret c | |
| log.Println("==> includeDirs:", incDirs) | ||
| } | ||
|
|
||
| topHeaders, err := pputil.TopHeaders(dir, recursive, false, incDirs) | ||
| if err != nil { | ||
| return | ||
| var topHeaders []string | ||
| var selFiles = cfg.Files | ||
| if len(selFiles) > 0 { | ||
| topHeaders = listHeaderFiles(selFiles, dir) | ||
| } else { | ||
| topHeaders, err = pputil.TopHeaders(dir, recursive, false, incDirs) | ||
| if err != nil { | ||
| return | ||
| } | ||
| } | ||
|
|
||
| files, err := ParseSources(index, topHeaders, incDirs, cfg.Language) | ||
|
|
@@ -150,7 +158,10 @@ func (cfg *Config) NewPackage(pkgPath, workDir string, index clang.Index) (ret c | |
| defer DisposeSources(files) | ||
|
|
||
| srcFilePrefix := dir + string(os.PathSeparator) | ||
| ret, err = cl.NewPackage(pkgPath, cfg.Name, files, &cl.Config{ | ||
| if pkgName == "" { | ||
| pkgName = path.Base(cfg.Name) | ||
| } | ||
| ret, err = cl.NewPackage(pkgPath, pkgName, files, &cl.Config{ | ||
| Fset: fset, | ||
| Importer: imp, | ||
| LLGoPackage: cfg.LLGoPackage, | ||
|
|
@@ -186,6 +197,16 @@ func (cfg *Config) NewPackage(pkgPath, workDir string, index clang.Index) (ret c | |
| return | ||
| } | ||
|
|
||
| func listHeaderFiles(selFiles []string, headerDir string) (topHeaders []string) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| headerDir += string(os.PathSeparator) | ||
| topHeaders = make([]string, len(selFiles)) | ||
| for i, selFile := range selFiles { | ||
| topHeaders[i] = filepath.Join(headerDir, selFile) | ||
| } | ||
| sort.Strings(topHeaders) | ||
| return | ||
| } | ||
|
|
||
| func goFileOf(at, srcFilePrefix string) (fname string, ok bool) { | ||
| const pathSep = string(os.PathSeparator) | ||
| const goFileExt = ".go" | ||
|
|
@@ -324,7 +345,7 @@ func Gen(destDir, srcDir string, index clang.Index) (err error) { | |
| return | ||
| } | ||
|
|
||
| pkg, _, err := cfg.NewPackage("", srcDir, index) | ||
| pkg, _, err := cfg.NewPackage("", "", srcDir, index) | ||
| if err != nil { | ||
| return | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.