auto select output platform

This commit is contained in:
Alexander Popov 2020-10-17 00:26:41 +03:00
parent af9dfb6f90
commit 219bc5ba5c

15
tools/make_libs_list.py Normal file → Executable file
View File

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys
import json import json
import click import click
@ -9,7 +10,7 @@ __license__ = "Unlicense"
@click.command() @click.command()
@click.option("--platform", default="win", help="Output platform (win, unix).") @click.option("--platform", default=sys.platform, help="Output platform (win32, linux, darwin).")
@click.option("--output", default="tty", help="Output option (tty, txt).") @click.option("--output", default="tty", help="Output option (tty, txt).")
def make_output(platform, output): def make_output(platform, output):
""" Return libraries list """ """ Return libraries list """
@ -17,7 +18,7 @@ def make_output(platform, output):
libraries = parse_libs() libraries = parse_libs()
# OS libs separate # OS libs separate
_ = {"win": ";", "unix": ":"} _ = {"win": ";", "linux": ":", "darwin": ":"}
out_lib = str() out_lib = str()
@ -28,24 +29,24 @@ def make_output(platform, output):
out_lib = out_lib + "$MC_DIR/versions/$GAME_VERSION/$GAME_VERSION.jar" out_lib = out_lib + "$MC_DIR/versions/$GAME_VERSION/$GAME_VERSION.jar"
# Replace for OS shell variable symbol # Replace for OS shell variable symbol
if platform == "win": if platform == "win32":
out_lib = out_lib.replace("$MC_DIR", "%MC_DIR%") out_lib = out_lib.replace("$MC_DIR", "%MC_DIR%")
out_lib = out_lib.replace("$GAME_VERSION", "%GAME_VERSION%") out_lib = out_lib.replace("$GAME_VERSION", "%GAME_VERSION%")
if output == "tty": if output == "tty":
click.echo(out_lib) click.echo(out_lib)
if platform == "win": if platform == "win32":
print("\nWindows generate libraries list complete!") print("\nWindows generate libraries list complete!")
elif platform == "unix": elif platform == "linux" or platform == "darwin":
print("\nLinux generate libraries list complete!") print("\nLinux generate libraries list complete!")
elif output == "txt": elif output == "txt":
with open("./libs.txt", "w", encoding="utf-8") as f: with open("./libs.txt", "w", encoding="utf-8") as f:
f.write(out_lib) f.write(out_lib)
if platform == "win": if platform == "win32":
print("\nWindows generate libraries list complete!\n" "See libs.txt file.") print("\nWindows generate libraries list complete!\n" "See libs.txt file.")
elif platform == "unix": elif platform == "linux" or platform == "darwin":
print("\nLinux generate libraries list complete!\n" "See libs.txt file.") print("\nLinux generate libraries list complete!\n" "See libs.txt file.")