Skip to content

feat(metadata): add cc flag parser#112

Merged
luoliwoshang merged 3 commits into
xgo-dev:mainfrom
MeteorsLiu:feat/metadata-cc
May 26, 2026
Merged

feat(metadata): add cc flag parser#112
luoliwoshang merged 3 commits into
xgo-dev:mainfrom
MeteorsLiu:feat/metadata-cc

Conversation

@MeteorsLiu

Copy link
Copy Markdown
Collaborator

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new cc package for parsing C/C++ build metadata flags into a structured format, including support for sysroot extraction and linker flag identification. Feedback identifies a bug where linker flags followed by a space (e.g., -L /path) result in the argument being miscategorized as a compiler flag. Additionally, the CFLAGS field in the Metadata struct is currently unused and should either be populated or removed to avoid confusion.

Comment thread metadata/cc/cc.go Outdated
Comment thread metadata/cc/cc.go Outdated
@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.80531% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.48%. Comparing base (9c6e52a) to head (bfd8a58).

Files with missing lines Patch % Lines
x/metadata/cc/cc.go 93.80% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
+ Coverage   79.69%   80.48%   +0.78%     
==========================================
  Files          35       36       +1     
  Lines        1921     2034     +113     
==========================================
+ Hits         1531     1637     +106     
- Misses        285      290       +5     
- Partials      105      107       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

fennoai[bot]

This comment was marked as outdated.

@MeteorsLiu

Copy link
Copy Markdown
Collaborator Author

/review

fennoai[bot]

This comment was marked as outdated.

@MeteorsLiu MeteorsLiu requested a review from luoliwoshang May 22, 2026 08:56
@MeteorsLiu

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the cc package to parse C/C++ build metadata flags into a structured Metadata object, including logic to categorize flags for compilation, linking, and sysroot. Feedback focuses on improving adherence to Go naming conventions for the Metadata struct and unifying field visibility. Several opportunities for code cleanup were also identified, such as removing unused constants, eliminating redundant string splitting for linker flags, and simplifying the sysroot assignment logic.

Comment thread x/metadata/cc/cc.go
Comment thread x/metadata/cc/cc.go Outdated
Comment thread x/metadata/cc/cc.go
Comment thread x/metadata/cc/cc.go
Comment thread x/metadata/cc/cc.go
@luoliwoshang

Copy link
Copy Markdown
Collaborator

/review

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Clean, well-structured Go package for parsing C/C++ compiler flags. The code is idiomatic, the test suite is thorough, and the separation between parsing and classification is well done. A few observations below — mostly minor.

Comment thread x/metadata/cc/cc.go
Comment thread x/metadata/cc/cc.go
Comment thread x/metadata/cc/cc.go
Comment thread x/metadata/cc/cc.go
Comment on lines +17 to +18
// CFLAGS contains flags that apply specifically to C compilation.
CFLAGS []string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments for CFLAGS and CXXFLAGS say "flags that apply specifically to C/C++ compilation," but in practice only -std flags (with C or C++ standard values) are routed here — no other C/C++-specific flags get classified separately. This could mislead consumers into expecting e.g. -Wstrict-prototypes to land in CFLAGS. Consider narrowing the wording, e.g.:

// CFLAGS contains -std flags with C language standard values (e.g. c99, gnu11).

Comment thread x/metadata/cc/cc.go
Comment thread x/metadata/cc/cc.go

@luoliwoshang luoliwoshang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luoliwoshang luoliwoshang merged commit acb4258 into xgo-dev:main May 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants