Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build fail on windows #18721

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions buildroot/share/PlatformIO/scripts/common-features-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,29 @@ def install_features_dependencies():
proj.set("env:" + env["PIOENV"], "src_filter", src_filter)
env.Replace(SRC_FILTER=src_filter)

# search the current compiler, considering the OS
def search_compiler():
if env['PLATFORM'] == 'win32':
# the first path have the compiler
compiler_path = None
for path in env['ENV']['PATH'].split(';'):
if re.search(r'platformio\\packages.*\\bin', path):
compiler_path = path
break
if compiler_path == None:
print("Could not find the g++ path")
return None

print(compiler_path)
for file in os.listdir(compiler_path):
if file.endswith("g++.exe"):
return file
print("Could not find the g++")
return None
else:
return env.get('CXX')


# load marlin features
def load_marlin_features():
if "MARLIN_FEATURES" in env:
Expand All @@ -102,7 +125,10 @@ def load_marlin_features():
# print(env.Dump())
build_flags = env.get('BUILD_FLAGS')
build_flags = env.ParseFlagsExtended(build_flags)
cmd = []

cxx = search_compiler()
cmd = [cxx]

# build flags from board.json
# if 'BOARD' in env:
# cmd += [env.BoardConfig().get("build.extra_flags")]
Expand All @@ -113,7 +139,6 @@ def load_marlin_features():
cmd += ['-D' + s]
# cmd += ['-w -dM -E -x c++ Marlin/src/inc/MarlinConfigPre.h']
cmd += ['-w -dM -E -x c++ buildroot/share/PlatformIO/scripts/common-features-dependencies.h']
cmd = [env.get('CXX')] + cmd
cmd = ' '.join(cmd)
print(cmd)
define_list = subprocess.check_output(cmd, shell=True).splitlines()
Expand Down