Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

2. Setup

Brian Chew edited this page Jun 19, 2020 · 11 revisions

Now that you (hopefully) have some level of familiarity with Rust, time to get setup with the toolchain needed to make plugins for skyline.

First up install the following:

Next run the following command in a terminal of your choice:

cargo install cargo-skyline

This will install cargo-skyline, an extension to cargo (the Rust package manager). To check it is installed properly, try viewing the help text using:

cargo skyline --help

This should display a list of subcommands available to you.

Workspace Setup / Compiling your first plugin

First up, find a good place for all your future plugins to go. This will be your workplace. Probably start with an empty folder, as that will make navigation easier.

Example of an appropriate workspace directory:

C:\Users\jam1garner\skyline-workspace

Now, open a command line within that directory and run the following command:

cargo skyline new my_first_plugin

This will create your first plugin and also prompt you to do initial setup, like so:

Double check that the folder structure looks correct to you, then type "y" and hit enter. Then wait for the command to finishing setting up your workspace. Enjoy the small bit of peace. Let the tension out of your shoulders. Take some deep breaths.

Now that that's finished, change your current directory to be inside that of your plugin (cd my_first_plugin) and then run the following command inside your plugin directory to build your plugin:

cargo skyline build

The resulting plugin should be at the following location: target/aarch64-skyline-switch/debug/libmy_first_plugin.nro.

Note: Even if this successfully runs, it will show you some warnings as well as it may show the following error:

error: package collision in the lockfile: packages core v0.0.0 

So long as it reaches the point where it says

Finished dev [unoptimized + debuginfo] target(s)

It was successful. These warnings/errors shouldn't show after the first compile and can be ignored.


Troubleshooting

"Could not find command git"

All you need to do is visit git-scm, select your operating system and follow the instructions for installing 'git'.

"rust-lld missing"

This error is caused because 'rust-lld' has not been added to your PATH. Fixing this is very simple but the process differs depending on your Operation System.

For Windows 10
  • Open the Start menu and look for "Edit the system environment variables". (You can simply type that when the menu is open)
  • At the bottom of the window is a button with the label "Environment Variables...", click on it.
  • A new window with two different lists will show up. In the bottom one (System variables), look for 'Path' in the list. Select it and click on the "Edit" button.
  • On the right in the "Edit environment variable" window is a "New" button. Press it.
  • What you want is to add the location of your .cargo\bin folder, which is located in your user profile directory by default. For this, we'll assume you are working with the default settings.
    Add C:\Users\XXXXXXX\.cargo\bin to the list but make sure to replace XXXXXXX with your user name.
  • Confirm with "Ok", open a new command prompt and run the command again.
Alternative WSL/Linux Fix

The fix involves setting your linker to use lld instead of rust-lld.

  1. Install LLD

1a) Ubuntu 20.04 (you can check your versions using lsb_release -a)

    sudo apt install lld

1b) Ubuntu 18.04/16.04

    sudo apt install lld-8
  1. Create a global cargo config. This should be located in [plugin workspace]/.cargo/config (Note: this file should not already exist and is different from the .cargo folder in your plugin directory)
  2. Include the following text in your config file:
[target.aarch64-skyline-switch]
linker = "lld"

(For 18.04 and 16.04 users, replace "lld" with "lld-8")

"core missing"

Make sure you're using the latest version of cargo-skyline using:

cargo install cargo-skyline

"xargo missing"

Install xargo with the following command:

cargo install xargo