Skip to content

Commit a5745ca

Browse files
committed
Use PATH env variable when gcc found in PATH
Resolves the github issue #3790: Blinky fails to build (on Mac) after addition of linker script preprocessing feature. Paraphrasing, this issue is that Homebrew on mac does not install `arm-none-eabi-gcc` in the same location as `arm-none-eabi-cpp`, the C Pre-Processor. The tools prior to this commit, and after turning on the pre-processing of the linker-script will fail on any Mac homebrew installed toolchains. This commit resolves the above issue by allowing the toolchain's path to the executable to remain empty after a call to `check_executable`. When this path is empty, the tools will search the PATH environment variable for the executable.
1 parent 3a27568 commit a5745ca

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tools/toolchains/gcc.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
limitations under the License.
1616
"""
1717
import re
18-
from os.path import join, basename, splitext, dirname
18+
from os.path import join, basename, splitext, dirname, exists
19+
from distutils.spawn import find_executable
1920

2021
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
2122
from tools.hooks import hook_tool
@@ -285,7 +286,15 @@ def check_executable():
285286
"""Returns True if the executable (arm-none-eabi-gcc) location
286287
specified by the user exists OR the executable can be found on the PATH.
287288
Returns False otherwise."""
288-
return mbedToolchain.generic_check_executable("GCC_ARM", 'arm-none-eabi-gcc', 1)
289+
if not TOOLCHAIN_PATHS['GCC_ARM'] or not exists(TOOLCHAIN_PATHS['GCC_ARM']):
290+
if find_executable('arm-none-eabi-gcc'):
291+
TOOLCHAIN_PATHS['GCC_ARM'] = ''
292+
return True
293+
else:
294+
return False
295+
else:
296+
exec_name = join(TOOLCHAIN_PATHS['GCC_ARM'], 'arm-none-eabi-gcc')
297+
return exists(exec_name) or exists(exec_name + '.exe')
289298

290299
class GCC_ARM(GCC):
291300
pass

0 commit comments

Comments
 (0)