From c49bddfb67752d0f3dd08d127563a7b2123c42f8 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Fri, 21 Sep 2018 16:39:37 -0700 Subject: [PATCH] to-upper and to-lower move to strings.mk So that config.mk can use these functions. Test: builds Change-Id: I6634226cbed56c34977803ff9c75b8d481c21c34 --- core/config.mk | 2 ++ core/definitions.mk | 29 ----------------------------- core/strings.mk | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 core/strings.mk diff --git a/core/config.mk b/core/config.mk index 676bd64278..b34bd2bd2c 100644 --- a/core/config.mk +++ b/core/config.mk @@ -144,6 +144,8 @@ endif # Here since this file is included by envsetup as well as during build. include $(BUILD_SYSTEM)/math.mk +include $(BUILD_SYSTEM)/strings.mk + # Various mappings to avoid hard-coding paths all over the place include $(BUILD_SYSTEM)/pathmap.mk diff --git a/core/definitions.mk b/core/definitions.mk index 743d6675f4..995c95fa7d 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -3442,35 +3442,6 @@ $(filter-out current,\ $(if $(call has-system-sdk-version,$(1)),$(patsubst system_%,%,$(1)),$(1))) endef -########################################################### -## Convert to lower case without requiring a shell, which isn't cacheable. -## -## $(1): string -########################################################### -to-lower=$(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) - -########################################################### -## Convert to upper case without requiring a shell, which isn't cacheable. -## -## $(1): string -########################################################### -to-upper=$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1)))))))))))))))))))))))))) - -# Sanity-check to-lower and to-upper -lower := abcdefghijklmnopqrstuvwxyz-_ -upper := ABCDEFGHIJKLMNOPQRSTUVWXYZ-_ - -ifneq ($(lower),$(call to-lower,$(upper))) - $(error to-lower sanity check failure) -endif - -ifneq ($(upper),$(call to-upper,$(lower))) - $(error to-upper sanity check failure) -endif - -lower := -upper := - ########################################################### ## Verify module name meets character requirements: ## a-z A-Z 0-9 diff --git a/core/strings.mk b/core/strings.mk new file mode 100644 index 0000000000..98dbb0f690 --- /dev/null +++ b/core/strings.mk @@ -0,0 +1,44 @@ +# +# Copyright (C) 2018 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +########################################################### +## Convert to lower case without requiring a shell, which isn't cacheable. +## +## $(1): string +########################################################### +to-lower=$(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1)))))))))))))))))))))))))) + +########################################################### +## Convert to upper case without requiring a shell, which isn't cacheable. +## +## $(1): string +########################################################### +to-upper=$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1)))))))))))))))))))))))))) + +# Sanity-check to-lower and to-upper +lower := abcdefghijklmnopqrstuvwxyz-_ +upper := ABCDEFGHIJKLMNOPQRSTUVWXYZ-_ + +ifneq ($(lower),$(call to-lower,$(upper))) + $(error to-lower sanity check failure) +endif + +ifneq ($(upper),$(call to-upper,$(lower))) + $(error to-upper sanity check failure) +endif + +lower := +upper :=