-
Notifications
You must be signed in to change notification settings - Fork 155
/
config.w32
186 lines (163 loc) · 7.78 KB
/
config.w32
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
ARG_ENABLE("ddtrace", "Datadog tracing support", "shared");
var ddtrace_cargo_profile = "debug";
if (PHP_DDTRACE != 'no') {
if (!PATH_PROG('cargo')) {
ERROR('cargo is required');
}
var versionpath = configure_module_dirname + "/ext/version.h";
var versionfile = FSO.CreateTextFile(versionpath, true);
versionfile.WriteLine("#ifndef PHP_DDTRACE_VERSION");
versionfile.WriteLine('#define PHP_DDTRACE_VERSION "' + FSO.OpenTextFile(configure_module_dirname + "/VERSION", 1).ReadAll() + '"');
versionfile.WriteLine("#endif");
versionfile.Close();
var version = PHP_VERSION * 100 + PHP_MINOR_VERSION;
var DDTRACE_EXT_SOURCES = "agent_info.c";
DDTRACE_EXT_SOURCES += " arrays.c";
DDTRACE_EXT_SOURCES += " auto_flush.c";
DDTRACE_EXT_SOURCES += " autoload_php_files.c";
DDTRACE_EXT_SOURCES += " collect_backtrace.c";
DDTRACE_EXT_SOURCES += " compat_string.c";
DDTRACE_EXT_SOURCES += " configuration.c";
DDTRACE_EXT_SOURCES += " distributed_tracing_headers.c";
DDTRACE_EXT_SOURCES += " ddshared.c";
DDTRACE_EXT_SOURCES += " dogstatsd.c";
DDTRACE_EXT_SOURCES += " engine_api.c";
DDTRACE_EXT_SOURCES += " engine_hooks.c";
DDTRACE_EXT_SOURCES += " exception_serialize.c";
DDTRACE_EXT_SOURCES += " excluded_modules.c";
DDTRACE_EXT_SOURCES += " git.c";
DDTRACE_EXT_SOURCES += " handlers_api.c";
DDTRACE_EXT_SOURCES += " handlers_curl" + (version < 800 ? "_php7" : "") + ".c";
DDTRACE_EXT_SOURCES += " handlers_exception.c";
DDTRACE_EXT_SOURCES += " handlers_internal.c";
DDTRACE_EXT_SOURCES += " handlers_pcntl.c";
DDTRACE_EXT_SOURCES += " ip_extraction.c";
DDTRACE_EXT_SOURCES += " live_debugger.c";
DDTRACE_EXT_SOURCES += " logging.c";
DDTRACE_EXT_SOURCES += " memory_limit.c";
DDTRACE_EXT_SOURCES += " otel_config.c";
DDTRACE_EXT_SOURCES += " profiling.c";
DDTRACE_EXT_SOURCES += " random.c";
DDTRACE_EXT_SOURCES += " remote_config.c";
DDTRACE_EXT_SOURCES += " serializer.c";
DDTRACE_EXT_SOURCES += " sidecar.c";
DDTRACE_EXT_SOURCES += " span.c";
DDTRACE_EXT_SOURCES += " startup_logging.c";
DDTRACE_EXT_SOURCES += " telemetry.c";
DDTRACE_EXT_SOURCES += " threads.c";
DDTRACE_EXT_SOURCES += " user_request.c";
if (version >= 800 && version < 802) {
DDTRACE_EXT_SOURCES += " weakrefs.c";
}
if (version >= 801) {
DDTRACE_EXT_SOURCES += " handlers_fiber.c";
}
if (version < 703 || version == 803) {
DDTRACE_EXT_SOURCES += " zend_hrtime.c";
}
var DDTRACE_HOOK_SOURCES = "uhook.c uhook_legacy.c";
if (version >= 800) {
DDTRACE_HOOK_SOURCES += " uhook_attributes.c";
}
var zai_dirname = configure_module_dirname + "/zend_abstract_interface";
var components_dirname = configure_module_dirname + "/components";
EXTENSION('ddtrace', "ext\\ddtrace.c");
ADD_FLAG("CFLAGS_DDTRACE", " /I " + configure_module_dirname + " ");
ADD_FLAG("CFLAGS_DDTRACE", " /I " + configure_module_dirname + "/ext ");
// ADD_FLAG("CFLAGS_DDTRACE", " /I " + configure_module_dirname + "/src/dogstatsd ");
ADD_FLAG("CFLAGS_DDTRACE", " /I " + zai_dirname + " ");
// We need the "new" preprocessor to successfully parse configuration.h
if (version < 800) {
ADD_FLAG("CFLAGS_DDTRACE", " /experimental:preprocessor ");
} else {
ADD_FLAG("CFLAGS_DDTRACE", " /Zc:preprocessor ");
}
ADD_SOURCES(configure_module_dirname + "/ext", DDTRACE_EXT_SOURCES, "ddtrace");
ADD_SOURCES(configure_module_dirname + "/ext/hook", DDTRACE_HOOK_SOURCES, "ddtrace");
ADD_SOURCES(configure_module_dirname + "/ext/integrations", "exec_integration.c integrations.c", "ddtrace");
ADD_SOURCES(configure_module_dirname + "/ext/limiter", "limiter.c", "ddtrace");
ADD_SOURCES(configure_module_dirname + "/ext/priority_sampling", "priority_sampling.c", "ddtrace");
ADD_SOURCES(configure_module_dirname + "/ext/tracer_tag_propagation", "tracer_tag_propagation.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/config", "config.c config_decode.c config_ini.c config_runtime.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/env", "env.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/exceptions", "exceptions.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/headers", "headers.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/hook", "hook.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/json", "json.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/zai_string", "string.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/symbols", "call.c lookup.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/uri_normalization", "uri_normalization.c", "ddtrace");
if (version < 800) {
ADD_SOURCES(zai_dirname + "/sandbox/php7", "sandbox.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/interceptor/php7", "interceptor.c resolver.c", "ddtrace");
} else {
ADD_SOURCES(zai_dirname + "/jit_utils", "jit_blacklist.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/sandbox/php8", "sandbox.c", "ddtrace");
ADD_SOURCES(zai_dirname + "/interceptor/php8", "interceptor.c resolver" + (version < 802 ? "_pre-8_2" : "") + ".c", "ddtrace");
}
ADD_SOURCES(configure_module_dirname + "/ext/vendor/mpack", "mpack.c", "ddtrace");
ADD_SOURCES(configure_module_dirname + "/ext/vendor/mt19937", "mt19937-64.c", "ddtrace");
// ADD_SOURCES(configure_module_dirname + "/src/dogstatsd", "client.c", "ddtrace");
ADD_SOURCES(components_dirname + "/log", "log.c", "ddtrace");
ADD_SOURCES(components_dirname + "/sapi", "sapi.c", "ddtrace");
ADD_SOURCES(components_dirname + "/string_view", "string_view.c", "ddtrace");
function recursivelySearchRustFiles(path) {
var folder = FSO.GetFolder(path);
var files = [];
var fc = new Enumerator(folder.SubFolders);
for (; !fc.atEnd(); fc.moveNext()) {
var item_name = FSO.GetFileName(fc.item());
files = files.concat(recursivelySearchRustFiles(fc.item().Path));
}
var fc = new Enumerator(folder.Files);
for (; !fc.atEnd(); fc.moveNext()) {
var item_name = fc.item().Path;
if (item_name.match(/\.rs$/) || item_name.match(/Cargo\.toml$/)) {
files.push(condense_path(item_name));
}
}
return files;
}
var rust_files = recursivelySearchRustFiles(configure_module_dirname + "/libdatadog").concat(recursivelySearchRustFiles(configure_module_dirname + "/components-rs"));
var cargo_lib = "$(BUILD_DIR)/target/" + ddtrace_cargo_profile + "/ddtrace_php.lib";
var fragment = configure_module_dirname + "/Makefile.frag.w32";
frag_out = FSO.CreateTextFile(fragment, true);
frag_out.WriteLine("CARGO_TARGET_DIR=$(BUILD_DIR)/target/");
// Promote to env var
frag_out.WriteLine("!if [set CARGO_TARGET_DIR=$(CARGO_TARGET_DIR)]");
frag_out.WriteLine("!endif");
frag_out.WriteLine("!if [set RUSTC_BOOTSTRAP=1]");
frag_out.WriteLine("!endif");
frag_out.WriteLine("!if [set RUSTFLAGS=--cfg windows_seh_wrapper]");
// Not supported yet on Windows: --cfg tokio_unstable --cfg tokio_taskdump
frag_out.WriteLine("!endif");
frag_out.WriteLine(cargo_lib + ": " + rust_files.join(" "));
var build_cargo = "\t$(CARGO) build --package ddtrace-php " + (ddtrace_cargo_profile == "release" ? "--profile tracer-release" : "");
if (configure_module_dirname.match(/^[A-Z]:/)) {
frag_out.WriteLine(build_cargo);
} else {
frag_out.WriteLine("\t@cd \"$(PHP_SRC_DIR)/" + configure_module_dirname + "\"");
frag_out.WriteLine(build_cargo);
frag_out.WriteLine("\t@cd \"$(PHP_SRC_DIR)\"");
}
frag_out.Close();
ADD_FLAG("STATIC_EXT_OBJS", cargo_lib);
ADD_FLAG("DEPS_DDTRACE", cargo_lib);
ADD_FLAG("LIBS_DDTRACE", "userenv.lib crypt32.lib Powrprof.lib Secur32.Lib ncrypt.lib ntdll.lib oleaut32.lib " + cargo_lib);
var defpath = configure_module_dirname + "/ddtrace.def";
deffile = FSO.CreateTextFile(defpath, true);
deffile.WriteLine("EXPORTS");
var contents = FSO.OpenTextFile(configure_module_dirname + "/ddtrace.sym", 1).ReadAll();
if (!PHP_DDTRACE_SHARED) {
contents = contents.replace(/get_module\s*/, "");
}
deffile.Write(contents);
deffile.Close();
defpath = defpath.replace(/\//, "\\");
if (PHP_DDTRACE_SHARED) {
ADD_FLAG("DLL_LDFLAGS", "/def:" + defpath);
} else {
ADD_DEF_FILE(defpath);
}
ADD_MAKEFILE_FRAGMENT(fragment);
}