0003-mk-core-ta-Configurable-Python-interpreter.patch 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. From 49c7d2557d92993a1e09e50c961b9d4f7ab1091b Mon Sep 17 00:00:00 2001
  2. From: Dick Olsson <hi@senzilla.io>
  3. Date: Wed, 22 Jul 2020 08:49:12 +0200
  4. Subject: [PATCH] mk: core: ta: Configurable Python interpreter
  5. Build systems that manage multiple different python interpreters need
  6. explicit control over which version of the interpreter to use.
  7. This patch enables one to override the default interpreter with the path
  8. to a specific one.
  9. Signed-off-by: Dick Olsson <hi@senzilla.io>
  10. Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
  11. Reviewed-by: Jerome Forissier <jerome@forissier.org>
  12. ---
  13. core/arch/arm/arm.mk | 2 ++
  14. core/arch/arm/kernel/link.mk | 22 +++++++++++-----------
  15. core/sub.mk | 10 +++++-----
  16. mk/config.mk | 6 ++++++
  17. mk/lib.mk | 2 +-
  18. ta/arch/arm/link.mk | 2 +-
  19. ta/arch/arm/link_shlib.mk | 2 +-
  20. ta/ta.mk | 2 +-
  21. 8 files changed, 28 insertions(+), 20 deletions(-)
  22. diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk
  23. index 5c9f16ef..878035c5 100644
  24. --- a/core/arch/arm/arm.mk
  25. +++ b/core/arch/arm/arm.mk
  26. @@ -245,6 +245,7 @@ ta-mk-file-export-add-ta_arm32 += CROSS_COMPILE32 ?= $$(CROSS_COMPILE)_nl_
  27. ta-mk-file-export-add-ta_arm32 += CROSS_COMPILE_ta_arm32 ?= $$(CROSS_COMPILE32)_nl_
  28. ta-mk-file-export-add-ta_arm32 += COMPILER ?= gcc_nl_
  29. ta-mk-file-export-add-ta_arm32 += COMPILER_ta_arm32 ?= $$(COMPILER)_nl_
  30. +ta-mk-file-export-add-ta_arm32 += PYTHON3 ?= python3_nl_
  31. endif
  32. ifneq ($(filter ta_arm64,$(ta-targets)),)
  33. @@ -275,6 +276,7 @@ ta-mk-file-export-add-ta_arm64 += CROSS_COMPILE64 ?= $$(CROSS_COMPILE)_nl_
  34. ta-mk-file-export-add-ta_arm64 += CROSS_COMPILE_ta_arm64 ?= $$(CROSS_COMPILE64)_nl_
  35. ta-mk-file-export-add-ta_arm64 += COMPILER ?= gcc_nl_
  36. ta-mk-file-export-add-ta_arm64 += COMPILER_ta_arm64 ?= $$(COMPILER)_nl_
  37. +ta-mk-file-export-add-ta_arm64 += PYTHON3 ?= python3_nl_
  38. endif
  39. # Set cross compiler prefix for each TA target
  40. diff --git a/core/arch/arm/kernel/link.mk b/core/arch/arm/kernel/link.mk
  41. index 1b89b895..69375ad6 100644
  42. --- a/core/arch/arm/kernel/link.mk
  43. +++ b/core/arch/arm/kernel/link.mk
  44. @@ -62,13 +62,13 @@ cleanfiles += $(link-out-dir)/text_unpaged.ld.S
  45. $(link-out-dir)/text_unpaged.ld.S: $(link-out-dir)/unpaged.o
  46. @$(cmd-echo-silent) ' GEN $@'
  47. $(q)$(READELFcore) -S -W $< | \
  48. - ./scripts/gen_ld_sects.py .text. > $@
  49. + $(PYTHON3) ./scripts/gen_ld_sects.py .text. > $@
  50. cleanfiles += $(link-out-dir)/rodata_unpaged.ld.S
  51. $(link-out-dir)/rodata_unpaged.ld.S: $(link-out-dir)/unpaged.o
  52. @$(cmd-echo-silent) ' GEN $@'
  53. $(q)$(READELFcore) -S -W $< | \
  54. - ./scripts/gen_ld_sects.py .rodata. > $@
  55. + $(PYTHON3) ./scripts/gen_ld_sects.py .rodata. > $@
  56. cleanfiles += $(link-out-dir)/init_entries.txt
  57. @@ -92,12 +92,12 @@ cleanfiles += $(link-out-dir)/text_init.ld.S
  58. $(link-out-dir)/text_init.ld.S: $(link-out-dir)/init.o
  59. @$(cmd-echo-silent) ' GEN $@'
  60. $(q)$(READELFcore) -S -W $< | \
  61. - ./scripts/gen_ld_sects.py .text. > $@
  62. + $(PYTHON3) ./scripts/gen_ld_sects.py .text. > $@
  63. cleanfiles += $(link-out-dir)/rodata_init.ld.S
  64. $(link-out-dir)/rodata_init.ld.S: $(link-out-dir)/init.o
  65. @$(cmd-echo-silent) ' GEN $@'
  66. - $(q)$(READELFcore) -S -W $< | ./scripts/gen_ld_sects.py .rodata. > $@
  67. + $(q)$(READELFcore) -S -W $< | $(PYTHON3) ./scripts/gen_ld_sects.py .rodata. > $@
  68. -include $(link-script-dep)
  69. @@ -176,39 +176,39 @@ cleanfiles += $(link-out-dir)/tee-pager.bin
  70. $(link-out-dir)/tee-pager.bin: $(link-out-dir)/tee.elf scripts/gen_tee_bin.py
  71. @echo Warning: $@ is deprecated
  72. @$(cmd-echo-silent) ' GEN $@'
  73. - $(q)scripts/gen_tee_bin.py --input $< --out_tee_pager_bin $@
  74. + $(q)$(PYTHON3) scripts/gen_tee_bin.py --input $< --out_tee_pager_bin $@
  75. cleanfiles += $(link-out-dir)/tee-pageable.bin
  76. $(link-out-dir)/tee-pageable.bin: $(link-out-dir)/tee.elf scripts/gen_tee_bin.py
  77. @echo Warning: $@ is deprecated
  78. @$(cmd-echo-silent) ' GEN $@'
  79. - $(q)scripts/gen_tee_bin.py --input $< --out_tee_pageable_bin $@
  80. + $(q)$(PYTHON3) scripts/gen_tee_bin.py --input $< --out_tee_pageable_bin $@
  81. all: $(link-out-dir)/tee.bin
  82. cleanfiles += $(link-out-dir)/tee.bin
  83. $(link-out-dir)/tee.bin: $(link-out-dir)/tee.elf scripts/gen_tee_bin.py
  84. @$(cmd-echo-silent) ' GEN $@'
  85. - $(q)scripts/gen_tee_bin.py --input $< --out_tee_bin $@
  86. + $(q)$(PYTHON3) scripts/gen_tee_bin.py --input $< --out_tee_bin $@
  87. all: $(link-out-dir)/tee-header_v2.bin
  88. cleanfiles += $(link-out-dir)/tee-header_v2.bin
  89. $(link-out-dir)/tee-header_v2.bin: $(link-out-dir)/tee.elf \
  90. scripts/gen_tee_bin.py
  91. @$(cmd-echo-silent) ' GEN $@'
  92. - $(q)scripts/gen_tee_bin.py --input $< --out_header_v2 $@
  93. + $(q)$(PYTHON3) scripts/gen_tee_bin.py --input $< --out_header_v2 $@
  94. all: $(link-out-dir)/tee-pager_v2.bin
  95. cleanfiles += $(link-out-dir)/tee-pager_v2.bin
  96. $(link-out-dir)/tee-pager_v2.bin: $(link-out-dir)/tee.elf scripts/gen_tee_bin.py
  97. @$(cmd-echo-silent) ' GEN $@'
  98. - $(q)scripts/gen_tee_bin.py --input $< --out_pager_v2 $@
  99. + $(q)$(PYTHON3) scripts/gen_tee_bin.py --input $< --out_pager_v2 $@
  100. all: $(link-out-dir)/tee-pageable_v2.bin
  101. cleanfiles += $(link-out-dir)/tee-pageable_v2.bin
  102. $(link-out-dir)/tee-pageable_v2.bin: $(link-out-dir)/tee.elf \
  103. scripts/gen_tee_bin.py
  104. @$(cmd-echo-silent) ' GEN $@'
  105. - $(q)scripts/gen_tee_bin.py --input $< --out_pageable_v2 $@
  106. + $(q)$(PYTHON3) scripts/gen_tee_bin.py --input $< --out_pageable_v2 $@
  107. all: $(link-out-dir)/tee.symb_sizes
  108. cleanfiles += $(link-out-dir)/tee.symb_sizes
  109. @@ -222,5 +222,5 @@ mem_usage: $(link-out-dir)/tee.mem_usage
  110. $(link-out-dir)/tee.mem_usage: $(link-out-dir)/tee.elf
  111. @$(cmd-echo-silent) ' GEN $@'
  112. - $(q)./scripts/mem_usage.py $< > $@
  113. + $(q)$(PYTHON3) ./scripts/mem_usage.py $< > $@
  114. endif
  115. diff --git a/core/sub.mk b/core/sub.mk
  116. index 03cc6bc7..0959c9a9 100644
  117. --- a/core/sub.mk
  118. +++ b/core/sub.mk
  119. @@ -9,13 +9,13 @@ ifeq ($(CFG_WITH_USER_TA),y)
  120. gensrcs-y += ta_pub_key
  121. produce-ta_pub_key = ta_pub_key.c
  122. depends-ta_pub_key = $(TA_SIGN_KEY) scripts/pem_to_pub_c.py
  123. -recipe-ta_pub_key = scripts/pem_to_pub_c.py --prefix ta_pub_key \
  124. +recipe-ta_pub_key = $(PYTHON3) scripts/pem_to_pub_c.py --prefix ta_pub_key \
  125. --key $(TA_SIGN_KEY) --out $(sub-dir-out)/ta_pub_key.c
  126. gensrcs-y += ldelf
  127. produce-ldelf = ldelf_hex.c
  128. depends-ldelf = scripts/gen_ldelf_hex.py $(out-dir)/ldelf/ldelf.elf
  129. -recipe-ldelf = scripts/gen_ldelf_hex.py --input $(out-dir)/ldelf/ldelf.elf \
  130. +recipe-ldelf = $(PYTHON3) scripts/gen_ldelf_hex.py --input $(out-dir)/ldelf/ldelf.elf \
  131. --output $(sub-dir-out)/ldelf_hex.c
  132. endif
  133. @@ -25,7 +25,7 @@ early-ta-$1-uuid := $(firstword $(subst ., ,$(notdir $1)))
  134. gensrcs-y += early-ta-$1
  135. produce-early-ta-$1 = early_ta_$$(early-ta-$1-uuid).c
  136. depends-early-ta-$1 = $1 scripts/ta_bin_to_c.py
  137. -recipe-early-ta-$1 = scripts/ta_bin_to_c.py --compress --ta $1 \
  138. +recipe-early-ta-$1 = $(PYTHON3) scripts/ta_bin_to_c.py --compress --ta $1 \
  139. --out $(sub-dir-out)/early_ta_$$(early-ta-$1-uuid).c
  140. endef
  141. $(foreach f, $(EARLY_TA_PATHS), $(eval $(call process_early_ta,$(f))))
  142. @@ -40,7 +40,7 @@ core-embed-fdt-c = $(out-dir)/$(arch-dir)/dts/$(CFG_EMBED_DTB_SOURCE_FILE:.dts=.
  143. gensrcs-y += embedded_secure_dtb
  144. produce-embedded_secure_dtb = arch/$(ARCH)/dts/$(CFG_EMBED_DTB_SOURCE_FILE:.dts=.c)
  145. depends-embedded_secure_dtb = $(core-embed-fdt-dtb) scripts/bin_to_c.py
  146. -recipe-embedded_secure_dtb = scripts/bin_to_c.py \
  147. +recipe-embedded_secure_dtb = $(PYTHON3) scripts/bin_to_c.py \
  148. --bin $(core-embed-fdt-dtb) \
  149. --vname embedded_secure_dtb \
  150. --out $(core-embed-fdt-c)
  151. @@ -58,7 +58,7 @@ $(conf-mk-xz-base64): $(conf-mk-file)
  152. gensrcs-y += conf_str
  153. produce-conf_str = conf.mk.xz.base64.c
  154. depends-conf_str = $(conf-mk-xz-base64)
  155. -recipe-conf_str = scripts/bin_to_c.py --text --bin $(conf-mk-xz-base64) \
  156. +recipe-conf_str = $(PYTHON3) scripts/bin_to_c.py --text --bin $(conf-mk-xz-base64) \
  157. --out $(sub-dir-out)/conf.mk.xz.base64.c \
  158. --vname conf_str
  159. endif
  160. diff --git a/mk/config.mk b/mk/config.mk
  161. index 70732c4d..1fe65576 100644
  162. --- a/mk/config.mk
  163. +++ b/mk/config.mk
  164. @@ -32,6 +32,12 @@ endif
  165. # Supported values: undefined, 1, 2 and 3. 3 gives more warnings.
  166. WARNS ?= 3
  167. +# Path to the Python interpreter used by the build system.
  168. +# This variable is set to the default python3 interpreter in the user's
  169. +# path. But build environments that require more explicit control can
  170. +# set the path to a specific interpreter through this variable.
  171. +PYTHON3 ?= python3
  172. +
  173. # Define DEBUG=1 to compile without optimization (forces -O0)
  174. # DEBUG=1
  175. diff --git a/mk/lib.mk b/mk/lib.mk
  176. index 6e890893..3bd422d6 100644
  177. --- a/mk/lib.mk
  178. +++ b/mk/lib.mk
  179. @@ -72,7 +72,7 @@ $(lib-shlibstrippedfile): $(lib-shlibfile)
  180. $(lib-shlibtafile): $(lib-shlibstrippedfile) $(TA_SIGN_KEY)
  181. @$(cmd-echo-silent) ' SIGN $$@'
  182. - $$(q)$$(SIGN) --key $(TA_SIGN_KEY) --uuid $(libuuid) --in $$< --out $$@
  183. + $$(q)$$(PYTHON3) $$(SIGN) --key $(TA_SIGN_KEY) --uuid $(libuuid) --in $$< --out $$@
  184. $(lib-libuuidln): $(lib-shlibfile)
  185. @$(cmd-echo-silent) ' LN $$@'
  186. diff --git a/ta/arch/arm/link.mk b/ta/arch/arm/link.mk
  187. index db7d0b9a..b95c0cba 100644
  188. --- a/ta/arch/arm/link.mk
  189. +++ b/ta/arch/arm/link.mk
  190. @@ -2,7 +2,7 @@ link-script$(sm) = $(ta-dev-kit-dir$(sm))/src/ta.ld.S
  191. link-script-pp$(sm) = $(link-out-dir$(sm))/ta.lds
  192. link-script-dep$(sm) = $(link-out-dir$(sm))/.ta.ld.d
  193. -SIGN_ENC ?= $(ta-dev-kit-dir$(sm))/scripts/sign_encrypt.py
  194. +SIGN_ENC ?= $(PYTHON3) $(ta-dev-kit-dir$(sm))/scripts/sign_encrypt.py
  195. TA_SIGN_KEY ?= $(ta-dev-kit-dir$(sm))/keys/default_ta.pem
  196. ifeq ($(CFG_ENCRYPT_TA),y)
  197. diff --git a/ta/arch/arm/link_shlib.mk b/ta/arch/arm/link_shlib.mk
  198. index ed81e59a..cc177ef0 100644
  199. --- a/ta/arch/arm/link_shlib.mk
  200. +++ b/ta/arch/arm/link_shlib.mk
  201. @@ -47,5 +47,5 @@ $(link-out-dir)/$(shlibuuid).elf: $(link-out-dir)/$(shlibname).so
  202. $(link-out-dir)/$(shlibuuid).ta: $(link-out-dir)/$(shlibname).stripped.so \
  203. $(TA_SIGN_KEY)
  204. @$(cmd-echo-silent) ' SIGN $@'
  205. - $(q)$(SIGN) --key $(TA_SIGN_KEY) --uuid $(shlibuuid) \
  206. + $(q)$(PYTHON3) $(SIGN) --key $(TA_SIGN_KEY) --uuid $(shlibuuid) \
  207. --in $< --out $@
  208. diff --git a/ta/ta.mk b/ta/ta.mk
  209. index 918880f4..59ed87f7 100644
  210. --- a/ta/ta.mk
  211. +++ b/ta/ta.mk
  212. @@ -67,7 +67,7 @@ $$(arm32-user-sysregs-out)/$$(arm32-user-sysregs-$(1)-h): \
  213. $(1) scripts/arm32_sysreg.py
  214. @$(cmd-echo-silent) ' GEN $$@'
  215. $(q)mkdir -p $$(dir $$@)
  216. - $(q)scripts/arm32_sysreg.py --guard __$$(arm32-user-sysregs-$(1)-h) \
  217. + $(q)$(PYTHON3) scripts/arm32_sysreg.py --guard __$$(arm32-user-sysregs-$(1)-h) \
  218. < $$< > $$@
  219. endef #process-arm32-user-sysreg
  220. --
  221. 2.20.1