From 78cec80ed2ff120fb1b2b5ede18e3a4b325d30bd Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Wed, 1 Oct 2014 23:23:27 -0700 Subject: [PATCH] Bug 1065306 - Part 2: Extract generated_file_template. r=mshal This was essentially mechanical: s/$/$$/; s/suggestedsites/$(1)/; move libs realchrome:: and GARBAGE rules into template. I feel like there should be a more direct form of $$($(1)), but I can't think of it. --- mobile/android/base/locales/Makefile.in | 29 +++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/mobile/android/base/locales/Makefile.in b/mobile/android/base/locales/Makefile.in index 00e02f186095..a5287e3b7a32 100644 --- a/mobile/android/base/locales/Makefile.in +++ b/mobile/android/base/locales/Makefile.in @@ -31,13 +31,8 @@ GARBAGE += $(strings-xml) dir-res-raw := ../res/raw suggestedsites := $(dir-res-raw)/suggestedsites.json -GARBAGE += \ - $(suggestedsites) \ - $(NULL) - libs realchrome:: \ $(strings-xml) \ - $(suggestedsites) \ $(NULL) chrome-%:: AB_CD=$* @@ -94,21 +89,33 @@ $(dir-strings-xml)/strings.xml: $(strings-xml-preqs) $< \ -o $@) -suggestedsites-srcdir := $(if $(filter en-US,$(AB_CD)),,$(or $(realpath $(L10NBASEDIR)),$(abspath $(L10NBASEDIR)))/$(AB_CD)/mobile/chrome) +# Arg 1: Valid Make identifier, like suggestedsites. +# Arg 2: File name, like suggestedsites.json. +define generated_file_template # Determine the ../res/raw[-*] path. This can be ../res/raw when no # locale is explicitly specified. -suggestedsites-bypath = $(filter %/suggestedsites.json,$(MAKECMDGOALS)) -ifeq (,$(strip $(suggestedsites-bypath))) - suggestedsites-bypath = $(suggestedsites) +$(1)-bypath = $(filter %/$(2),$(MAKECMDGOALS)) +ifeq (,$$(strip $$($(1)-bypath))) + $(1)-bypath = $($(1)) endif -suggestedsites-dstdir-raw = $(patsubst %/,%,$(dir $(suggestedsites-bypath))) +$(1)-dstdir-raw = $$(patsubst %/,%,$$(dir $$($(1)-bypath))) + +GARBAGE += $($(1)) + +libs realchrome:: $($(1)) +endef + +# L10NBASEDIR is not defined for en-US. +l10n-srcdir := $(if $(filter en-US,$(AB_CD)),,$(or $(realpath $(L10NBASEDIR)),$(abspath $(L10NBASEDIR)))/$(AB_CD)/mobile/chrome) + +$(eval $(call generated_file_template,suggestedsites,suggestedsites.json)) $(suggestedsites-dstdir-raw)/suggestedsites.json: FORCE $(call py_action,generate_suggestedsites, \ --verbose \ --android-package-name=$(ANDROID_PACKAGE_NAME) \ --resources=$(srcdir)/../resources \ - $(if $(filter en-US,$(AB_CD)),,--srcdir=$(suggestedsites-srcdir)) \ + $(if $(filter en-US,$(AB_CD)),,--srcdir=$(l10n-srcdir)) \ --srcdir=$(topsrcdir)/mobile/locales/en-US/chrome \ $@)