-
Notifications
You must be signed in to change notification settings - Fork 447
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(options): add SRC_DIR var to allow sources to live in a subfolder #406
base: master
Are you sure you want to change the base?
Conversation
+1 for this, having a Makefile in the project's root and the project's source in the @sudar What's needed for this to be merged? And can you trigger Travis again? Seems like it got stuck on something unrelated. |
@sej7278 What are your thoughts on this? I don't see a way to restart the Travis test again. Let me see if I can manually trigger it somehow. |
i know the ide is going to support searching the src/ subdirectory in 1.6.10 instead of recursively scanning all subdirectories that it currently does in 1.6.9 - which breaks cached rebuilds and you have to could we append rather than overwrite the variables, so we can use the current directory as well as the src/ subdirectory? as it is if i'd rather we followed the ide and hardcoded -LOCAL_C_SRCS ?= $(wildcard *.c)
-LOCAL_CPP_SRCS ?= $(wildcard *.cpp)
-LOCAL_CC_SRCS ?= $(wildcard *.cc)
-LOCAL_PDE_SRCS ?= $(wildcard *.pde)
-LOCAL_INO_SRCS ?= $(wildcard *.ino)
-LOCAL_AS_SRCS ?= $(wildcard *.S)
+SRC_DIR ?= src
+LOCAL_C_SRCS ?= $(wildcard $(SRC_DIR)/*.c *.c)
+LOCAL_CPP_SRCS ?= $(wildcard $(SRC_DIR)/*.cpp *.cpp)
+LOCAL_CC_SRCS ?= $(wildcard $(SRC_DIR)/*.cc *.cc)
+LOCAL_PDE_SRCS ?= $(wildcard $(SRC_DIR)/*.pde *.pde)
+LOCAL_INO_SRCS ?= $(wildcard $(SRC_DIR)/*.ino *.ino)
+LOCAL_AS_SRCS ?= $(wildcard $(SRC_DIR)/*.S *.S) by using BOARD_TAG = leonardo
MONITOR_PORT = /dev/ttyACM0
ARDUINO_LIBS = WiiChuck Wire Servo
USER_LIB_PATH = src/libs
include $(HOME)/Arduino-Makefile/Arduino.mk
need to add some info to HISTORY.md and arduino-mk-vars.md pip keeps breaking travis for some reason, temp files not being cleared or something. |
But isn't only using |
yes its a good point perhaps its better to explicitly set the SRC_DIR (or not) rather than also include files from the CWD that may confuse things. you'd have to document that you need a trailing / |
we should probably output
diff --git a/Arduino.mk b/Arduino.mk
index 322ca38..7957a34 100644
--- a/Arduino.mk
+++ b/Arduino.mk
@@ -762,12 +762,12 @@ endif
########################################################################
# Local sources
-LOCAL_C_SRCS ?= $(wildcard *.c)
-LOCAL_CPP_SRCS ?= $(wildcard *.cpp)
-LOCAL_CC_SRCS ?= $(wildcard *.cc)
-LOCAL_PDE_SRCS ?= $(wildcard *.pde)
-LOCAL_INO_SRCS ?= $(wildcard *.ino)
-LOCAL_AS_SRCS ?= $(wildcard *.S)
+LOCAL_C_SRCS ?= $(wildcard $(SRC_DIR)*.c)
+LOCAL_CPP_SRCS ?= $(wildcard $(SRC_DIR)*.cpp)
+LOCAL_CC_SRCS ?= $(wildcard $(SRC_DIR)*.cc)
+LOCAL_PDE_SRCS ?= $(wildcard $(SRC_DIR)*.pde)
+LOCAL_INO_SRCS ?= $(wildcard $(SRC_DIR)*.ino)
+LOCAL_AS_SRCS ?= $(wildcard $(SRC_DIR)*.S)
LOCAL_SRCS = $(LOCAL_C_SRCS) $(LOCAL_CPP_SRCS) \
$(LOCAL_CC_SRCS) $(LOCAL_PDE_SRCS) \
$(LOCAL_INO_SRCS) $(LOCAL_AS_SRCS)
@@ -780,6 +780,10 @@ ifeq ($(words $(LOCAL_SRCS)), 0)
$(error At least one source file (*.ino, *.pde, *.cpp, *c, *cc, *.S) is needed)
endif
+ifdef SRC_DIR
+ $(call show_config_variable,SRC_DIR,[USER])
+endif
+
# CHK_SOURCES is used by flymake
# flymake creates a tmp file in the same directory as the file under edition
# we must skip the verification in this particular case Might be worth merging #429 into this commit too, as its the same area of code....? |
👍
Even though that PR touches parts of the same code there doesn't seem to be a real relation between these 2 issues/PRs and there's value in both of them separate from the other one, so I'd leave them as separate PRs. |
i just meant this is going to totally break that PR, so maybe it would be nice to figure out a way around that. otherwise if we can get SRC_DIR documented and HISTORY.md updated, it should be good to merge i guess. |
Well, one of them has to rebase anyway ;) |
Do you still think this PR makes sense? If yes, then I can update the Readme and documentation and trigger the Travis CI again. If not, we can close it. |
its a nice idea, and it looks like it should merge ok 👍 |
Can you please add a note about the changes in the |
@@ -762,12 +762,12 @@ endif | |||
######################################################################## | |||
# Local sources | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excited to see this!
May I suggest:
SRC_DIR ?= $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) |
This would default SRC_DIR to the location of the users Makefile. Since it would then always be defined, you could then print it in configuration vars without it being weird and use slash notation in your wildcard searches (if you cared to).
Would fix #267.