feat(tool): support passing .go files to otelc go build#483
feat(tool): support passing .go files to otelc go build#483amazingakai wants to merge 7 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #483 +/- ##
==========================================
- Coverage 63.70% 63.70% -0.01%
==========================================
Files 62 62
Lines 4794 4854 +60
==========================================
+ Hits 3054 3092 +38
- Misses 1486 1503 +17
- Partials 254 259 +5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds support for passing .go source files directly to otelc go build, aligning otelc behavior more closely with go build when users build from an explicit file list (which creates the synthetic command-line-arguments package).
Changes:
- Parse build targets into package patterns vs
.gofile targets and load packages accordingly. - Support file-target builds by accepting
command-line-argumentspackages and injectingotelc.runtime.goonto thego buildcommand line. - Extend unit tests to cover file targets and the new target-splitting behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tool/internal/setup/setup.go | Adds target splitting, file-target package loading/filtering, and runtime file injection for file-based builds. |
| tool/internal/setup/setup_test.go | Adds/updates tests for file targets, mixing targets, and default package loading. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| restArgs := args[1:] | ||
| if _, fileTargets, err2 := splitBuildTargets(restArgs); err2 == nil && len(fileTargets) > 0 { | ||
| // add otelc.runtime.go manually to command line for file targets | ||
| dir := filepath.Dir(fileTargets[0]) | ||
| otelcRuntimePath := filepath.Join(dir, OtelcRuntimeFile) | ||
| restArgs = append(restArgs, otelcRuntimePath) |
There was a problem hiding this comment.
This is not really true, If user does:
go build -C cmd main.go
It would do:
go build -C cmd main.go otelc.runtime.go
Similarly for:
go build -C cmd /home/.../absolute_path_to/main.go
It would do:
go build -C cmd /home/.../absolute_path_to/main.go cmd /home/.../absolute_path_to/otelc.runtime.go
In both cases, it should be correct, unless I'm missing something.
There was a problem hiding this comment.
-C wasn't supported before. LoadPackages never sets Dir for packages.Config. I've created an issue for tackling this #507
| restArgs := args[1:] | ||
| if _, fileTargets, err2 := splitBuildTargets(restArgs); err2 == nil && len(fileTargets) > 0 { | ||
| // add otelc.runtime.go manually to command line for file targets | ||
| dir := filepath.Dir(fileTargets[0]) | ||
| otelcRuntimePath := filepath.Join(dir, OtelcRuntimeFile) | ||
| restArgs = append(restArgs, otelcRuntimePath) |
There was a problem hiding this comment.
-C wasn't supported before. LoadPackages never sets Dir for packages.Config. I've created an issue for tackling this #507
|
Thank you for the review, I will try to address the comments soon |
53e16f3 to
577b856
Compare
|
This PR is ready for review again @y1yang0 @txabman42 I also don't think there is a performance regression here (or at least I don't see a reason for there to be). Not sure why the Windows integration tests are timing out. Benchmark results on my local machine look effectively unchanged: Before: After: |
Rerun just fixed it. Seems that runner was slow, probably bad neighbours. |
txabman42
left a comment
There was a problem hiding this comment.
LGTM! Just some nitpicks
577b856 to
a6ce8f6
Compare
|
Done. Thank you for the review ❤️ |
|
@amazingakai This needs a rebase. |
a6ce8f6 to
e406a18
Compare
|
@kakkoyun Done. |
Description
Support passing .go source files to
otelc go buildcommandMotivation
Currently passing .go files to
otelc go buildfails, while this is supported bygo buildcommand.Checklist
make formatmake lintmake test