Debian Codegraph @

platform/windows/SCsub

raw symbols ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #!/usr/bin/env python
2 from misc.utility.scons_hints import *
3
4 Import("env")
5
6 import os
7 from pathlib import Path
8
9 import platform_windows_builders
10
11 from methods import redirect_emitter
12
13 sources = []
14
15 common_win = [
16 "os_windows.cpp",
17 "display_server_windows.cpp",
18 "key_mapping_windows.cpp",
19 "tts_windows.cpp",
20 "windows_terminal_logger.cpp",
21 "windows_utils.cpp",
22 "native_menu_windows.cpp",
23 "gl_manager_windows_native.cpp",
24 "gl_manager_windows_angle.cpp",
25 "wgl_detect_version.cpp",
26 "rendering_context_driver_vulkan_windows.cpp",
27 "drop_target_windows.cpp",
28 ]
29
30 if env["library_type"] == "executable":
31 common_win += ["godot_windows.cpp"]
32 else:
33 common_win += ["libgodot_windows.cpp"]
34
35 if env.msvc:
36 common_win += ["crash_handler_windows_seh.cpp"]
37 else:
38 common_win += ["crash_handler_windows_signal.cpp"]
39
40 common_win_wrap = [
41 "console_wrapper_windows.cpp",
42 ]
43
44 env_wrap = env.Clone()
45
46 if env["arch"] == "x86_64" and env["library_type"] == "executable":
47 env_cpp_check = env.Clone()
48 env_cpp_check.add_source_files(sources, ["cpu_feature_validation.c"])
49 if env.msvc:
50 if "/d2archSSE42" in env_cpp_check["CCFLAGS"]:
51 env_cpp_check["CCFLAGS"].remove("/d2archSSE42")
52 env.Append(LINKFLAGS=["/ENTRY:ShimMainCRTStartup"])
53 else:
54 if "-msse4.2" in env_cpp_check["CCFLAGS"]:
55 env_cpp_check["CCFLAGS"].remove("-msse4.2")
56 env.Append(LINKFLAGS=["-Wl,--entry=ShimMainCRTStartup"])
57
58
59 def arrange_program_clean(prog):
60 """
61 Given an SCons program, arrange for output files SCons doesn't know about
62 to be cleaned when SCons is called with --clean
63 """
64 extensions_to_clean = [".ilk", ".exp", ".pdb", ".lib"]
65 for program in prog:
66 executable_stem = Path(program.name).stem
67 extra_files_to_clean = [f"#bin/{executable_stem}{extension}" for extension in extensions_to_clean]
68 Clean(prog, extra_files_to_clean)
69
70
71 env["BUILDERS"]["RES"].emitter = redirect_emitter
72 if env.editor_build:
73 res_file = "godot_res.rc"
74 res_target = "godot_res" + env["OBJSUFFIX"]
75 else:
76 res_file = "godot_res_template.rc"
77 res_target = "godot_res_template" + env["OBJSUFFIX"]
78 res_obj = env.RES(res_target, res_file)
79 env.Depends(res_obj, "#core/version_generated.gen.h")
80
81 env.add_source_files(sources, common_win)
82 sources += res_obj
83
84 if env["accesskit"] and not env.msvc:
85 sources += env.DEFLIB("uiautomationcore")
86
87 if env["library_type"] == "static_library":
88 prog = env.add_library("#bin/godot", sources, PROGSUFFIX=env["PROGSUFFIX"])
89 elif env["library_type"] == "shared_library":
90 prog = env.add_shared_library("#bin/godot", sources, PROGSUFFIX=env["PROGSUFFIX"])
91 else:
92 prog = env.add_program("#bin/godot", sources, PROGSUFFIX=env["PROGSUFFIX"])
93 arrange_program_clean(prog)
94
95 env.Depends(prog, "godot.manifest")
96 if env.msvc:
97 env.Depends(prog, "godot.natvis")
98
99 # Build console wrapper app.
100 if env["windows_subsystem"] == "gui":
101 if env.editor_build:
102 res_wrap_file = "godot_res_wrap.rc"
103 res_wrap_target = "godot_res_wrap" + env["OBJSUFFIX"]
104 else:
105 res_wrap_file = "godot_res_wrap_template.rc"
106 res_wrap_target = "godot_res_wrap_template" + env["OBJSUFFIX"]
107 res_wrap_obj = env_wrap.RES(res_wrap_target, res_wrap_file)
108 env_wrap.Depends(res_wrap_obj, "#core/version_generated.gen.h")
109
110 if env.msvc:
111 env_wrap.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"])
112 env_wrap.Append(LINKFLAGS=["version.lib"])
113 else:
114 env_wrap.Append(LINKFLAGS=["-Wl,--subsystem,console"])
115 env_wrap.Append(LIBS=["version"])
116
117 prog_wrap = env_wrap.add_program("#bin/godot", common_win_wrap + res_wrap_obj, PROGSUFFIX=env["PROGSUFFIX_WRAP"])
118 arrange_program_clean(prog_wrap)
119 env_wrap.Depends(prog_wrap, prog)
120 sources += common_win_wrap + res_wrap_obj
121
122 if env["d3d12"]:
123 dxc_target_aliases = {
124 "x86_32": "x86",
125 "x86_64": "x64",
126 "arm32": "arm",
127 "arm64": "arm64",
128 }
129 dxc_arch_subdir = dxc_target_aliases[env["arch"]]
130
131 agility_target_aliases = {
132 "x86_32": "win32",
133 "x86_64": "x64",
134 "arm32": "arm",
135 "arm64": "arm64",
136 }
137 agility_arch_subdir = agility_target_aliases[env["arch"]]
138
139 # Used in cases where we can have multiple archs side-by-side.
140 arch_bin_dir = "#bin/" + env["arch"]
141
142 # Agility SDK
143 if env["agility_sdk_path"] != "" and os.path.exists(env["agility_sdk_path"]):
144 agility_dlls = ["D3D12Core.dll", "d3d12SDKLayers.dll"]
145 # Whether these are loaded from arch-specific directory or not has to be known at build time.
146 target_dir = arch_bin_dir if env["agility_sdk_multiarch"] else "#bin"
147 for dll in agility_dlls:
148 env.CommandNoCache(
149 target_dir + "/" + dll,
150 env["agility_sdk_path"] + "/build/native/bin/" + agility_arch_subdir + "/" + dll,
151 Copy("$TARGET", "$SOURCE"),
152 )
153
154 # PIX
155 if env["use_pix"]:
156 pix_dll = "WinPixEventRuntime.dll"
157 env.CommandNoCache(
158 "#bin/" + pix_dll,
159 env["pix_path"] + "/bin/" + dxc_arch_subdir + "/" + pix_dll,
160 Copy("$TARGET", "$SOURCE"),
161 )
162
163 if not env.msvc:
164 if env["debug_symbols"]:
165 env.AddPostAction(prog, env.Run(platform_windows_builders.make_debug_mingw))
166 if env["windows_subsystem"] == "gui":
167 env.AddPostAction(prog_wrap, env.Run(platform_windows_builders.make_debug_mingw))
168
169 env.platform_sources += sources