diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml deleted file mode 100644 index 7db3c8f..0000000 --- a/.github/actions/setup/action.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Setup -description: Set up CI environment for Rust + 3DS development - -inputs: - toolchain: - description: The Rust toolchain to use for the steps - required: true - default: nightly - -runs: - using: composite - steps: - # https://github.com/nektos/act/issues/917#issuecomment-1074421318 - - if: ${{ env.ACT }} - shell: bash - name: Hack container for local development - run: | - curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - - sudo apt-get install -y nodejs - - - name: Setup default Rust toolchain - # Use this helper action so we get matcher support - # https://github.com/actions-rust-lang/setup-rust-toolchain/pull/15 - uses: actions-rust-lang/setup-rust-toolchain@v1 - with: - components: clippy, rustfmt, rust-src - toolchain: ${{ inputs.toolchain }} - - - name: Install build tools for host - shell: bash - run: sudo apt-get update && sudo apt-get install -y build-essential - - - name: Set PATH to include devkitARM - shell: bash - # For some reason devkitARM/bin is not part of the default PATH in the container - run: echo "${DEVKITARM}/bin" >> $GITHUB_PATH diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2470b6..e4fa23a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: - name: Checkout branch uses: actions/checkout@v2 - - uses: ./.github/actions/setup + - uses: rust3ds/actions/setup@v1 with: toolchain: ${{ matrix.toolchain }} @@ -53,7 +53,7 @@ jobs: - name: Checkout branch uses: actions/checkout@v3 - - uses: ./.github/actions/setup + - uses: rust3ds/actions/setup@v1 with: toolchain: ${{ matrix.toolchain }} diff --git a/src/command.rs b/src/command.rs index 35f2c32..f06f6e7 100644 --- a/src/command.rs +++ b/src/command.rs @@ -162,7 +162,7 @@ pub struct New { impl CargoCmd { /// Returns the additional arguments run by the "official" cargo subcommand. - pub fn cargo_args(&self) -> Vec { + pub(crate) fn cargo_args(&self) -> Vec { match self { CargoCmd::Build(build) => build.passthrough.cargo_args(), CargoCmd::Run(run) => run.build_args.passthrough.cargo_args(), @@ -185,7 +185,7 @@ impl CargoCmd { /// This is not equivalent to the lowercase name of the [`CargoCmd`] variant. /// Commands may use different commands under the hood to function (e.g. [`CargoCmd::Run`] uses `build` /// if no custom runner is configured). - pub fn subcommand_name(&self) -> &str { + pub(crate) fn subcommand_name(&self) -> &str { match self { CargoCmd::Build(_) => "build", CargoCmd::Run(run) => { @@ -202,7 +202,7 @@ impl CargoCmd { } /// Whether or not this command should compile any code, and thus needs import the custom environment configuration (e.g. target spec). - pub fn should_compile(&self) -> bool { + pub(crate) fn should_compile(&self) -> bool { matches!( self, Self::Build(_) | Self::Run(_) | Self::Test(_) | Self::Passthrough(_) @@ -225,16 +225,6 @@ impl CargoCmd { } } - /// Whether or not the resulting executable should be sent to the 3DS with - /// `3dslink`. - pub fn should_link_to_device(&self) -> bool { - match self { - Self::Test(Test { no_run: true, .. }) => false, - Self::Run(run) | Self::Test(Test { run_args: run, .. }) => !run.use_custom_runner(), - _ => false, - } - } - pub const DEFAULT_MESSAGE_FORMAT: &'static str = "json-render-diagnostics"; pub fn extract_message_format(&mut self) -> Result, String> { @@ -394,12 +384,12 @@ impl Callbacks for CargoCmd { impl RemainingArgs { /// Get the args to be passed to `cargo`. - pub fn cargo_args(&self) -> Vec { + pub(crate) fn cargo_args(&self) -> Vec { self.split_args().0 } /// Get the args to be passed to the executable itself (not `cargo`). - pub fn exe_args(&self) -> Vec { + pub(crate) fn exe_args(&self) -> Vec { self.split_args().1 } @@ -440,14 +430,16 @@ impl Callbacks for Run { /// /// This callback handles launching the application via `3dslink`. fn run_callback(&self, config: &CTRConfig) { - eprintln!("Running 3dslink"); - link(config, self, self.build_args.verbose); + if !self.use_custom_runner() { + eprintln!("Running 3dslink"); + link(config, self, self.build_args.verbose); + } } } impl Run { /// Get the args to pass to `3dslink` based on these options. - pub fn get_3dslink_args(&self) -> Vec { + pub(crate) fn get_3dslink_args(&self) -> Vec { let mut args = Vec::new(); if let Some(address) = self.address { @@ -495,7 +487,7 @@ impl Run { /// - `.cargo/config.toml` /// - Environment variables /// - Command-line `--config` overrides - pub fn use_custom_runner(&self) -> bool { + pub(crate) fn use_custom_runner(&self) -> bool { static HAS_RUNNER: OnceLock = OnceLock::new(); let &custom_runner_configured = HAS_RUNNER.get_or_init(|| { diff --git a/src/graph.rs b/src/graph.rs index 67e5cc8..1209d81 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -23,7 +23,7 @@ impl UnitGraph { /// build and the graph is output instead. /// /// See . - pub fn from_cargo(cargo_cmd: &Command, verbose: bool) -> Result> { + pub(crate) fn from_cargo(cargo_cmd: &Command, verbose: bool) -> Result> { // Since Command isn't Clone, copy it "by hand", by copying its args and envs let mut cmd = Command::new(cargo_cmd.get_program()); diff --git a/src/lib.rs b/src/lib.rs index 43d2753..cc9ab00 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -107,7 +107,7 @@ fn should_use_ctru_debuginfo(cargo_cmd: &Command, verbose: bool) -> bool { /// /// For "build" commands (which compile code, such as `cargo 3ds build` or `cargo 3ds clippy`), /// if there is no pre-built std detected in the sysroot, `build-std` will be used instead. -pub fn make_cargo_command(input: &Input, message_format: &Option) -> Command { +pub(crate) fn make_cargo_command(input: &Input, message_format: &Option) -> Command { let devkitpro = env::var("DEVKITPRO").expect("DEVKITPRO is not defined as an environment variable"); // TODO: should we actually prepend the user's RUSTFLAGS for linking order? not sure @@ -195,7 +195,7 @@ fn print_command(command: &Command) { } /// Finds the sysroot path of the current toolchain -pub fn find_sysroot() -> PathBuf { +pub(crate) fn find_sysroot() -> PathBuf { let sysroot = env::var("SYSROOT").ok().unwrap_or_else(|| { let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".to_string()); @@ -253,7 +253,7 @@ pub fn check_rust_version(input: &Input) { /// Parses messages returned by "build" cargo commands (such as `cargo 3ds build` or `cargo 3ds run`). /// The returned [`CTRConfig`] is then used for further building in and execution /// in [`CTRConfig::build_smdh`], [`build_3dsx`], and [`link`]. -pub fn get_artifact_config(package: Package, artifact: Artifact) -> CTRConfig { +pub(crate) fn get_artifact_config(package: Package, artifact: Artifact) -> CTRConfig { // For now, assume a single "kind" per artifact. It seems to be the case // when a single executable is built anyway but maybe not in all cases. let name = match artifact.target.kind[0].as_ref() { @@ -287,7 +287,7 @@ pub fn get_artifact_config(package: Package, artifact: Artifact) -> CTRConfig { /// Builds the 3dsx using `3dsxtool`. /// This will fail if `3dsxtool` is not within the running directory or in a directory found in $PATH -pub fn build_3dsx(config: &CTRConfig, verbose: bool) { +pub(crate) fn build_3dsx(config: &CTRConfig, verbose: bool) { let mut command = Command::new("3dsxtool"); command .arg(&config.target_path) @@ -323,7 +323,7 @@ pub fn build_3dsx(config: &CTRConfig, verbose: bool) { /// Link the generated 3dsx to a 3ds to execute and test using `3dslink`. /// This will fail if `3dslink` is not within the running directory or in a directory found in $PATH -pub fn link(config: &CTRConfig, run_args: &Run, verbose: bool) { +pub(crate) fn link(config: &CTRConfig, run_args: &Run, verbose: bool) { let mut command = Command::new("3dslink"); command .arg(config.path_3dsx()) @@ -380,17 +380,17 @@ pub struct CTRConfig { impl CTRConfig { /// Get the path to the output `.3dsx` file. - pub fn path_3dsx(&self) -> Utf8PathBuf { + pub(crate) fn path_3dsx(&self) -> Utf8PathBuf { self.target_path.with_extension("3dsx") } /// Get the path to the output `.smdh` file. - pub fn path_smdh(&self) -> Utf8PathBuf { + pub(crate) fn path_smdh(&self) -> Utf8PathBuf { self.target_path.with_extension("smdh") } /// Get the absolute path to the romfs directory, defaulting to `romfs` if not specified. - pub fn romfs_dir(&self) -> Utf8PathBuf { + pub(crate) fn romfs_dir(&self) -> Utf8PathBuf { self.manifest_dir .join(self.romfs_dir.as_deref().unwrap_or(Utf8Path::new("romfs"))) } @@ -401,7 +401,7 @@ impl CTRConfig { /// Builds the smdh using `smdhtool`. /// This will fail if `smdhtool` is not within the running directory or in a directory found in $PATH - pub fn build_smdh(&self, verbose: bool) { + pub(crate) fn build_smdh(&self, verbose: bool) { let description = self .description .as_deref()