Skip to content

Commit 30fef76

Browse files
Merge pull request #63 from rust3ds/fix/dont-always-link
2 parents 7fd38e2 + e3d83cd commit 30fef76

File tree

5 files changed

+23
-67
lines changed

5 files changed

+23
-67
lines changed

.github/actions/setup/action.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Checkout branch
2929
uses: actions/checkout@v2
3030

31-
- uses: ./.github/actions/setup
31+
- uses: rust3ds/actions/setup@v1
3232
with:
3333
toolchain: ${{ matrix.toolchain }}
3434

@@ -53,7 +53,7 @@ jobs:
5353
- name: Checkout branch
5454
uses: actions/checkout@v3
5555

56-
- uses: ./.github/actions/setup
56+
- uses: rust3ds/actions/setup@v1
5757
with:
5858
toolchain: ${{ matrix.toolchain }}
5959

src/command.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub struct New {
162162

163163
impl CargoCmd {
164164
/// Returns the additional arguments run by the "official" cargo subcommand.
165-
pub fn cargo_args(&self) -> Vec<String> {
165+
pub(crate) fn cargo_args(&self) -> Vec<String> {
166166
match self {
167167
CargoCmd::Build(build) => build.passthrough.cargo_args(),
168168
CargoCmd::Run(run) => run.build_args.passthrough.cargo_args(),
@@ -185,7 +185,7 @@ impl CargoCmd {
185185
/// This is not equivalent to the lowercase name of the [`CargoCmd`] variant.
186186
/// Commands may use different commands under the hood to function (e.g. [`CargoCmd::Run`] uses `build`
187187
/// if no custom runner is configured).
188-
pub fn subcommand_name(&self) -> &str {
188+
pub(crate) fn subcommand_name(&self) -> &str {
189189
match self {
190190
CargoCmd::Build(_) => "build",
191191
CargoCmd::Run(run) => {
@@ -202,7 +202,7 @@ impl CargoCmd {
202202
}
203203

204204
/// Whether or not this command should compile any code, and thus needs import the custom environment configuration (e.g. target spec).
205-
pub fn should_compile(&self) -> bool {
205+
pub(crate) fn should_compile(&self) -> bool {
206206
matches!(
207207
self,
208208
Self::Build(_) | Self::Run(_) | Self::Test(_) | Self::Passthrough(_)
@@ -225,16 +225,6 @@ impl CargoCmd {
225225
}
226226
}
227227

228-
/// Whether or not the resulting executable should be sent to the 3DS with
229-
/// `3dslink`.
230-
pub fn should_link_to_device(&self) -> bool {
231-
match self {
232-
Self::Test(Test { no_run: true, .. }) => false,
233-
Self::Run(run) | Self::Test(Test { run_args: run, .. }) => !run.use_custom_runner(),
234-
_ => false,
235-
}
236-
}
237-
238228
pub const DEFAULT_MESSAGE_FORMAT: &'static str = "json-render-diagnostics";
239229

240230
pub fn extract_message_format(&mut self) -> Result<Option<String>, String> {
@@ -394,12 +384,12 @@ impl Callbacks for CargoCmd {
394384

395385
impl RemainingArgs {
396386
/// Get the args to be passed to `cargo`.
397-
pub fn cargo_args(&self) -> Vec<String> {
387+
pub(crate) fn cargo_args(&self) -> Vec<String> {
398388
self.split_args().0
399389
}
400390

401391
/// Get the args to be passed to the executable itself (not `cargo`).
402-
pub fn exe_args(&self) -> Vec<String> {
392+
pub(crate) fn exe_args(&self) -> Vec<String> {
403393
self.split_args().1
404394
}
405395

@@ -440,14 +430,16 @@ impl Callbacks for Run {
440430
///
441431
/// This callback handles launching the application via `3dslink`.
442432
fn run_callback(&self, config: &CTRConfig) {
443-
eprintln!("Running 3dslink");
444-
link(config, self, self.build_args.verbose);
433+
if !self.use_custom_runner() {
434+
eprintln!("Running 3dslink");
435+
link(config, self, self.build_args.verbose);
436+
}
445437
}
446438
}
447439

448440
impl Run {
449441
/// Get the args to pass to `3dslink` based on these options.
450-
pub fn get_3dslink_args(&self) -> Vec<String> {
442+
pub(crate) fn get_3dslink_args(&self) -> Vec<String> {
451443
let mut args = Vec::new();
452444

453445
if let Some(address) = self.address {
@@ -495,7 +487,7 @@ impl Run {
495487
/// - `.cargo/config.toml`
496488
/// - Environment variables
497489
/// - Command-line `--config` overrides
498-
pub fn use_custom_runner(&self) -> bool {
490+
pub(crate) fn use_custom_runner(&self) -> bool {
499491
static HAS_RUNNER: OnceLock<bool> = OnceLock::new();
500492

501493
let &custom_runner_configured = HAS_RUNNER.get_or_init(|| {

src/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl UnitGraph {
2323
/// build and the graph is output instead.
2424
///
2525
/// See <https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#unit-graph>.
26-
pub fn from_cargo(cargo_cmd: &Command, verbose: bool) -> Result<Self, Box<dyn Error>> {
26+
pub(crate) fn from_cargo(cargo_cmd: &Command, verbose: bool) -> Result<Self, Box<dyn Error>> {
2727
// Since Command isn't Clone, copy it "by hand", by copying its args and envs
2828
let mut cmd = Command::new(cargo_cmd.get_program());
2929

src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fn should_use_ctru_debuginfo(cargo_cmd: &Command, verbose: bool) -> bool {
107107
///
108108
/// For "build" commands (which compile code, such as `cargo 3ds build` or `cargo 3ds clippy`),
109109
/// if there is no pre-built std detected in the sysroot, `build-std` will be used instead.
110-
pub fn make_cargo_command(input: &Input, message_format: &Option<String>) -> Command {
110+
pub(crate) fn make_cargo_command(input: &Input, message_format: &Option<String>) -> Command {
111111
let devkitpro =
112112
env::var("DEVKITPRO").expect("DEVKITPRO is not defined as an environment variable");
113113
// TODO: should we actually prepend the user's RUSTFLAGS for linking order? not sure
@@ -195,7 +195,7 @@ fn print_command(command: &Command) {
195195
}
196196

197197
/// Finds the sysroot path of the current toolchain
198-
pub fn find_sysroot() -> PathBuf {
198+
pub(crate) fn find_sysroot() -> PathBuf {
199199
let sysroot = env::var("SYSROOT").ok().unwrap_or_else(|| {
200200
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".to_string());
201201

@@ -253,7 +253,7 @@ pub fn check_rust_version(input: &Input) {
253253
/// Parses messages returned by "build" cargo commands (such as `cargo 3ds build` or `cargo 3ds run`).
254254
/// The returned [`CTRConfig`] is then used for further building in and execution
255255
/// in [`CTRConfig::build_smdh`], [`build_3dsx`], and [`link`].
256-
pub fn get_artifact_config(package: Package, artifact: Artifact) -> CTRConfig {
256+
pub(crate) fn get_artifact_config(package: Package, artifact: Artifact) -> CTRConfig {
257257
// For now, assume a single "kind" per artifact. It seems to be the case
258258
// when a single executable is built anyway but maybe not in all cases.
259259
let name = match artifact.target.kind[0].as_ref() {
@@ -287,7 +287,7 @@ pub fn get_artifact_config(package: Package, artifact: Artifact) -> CTRConfig {
287287

288288
/// Builds the 3dsx using `3dsxtool`.
289289
/// This will fail if `3dsxtool` is not within the running directory or in a directory found in $PATH
290-
pub fn build_3dsx(config: &CTRConfig, verbose: bool) {
290+
pub(crate) fn build_3dsx(config: &CTRConfig, verbose: bool) {
291291
let mut command = Command::new("3dsxtool");
292292
command
293293
.arg(&config.target_path)
@@ -323,7 +323,7 @@ pub fn build_3dsx(config: &CTRConfig, verbose: bool) {
323323

324324
/// Link the generated 3dsx to a 3ds to execute and test using `3dslink`.
325325
/// This will fail if `3dslink` is not within the running directory or in a directory found in $PATH
326-
pub fn link(config: &CTRConfig, run_args: &Run, verbose: bool) {
326+
pub(crate) fn link(config: &CTRConfig, run_args: &Run, verbose: bool) {
327327
let mut command = Command::new("3dslink");
328328
command
329329
.arg(config.path_3dsx())
@@ -380,17 +380,17 @@ pub struct CTRConfig {
380380

381381
impl CTRConfig {
382382
/// Get the path to the output `.3dsx` file.
383-
pub fn path_3dsx(&self) -> Utf8PathBuf {
383+
pub(crate) fn path_3dsx(&self) -> Utf8PathBuf {
384384
self.target_path.with_extension("3dsx")
385385
}
386386

387387
/// Get the path to the output `.smdh` file.
388-
pub fn path_smdh(&self) -> Utf8PathBuf {
388+
pub(crate) fn path_smdh(&self) -> Utf8PathBuf {
389389
self.target_path.with_extension("smdh")
390390
}
391391

392392
/// Get the absolute path to the romfs directory, defaulting to `romfs` if not specified.
393-
pub fn romfs_dir(&self) -> Utf8PathBuf {
393+
pub(crate) fn romfs_dir(&self) -> Utf8PathBuf {
394394
self.manifest_dir
395395
.join(self.romfs_dir.as_deref().unwrap_or(Utf8Path::new("romfs")))
396396
}
@@ -401,7 +401,7 @@ impl CTRConfig {
401401

402402
/// Builds the smdh using `smdhtool`.
403403
/// This will fail if `smdhtool` is not within the running directory or in a directory found in $PATH
404-
pub fn build_smdh(&self, verbose: bool) {
404+
pub(crate) fn build_smdh(&self, verbose: bool) {
405405
let description = self
406406
.description
407407
.as_deref()

0 commit comments

Comments
 (0)