makefile: improved the way options.mk files are included
parent
b8156b4329
commit
0a9f4ec61d
|
@ -32,25 +32,11 @@ KEYBOARD_LAYOUTS := \
|
|||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
CURDIRS := $(CURDIR) $(CURDIRS)
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/eeprom
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/twi
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/layout/eeprom-macro
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/layout/key-functions
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/layout/layer-stack
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(firstword $(CURDIRS))
|
||||
CURDIRS := $(wordlist 2,$(words $(CURDIRS)),$(CURDIRS))
|
||||
$(call include_options_once,lib/eeprom)
|
||||
$(call include_options_once,lib/twi)
|
||||
$(call include_options_once,lib/layout/eeprom-macro)
|
||||
$(call include_options_once,lib/layout/key-functions)
|
||||
$(call include_options_once,lib/layout/layer-stack)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ void eeprom__write (uint8_t * address, uint8_t data);
|
|||
|
||||
// === eeprom__write() ===
|
||||
/** functions/eeprom__write/description
|
||||
* Write `data` to `address` in the EEPROM memory space
|
||||
* Schedule a write to `address` in the EEPROM memory space
|
||||
*
|
||||
* Arguments:
|
||||
* - `address: The address of (i.e. a pointer to) the location to operate on
|
||||
|
@ -78,5 +78,10 @@ void eeprom__write (uint8_t * address, uint8_t data);
|
|||
* - If possible, writing `0xFF` should clear the memory (without writing
|
||||
* anything), and writing to a location currently set to `0xFF` should write
|
||||
* without clearing first.
|
||||
*
|
||||
* - If possible, this function should "schedule" writes to the EEPROM; that
|
||||
* is, it should keep track of what needs to be written and write it more or
|
||||
* less as soon as possible, but return quickly after it's called without
|
||||
* waiting for the write (or even previous writes) to finish.
|
||||
*/
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@ uint8_t eeprom__read(uint8_t * address) {
|
|||
*
|
||||
* - This function starts the write to the EEPROM, but returns long before it
|
||||
* has been completed.
|
||||
*
|
||||
* TODO: this should *schedule* writes
|
||||
*/
|
||||
void eeprom__write(uint8_t * address, uint8_t data) {
|
||||
|
||||
|
|
|
@ -158,15 +158,14 @@ struct macro_header {
|
|||
|
||||
struct log_header {
|
||||
uint8_t type;
|
||||
uint8_t run_length[2];
|
||||
uint8_t run_length;
|
||||
};
|
||||
|
||||
enum {
|
||||
HEADER_DELETED,
|
||||
HEADER_MACRO,
|
||||
MACRO,
|
||||
LOG_ATOMIC_WRITE,
|
||||
LOG_ATOMIC_COPY,
|
||||
HEADER_NULL = 0xFF,
|
||||
HEADER_NULL = 0xFF
|
||||
};
|
||||
|
||||
struct macro_action {
|
||||
|
|
|
@ -28,13 +28,31 @@ TARGET := firmware
|
|||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
include_options = \
|
||||
$(eval INCLUDED := $(1) $(INCLUDED)) \
|
||||
$(eval CURDIRS := $(CURDIR) $(CURDIRS)) \
|
||||
$(eval CURDIR := $(ROOTDIR)/$(1)) \
|
||||
$(eval include $(CURDIR)/options.mk) \
|
||||
$(eval CURDIR := $(firstword $(CURDIRS))) \
|
||||
$(eval CURDIRS := $(wordlist 2,$(words $(CURDIRS)),$(CURDIRS)))
|
||||
|
||||
include_options_once = \
|
||||
$(if $(findstring $(1),$(INCLUDED)), \
|
||||
, \
|
||||
$(call include_options,$(1)))
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
.PHONY: default-target
|
||||
default-target: all
|
||||
# (to retain default behavior when included makefiles specify dependencies)
|
||||
|
||||
CURDIR := .
|
||||
ROOTDIR := .
|
||||
# note: by default, `CURDIR` is initialized to (an absolute path to) the
|
||||
# current working directory
|
||||
CURDIR := .
|
||||
ROOTDIR := .
|
||||
INCLUDED :=
|
||||
# for including sub-makefiles
|
||||
# - by default, `CURDIR` is initialized to (an absolute path to) the
|
||||
# current working directory
|
||||
|
||||
SRC :=
|
||||
CFLAGS :=
|
||||
|
@ -42,23 +60,11 @@ LDFLAGS :=
|
|||
GENDEPFLAGS :=
|
||||
# (initialize variables, so we can use `+=` below and in the included files)
|
||||
|
||||
CURDIRS := $(CURDIR) $(CURDIRS)
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/keyboard/$(KEYBOARD_NAME)
|
||||
include $(CURDIR)/options.mk
|
||||
# (the place for everything a keyboard implementation might want to change)
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/usb
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/timer
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(ROOTDIR)/lib/data-types/list
|
||||
include $(CURDIR)/options.mk
|
||||
# -------
|
||||
CURDIR := $(firstword $(CURDIRS))
|
||||
CURDIRS := $(wordlist 2,$(words $(CURDIRS)),$(CURDIRS))
|
||||
|
||||
$(call include_options_once,keyboard/$(KEYBOARD_NAME))
|
||||
$(call include_options_once,lib/usb)
|
||||
$(call include_options_once,lib/timer)
|
||||
$(call include_options_once,lib/data-types/list)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue