mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-10 21:58:48 +01:00
fix util/generate_project.py
- fix premake args being incorrect - remove platform assumptions, making it portable - start with a best guess based on project layout - use fallback if not specified or not found - display errors/help if not found
This commit is contained in:
@ -3,26 +3,48 @@
|
|||||||
import sys
|
import sys
|
||||||
from os import getenv, path
|
from os import getenv, path
|
||||||
from subprocess import PIPE, run
|
from subprocess import PIPE, run
|
||||||
|
import platform
|
||||||
|
|
||||||
PREMAKE_DIR = path.join(path.dirname(__file__), "../projects/premake")
|
PREMAKE_DIR = path.join(path.dirname(__file__), "../projects/premake")
|
||||||
|
|
||||||
|
# Default binary name
|
||||||
|
PREMAKE_BIN = "premake5"
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
PREMAKE_BIN += ".exe"
|
||||||
|
|
||||||
def has(prog):
|
# We try the env first, as that's absolute.
|
||||||
return run(["command", "-v", prog], stdout=PIPE, stderr=PIPE).returncode == 0
|
# If not found we try the 'intended' approach,
|
||||||
|
# of placing a premake binary alongside premake5.lua.
|
||||||
|
# If that isn't found, attempt the plain binary name.
|
||||||
|
premake = getenv("WREN_PREMAKE", None)
|
||||||
|
if premake is None:
|
||||||
|
premake = PREMAKE_BIN
|
||||||
|
premake_local = path.join(PREMAKE_DIR, PREMAKE_BIN)
|
||||||
|
if path.isfile(premake_local):
|
||||||
|
print("Using local premake in 'projects/premake' ...")
|
||||||
|
premake = premake_local
|
||||||
|
else:
|
||||||
|
print("Using premake from 'WREN_PREMAKE' env ...")
|
||||||
|
|
||||||
def run_premake(action, os):
|
def run_premake(action, os):
|
||||||
run([premake, action, os], cwd=PREMAKE_DIR)
|
run([premake, action, "--os=" + os], cwd=PREMAKE_DIR)
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
premake = getenv("PREMAKE", "premake5")
|
run_premake("gmake2", "bsd")
|
||||||
if not has(premake):
|
run_premake("gmake2", "linux")
|
||||||
print("error: {} is not found", premake, file=sys.stderr)
|
run_premake("vs2017", "windows")
|
||||||
exit(1)
|
run_premake("vs2019", "windows")
|
||||||
|
run_premake("gmake2", "macosx")
|
||||||
|
run_premake("xcode4", "macosx")
|
||||||
|
|
||||||
run_premake("gmake2", "bsd")
|
except Exception as e:
|
||||||
run_premake("gmake2", "linux")
|
|
||||||
run_premake("gmake2", "macosx")
|
print("Unable to run premake, while trying the binary '" + premake + "' ...")
|
||||||
run_premake("vs2017", "windows")
|
print(" reason: " + str(e))
|
||||||
run_premake("vs2019", "windows")
|
print("\nIf premake can't be found, possible options are:")
|
||||||
run_premake("xcode4", "macosx")
|
print("- Set the env variable 'WREN_PREMAKE' to the path to a premake binary")
|
||||||
|
print("- Place a premake5 binary for your host platform in projects/premake")
|
||||||
|
print("- Add a location with a premake5 binary to the PATH")
|
||||||
|
|
||||||
|
exit(1)
|
||||||
Reference in New Issue
Block a user