Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ Contents:

1. Use one of these platforms:
- Windows (recommended)
- macOS
- Linux
2. Install the following:
- Python 3.11+ and pip
- GCC 9+
- Ninja
- Wine (macOS only)
3. Install the Python dependencies:
```shell
python -m pip install -r tools/requirements.txt
Expand Down
17 changes: 9 additions & 8 deletions tools/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
import ninja_syntax
from get_platform import Platform, get_platform

# Platform info
platform = get_platform()
if platform is None:
exit(1)

DEFAULT_WIBO_PATH = "./wibo"

DEFAULT_WINE_PATH = "./wibo"
if platform.system == "macos":
DEFAULT_WINE_PATH = "wine"

parser = argparse.ArgumentParser(description="Generates build.ninja")
parser.add_argument('-w', type=str, default=DEFAULT_WIBO_PATH, dest="wine", required=False, help="Path to Wine/Wibo (linux only)")
parser.add_argument('-w', type=str, default=DEFAULT_WINE_PATH, dest="wine", required=False, help="Path to Wine/Wibo (macOS/Linux only)")
parser.add_argument("--compiler", type=Path, required=False, help="Path to pre-installed compiler root directory")
parser.add_argument("--no-extract", action="store_true", help="Skip extract step")
parser.add_argument("--dsd", type=Path, required=False, help="Path to pre-installed dsd CLI")
Expand Down Expand Up @@ -104,10 +109,6 @@
CC_INCLUDES = " ".join(f"-i {include}" for include in includes)


# Platform info
platform = get_platform()
if platform is None:
exit(1)
EXE = platform.exe
WINE = args.wine if platform.system != "windows" else ""
DSD = str(args.dsd or os.path.join('.', str(root_path / f"dsd{EXE}")))
Expand Down Expand Up @@ -402,7 +403,7 @@ def add_download_tool_builds(n: ninja_syntax.Writer, project: Project):
)
n.newline()

if project.platform.system != "windows" and WINE == DEFAULT_WIBO_PATH:
if project.platform.system != "windows" and WINE == DEFAULT_WINE_PATH:
n.build(
rule="download_tool",
outputs=WINE,
Expand Down
28 changes: 19 additions & 9 deletions tools/get_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
class Platform:
def __init__(self, *, system: str, machine: str, exe: str):
self.system = system
'''Name of operating system: "windows" or "linux"'''
'''Name of operating system: "windows", "linux" or "macos"'''
self.machine = machine
'''Name of machine architecture: "x86_64"'''
'''Name of machine architecture: "x86_64", "arm64"'''
self.exe = exe
'''Executable file extension: ".exe" for Windows, "" otherwise'''

Expand All @@ -19,13 +19,23 @@ def get_platform() -> Platform | None:
exe = ".exe"
elif system == "Linux":
system = "linux"
else:
print(f"Unknown system '{system}'")
return None
elif system == "Darwin":
system = "macos"
match platform.machine().lower():
case "amd64" | "x86_64": machine = "x86_64"
case machine:
print(f"Unknown machine: {machine}")
return None
case "arm64": machine = "arm64"
case machine: pass

supported_platforms = [
"windows-x86_64",
"linux-x86_64",
"macos-x86_64",
"macos-arm64"
]

combined = f"{system}-{machine}"
if combined not in supported_platforms:
print(f"Unsupported platform: {combined}")
return None

return Platform(system=system, machine=machine, exe=exe)
return Platform(system=system, machine=machine, exe=exe)
Loading