File: api_solution_build.py

package info (click to toggle)
godot 3.2.3-stable-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 121,308 kB
  • sloc: cpp: 804,285; ansic: 597,434; xml: 77,823; asm: 17,127; cs: 13,535; lisp: 12,017; python: 9,376; java: 7,474; sh: 973; javascript: 659; perl: 264; pascal: 203; objc: 116; makefile: 105
file content (80 lines) | stat: -rw-r--r-- 2,531 bytes parent folder | download | duplicates (3)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Build the Godot API solution

import os

from SCons.Script import Dir


def build_api_solution(source, target, env):
    # source and target elements are of type SCons.Node.FS.File, hence why we convert them to str

    module_dir = env["module_dir"]

    solution_path = os.path.join(module_dir, "glue/GodotSharp/GodotSharp.sln")

    build_config = env["solution_build_config"]

    extra_msbuild_args = ["/p:NoWarn=1591"]  # Ignore missing documentation warnings

    from .solution_builder import build_solution

    build_solution(env, solution_path, build_config, extra_msbuild_args=extra_msbuild_args)

    # Copy targets

    core_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, "GodotSharp", "bin", build_config))
    editor_src_dir = os.path.abspath(os.path.join(solution_path, os.pardir, "GodotSharpEditor", "bin", build_config))

    dst_dir = os.path.abspath(os.path.join(str(target[0]), os.pardir))

    if not os.path.isdir(dst_dir):
        assert not os.path.isfile(dst_dir)
        os.makedirs(dst_dir)

    def copy_target(target_path):
        from shutil import copy

        filename = os.path.basename(target_path)

        src_path = os.path.join(core_src_dir, filename)
        if not os.path.isfile(src_path):
            src_path = os.path.join(editor_src_dir, filename)

        copy(src_path, target_path)

    for scons_target in target:
        copy_target(str(scons_target))


def build(env_mono):
    assert env_mono["tools"]

    target_filenames = [
        "GodotSharp.dll",
        "GodotSharp.pdb",
        "GodotSharp.xml",
        "GodotSharpEditor.dll",
        "GodotSharpEditor.pdb",
        "GodotSharpEditor.xml",
    ]

    depend_cmd = []

    for build_config in ["Debug", "Release"]:
        output_dir = Dir("#bin").abspath
        editor_api_dir = os.path.join(output_dir, "GodotSharp", "Api", build_config)

        targets = [os.path.join(editor_api_dir, filename) for filename in target_filenames]

        cmd = env_mono.CommandNoCache(
            targets, depend_cmd, build_api_solution, module_dir=os.getcwd(), solution_build_config=build_config
        )
        env_mono.AlwaysBuild(cmd)

        # Make the Release build of the API solution depend on the Debug build.
        # We do this in order to prevent SCons from building them in parallel,
        # which can freak out MSBuild. In many cases, one of the builds would
        # hang indefinitely requiring a key to be pressed for it to continue.
        depend_cmd = cmd

    return depend_cmd