Restrict characters in module names
See the Changes.md documentation for more information. Test: build_test on downstream branches Change-Id: I1524b1dbfd44a7feac3b9a212f37986f870bd837
This commit is contained in:
parent
acbfc3fb94
commit
bbe6a022a3
11
Changes.md
11
Changes.md
|
@ -1,5 +1,16 @@
|
|||
# Build System Changes for Android.mk Writers
|
||||
|
||||
## Valid Module Names {#name}
|
||||
|
||||
We've adopted lexical requirements very similar to [Bazel's
|
||||
requirements](https://docs.bazel.build/versions/master/build-ref.html#name) for
|
||||
target names. Valid characters are `a-z`, `A-Z`, `0-9`, and the special
|
||||
characters `_.+-=,@~/`. This currently applies to `LOCAL_PACKAGE_NAME`,
|
||||
`LOCAL_MODULE`, and `LOCAL_MODULE_SUFFIX`, and `LOCAL_MODULE_STEM*`.
|
||||
|
||||
Many other characters already caused problems if you used them, so we don't
|
||||
expect this to have a large effect.
|
||||
|
||||
## PATH Tools {#PATH_Tools}
|
||||
|
||||
The build has started restricting the external host tools usable inside the
|
||||
|
|
|
@ -31,6 +31,7 @@ LOCAL_MODULE := $(strip $(LOCAL_MODULE))
|
|||
ifeq ($(LOCAL_MODULE),)
|
||||
$(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
|
||||
endif
|
||||
$(call verify-module-name)
|
||||
|
||||
LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
|
||||
LOCAL_IS_AUX_MODULE := $(strip $(LOCAL_IS_AUX_MODULE))
|
||||
|
|
|
@ -1,20 +1,26 @@
|
|||
my_multilib_stem := $(LOCAL_MODULE_STEM_$(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32))
|
||||
ifdef my_multilib_stem
|
||||
my_module_stem := $(my_multilib_stem)
|
||||
$(call verify-module-stem,my_multilib_stem)
|
||||
else ifdef LOCAL_MODULE_STEM
|
||||
my_module_stem := $(LOCAL_MODULE_STEM)
|
||||
$(call verify-module-stem,LOCAL_MODULE_STEM)
|
||||
else
|
||||
my_module_stem := $(LOCAL_MODULE)
|
||||
endif
|
||||
|
||||
ifdef LOCAL_BUILT_MODULE_STEM
|
||||
my_built_module_stem := $(LOCAL_BUILT_MODULE_STEM)
|
||||
$(call verify-module-stem,LOCAL_BUILT_MODULE_STEM)
|
||||
else
|
||||
my_built_module_stem := $(my_module_stem)$(LOCAL_MODULE_SUFFIX)
|
||||
$(call verify-module-stem,LOCAL_MODULE_SUFFIX)
|
||||
endif
|
||||
|
||||
ifdef LOCAL_INSTALLED_MODULE_STEM
|
||||
my_installed_module_stem := $(LOCAL_INSTALLED_MODULE_STEM)
|
||||
$(call verify-module-stem,LOCAL_INSTALLED_MODULE_STEM)
|
||||
else
|
||||
my_installed_module_stem := $(my_module_stem)$(LOCAL_MODULE_SUFFIX)
|
||||
$(call verify-module-stem,LOCAL_MODULE_SUFFIX)
|
||||
endif
|
||||
|
|
|
@ -3456,10 +3456,18 @@ $(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.
|
||||
###########################################################
|
||||
## 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.
|
||||
###########################################################
|
||||
## 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
|
||||
|
@ -3476,3 +3484,36 @@ endif
|
|||
|
||||
lower :=
|
||||
upper :=
|
||||
|
||||
###########################################################
|
||||
## Verify module name meets character requirements:
|
||||
## a-z A-Z 0-9
|
||||
## _.+-=,@~/
|
||||
##
|
||||
## This is equivalent to bazel's target name restrictions:
|
||||
## https://docs.bazel.build/versions/master/build-ref.html#name
|
||||
###########################################################
|
||||
define verify-module-name
|
||||
$(if $(call _invalid-name-chars,$(LOCAL_MODULE)), \
|
||||
$(call pretty-error,Invalid characters in module name: $(call _invalid-name-chars,$(LOCAL_MODULE))))
|
||||
endef
|
||||
define _invalid-name-chars
|
||||
$(subst /,,$(subst _,,$(subst .,,$(subst +,,$(subst -,,$(subst =,,$(subst $(comma),,$(subst @,,$(subst ~,,$(subst 0,,$(subst 1,,$(subst 2,,$(subst 3,,$(subst 4,,$(subst 5,,$(subst 6,,$(subst 7,,$(subst 8,,$(subst 9,,$(subst a,,$(subst b,,$(subst c,,$(subst d,,$(subst e,,$(subst f,,$(subst g,,$(subst h,,$(subst i,,$(subst j,,$(subst k,,$(subst l,,$(subst m,,$(subst n,,$(subst o,,$(subst p,,$(subst q,,$(subst r,,$(subst s,,$(subst t,,$(subst u,,$(subst v,,$(subst w,,$(subst x,,$(subst y,,$(subst z,,$(call to-lower,$(1)))))))))))))))))))))))))))))))))))))))))))))))
|
||||
endef
|
||||
.KATI_READONLY := verify-module-name _invalid-name-chars
|
||||
|
||||
###########################################################
|
||||
## Verify module stem meets character requirements:
|
||||
## a-z A-Z 0-9
|
||||
## _.+-=,@~/
|
||||
##
|
||||
## This is a subset of bazel's target name restrictions:
|
||||
## https://docs.bazel.build/versions/master/build-ref.html#name
|
||||
##
|
||||
## $(1): The module stem variable to check
|
||||
###########################################################
|
||||
define verify-module-stem
|
||||
$(if $(call _invalid-name-chars,$($(1))), \
|
||||
$(call pretty-error,Invalid characters in module stem ($(1)): $(call _invalid-name-chars,$($(1)))))
|
||||
endef
|
||||
.KATI_READONLY := verify-module-stem
|
||||
|
|
Loading…
Reference in New Issue