Multiple Makefiles in a Single Project


#1

Hi, I am falling in love with Atom, but that’s off topic.

Do any of the makefile / build packages support a project where there is more than one Makefile (for multiple components)? So far I’ve tried build, build-tools and makro.

Here is the big picture:

I’m working on three different platforms, using c/c++ (arduino, ios) and coffeescript+node.js on the Pi. I’d like to not split the project into three by platform. And that doesn’t help in the case of arduino, where there in addition to the app source, there are multiple test / prototype programs that I make need to build and upload to the board to diagnose problems.

Any direction would be helpful, I’m not afraid to get in there and do some coding. I have quite a bit of experience writing coffeescript and node.js apps. If none of the packages have this feature, which would be easiest to add it too?

What I had in mind as a simple hack to makro was to make it look backwards from the path of the current file open in the editor, find the first Makefile … and done. But I’d really like to get the colorized output and clickable errors that build and build-tools offer.

Thanks!


#2

There are 4 ways to use multiple Makefiles in build-tools:

  1. Split the project into three by platform and configure the make commands with my package’s settings-view. build-tools looks backwards from the path of the current file until it finds a folder with configured commands, so even if you go back to having only one large project folder it would still find the correct Makefile to execute.

  2. Configure multiple make commands in the large project. It’s easier to manage but then it would not choose the correct Makefile based on the currently active file.

  3. build-tools supports different configurations for different folders of a project but it’s beta and involves editing CSON files manually instead of using the settings page.

  4. As a last resort you could create a bash script which looks for the correct Makefile manually using the %f wildcard.

Hope this helps.


#3

Thanks for the reply. It was really helpful. I created a simple shell script as you suggested as a last resort. I think it works (makefile.sh in root dir):

#!/bin/bash
cd `dirname $1` && make $2 

I can now open up the analogRead.ino file and do ctrl+l ctrl+l and build / upload. Yay! Now If I could just figure out how to navigate to the build errors.

I


#4

My package reads build errors from the command’s output using so called “profiles”. Your build command has its highlighting options set to “Highlight tags”, which is a really simple profile that only highlights one line of the error message and you cannot click on them.
For avr-g++ you should probably use the GCC/Clang profile for stderr and no highlighting for stdout (you can copy the highlighting options from my example screenshot).
To display and navigate build errors you need linter.
Unfortunately though my GCC/Clang profile does not support arduino file extensions (yet), so you must wait until I upgrade it to v3.6.1.

EDIT: 3 Things:

  1. I released v3.6.1 with arduino support.
  2. You need either language-arduino or language-ino (but I assume you already have one of those)
  3. Instead of using your shell script you can also set Command to make and Working Directory to %d and enable wildcards.

#5

I just installed you’re latest update. Well done! Everything totally works as expected with the settings below.

BTW, I’m maintaining an Arduino makefile that works with the latest version of Arduino client on mac. https://github.com/littlebee/arduino-mk