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

Merge binaries into main probe-rs crate. #1637

Merged
merged 9 commits into from
Jun 20, 2023
Merged

Merge binaries into main probe-rs crate. #1637

merged 9 commits into from
Jun 20, 2023

Conversation

Dirbaio
Copy link
Member

@Dirbaio Dirbaio commented Jun 12, 2023

TODO:

  • Make the cargo-flash/cargo-embed shim binaries work on Windows
  • Fix "unused" warnings

@noppej
Copy link
Contributor

noppej commented Jun 12, 2023

@Dirbaio ... This file rename: probe-rs/cli/src/debugger.rs -> probe-rs/src/bin/probe-rs/debugger.rs

Does it make sense to introduce a subfolder probe-rs/src/bin/cli that can hold all the files associated with the current and future CLI capabilities (e.g. benchmark, debugger, trace, run, etc.)?

@Dirbaio
Copy link
Member Author

Dirbaio commented Jun 12, 2023

Yes, that's sort of what I'm doing. The main probe-rs binary is at src/bin/probe-rs, all the CLI functionality is modules under it.

@Dirbaio Dirbaio marked this pull request as draft June 12, 2023 23:50
@Dirbaio Dirbaio changed the title WIP: Merge binaries into main probe-rs crate. Merge binaries into main probe-rs crate. Jun 13, 2023
@Dirbaio Dirbaio marked this pull request as ready for review June 13, 2023 01:13
@noppej
Copy link
Contributor

noppej commented Jun 13, 2023

Yes, that's sort of what I'm doing. The main probe-rs binary is at src/bin/probe-rs, all the CLI functionality is modules under it.

