helgoboss / reaper-rs

Rust bindings for the REAPER C++ API
MIT License
78 stars 8 forks source link

Add note about `reaper_` prefix, add step-by-step #35

Closed GavinRay97 closed 3 years ago

GavinRay97 commented 3 years ago

[Close #34]

Unsure of how accurate all of this is, for instance:

This appears to be true, but not sure about how exactly extensions work:

Compiled REAPER Plug-in Extensions (IE, .dll files) must be prefixed with reaper_ in order for REAPER to load them during startup.

Is cargo fetch necessary prior to cargo build, or will cargo build run fetch? I figured if anything, you want the packages downloaded so that you can get IDE completions and types + documentation for them in case you want to edit before compiling the starter extension code.

  1. From within the top-level of the newly created project directory (where the Cargo.toml resides), run cargo fetch to fetch needed dependencies
  2. Run cargo build to generate the compiled plugin extension inside of the target/debug directory
GavinRay97 commented 3 years ago

Apologies, I just noticed the diff is a bit dirty. I think Prettier auto-formatted the Markdown and removed some trailing spaces on lines =/

The raw changes are:

  1. Extension Cargo.toml lib named to start with reaper_
    [lib]
    name = "reaper_my_extension"
  2. Added note section about name:
    > **IMPORTANT:** Compiled REAPER Plug-in Extensions (IE, `.dll` files) must be prefixed with `reaper_` in order for REAPER to load them during startup. Naming the library `reaper_my_extension` in `Cargo.toml` will result in the compiled file being named `reaper_my_extension`, thus obeying this rule. If you rename your library, make sure that the compiled file placed in `REAPER/UserPlugins` is prefixed with `reaper_` before attempting to test it.
  3. Step-by-Step:
    
    #### Step-by-Step Instructions

The following instructions should result in a functional extension, loaded into REAPER on start:

  1. Make a new directory for the project.
  2. Copy the contents of the Cargo.toml above to the directory
  3. Copy the contents of the lib.rs to src/lib.rs in the directory
  4. From within the top-level of the newly created project directory (where the Cargo.toml resides), run cargo fetch to fetch needed dependencies
  5. Run cargo build to generate the compiled plugin extension inside of the target/debug directory
  6. Copy the plugin extension to the REAPER/UserPlugins directory
    • You could do this manually, and overwrite the file after each build
    • Or, you could create a symbolic link from the target/debug file, to REAPER/UserPlugins so that they were synced
      • To do this, on unix-based systems, run ln -s ./target/debug/<name-of-the-compiled-extension-file> <path to REAPER/UserPlugins>
      • On Windows, you can use the same command if running Git Bash, else you can use mklink \D target\debug\<name-of-the-compiled-extension-file> %AppData%\REAPER\UserPlugins
  7. Now start REAPER, and you should see the console message from the code appear!
helgoboss commented 3 years ago

Thanks @GavinRay97!