aboutsummaryrefslogtreecommitdiff
path: root/tools/macos_osxcross.py
blob: 8ed9a5d20fe0d942eebfe46d1f8aec59cfc4882c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Copied from https://github.com/godotengine/godot-cpp/blob/0ee980abae91c481009152cdccab8e61c9625303/tools/macos_osxcross.py
import os


def options(opts):
    opts.Add("osxcross_sdk", "OSXCross SDK version", "darwin16")


def exists(env):
    return "OSXCROSS_ROOT" in os.environ


def generate(env):
    root = os.environ.get("OSXCROSS_ROOT", "")
    if env["arch"] == "arm64":
        basecmd = root + "/target/bin/arm64-apple-" + env["osxcross_sdk"] + "-"
    else:
        basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-"

    env["CC"] = basecmd + "clang"
    env["CXX"] = basecmd + "clang++"
    env["AR"] = basecmd + "ar"
    env["RANLIB"] = basecmd + "ranlib"
    env["AS"] = basecmd + "as"

    binpath = os.path.join(root, "target", "bin")
    if binpath not in env["ENV"]["PATH"]:
        # Add OSXCROSS bin folder to PATH (required for linking).
        env["ENV"]["PATH"] = "%s:%s" % (binpath, env["ENV"]["PATH"])