Skip to content
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

[CLI] Add message-format-json experiment value to aptos move compile and aptos move lint #15540

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

mkurnikov
Copy link
Contributor

@mkurnikov mkurnikov commented Dec 8, 2024

Description

I would like to add the flag to the CLI which changes all the human-readable codespan_reporting output into the JSON output.
I specifically need it for the proper integration with the IDE.

How Has This Been Tested?

Not tested yet.

Key Areas to Review

This is WIP. I have only added the flag for the compilation and lint errors. I also ignored compiler-v1, I assume it's eventually going to be removed, so it's alright to just add no-op flag there.

@vgao1996 Could you look at this impl and let me know whether the approach is acceptable?

Type of Change

  • New feature
  • Bug fix
  • Breaking change
  • Performance improvement
  • Refactoring
  • Dependency update
  • Documentation update
  • Tests

Which Components or Systems Does This Change Impact?

  • Validator Node
  • Full Node (API, Indexer, etc.)
  • Move/Aptos Virtual Machine
  • Aptos Framework
  • Aptos CLI/SDK
  • Developer Infrastructure
  • Move Compiler
  • Other (specify)

Checklist

  • I have read and followed the CONTRIBUTING doc
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I identified and added all stakeholders and component owners affected by this change as reviewers
  • I tested both happy and unhappy path of the functionality
  • I have made corresponding changes to the documentation

Copy link

trunk-io bot commented Dec 8, 2024

⏱️ 11s total CI duration on this PR

Job Cumulative Duration Recent Runs
permission-check 6s 🟥🟥
permission-check 5s 🟥🟥

settingsfeedbackdocs ⋅ learn more about trunk.io

/// Run move compiler and print errors to given writer. Returns the set of compiled units.
pub fn run_move_compiler_with_emitter(
mut emitter: Box<dyn Emitter>,
options: Options,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the code duplication? Could we not create the emitter based on the message format in options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, it's a draft, I'll remove it when someone confirms that the Emitter trait approach works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -107,6 +110,8 @@ pub struct BuildOptions {
/// Select bytecode, language, compiler for Move 2
#[clap(long)]
pub move_2: bool,
#[clap(long, default_value = "human")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of another field, could we just reuse experiments above, and have this be another "experiment" (that is, if the experiment is on, then we have JSON formatted messages, e.g.)? See third_party/move/move-compiler-v2/src/experiments.rs and the function experiments_from_opt_level for an example of threading through an "option" via experiments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think it's a better option. I'll rewrite the PR now, removing the message_format field, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@mkurnikov mkurnikov marked this pull request as ready for review December 18, 2024 15:23
@mkurnikov mkurnikov requested a review from vineethk December 18, 2024 15:39
@mkurnikov mkurnikov changed the title [CLI] Add --message-format to aptos move compile and aptos move lint [CLI] Add message-format-json experiment value to aptos move compile and aptos move lint Dec 18, 2024
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