-
Notifications
You must be signed in to change notification settings - Fork 37
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
feat: support llpkg
for building
#1048
base: main
Are you sure you want to change the base?
Conversation
feat: add version mappings querying func.
llpkg
for building
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1048 +/- ##
==========================================
- Coverage 89.07% 86.18% -2.90%
==========================================
Files 27 35 +8
Lines 6959 7454 +495
==========================================
+ Hits 6199 6424 +225
- Misses 720 953 +233
- Partials 40 77 +37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
compiler/internal/build/build.go
Outdated
@@ -302,6 +378,10 @@ func buildAllPkgs(ctx *context, initial []*packages.Package, verbose bool) (pkgs | |||
continue | |||
} | |||
built[pkg.ID] = none{} | |||
|
|||
err := buildLLPkg(ctx, pkg, verbose) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要按 pkg 来查找,而是按 module 检查,参考 allPkgs 函数中可以获取所有使用的 module 。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
老师我没太明白,意思是先从allPkgs获取所有module,然后安装,最后再build吗?
还是说,像allPkgs一样,Visit所有package途中,一个个去安装?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler/internal/build/build.go
Outdated
} | ||
|
||
func getModule(ctx *context, ver module.Version, llpkg installer.Package, verbose bool) error { | ||
cmd := exec.Command("llgo", "get", ver.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
通常情况下,module 已经存在,不需要重新 get 。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler/internal/build/build.go
Outdated
@@ -281,6 +300,49 @@ type context struct { | |||
|
|||
needRt map[*packages.Package]bool | |||
needPyInit map[*packages.Package]bool | |||
|
|||
installer installer.Installer | |||
moduleVersion map[string]*module.Version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
查找的动态库对应的是 mod ,而不是 pkgpath 。可以将 mod 的 path@version 或 module.Version 作为 key,并且 modpath 必须为以github.com/goplus/llpkg
开始。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler/internal/build/build.go
Outdated
@@ -281,6 +300,49 @@ type context struct { | |||
|
|||
needRt map[*packages.Package]bool | |||
needPyInit map[*packages.Package]bool | |||
|
|||
mod map[string]*module.Version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
llpkgMod map[module.Version]none
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
老师,我发现这套根据module来的方案有个问题。
因为Go允许同库不同版本,只需要加个module path后缀就行,例如
github.com/goplus/llpkg/zlib/v2
那么,根据之前根据module设置PC似乎并不对,例如说A库依赖zlib 1.3.1 => v2.0.0, B库依赖zlib 1.2.1 => v1.0.0
那么,如果说某个package先依赖了A,后依赖B,那么zlib 1.3.1的PC总是比zlib 1.2.1优先级要高,因此我还是决定将根据package来设置pc,而llpkg拉取则是在Visit途中完成
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
老师我发现以上依然无法解决问题,不过按照package设置pc还是需要的,因为map循环是乱序的,pc需要顺序
compiler/internal/build/build.go
Outdated
return filepath.Join(dir, "lib", "pkgconfig"), nil | ||
} | ||
|
||
func buildAllLLPkg(ctx *context, verbose bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
函数名称不准确
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in fix: set pc by each package
compiler/internal/build/build.go
Outdated
installer installer.Installer | ||
} | ||
|
||
func getModule(ctx *context, ver module.Version, llpkg installer.Package, verbose bool) (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
函数名称不准确
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in fix: set pc by each package
compiler/internal/build/build.go
Outdated
return "", err | ||
} | ||
|
||
_, err = os.Stat(dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果建立目录完成,但安装未成功,下次则认为已经存在。可以判断是否存在 dir/lib/pkgconfig 。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in fix: some details
compiler/internal/build/build.go
Outdated
@@ -302,6 +347,9 @@ func buildAllPkgs(ctx *context, initial []*packages.Package, verbose bool) (pkgs | |||
continue | |||
} | |||
built[pkg.ID] = none{} | |||
|
|||
setDepsPC(ctx, pkg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
只有以 github.com/goplus/llpkg/ 开始的 pkg 才需要设置 llpkg 的 pc 。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compiler/internal/build/build.go
Outdated
} | ||
} | ||
if len(pcDir) > 0 { | ||
os.Setenv("PKG_CONFIG_PATH", pc.AppendPCPath(strings.Join(pcDir, ":"))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
很难理解 pc.AppendPCPath 做了什么,建议去掉 pc 这个 pkg 。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Git-flow] Hi @MeteorsLiu, There are some suggestions for your information: Rebase suggestions
Which seems insignificant, recommend to use For other If you have any questions about this comment, feel free to raise an issue here: |
Resolve #1058
Build process of
llpkg
:llpkg
by parsingllpkg.cfg
ghReleaseInstaller
PKG_CONFIG_PATH
toLLGoCacheDir/{{ModulePath}}