Merge pull request #35862 from mansnils:MbedBuildGeneration

PiperOrigin-RevId: 292400516
Change-Id: I04bfa9c605c656d4bbdcdd79402c79cacc0cb248
This commit is contained in:
TensorFlower Gardener 2020-01-30 12:29:47 -08:00
commit a59426a65c

View File

@ -2,6 +2,9 @@
# Reverses a space-separated list of words.
reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))
# Get macros only (i.e. the ones starting with -D) from two lists and remove duplicates
getmacros = $(patsubst -D%,%,$(filter -D%,$(sort $(filter -D%, $(1)) $(filter -D%, $(2)))))
# Look for platform or target-specific implementation files to replace reference
# implementations with, given a tag. These are expected to occur in subfolders
# of a directory where a reference implementation exists, and have the same
@ -92,6 +95,12 @@ $(PRJDIR)$(3)/$(1)/.vscode/tasks.json : tensorflow/lite/micro/tools/make/templat
@cp $$< $$@
generate_$(3)_$(1)_project: $(addprefix $(PRJDIR)$(3)/$(1)/, $(4) $(5) $(2))
ifeq (mbed, $(1))
$(eval macrolist := $(call getmacros, $7, $8))
$(eval jsonfilename := $(PRJDIR)$(3)/$(1)/mbed_app)
@awk 'FNR==NR{ if (/}/) p=NR; next} 1; FNR==(p-1){ n=split("$(macrolist)",a," "); print(" ,\"macros\": [");for (i=1; i <= n; i++){ printf(" \"%s\"", a[i]); if(i<n){printf(",\n")}}printf("\n ]\n")}' \
$(jsonfilename).json $(jsonfilename).json > $(jsonfilename).tmp && mv $(jsonfilename).tmp $(jsonfilename).json
endif
list_$(3)_$(1)_files:
@echo $(4) $(5)