From 127da9e4aa78d4e26484db2a8daa3f05d90e27fa Mon Sep 17 00:00:00 2001 From: Ying Wang Date: Tue, 22 Sep 2015 14:37:53 -0700 Subject: [PATCH] Use md5sum as the build.ninja filename suffix if the suffix gets too long. Use md5sum as the build.ninja filename suffix if the suffix is longer than 64 characters. Also store the original suffix in a corresponding .suf file for human lookup. This fixes the "File name too long" error when kati tries to write to build.ninja with the long original suffix. Bug: 24302576 Change-Id: Ie04b0c14e1a9d593aa5c2a6b357b19a9e8a7158e --- core/config.mk | 4 ++++ core/ninja.mk | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/config.mk b/core/config.mk index e7a1d2020..dd0dfc2d8 100644 --- a/core/config.mk +++ b/core/config.mk @@ -23,6 +23,10 @@ define newline endef +# The pound character "#" +define pound +# +endef # Unfortunately you can't simply define backslash as \ or \\. backslash := \a backslash := $(patsubst %a,%,$(backslash)) diff --git a/core/ninja.mk b/core/ninja.mk index 56b4ac565..2aa0b283a 100644 --- a/core/ninja.mk +++ b/core/ninja.mk @@ -73,8 +73,26 @@ ifneq ($(BUILD_MODULES_IN_PATHS),) KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-mmma-$(call replace_space_and_slash,$(BUILD_MODULES_IN_PATHS)) endif +my_checksum_suffix := +ifneq ($(KATI_NINJA_SUFFIX),) +my_ninja_suffix_too_long := $(filter 1, $(shell v='$(KATI_NINJA_SUFFIX)' && echo $$(($${$(pound)v} > 64)))) +ifneq ($(my_ninja_suffix_too_long),) +# Replace the suffix with a checksum if it gets too long. +my_checksum_suffix := $(KATI_NINJA_SUFFIX) +KATI_NINJA_SUFFIX := -$(word 1, $(shell echo $(my_checksum_suffix) | $(MD5SUM))) +endif +endif + KATI_BUILD_NINJA := $(PRODUCT_OUT)/build$(KATI_NINJA_SUFFIX).ninja KATI_NINJA_SH := $(PRODUCT_OUT)/ninja$(KATI_NINJA_SUFFIX).sh + +# Write out a file mapping checksum to the real suffix. +ifneq ($(my_checksum_suffix),) +my_ninja_suffix_file := $(basename $(KATI_BUILD_NINJA)).suf +$(shell mkdir -p $(dir $(my_ninja_suffix_file)) && \ + echo $(my_checksum_suffix) > $(my_ninja_suffix_file)) +endif + KATI_OUTPUTS := $(KATI_BUILD_NINJA) $(KATI_NINJA_SH) ifeq (,$(NINJA_STATUS)) @@ -115,7 +133,6 @@ $(KATI_OUTPUTS): kati.intermediate $(KATI_FORCE) .INTERMEDIATE: kati.intermediate kati.intermediate: $(KATI) $(MAKEPARALLEL) @echo Running kati to generate build$(KATI_NINJA_SUFFIX).ninja... - @#TODO: use separate ninja file for mm or single target build +$(hide) $(KATI_MAKEPARALLEL) $(KATI) --ninja --ninja_dir=$(PRODUCT_OUT) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo --use_find_emulator $(KATI_REMOTE_NUM_JOBS_FLAG) -f build/core/main.mk $(or $(KATI_TARGETS),--gen_all_phony_targets) USE_NINJA=false KATI_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CPPFLAGS) -- 2.11.0