Skip to content

Commit

Permalink
Merge pull request #12248 from cladmi/pr/makefile_base/thin_archive_fix
Browse files Browse the repository at this point in the history
Makefile.base: implement relative path linking without 'realpath'
  • Loading branch information
benpicco authored Sep 16, 2019
2 parents 071c2b2 + a019faa commit 92d5428
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ $(BINDIR)/$(MODULE)/:

$(BINDIR)/$(MODULE).a $(OBJ): | $(BINDIR)/$(MODULE)/

relpath = $(shell realpath --relative-to=$(abspath .) $(1))

# Build the archive from the output directory to create relative thin archives
# This allows having them valid in and outside of docker
$(BINDIR)/$(MODULE).a: $(OBJ) | $(DIRS:%=ALL--%)
@# Recreate archive to cleanup deleted/non selected source files objects
$(Q)$(RM) $@
$(Q)$(AR) $(ARFLAGS) $(foreach f,$@ $^,$(call relpath,$f))
$(Q)cd $(@D) && $(AR) $(ARFLAGS) $(@F) $(subst $(@D)/,,$^)

CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS)
CCASFLAGS = $(filter-out $(CCASUWFLAGS), $(CFLAGS)) $(CCASEXFLAGS)
Expand Down
3 changes: 2 additions & 1 deletion Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,8 @@ endif # BUILD_IN_DOCKER

# Rules to check the correctness of thin archives.

relpath = $(shell realpath --relative-to=$(abspath .) $(1))
# OS independant relpath as 'realpath --relative-to' is not supported on OSx
relpath = $(shell python3 -c 'import pathlib; print(pathlib.Path("$1").relative_to("$(CURDIR)"))')

# Each ARCHECK file contains all the absolute paths found inside the archive.
BASELIB_ARCHECKS = $(patsubst %.a,%.a-check,$(filter %.a,$(BASELIBS)))
Expand Down
2 changes: 1 addition & 1 deletion sys/arduino/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Define application sketches module, it will be generated into $(BINDIR)
SKETCH_MODULE ?= arduino_sketches
SKETCH_MODULE_DIR ?= $(BINDIR)/$(SKETCH_MODULE)_src
SKETCH_MODULE_DIR ?= $(BINDIR)/$(SKETCH_MODULE)
SKETCHES = $(wildcard $(APPDIR)/*.sketch)
include $(RIOTBASE)/sys/arduino/sketches.inc.mk

Expand Down
3 changes: 1 addition & 2 deletions sys/arduino/sketches.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ SKETCH_GENERATED_FILES = $(SKETCH_MODULE_DIR)/Makefile $(SKETCH_MODULE_DIR)/$(SK
# Building the module files
# Do not use $^ in receipes as Makefile is also a prerequisite
$(SKETCH_MODULE_DIR)/Makefile: $(SKETCH_MODULE_DIR)/$(SKETCH_CPP)
$(Q)echo 'MODULE = $(SKETCH_MODULE)' > $@
$(Q)echo 'SRCXX = $(SKETCH_CPP)' >> $@
$(Q)echo 'SRCXX = $(SKETCH_CPP)' > $@
$(Q)echo 'include $$(RIOTBASE)/Makefile.base' >> $@
$(SKETCH_MODULE_DIR)/$(SKETCH_CPP): $(SKETCHES_ALL)
@mkdir -p $(@D)
Expand Down

0 comments on commit 92d5428

Please sign in to comment.