mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-17 10:04:26 +00:00
fix(build): wrap toolchain paths in double quotes
Fix issue with Windows paths containing spaces. Recent toolchain
refactoring (cc277de
) caused a regression in the Windows build. Ensure
toolchain path utilities wrap paths in double quoted strings.
Change-Id: I7a136e459d85cff1e9851aedf0a5272a841df09c
Signed-off-by: Harrison Mutai <harrison.mutai@arm.com>
Signed-off-by: Chris Kay <chris.kay@arm.com>
Co-authored-by: Chris Kay <chris.kay@arm.com>
This commit is contained in:
parent
a6cb061b62
commit
4731c00bb6
5 changed files with 65 additions and 50 deletions
|
@ -10,11 +10,6 @@ ifneq (${eval_available},T)
|
||||||
$(error This makefile only works with a Make program that supports $$(eval))
|
$(error This makefile only works with a Make program that supports $$(eval))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Some utility macros for manipulating awkward (whitespace) characters.
|
|
||||||
blank :=
|
|
||||||
space :=${blank} ${blank}
|
|
||||||
comma := ,
|
|
||||||
|
|
||||||
# A user defined function to recursively search for a filename below a directory
|
# A user defined function to recursively search for a filename below a directory
|
||||||
# $1 is the directory root of the recursive search (blank for current directory).
|
# $1 is the directory root of the recursive search (blank for current directory).
|
||||||
# $2 is the file name to search for.
|
# $2 is the file name to search for.
|
||||||
|
|
|
@ -60,6 +60,8 @@ ifneq ($(filter aarch64,$(toolchains)),)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
include $(dir $(lastword $(MAKEFILE_LIST)))build_env.mk
|
include $(dir $(lastword $(MAKEFILE_LIST)))build_env.mk
|
||||||
|
include $(dir $(lastword $(MAKEFILE_LIST)))utilities.mk
|
||||||
|
|
||||||
include $(addprefix $(dir $(lastword $(MAKEFILE_LIST)))toolchains/, \
|
include $(addprefix $(dir $(lastword $(MAKEFILE_LIST)))toolchains/, \
|
||||||
$(addsuffix .mk,$(toolchains)))
|
$(addsuffix .mk,$(toolchains)))
|
||||||
|
|
||||||
|
@ -222,27 +224,27 @@ $(foreach toolchain,$(toolchains), \
|
||||||
#
|
#
|
||||||
|
|
||||||
# Arm Compiler for Embedded
|
# Arm Compiler for Embedded
|
||||||
guess-tool-arm-clang = $(shell $(1) --version 2>&1 <$(nul) | grep -o "Tool: armclang")
|
guess-tool-arm-clang = $(shell $(call escape-shell,$(1)) --version 2>&1 <$(nul) | grep -o "Tool: armclang")
|
||||||
guess-tool-arm-link = $(shell $(1) --help 2>&1 <$(nul) | grep -o "Tool: armlink")
|
guess-tool-arm-link = $(shell $(call escape-shell,$(1)) --help 2>&1 <$(nul) | grep -o "Tool: armlink")
|
||||||
guess-tool-arm-fromelf = $(shell $(1) --help 2>&1 <$(nul) | grep -o "Tool: fromelf")
|
guess-tool-arm-fromelf = $(shell $(call escape-shell,$(1)) --help 2>&1 <$(nul) | grep -o "Tool: fromelf")
|
||||||
guess-tool-arm-ar = $(shell $(1) --version 2>&1 <$(nul) | grep -o "Tool: armar")
|
guess-tool-arm-ar = $(shell $(call escape-shell,$(1)) --version 2>&1 <$(nul) | grep -o "Tool: armar")
|
||||||
|
|
||||||
# LLVM Project
|
# LLVM Project
|
||||||
guess-tool-llvm-clang = $(shell $(1) -v 2>&1 <$(nul) | grep -o "clang version")
|
guess-tool-llvm-clang = $(shell $(call escape-shell,$(1)) -v 2>&1 <$(nul) | grep -o "clang version")
|
||||||
guess-tool-llvm-lld = $(shell $(1) --help 2>&1 <$(nul) | grep -o "OVERVIEW: lld")
|
guess-tool-llvm-lld = $(shell $(call escape-shell,$(1)) --help 2>&1 <$(nul) | grep -o "OVERVIEW: lld")
|
||||||
guess-tool-llvm-objcopy = $(shell $(1) --help 2>&1 <$(nul) | grep -o "llvm-objcopy tool")
|
guess-tool-llvm-objcopy = $(shell $(call escape-shell,$(1)) --help 2>&1 <$(nul) | grep -o "llvm-objcopy tool")
|
||||||
guess-tool-llvm-objdump = $(shell $(1) --help 2>&1 <$(nul) | grep -o "llvm object file dumper")
|
guess-tool-llvm-objdump = $(shell $(call escape-shell,$(1)) --help 2>&1 <$(nul) | grep -o "llvm object file dumper")
|
||||||
guess-tool-llvm-ar = $(shell $(1) --help 2>&1 <$(nul) | grep -o "LLVM Archiver")
|
guess-tool-llvm-ar = $(shell $(call escape-shell,$(1)) --help 2>&1 <$(nul) | grep -o "LLVM Archiver")
|
||||||
|
|
||||||
# GNU Compiler Collection & GNU Binary Utilities
|
# GNU Compiler Collection & GNU Binary Utilities
|
||||||
guess-tool-gnu-gcc = $(shell $(1) -v 2>&1 <$(nul) | grep -o "gcc version")
|
guess-tool-gnu-gcc = $(shell $(call escape-shell,$(1)) -v 2>&1 <$(nul) | grep -o "gcc version")
|
||||||
guess-tool-gnu-ld = $(shell $(1) -v 2>&1 <$(nul) | grep -o "GNU ld")
|
guess-tool-gnu-ld = $(shell $(call escape-shell,$(1)) -v 2>&1 <$(nul) | grep -o "GNU ld")
|
||||||
guess-tool-gnu-objcopy = $(shell $(1) --version 2>&1 <$(nul) | grep -o "GNU objcopy")
|
guess-tool-gnu-objcopy = $(shell $(call escape-shell,$(1)) --version 2>&1 <$(nul) | grep -o "GNU objcopy")
|
||||||
guess-tool-gnu-objdump = $(shell $(1) --version 2>&1 <$(nul) | grep -o "GNU objdump")
|
guess-tool-gnu-objdump = $(shell $(call escape-shell,$(1)) --version 2>&1 <$(nul) | grep -o "GNU objdump")
|
||||||
guess-tool-gnu-ar = $(shell $(1) --version 2>&1 <$(nul) | grep -o "GNU ar")
|
guess-tool-gnu-ar = $(shell $(call escape-shell,$(1)) --version 2>&1 <$(nul) | grep -o "GNU ar")
|
||||||
|
|
||||||
# Other tools
|
# Other tools
|
||||||
guess-tool-dtc = $(shell $(1) --version 2>&1 <$(nul) | grep -o "Version: DTC")
|
guess-tool-dtc = $(shell $(call escape-shell,$(1)) --version 2>&1 <$(nul) | grep -o "Version: DTC")
|
||||||
|
|
||||||
guess-tool = $(firstword $(foreach candidate,$(1), \
|
guess-tool = $(firstword $(foreach candidate,$(1), \
|
||||||
$(if $(call guess-tool-$(candidate),$(2)),$(candidate))))
|
$(if $(call guess-tool-$(candidate),$(2)),$(candidate))))
|
||||||
|
@ -271,34 +273,32 @@ guess-tool = $(firstword $(foreach candidate,$(1), \
|
||||||
# variable.
|
# variable.
|
||||||
#
|
#
|
||||||
|
|
||||||
guess-arm-clang-cpp = $(1) # Use the C compiler
|
guess-arm-clang-cpp = $(1)
|
||||||
guess-arm-clang-as = $(1) # Use the C compiler
|
guess-arm-clang-as = $(1)
|
||||||
guess-arm-clang-ld = # Fall back to `$(toolchain)-ld-default`
|
guess-arm-clang-ld = # Fall back to `$(toolchain)-ld-default`
|
||||||
guess-arm-clang-oc = # Fall back to `$(toolchain)-oc-default`
|
guess-arm-clang-oc = # Fall back to `$(toolchain)-oc-default`
|
||||||
guess-arm-clang-od = # Fall back to `$(toolchain)-od-default`
|
guess-arm-clang-od = # Fall back to `$(toolchain)-od-default`
|
||||||
guess-arm-clang-ar = # Fall back to `$(toolchain)-ar-default`
|
guess-arm-clang-ar = # Fall back to `$(toolchain)-ar-default`
|
||||||
|
|
||||||
guess-llvm-clang-cpp = $(1) # Use the C compiler
|
guess-llvm-clang-cpp = $(1)
|
||||||
guess-llvm-clang-as = $(1) # Use the C compiler
|
guess-llvm-clang-as = $(1)
|
||||||
guess-llvm-clang-ld = $(shell $(1) --print-prog-name ld.lld 2>$(nul))
|
guess-llvm-clang-ld = $(shell $(call escape-shell,$(1)) --print-prog-name ld.lld 2>$(nul))
|
||||||
guess-llvm-clang-oc = $(shell $(1) --print-prog-name llvm-objcopy 2>$(nul))
|
guess-llvm-clang-oc = $(shell $(call escape-shell,$(1)) --print-prog-name llvm-objcopy 2>$(nul))
|
||||||
guess-llvm-clang-od = $(shell $(1) --print-prog-name llvm-objdump 2>$(nul))
|
guess-llvm-clang-od = $(shell $(call escape-shell,$(1)) --print-prog-name llvm-objdump 2>$(nul))
|
||||||
guess-llvm-clang-ar = $(shell $(1) --print-prog-name llvm-ar 2>$(nul))
|
guess-llvm-clang-ar = $(shell $(call escape-shell,$(1)) --print-prog-name llvm-ar 2>$(nul))
|
||||||
|
|
||||||
guess-gnu-gcc-cpp = $(1) # Use the C compiler
|
guess-gnu-gcc-cpp = $(1)
|
||||||
guess-gnu-gcc-as = $(1) # Use the C compiler
|
guess-gnu-gcc-as = $(1)
|
||||||
guess-gnu-gcc-ld = $(1) # Use the C compiler
|
guess-gnu-gcc-ld = $(1)
|
||||||
guess-gnu-gcc-oc = $(shell $(1) --print-prog-name objcopy 2>$(nul))
|
guess-gnu-gcc-oc = $(shell $(call escape-shell,$(1)) --print-prog-name objcopy 2>$(nul))
|
||||||
guess-gnu-gcc-od = $(shell $(1) --print-prog-name objdump 2>$(nul))
|
guess-gnu-gcc-od = $(shell $(call escape-shell,$(1)) --print-prog-name objdump 2>$(nul))
|
||||||
guess-gnu-gcc-ar = $(call which,$(patsubst %$(notdir $(1)),%$(subst gcc,gcc-ar,$(notdir $(1))),$(1)))
|
guess-gnu-gcc-ar = $(call which,$(call decompat-path,$(patsubst %$(call file-name,$(1)),%$(subst gcc,gcc-ar,$(call file-name,$(1))),$(call compat-path,$(1)))))
|
||||||
|
|
||||||
define locate-toolchain-tool-cc
|
define locate-toolchain-tool-cc
|
||||||
$(eval toolchain := $(1))
|
$(eval toolchain := $(1))
|
||||||
|
|
||||||
$(toolchain)-cc := $$(strip \
|
$(toolchain)-cc := $$(or $$($(toolchain)-cc),$$($(toolchain)-cc-default))
|
||||||
$$(or $$($(toolchain)-cc),$$($(toolchain)-cc-default)))
|
$(toolchain)-cc-id := $$(call guess-tool,$$(tools-cc),$$($(toolchain)-cc))
|
||||||
$(toolchain)-cc-id := $$(strip \
|
|
||||||
$$(call guess-tool,$$(tools-cc),$$($(toolchain)-cc)))
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define locate-toolchain-tool
|
define locate-toolchain-tool
|
||||||
|
@ -306,26 +306,24 @@ define locate-toolchain-tool
|
||||||
$(eval tool-class := $(2))
|
$(eval tool-class := $(2))
|
||||||
|
|
||||||
ifndef $(toolchain)-$(tool-class)
|
ifndef $(toolchain)-$(tool-class)
|
||||||
$(toolchain)-$(tool-class) := $$(strip \
|
$(toolchain)-$(tool-class) := $$(call guess-$$($(toolchain)-cc-id)-$(tool-class),$$($(toolchain)-cc-path))
|
||||||
$$(call guess-$$($(toolchain)-cc-id)-$(tool-class),$$($(toolchain)-cc)))
|
|
||||||
|
|
||||||
ifeq ($$($(toolchain)-$(tool-class)),)
|
ifeq ($$($(toolchain)-$(tool-class)),)
|
||||||
$(toolchain)-$(tool-class) := $$(strip \
|
$(toolchain)-$(tool-class) := $$($(toolchain)-$(tool-class)-default)
|
||||||
$$($(toolchain)-$(tool-class)-default))
|
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
$(toolchain)-$(tool-class)-id := $$(strip \
|
$(toolchain)-$(tool-class)-id := $$(call guess-tool,$$(tools-$(tool-class)),$$($$(toolchain)-$(tool-class)))
|
||||||
$$(call guess-tool,$$(tools-$(tool-class)),$$($$(toolchain)-$(tool-class))))
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define canonicalize-toolchain-tool-path
|
define canonicalize-toolchain-tool-path
|
||||||
$(eval toolchain := $(1))
|
$(eval toolchain := $(1))
|
||||||
$(eval tool-class := $(2))
|
$(eval tool-class := $(2))
|
||||||
|
|
||||||
$(toolchain)-$(tool-class) := $$(strip $$(or \
|
$(toolchain)-$(tool-class)-path := $$(call absolute-path,$$(call which,$$($(toolchain)-$(tool-class))))
|
||||||
$$(call which,$$($(toolchain)-$(tool-class))), \
|
$(toolchain)-$(tool-class)-path := $$(or $$($(toolchain)-$(tool-class)-path),$$($(toolchain)-$(tool-class)))
|
||||||
$$($(toolchain)-$(tool-class))))
|
|
||||||
|
$(toolchain)-$(tool-class) := $(call escape-shell,$$($(toolchain)-$(tool-class)-path))
|
||||||
endef
|
endef
|
||||||
|
|
||||||
define locate-toolchain
|
define locate-toolchain
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
|
# Copyright (c) 2016-2024, Arm Limited and Contributors. All rights reserved.
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: BSD-3-Clause
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
#
|
#
|
||||||
|
@ -59,5 +59,5 @@ ${1} : ${2}
|
||||||
|
|
||||||
nul := /dev/null
|
nul := /dev/null
|
||||||
|
|
||||||
which = $(shell which $(1) 2>$(nul))
|
which = $(shell command -v $(call escape-shell,$(1)) 2>$(nul))
|
||||||
endif
|
endif
|
||||||
|
|
22
make_helpers/utilities.mk
Normal file
22
make_helpers/utilities.mk
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#
|
||||||
|
# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
#
|
||||||
|
|
||||||
|
space :=
|
||||||
|
space := $(space) $(space)
|
||||||
|
comma := ,
|
||||||
|
|
||||||
|
null := <20>
|
||||||
|
|
||||||
|
compat-path = $(subst $(space),$(null),$(1))
|
||||||
|
decompat-path = $(subst $(null), ,$(1))
|
||||||
|
|
||||||
|
absolute-path = $(call decompat-path,$(abspath $(call compat-path,$(1))))
|
||||||
|
real-path = $(call decompat-path,$(realpath $(call compat-path,$(1))))
|
||||||
|
|
||||||
|
file-name = $(call decompat-path,$(notdir $(call compat-path,$(1))))
|
||||||
|
directory-name = $(call decompat-path,$(dir $(call compat-path,$(1))))
|
||||||
|
|
||||||
|
escape-shell = '$(subst ','\'',$(1))'
|
|
@ -70,7 +70,7 @@ ${1} : ${2}
|
||||||
|
|
||||||
nul := nul
|
nul := nul
|
||||||
|
|
||||||
which = $(shell where $(1) 2>$(nul))
|
which = $(shell where "$(1)" 2>$(nul))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Because git is not available from CMD.EXE, we need to avoid
|
# Because git is not available from CMD.EXE, we need to avoid
|
||||||
|
|
Loading…
Add table
Reference in a new issue