adafruit / nofrendo_arcada

NES emulator in Arduino that runs on SAMD51 at full speed w/audio
https://learn.adafruit.com/nes-emulator-for-arcada
57 stars 12 forks source link

Move sketch to appropriately named subfolder #2

Closed per1234 closed 5 years ago

per1234 commented 5 years ago

The Arduino IDE requires that a sketch be located in a folder of the same name. Although the name of the repository does match the sketch name, when GitHub's popular Clone or download > Download ZIP feature is used to download the contents of a repository the branch/tag/commit name is appended to the folder name, causing a mismatch.

When opening a file that does not meet this sketch/folder name matching requirement the Arduino IDE presents a dialog:

The file "nofrendo_arcata.ino" needs to be inside a sketch folder named "nofrendo_arcata".
Create this folder, move the file, and continue?

After clicking "OK" the Arduino IDE currently moves only the file nofrendo_arcata.ino to the new folder, leaving behind the other source files. This causes compilation of the sketch to fail:

nofrendo_arcada:2:12: error: emuapi.h: No such file or directory

   #include "emuapi.h"
ladyada commented 5 years ago

hmm i would rather update the instructions to indicate they need to rename the sketch folder cause right now i have it cloned within my Sketchbook folder which works very well :)

ladyada commented 5 years ago

ok guide & readme added. thank you for the contribution! if you can help adjust the builder so it looks in subfolders, that would be great cause this project is kinda bonkers-looking due to having to flatten all the c and h files into the top level :D

per1234 commented 5 years ago

right now i have it cloned within my Sketchbook folder which works very well

That would still work with the sketch in a subfolder of the repository:

{sketchbook folder}
|_nofrendo_arcada
   |_nofrendo_arcada
      |_nofrendo_arcada.ino
      |_etc.

Can be accessed via the Arduino IDE's File > Sketchbook > nofrendo_arcada > nofrendo_arcada menu. But it's your choice of course.

if you can help adjust the builder so it looks in subfolders, that would be great cause this project is kinda bonkers-looking due to having to flatten all the c and h files into the top level

arduino-builder already does recursive compilation of the src subfolder of the sketch folder. You can put only the primary .ino file and any other files you want to expose to the user (files in subfolders of the sketch are not opened as tabs in the Arduino IDE) and then organize the rest of the files in any folder structure you like under the src folder. You only need to update the #include directives accordingly. For example, if emuapi.h was moved to src/emuapi.h, you would need to change line 2 of nofrendo_arcada.ino to:

#include "src/emuapi.h"
ladyada commented 5 years ago

hmm that would be way better i think! especially if there were subfolders. does it work for .c files as well as .cpp?

per1234 commented 5 years ago

Yes, it recursively compiles .c files under the src subfolder of the sketch folder as well.

It's a really nice feature that was added a few years ago, but has not been documented so a lot of users don't know about it. I have used it to bundle libraries with a sketch when I wanted to send it to an unexperienced friend as a complete package so they wouldn't need to go through the extra complexity of library installations to get started.

Marlin has hundreds of files, but most users only even need to see a couple of these, so that was a big improvement in usability when they moved the rest to the src folder.

ladyada commented 5 years ago

ok if you're feeling up to it you could try putting these files in src & it would be incredibly appreciated (i'm a little weary of this repo as its been many weekends of work so far :)

per1234 commented 5 years ago

I'd be happy to. Do you just want all the files except nofrendo_arcada.ino moved directly under the src folder?

ladyada commented 5 years ago

yes! omg thank you :)

ladyada commented 5 years ago

(and if its possible, move the mapXXX to a 'mappers' folder, but not necessary, just makes it a little tidier)