-
Notifications
You must be signed in to change notification settings - Fork 165
Difference in sed invocation between Linux and OSX #233
Description
The invocations of sed are different between OSX and Linux during the build (relative lines linked below), this means the OSX version correctly handles leading forward slashes due to the different delimiter used for sed, =. But forward slashes do not work for Linux without being escaped. Such that setting FROZEN_MPY_DIR=/frozens causes a syntax error and the build to fail later with no frozen files for mpy-cross to build.
pycom-micropython-sigfox/py/mkrules.mk
Lines 109 to 125 in f517b1d
| ifneq ($(FROZEN_MPY_DIR),) | |
| OS_NAME := $(shell uname -s) | |
| ifeq ($(OS_NAME), Linux) | |
| # make a list of all the .py files that need compiling and freezing | |
| FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR)/Base/ -type f -name '*.py' | $(SED) -e 's/$(FROZEN_MPY_DIR)\/Base\///') | |
| FROZEN_MPY_PY_FILES += $(shell find -L $(FROZEN_MPY_DIR)/Common/ -type f -name '*.py' | $(SED) -e 's/$(FROZEN_MPY_DIR)\/Common\///') | |
| ifeq ($(BOARD), $(filter $(BOARD), GPY FIPY)) | |
| FROZEN_MPY_PY_FILES += $(shell find -L $(FROZEN_MPY_DIR)/LTE/ -type f -name '*.py' | $(SED) -e 's/$(FROZEN_MPY_DIR)\/LTE\///') | |
| endif | |
| else | |
| # make a list of all the .py files that need compiling and freezing | |
| FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR)/Base/ -type f -name '*.py' | $(SED) -e 's=^$(FROZEN_MPY_DIR)\/Base\//==') | |
| FROZEN_MPY_PY_FILES += $(shell find -L $(FROZEN_MPY_DIR)/Common/ -type f -name '*.py' | $(SED) -e 's=^$(FROZEN_MPY_DIR)\/Common\//==') | |
| ifeq ($(BOARD), $(filter $(BOARD), GPY FIPY)) | |
| FROZEN_MPY_PY_FILES += $(shell find -L $(FROZEN_MPY_DIR)/LTE/ -type f -name '*.py' | $(SED) -e 's=^$(FROZEN_MPY_DIR)\/LTE\//==') | |
| endif | |
| endif |
I propose bringing these two in line, the only fundamental difference, other than the delimiter of the two sed invocations is the leading ^, is there a real world need for this match? If not, the sed command for both OSX and Linux can be the same.
I've changed my end to use
ifneq ($(FROZEN_MPY_DIR),)
OS_NAME := $(shell uname -s)
ifeq ($(OS_NAME), Linux)
# make a list of all the .py files that need compiling and freezing
FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR)/Base/ -type f -name '*.py' | $(SED) -e 's=$(FROZEN_MPY_DIR)\/Base\/==')
FROZEN_MPY_PY_FILES += $(shell find -L $(FROZEN_MPY_DIR)/Common/ -type f -name '*.py' | $(SED) -e 's=$(FROZEN_MPY_DIR)\/Common\/==')
ifeq ($(BOARD), $(filter $(BOARD), GPY FIPY))
FROZEN_MPY_PY_FILES += $(shell find -L $(FROZEN_MPY_DIR)/LTE/ -type f -name '*.py' | $(SED) -e 's=$(FROZEN_MPY_DIR)\/LTE\/==')
endif
else
# make a list of all the .py files that need compiling and freezing
FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR)/Base/ -type f -name '*.py' | $(SED) -e 's=^$(FROZEN_MPY_DIR)\/Base\//==')
FROZEN_MPY_PY_FILES += $(shell find -L $(FROZEN_MPY_DIR)/Common/ -type f -name '*.py' | $(SED) -e 's=^$(FROZEN_MPY_DIR)\/Common\//==')
ifeq ($(BOARD), $(filter $(BOARD), GPY FIPY))
FROZEN_MPY_PY_FILES += $(shell find -L $(FROZEN_MPY_DIR)/LTE/ -type f -name '*.py' | $(SED) -e 's=^$(FROZEN_MPY_DIR)\/LTE\//==')
endif
endif
Note: I would prefer to do away with ifeq ($(OS_NAME), Linux) entirely.
This has resolved my issue with having frozens stored at the root, /frozen
I can create a pull request for this, firstly I would like to know why the "start of match" character, ^ is required. I cannot test on OSX.
Side Note: The build should probably fail if find/sed terminates with a non zero return value.
Thanks