Looking at the final directory structure, it feels like there is an opportunity to move all the src/bin/probe-rs/*.rs except for main.rs into a src/bin/probe-rs/cli folder. Not sure I'm explaining it properly, but it feels like the cli functionality can grow over time, just like the other folders under src/bin/probe-rs, so keeping it out of the root of that folder might keep it neater. Just a thought :)

PS. There are some list and list-chips capabilities in the dap-server, which is now provided by the integrated binary. I'm happy to PR that cleanup in the future if you prefer.

Copy link
Contributor

@noppej noppej left a comment

Choose a reason for hiding this comment

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

At first, I thought there was no way to cargo install the dap-server, but then I figured out that the cargo install --features="cli" will install the probe-rs binary that includes the dap-server sub command.

I'm wondering if it makes sense to make that the default feature? Or else perhaps update the error message for cargo install, which currently gives you

warning: none of the package's binaries are available for install using the selected features
  bin "probe-rs" requires the features: `cli`
  bin "cargo-flash" requires the features: `cli`
  bin "cargo-embed" requires the features: `cli`
  example "nrf53_recover" requires the features: 
  example "ram_download" requires the features: 
  example "multidrop_raw" requires the features: 
  example "tcp_itm" requires the features: 
1 more targets also requires features not enabled. See them in the Cargo.toml file.
Consider enabling some of the needed features by passing, e.g., `--features="cli"`

To help users understand that the --features="cli" will enable gdb and dap servers also.

@noppej
Copy link
Contributor

noppej commented Jun 13, 2023

I'm not sure how to add this to review, but in the file .vscode/launch.json, can you please update the entry for testing the DAP server, to look like this (reflect the new binary names):

    {
      "type": "lldb",
      "request": "launch",
      "name": "DAP-Server probe-rs", // Use this to test the dap server .
      "cargo": {
        "args": ["build", "--bin=probe-rs", "--features=cli"],
        "filter": {
          "name": "probe-rs",
          "kind": "bin"
        }
      },
      "args": ["dap-server", "debug", "--port", "50001"],
      // "env": {
      //     "RUST_LOG": "error",
      //     "DEFMT_LOG": "info"
      // },
      "cwd": "${workspaceFolder}/probe-rs/src/bin/probe-rs/dap_server"
    }

@Dirbaio
Copy link
Member Author

Dirbaio commented Jun 13, 2023

Looking at the final directory structure, it feels like there is an opportunity to move all the src/bin/probe-rs/*.rs except for main.rs into a src/bin/probe-rs/cli folder. Not sure I'm explaining it properly, but it feels like the cli functionality can grow over time, just like the other folders under src/bin/probe-rs, so keeping it out of the root of that folder might keep it neater. Just a thought :)

I'm not sure. Everything under src/bin/probe-rs is already "the CLI". There's the main.rs file, and then all subcommands are already child mods of that. We'd be adding a cli mod that's empty if we did this. IMO the paths are already long enough.

PS. There are some list and list-chips capabilities in the dap-server, which is now provided by the integrated binary. I'm happy to PR that cleanup in the future if you prefer.

Yes, for now I've focused on merging everything as-is and not doing any cleanup/reorganization to make review easier/faster. There's lots of stuff to clean up, I was planning on doing it in future PRs.

At first, I thought there was no way to cargo install the dap-server, but then I figured out that the cargo install --features="cli" will install the probe-rs binary that includes the dap-server sub command.

The idea of the merge is that the user doesn't "install the DAP server" or "install cargo-embed". They "install probe-rs", that's it. It's a single thing with all the functionality.

I'm wondering if it makes sense to make that the default feature?

Making it default means everyone using the probe-rs crate as a lib will get all the CLI deps in their dep tree, which add quire a bit of build time. (Yes, users could do default-features = false to avoid it, but they WILL forget to do it).

I agree having to set the feature is not great UX. However, I'm not too worried about the cargo install UX, because we will provide binary builds in the future, everyone will install using that.

Or else perhaps update the error message for cargo install, which currently gives you

That error message is not customizable. :(

To help users understand that the --features="cli" will enable gdb and dap servers also.

I don't think we should make the user worry about "getting the DAP server", they should just worry about "installing probe-rs". ie the vscode extension docs could tell the user "Install probe-rs, then install the probe-rs vscode extension. The extension uses the system-wide probe-rs installation".

@noppej
Copy link
Contributor

noppej commented Jun 13, 2023

The idea of the merge is that the user doesn't "install the DAP server" or "install cargo-embed". They "install probe-rs", that's it. It's a single thing with all the functionality.

Totally understood and the logic about keeping the api dep tree clean. In that case, do we want to call that feature "cli" (the feature name sent me down the path of misunderstanding, because I didn't see 'server' components falling under 'cli')? Perhaps something like "tools"?

@Dirbaio
Copy link
Member Author

Dirbaio commented Jun 13, 2023

It's not "tools", it's THE probe-rs tool :) IMO cli is fine. Perhaps bin? Dunno, I'm fine with whatever name you guys choose.

@noppej
Copy link
Contributor

noppej commented Jun 13, 2023

I will leave it up to tiwalun and yatekii to decide. I was just trying to help make sure new users don't get too confused when trying to get off the ground with probe-rs.

Copy link
Contributor

@noppej noppej left a comment

Choose a reason for hiding this comment

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

Refactoring is never fun, but it feels like this sets us on the right path ... thanks :)

Copy link
Member

@Tiwalun Tiwalun left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for all the work!

Just some small nits, but nothing big regarding the code.

I think we should update the README as well, now it seems that all the installation instructions which were part of the individual readmes are gone. Could also be done in a separate PR, but then we should create an issue so it doesn't get forgotten.

.github/workflows/start-release.yml Show resolved Hide resolved
probe-rs/Cargo.toml Show resolved Hide resolved
probe-rs/src/bin/cargo-embed.rs Outdated Show resolved Hide resolved
probe-rs/src/bin/cargo-flash.rs Outdated Show resolved Hide resolved
probe-rs/src/bin/cargo-embed.rs Show resolved Hide resolved
@Tiwalun
Copy link
Member

Tiwalun commented Jun 13, 2023

@Dirbaio @MabezDev How do you want to handle this and #1629 ? Not sure what order of merging the PRs is easier.

@MabezDev
Copy link
Member

Merge this first I think, my rebase should be pretty straightforward.

@Dirbaio
Copy link
Member Author

Dirbaio commented Jun 20, 2023

Rebased, resolved @Tiwalun 's comments (except one)

Copy link
Member

@Tiwalun Tiwalun left a comment

Choose a reason for hiding this comment

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

Thanks! ❤️

@Yatekii Yatekii added this pull request to the merge queue Jun 20, 2023
Merged via the queue into master with commit d92d17f Jun 20, 2023
@Yatekii Yatekii deleted the megamerge branch June 20, 2023 19:17
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.

5 participants