Skip to content

Commit

Permalink
fix: compile failed if one target has multiple compiler
Browse files Browse the repository at this point in the history
For example, esp32 has esp-2021r2-8.4.0 (in environment variables) and esp-2021r2-patch3-8.4.0 (installed with idf_tools.py) compiler at the same time,
the project build maybe choose esp-2021r2-8.4.0 as the default compiler,
it causes to compile fail due to unmatched compiler.
  • Loading branch information
ustccw committed May 12, 2022
1 parent e8d6397 commit 0c39f75
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,19 @@
import sys
import subprocess
import json

# color output on windows
if sys.platform == 'win32':
from colorama import init

# preset environment variables
if sys.platform == 'win32':
sys_cmd = 'set'
sys_delimiter = ';'
else:
sys_cmd = 'export'
sys_delimiter = ':'

def ESP_LOGI(x):
print('\033[32m{}\033[0m'.format(x))

Expand Down Expand Up @@ -163,13 +173,10 @@ def build_project(platform_name, module_name, silence, build_args):

tool = os.path.join('esp-idf', 'tools', 'idf.py')
if sys.platform == 'win32':
sys_cmd = 'set'
sys_python_path = sys.executable
elif sys.platform == 'linux2':
sys_cmd = 'export'
sys_python_path = sys.executable
else:
sys_cmd = 'export'
if os.environ.get('IDF_PYTHON_ENV_PATH') is None:
sys_python_path = 'python'
else:
Expand Down Expand Up @@ -360,7 +367,7 @@ def setup_env_variables():
print('sys.platform is {}'.format(sys.platform))

export_str = ''
if sys.platform != 'win32' and sys.platform != 'linux2':
if sys.platform != 'linux2':
cmd = '{} {} export --format=key-value'.format(sys.executable, os.path.join('esp-idf', 'tools', 'idf_tools.py'))
try:
export_str = subprocess.check_output(cmd, shell=True).decode('utf-8')
Expand All @@ -377,9 +384,10 @@ def setup_env_variables():
if line.startswith('IDF_PYTHON_ENV_PATH='):
idf_python_env_path = line.split('IDF_PYTHON_ENV_PATH=')[1]
# set PATH and IDF_PYTHON_ENV_PATH and print
at_env_path = os.environ.get('PATH') + ':' + idf_tc_env_path
os.environ['PATH']=at_env_path
os.environ['IDF_PYTHON_ENV_PATH']=idf_python_env_path
at_env_path = idf_tc_env_path + sys_delimiter + os.environ.get('PATH')
os.environ['PATH'] = at_env_path
if idf_python_env_path:
os.environ['IDF_PYTHON_ENV_PATH'] = idf_python_env_path

print('PATH is {}'.format(os.environ.get('PATH')))
print('IDF_PYTHON_ENV_PATH is {}'.format(os.environ.get('IDF_PYTHON_ENV_PATH')))
Expand Down

0 comments on commit 0c39f75

Please sign in to comment.