diff options
| author | Takeshi ISHII <2170248+mtei@users.noreply.github.com> | 2018-12-15 14:31:56 +0900 |
|---|---|---|
| committer | Drashna Jaelre <drashna@live.com> | 2018-12-14 21:31:56 -0800 |
| commit | 8f790948e5f7ed62b2c56e1a6aa63dae89d5c860 (patch) | |
| tree | 5d934ecae5855bf3f907b0ad485e78b42d9c228a /tmk_core | |
| parent | a49d98e665d934c318894cfc9d9813adacd08f11 (diff) | |
| download | qmk_firmware-8f790948e5f7ed62b2c56e1a6aa63dae89d5c860.tar.gz qmk_firmware-8f790948e5f7ed62b2c56e1a6aa63dae89d5c860.zip | |
Refactor quantum/split_common/i2c.c, quantum/split_common/serial.c (#4522)
* add temporary compile test shell script
* Extended support of SKIP_VERSION to make invariant compile results during testing.
* build_keyboard.mk, tmk_core/rules.mk: add LIB_SRC, QUANTUM_LIB_SRC support
Support compiled object enclosed in library.
e.g.
```
LIB_SRC += xxxx.c
xxxx.c --> xxxx.o ---> xxxx.a
```
* remove 'ifdef/ifndef USE_I2C' from quantum/split_common/{i2c|serial}.c
* add SKIP_DEBUG_INFO into tmk_core/rules.mk
When SKIP_DEBUG_INFO=yes is specified, do not use the -g option at compile time.
* tmk_core/rules.mk: Library object need -fno-lto
* add SKIP_DEBUG_INFO=yes
* remove temporary compile test shell script
* add '#define SOFT_SERIAL_PIN D0' to keyboards/lets_split/rev?/config.h
* quantum/split_common/serial.c: Changed not to use USE_I2C.
Diffstat (limited to 'tmk_core')
| -rw-r--r-- | tmk_core/common/command.c | 4 | ||||
| -rw-r--r-- | tmk_core/rules.mk | 36 |
2 files changed, 32 insertions, 8 deletions
diff --git a/tmk_core/common/command.c b/tmk_core/common/command.c index f79d5a257..aab99290d 100644 --- a/tmk_core/common/command.c +++ b/tmk_core/common/command.c | |||
| @@ -181,7 +181,11 @@ static void print_version(void) | |||
| 181 | print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " | 181 | print("VID: " STR(VENDOR_ID) "(" STR(MANUFACTURER) ") " |
| 182 | "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " | 182 | "PID: " STR(PRODUCT_ID) "(" STR(PRODUCT) ") " |
| 183 | "VER: " STR(DEVICE_VER) "\n"); | 183 | "VER: " STR(DEVICE_VER) "\n"); |
| 184 | #ifdef SKIP_VERSION | ||
| 185 | print("BUILD: (" __DATE__ ")\n"); | ||
| 186 | #else | ||
| 184 | print("BUILD: " STR(QMK_VERSION) " (" __TIME__ " " __DATE__ ")\n"); | 187 | print("BUILD: " STR(QMK_VERSION) " (" __TIME__ " " __DATE__ ")\n"); |
| 188 | #endif | ||
| 185 | 189 | ||
| 186 | /* build options */ | 190 | /* build options */ |
| 187 | print("OPTIONS:" | 191 | print("OPTIONS:" |
diff --git a/tmk_core/rules.mk b/tmk_core/rules.mk index ce3cd83b3..2e419dd66 100644 --- a/tmk_core/rules.mk +++ b/tmk_core/rules.mk | |||
| @@ -28,12 +28,13 @@ VPATH := | |||
| 28 | 28 | ||
| 29 | # Convert all SRC to OBJ | 29 | # Convert all SRC to OBJ |
| 30 | define OBJ_FROM_SRC | 30 | define OBJ_FROM_SRC |
| 31 | $(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.cc,$1/%.o,$(patsubst %.S,$1/%.o,$($1_SRC))))) | 31 | $(patsubst %.c,$1/%.o,$(patsubst %.cpp,$1/%.o,$(patsubst %.cc,$1/%.o,$(patsubst %.S,$1/%.o,$(patsubst %.clib,$1/%.a,$($1_SRC)))))) |
| 32 | endef | 32 | endef |
| 33 | $(foreach OUTPUT,$(OUTPUTS),$(eval $(OUTPUT)_OBJ +=$(call OBJ_FROM_SRC,$(OUTPUT)))) | 33 | $(foreach OUTPUT,$(OUTPUTS),$(eval $(OUTPUT)_OBJ +=$(call OBJ_FROM_SRC,$(OUTPUT)))) |
| 34 | 34 | ||
| 35 | # Define a list of all objects | 35 | # Define a list of all objects |
| 36 | OBJ := $(foreach OUTPUT,$(OUTPUTS),$($(OUTPUT)_OBJ)) | 36 | OBJ := $(foreach OUTPUT,$(OUTPUTS),$($(OUTPUT)_OBJ)) |
| 37 | NO_LTO_OBJ := $(filter %.a,$(OBJ)) | ||
| 37 | 38 | ||
| 38 | MASTER_OUTPUT := $(firstword $(OUTPUTS)) | 39 | MASTER_OUTPUT := $(firstword $(OUTPUTS)) |
| 39 | 40 | ||
| @@ -81,7 +82,9 @@ CSTANDARD = -std=gnu99 | |||
| 81 | # -Wall...: warning level | 82 | # -Wall...: warning level |
| 82 | # -Wa,...: tell GCC to pass this to the assembler. | 83 | # -Wa,...: tell GCC to pass this to the assembler. |
| 83 | # -adhlns...: create assembler listing | 84 | # -adhlns...: create assembler listing |
| 84 | CFLAGS += -g$(DEBUG) | 85 | ifndef SKIP_DEBUG_INFO |
| 86 | CFLAGS += -g$(DEBUG) | ||
| 87 | endif | ||
| 85 | CFLAGS += $(CDEFS) | 88 | CFLAGS += $(CDEFS) |
| 86 | CFLAGS += -O$(OPT) | 89 | CFLAGS += -O$(OPT) |
| 87 | # add color | 90 | # add color |
| @@ -110,7 +113,9 @@ CFLAGS += $(CSTANDARD) | |||
| 110 | # -Wall...: warning level | 113 | # -Wall...: warning level |
| 111 | # -Wa,...: tell GCC to pass this to the assembler. | 114 | # -Wa,...: tell GCC to pass this to the assembler. |
| 112 | # -adhlns...: create assembler listing | 115 | # -adhlns...: create assembler listing |
| 113 | CPPFLAGS += -g$(DEBUG) | 116 | ifndef SKIP_DEBUG_INFO |
| 117 | CPPFLAGS += -g$(DEBUG) | ||
| 118 | endif | ||
| 114 | CPPFLAGS += $(CPPDEFS) | 119 | CPPFLAGS += $(CPPDEFS) |
| 115 | CPPFLAGS += -O$(OPT) | 120 | CPPFLAGS += -O$(OPT) |
| 116 | # to supress "warning: only initialized variables can be placed into program memory area" | 121 | # to supress "warning: only initialized variables can be placed into program memory area" |
| @@ -138,7 +143,11 @@ CPPFLAGS += -Wa,-adhlns=$(@:%.o=%.lst) | |||
| 138 | # -listing-cont-lines: Sets the maximum number of continuation lines of hex | 143 | # -listing-cont-lines: Sets the maximum number of continuation lines of hex |
| 139 | # dump that will be displayed for a given single line of source input. | 144 | # dump that will be displayed for a given single line of source input. |
| 140 | ASFLAGS += $(ADEFS) | 145 | ASFLAGS += $(ADEFS) |
| 141 | ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 | 146 | ifndef SKIP_DEBUG_INFO |
| 147 | ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),-gstabs,--listing-cont-lines=100 | ||
| 148 | else | ||
| 149 | ASFLAGS += -Wa,-adhlns=$(@:%.o=%.lst),--listing-cont-lines=100 | ||
| 150 | endif | ||
| 142 | 151 | ||
| 143 | #---------------- Library Options ---------------- | 152 | #---------------- Library Options ---------------- |
| 144 | # Minimalistic printf version | 153 | # Minimalistic printf version |
| @@ -210,6 +219,11 @@ ALL_CFLAGS = $(MCUFLAGS) $(CFLAGS) $(EXTRAFLAGS) | |||
| 210 | ALL_CPPFLAGS = $(MCUFLAGS) -x c++ $(CPPFLAGS) $(EXTRAFLAGS) | 219 | ALL_CPPFLAGS = $(MCUFLAGS) -x c++ $(CPPFLAGS) $(EXTRAFLAGS) |
| 211 | ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) | 220 | ALL_ASFLAGS = $(MCUFLAGS) -x assembler-with-cpp $(ASFLAGS) $(EXTRAFLAGS) |
| 212 | 221 | ||
| 222 | define NO_LTO | ||
| 223 | $(patsubst %.a,%.o,$1): NOLTO_CFLAGS += -fno-lto | ||
| 224 | endef | ||
| 225 | $(foreach LOBJ, $(NO_LTO_OBJ), $(eval $(call NO_LTO,$(LOBJ)))) | ||
| 226 | |||
| 213 | MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@) | 227 | MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@) |
| 214 | 228 | ||
| 215 | 229 | ||
| @@ -290,8 +304,8 @@ $1_INCFLAGS := $$(patsubst %,-I%,$$($1_INC)) | |||
| 290 | ifdef $1_CONFIG | 304 | ifdef $1_CONFIG |
| 291 | $1_CONFIG_FLAGS += $$(patsubst %,-include %,$$($1_CONFIG)) | 305 | $1_CONFIG_FLAGS += $$(patsubst %,-include %,$$($1_CONFIG)) |
| 292 | endif | 306 | endif |
| 293 | $1_CFLAGS = $$(ALL_CFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) | 307 | $1_CFLAGS = $$(ALL_CFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) $$(NOLTO_CFLAGS) |
| 294 | $1_CPPFLAGS= $$(ALL_CPPFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) | 308 | $1_CPPFLAGS= $$(ALL_CPPFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) $$(NOLTO_CFLAGS) |
| 295 | $1_ASFLAGS= $$(ALL_ASFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) | 309 | $1_ASFLAGS= $$(ALL_ASFLAGS) $$($1_DEFS) $$($1_INCFLAGS) $$($1_CONFIG_FLAGS) |
| 296 | 310 | ||
| 297 | # Compile: create object files from C source files. | 311 | # Compile: create object files from C source files. |
| @@ -321,6 +335,12 @@ $1/%.o : %.S $1/asflags.txt $1/compiler.txt | $(BEGIN) | |||
| 321 | $$(eval CMD=$$(CC) -c $$($1_ASFLAGS) $$< -o $$@) | 335 | $$(eval CMD=$$(CC) -c $$($1_ASFLAGS) $$< -o $$@) |
| 322 | @$$(BUILD_CMD) | 336 | @$$(BUILD_CMD) |
| 323 | 337 | ||
| 338 | $1/%.a : $1/%.o | ||
| 339 | @mkdir -p $$(@D) | ||
| 340 | @$(SILENT) || printf "Archiving: $$<" | $$(AWK_CMD) | ||
| 341 | $$(eval CMD=$$(AR) $$@ $$<) | ||
| 342 | @$$(BUILD_CMD) | ||
| 343 | |||
| 324 | $1/force: | 344 | $1/force: |
| 325 | 345 | ||
| 326 | $1/cflags.txt: $1/force | 346 | $1/cflags.txt: $1/force |
| @@ -346,7 +366,7 @@ $(MASTER_OUTPUT)/ldflags.txt: $(MASTER_OUTPUT)/force | |||
| 346 | 366 | ||
| 347 | 367 | ||
| 348 | # We have to use static rules for the .d files for some reason | 368 | # We have to use static rules for the .d files for some reason |
| 349 | DEPS = $(patsubst %.o,%.d,$(OBJ)) | 369 | DEPS = $(patsubst %.o,%.d,$(patsubst %.a,%.o,$(OBJ))) |
| 350 | # Keep the .d files | 370 | # Keep the .d files |
| 351 | .PRECIOUS: $(DEPS) | 371 | .PRECIOUS: $(DEPS) |
| 352 | # Empty rule to force recompilation if the .d file is missing | 372 | # Empty rule to force recompilation if the .d file is missing |
| @@ -391,7 +411,7 @@ $(shell mkdir -p $(BUILD_DIR) 2>/dev/null) | |||
| 391 | $(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null))) | 411 | $(eval $(foreach OUTPUT,$(OUTPUTS),$(shell mkdir -p $(OUTPUT) 2>/dev/null))) |
| 392 | 412 | ||
| 393 | # Include the dependency files. | 413 | # Include the dependency files. |
| 394 | -include $(patsubst %.o,%.d,$(OBJ)) | 414 | -include $(patsubst %.o,%.d,$(patsubst %.a,%.o,$(OBJ))) |
| 395 | 415 | ||
| 396 | 416 | ||
| 397 | # Listing of phony targets. | 417 | # Listing of phony targets. |
