Skip to content

Commit 8771166

Browse files
Search for system mcpp if included binary fails on Linux
1 parent 7526dc7 commit 8771166

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Malt/GL/Shader.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ def shader_preprocessor(shader_source, include_directories=[], definitions=[]):
169169
dependencies_path = os.path.join(os.path.dirname(__file__), '..', f'.Dependencies-{py_version}')
170170
mcpp = os.path.join(dependencies_path, f'mcpp-{platform.system()}')
171171

172+
if platform.system() == "Linux":
173+
# NixOS and Guix System will cannot run the included mcpp binary
174+
result = subprocess.run(f'"{mcpp}"', shell=True, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
175+
if result.returncode != 0:
176+
# Search for system mcpp
177+
for directory in os.get_exec_path():
178+
path = os.path.join(directory, "mcpp")
179+
if os.path.isfile(path) and os.access(path, os.X_OK):
180+
mcpp = path
181+
182+
172183
command = f'"{mcpp}"'
173184
command += ' -C' #keep comments
174185
for directory in include_directories:

0 commit comments

Comments
 (0)