From f3889a8c28fbcaace6b42a94de0553c2d3c9878f Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sun, 24 Jul 2022 15:15:34 +0800 Subject: [PATCH] loadFile: srcFile can be empty --- cl/compile.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cl/compile.go b/cl/compile.go index 5bff202..2d226e8 100644 --- a/cl/compile.go +++ b/cl/compile.go @@ -256,13 +256,9 @@ func loadFile(p *gox.Package, conf *Config, file *ast.Node) (pi *PkgInfo, err er if file.Kind != ast.TranslationUnitDecl { return nil, syscall.EINVAL } - baseDir, err := filepath.Abs(conf.Dir) - if err != nil { - return - } - srcFile, err := filepath.Abs(conf.SrcFile) - if err != nil { - return + srcFile := conf.SrcFile + if srcFile != "" { + srcFile, _ = filepath.Abs(srcFile) } ctx := &blockCtx{ pkg: p, cb: p.CB(), fset: p.Fset, @@ -276,6 +272,7 @@ func loadFile(p *gox.Package, conf *Config, file *ast.Node) (pi *PkgInfo, err er bfm: conf.BuiltinFuncMode, testMain: conf.TestMain, } + baseDir, _ := filepath.Abs(conf.Dir) ctx.initMultiFileCtl(p, baseDir, conf) ctx.initCTypes() ctx.initFile()