Skip to content

Commit cc5301d

Browse files
authored
Merge pull request #525 from tock/make-lib-versions-u8g2
Build system: handle library version updates and update u8g2 library
2 parents c066da5 + 3cc1ed0 commit cc5301d

File tree

6 files changed

+43
-17
lines changed

6 files changed

+43
-17
lines changed

AppMakefile.mk

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,29 @@ $(call check_no_spaces, PACKAGE_NAME)
5757
# Arguments:
5858
# - $(1): Pattern matching all arch-specific library files.
5959
# - $(2): The path to the library.
60+
# - $(3): The uppercase name of the library.
6061
define EXTERN_LIB_BUILD_RULE
6162

6263
ifneq "$$(wildcard $(2)/Makefile.setup)" ""
6364
# Since a Makefile.setup exists, do any setup steps needed to fetch the library.
65+
66+
ifneq "$$(wildcard $(2)/Makefile.version)" ""
67+
# Since a Makefile.version exists, use it to set the necessary dependency.
68+
include $(2)/Makefile.version
69+
70+
$$($(3)_SENTINEL_FILE):
71+
$$(MAKE) -C $(2) -f Makefile.setup all
72+
$$(MAKE) -C $(2) -f Makefile all
73+
74+
$(1): $$($(3)_SENTINEL_FILE) ;
75+
else
76+
# No Makefile.version, so this will work the first time the library is built.
6477
$(1):
6578
$$(MAKE) -C $(2) -f Makefile.setup all
6679
$$(MAKE) -C $(2) -f Makefile all
80+
endif
6781
else
82+
# No setup needed, just build the library the first time.
6883
$(1):
6984
$$(MAKE) -C $(2) -f Makefile all
7085
endif
@@ -90,8 +105,8 @@ $$(notdir $(1))_BUILDDIR ?= $(1)/build
90105
$$(foreach arch, $$(TOCK_ARCHS), $$(eval LIBS_$$(arch) += $$($(notdir $(1))_BUILDDIR)/$$(arch)/$(notdir $(1)).a))
91106

92107
# Generate rule for building the library.
93-
# $$(info $$(call EXTERN_LIB_BUILD_RULE,$$(foreach arch,$$(TOCK_ARCHS),%/$$(arch)/$(notdir $(1)).a),$(1)))
94-
$$(eval $$(call EXTERN_LIB_BUILD_RULE,$$(foreach arch,$$(TOCK_ARCHS),%/$$(arch)/$(notdir $(1)).a),$(1)))
108+
# $$(info $$(call EXTERN_LIB_BUILD_RULE,$$(foreach arch,$$(TOCK_ARCHS),%/$$(arch)/$(notdir $(1)).a),$(1),$(shell echo '$(notdir $(1))' | tr '[:lower:]' '[:upper:]')))
109+
$$(eval $$(call EXTERN_LIB_BUILD_RULE,$$(foreach arch,$$(TOCK_ARCHS),%/$$(arch)/$(notdir $(1)).a),$(1),$(shell echo '$(notdir $(1))' | tr '[:lower:]' '[:upper:]')))
95110

96111
endef
97112

doc/compilation.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ a prerequisite of building the app.
122122
The `Makefile.setup` file should have rules to download the source for the
123123
library.
124124

125+
If a library includes a `Makefile.version` with a `<LIBRARY_NAME>_SENTINEL_FILE`
126+
variable set, that file will be used to determine if the library needs to be
127+
rebuilt.
128+
125129
**Example:** the `u8g2` library uses this.
126130

127131
### Pre-built libraries

u8g2/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# Git hash of the library to use
2-
VERSION_HASH := c4f9cd9f8717661c46be16bfbcb0017d785db3c1
1+
include Makefile.version
32

43
# Base folder definitions
54
TOCK_USERLAND_BASE_DIR ?= ..
65
LIBNAME := u8g2
76
$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/$(LIBNAME)
8-
LIB_SRC_DIR := $($(LIBNAME)_DIR)/u8g2-$(VERSION_HASH)
7+
LIB_SRC_DIR := $($(LIBNAME)_DIR)/u8g2-$(U8G2_VERSION_HASH)
98

109
# List all C and Assembly files
1110
$(LIBNAME)_SRCS_ALL += $(wildcard $(LIB_SRC_DIR)/csrc/u8g2*.c)

u8g2/Makefile.app

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Git hash of the library to use. Must match the hash in Makefile.
2-
U8G2_VERSION_HASH := c4f9cd9f8717661c46be16bfbcb0017d785db3c1
1+
# Git hash of the library to use. Must match the hash in Makefile.version.
2+
U8G2_VERSION_HASH := bde09fbf787892c79a184e88b124aa5c79393aed
33

44
# Base folder definitions
55
U8G2_LIB_DIR := $(TOCK_USERLAND_BASE_DIR)/u8g2

u8g2/Makefile.setup

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,16 @@
22
### Helper Makefile for downloading the U8G2 library and unzipping.
33
###
44

5-
TOCK_USERLAND_BASE_DIR ?= ..
6-
7-
# Git hash of the library to use. Must match the hash in Makefile.
8-
U8G2_VERSION_HASH := c4f9cd9f8717661c46be16bfbcb0017d785db3c1
9-
10-
# Base folder definitions
11-
U8G2_LIB_DIR := $(TOCK_USERLAND_BASE_DIR)/u8g2
12-
U8G2_SRC_DIR := $(U8G2_LIB_DIR)/u8g2-$(U8G2_VERSION_HASH)
5+
include Makefile.version
136

147
# Rules to download the source repository if needed. These are here so that the
158
# expanded library is available before calling into the library Makefile.
169
$(U8G2_SRC_DIR).zip:
1710
curl -L --output $(U8G2_SRC_DIR).zip https://codeload.github.com/olikraus/u8g2/zip/$(U8G2_VERSION_HASH)
1811

1912
# The .h file will exist when the library is unzipped.
20-
$(U8G2_SRC_DIR)/csrc/u8g2.h: | $(U8G2_SRC_DIR).zip
13+
$(U8G2_SENTINEL_FILE): | $(U8G2_SRC_DIR).zip
2114
unzip -q -d $(U8G2_LIB_DIR) $(U8G2_SRC_DIR).zip
2215

2316
# Main rule to check if we need to fetch the library.
24-
all: | $(U8G2_SRC_DIR)/csrc/u8g2.h
17+
all: | $(U8G2_SENTINEL_FILE)

u8g2/Makefile.version

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
###
2+
### Helper Makefile for the version of the library.
3+
###
4+
5+
TOCK_USERLAND_BASE_DIR ?= ..
6+
7+
# Git hash of the library to use. Must match the hash in Makefile.
8+
U8G2_VERSION_HASH := bde09fbf787892c79a184e88b124aa5c79393aed
9+
10+
# Base folder definitions
11+
U8G2_LIB_DIR := $(TOCK_USERLAND_BASE_DIR)/u8g2
12+
U8G2_SRC_DIR := $(U8G2_LIB_DIR)/u8g2-$(U8G2_VERSION_HASH)
13+
14+
# The file we use to determine if the library has been fetched and built.
15+
U8G2_SENTINEL_FILE := $(U8G2_SRC_DIR)/csrc/u8g2.h

0 commit comments

Comments
 (0)