Skip to content
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

[FR] Provide well known path for including a local Makefile #20451

Open
brianredbeard opened this issue Dec 13, 2020 · 0 comments
Open

[FR] Provide well known path for including a local Makefile #20451

brianredbeard opened this issue Dec 13, 2020 · 0 comments
Labels
T: Feature Request Features requested by users.

Comments

@brianredbeard
Copy link

Description

Provide a set of well known file globs/paths for users to incorporate their own build logic without having to worry about merge conflicts or breaking changes.

Background

There are a few concurrent changes happening with relation to how Marlin is developed and tested. Since the 1.0.x branch I've used a Makefile in the root of the project for the management of the project. Moving to the 2.0.x branch required a little bit of re-tooling and incorporating PlatformIO commands instead of my previous avr-gcc commands, but this was not a problem as it was a one time change.

With the work being done on #19640 I may consider swapping some of these back out, though the library management of PlatformIO works well enough and does provide a bit of time savings.

Unfortunately #19981 caught me by surprise as there has never been a Makefile in the root of the project (at least as best I could tell checking all the way back to @boelle tagging 1.0.1 in 2014). Furthermore, the mutations it caused (noted in #20433) added additional annoyance, beyond the simple resolution of merge conflicts.

Personally, it would be nice to have some way of defining my own Makefile.local.mk type file in which I know I can add my own targets while being able to cleanly fast-forward the rest of the repository.

Sample change

I have a mock up in my current repository, which can be seen here:

https://github.com/brianredbeard/marlin-firmware/blob/45faff56f03c219233a08033806ecadcb233b053/Makefile#L1-L16

THIS_FILE := $(lastword $(MAKEFILE_LIST))
EXTRA_MAKEFILES := $(strip $(wildcard Makefile.*.mk))

ifneq ($(EXTRA_MAKEFILES),)
  contents := $(shell echo including extra makefiles $(EXTRA_MAKEFILES))
  include $(EXTRA_MAKEFILES)
endif

list:
	@$(MAKE) -pRrq -f $(THIS_FILE) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
.PHONY: list

In this change set I am establishing a conditional include (in the event that the files exist) of any files matching the pattern Makefile.*.mk will be included into the workflow. Additionally, a new target (list) is added which will enumerate all targets found across the composed Makefile.

Next steps

Discussion of the idea, specifically around: pros, cons, potential areas where this may break or introduce additional problems, etc.

@brianredbeard brianredbeard added the T: Feature Request Features requested by users. label Dec 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: Feature Request Features requested by users.
Projects
None yet
Development

No branches or pull requests

1 participant