Debian Codegraph @

platform/windows/SCsub

raw symbols ◀ ▶ SCIP
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 godot_bin_path = f"#{env['output_path']}" if env["output_path"] else "#bin/godot"
88 if env["library_type"] == "static_library":
•89 prog = env.add_library(godot_bin_path, sources, PROGSUFFIX=env["PROGSUFFIX"])
90 elif env["library_type"] == "shared_library":
•91 prog = env.add_shared_library(godot_bin_path, sources, PROGSUFFIX=env["PROGSUFFIX"])
92 else:
•93 prog = env.add_program(godot_bin_path, sources, PROGSUFFIX=env["PROGSUFFIX"])
94 arrange_program_clean(prog)
95
96 env.Depends(prog, "godot.manifest")
97 if env.msvc:
98 env.Depends(prog, "godot.natvis")
99
100 # Build console wrapper app.
101 if env["windows_subsystem"] == "gui":
102 if env.editor_build:
103 res_wrap_file = "godot_res_wrap.rc"
104 res_wrap_target = "godot_res_wrap" + env["OBJSUFFIX"]
105 else:
106 res_wrap_file = "godot_res_wrap_template.rc"
107 res_wrap_target = "godot_res_wrap_template" + env["OBJSUFFIX"]
108 res_wrap_obj = env_wrap.RES(res_wrap_target, res_wrap_file)
109 env_wrap.Depends(res_wrap_obj, "#core/version_generated.gen.h")
110
111 if env.msvc:
112 env_wrap.Append(LINKFLAGS=["/SUBSYSTEM:CONSOLE"])
113 env_wrap.Append(LINKFLAGS=["version.lib"])
114 else:
115 env_wrap.Append(LINKFLAGS=["-Wl,--subsystem,console"])
116 env_wrap.Append(LIBS=["version"])
117
118 prog_wrap = env_wrap.add_program("#bin/godot", common_win_wrap + res_wrap_obj, PROGSUFFIX=env["PROGSUFFIX_WRAP"])
119 arrange_program_clean(prog_wrap)
120 env_wrap.Depends(prog_wrap, prog)
121 sources += common_win_wrap + res_wrap_obj
122
123 if env["d3d12"]:
124 dxc_target_aliases = {
125 "x86_32": "x86",
126 "x86_64": "x64",
127 "arm32": "arm",
128 "arm64": "arm64",
129 }
130 dxc_arch_subdir = dxc_target_aliases[env["arch"]]
131
132 agility_target_aliases = {
133 "x86_32": "win32",
134 "x86_64": "x64",
135 "arm32": "arm",
136 "arm64": "arm64",
137 }
138 agility_arch_subdir = agility_target_aliases[env["arch"]]
139
140 # Used in cases where we can have multiple archs side-by-side.
141 arch_bin_dir = "#bin/" + env["arch"]
142
143 # Agility SDK
144 if env["agility_sdk_path"] != "" and os.path.exists(env["agility_sdk_path"]):
145 agility_dlls = ["D3D12Core.dll", "d3d12SDKLayers.dll"]
146 # Whether these are loaded from arch-specific directory or not has to be known at build time.
147 target_dir = arch_bin_dir if env["agility_sdk_multiarch"] else "#bin"
148 for dll in agility_dlls:
149 env.CommandNoCache(
150 target_dir + "/" + dll,
151 env["agility_sdk_path"] + "/build/native/bin/" + agility_arch_subdir + "/" + dll,
152 Copy("$TARGET", "$SOURCE"),
153 )
154
155 # PIX
156 if env["use_pix"]:
157 pix_dll = "WinPixEventRuntime.dll"
158 env.CommandNoCache(
159 "#bin/" + pix_dll,
160 env["pix_path"] + "/bin/" + dxc_arch_subdir + "/" + pix_dll,
161 Copy("$TARGET", "$SOURCE"),
162 )
163
164 if not env.msvc:
165 if env["debug_symbols"]:
166 env.AddPostAction(prog, env.Run(platform_windows_builders.make_debug_mingw))
167 if env["windows_subsystem"] == "gui":
168 env.AddPostAction(prog_wrap, env.Run(platform_windows_builders.make_debug_mingw))
169
170 env.platform_sources += sources