Repository navigation
Expand file tree
/
Copy pathconfig.w32
More file actions
101 lines (95 loc) · 4.44 KB
/
Copy pathconfig.w32
File metadata and controls
101 lines (95 loc) · 4.44 KB
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
// phpstan_turbo — Windows build (php-devel-pack: phpize && configure && nmake).
// The extension version is baked from the PHPSTANTURBO_VERSION environment
// variable at configure time (the CI workflow computes it the same way the
// Makefile does), falling back to VERSION.txt (the monorepo SHA, generated
// and committed into the phpstan/turbo-ext subsplit by its workflow —
// builds there have no usable git history); with neither it defaults to
// "dev", which the enabler rejects.
// "yes" builds the one self-contained php_phpstan_turbo.dll; "core" and
// "extension" build the pair the distributed binaries are (README.md,
// "Shared core"): the core DLL once per thread-safety flavour, and per PHP
// version the extension DLL, which delay-loads the core from its own
// directory (main.cpp) and links against its import library — expected in
// the extension's directory when configuring with "extension".
ARG_ENABLE("phpstan-turbo", "phpstan turbo extension (yes, core or extension)", "no");
// The sources compiled against a PHP version's own layout — the Makefile's
// SHIM_SOURCES; everything else goes into the core.
var PHPSTAN_TURBO_SHIM_SOURCES = ["Abi.cpp", "Shadow.cpp", "TrustedTypes.cpp", "main.cpp"];
// Every .cpp file of a directory under the extension, sorted, as the
// space-separated list EXTENSION() and ADD_SOURCES() take, each name behind
// the given prefix — the sources are discovered like the Makefile's
// wildcard and config.m4's glob, not listed. buildconf concatenates every
// extension's config.w32 into one configure.js, hence the prefixed name.
// `select` picks the shim sources (true), the others (false), or all
// (undefined); TerminateHandler.cpp only matters to the Linux static
// libstdc++ link and goes with the core.
function phpstan_turbo_sources(dir, prefix, select)
{
var names = [];
var files = new Enumerator(FSO.GetFolder(configure_module_dirname + "\\" + dir).Files);
for (; !files.atEnd(); files.moveNext()) {
var name = FSO.GetFileName(files.item());
if (!/\.cpp$/i.test(name)) {
continue;
}
if (typeof(select) != "undefined") {
var shim = false;
for (var i = 0; i < PHPSTAN_TURBO_SHIM_SOURCES.length; i++) {
if (PHPSTAN_TURBO_SHIM_SOURCES[i].toLowerCase() == name.toLowerCase()) {
shim = true;
}
}
if (shim != select) {
continue;
}
}
names.push(prefix + name);
}
names.sort();
return names.join(" ");
}
if (PHP_PHPSTAN_TURBO != "no") {
var version = WScript.CreateObject("WScript.Shell").Environment("PROCESS")("PHPSTANTURBO_VERSION");
if ((!version || version == "") && FSO.FileExists(configure_module_dirname + "\\VERSION.txt")) {
version = file_get_contents(configure_module_dirname + "\\VERSION.txt").replace(/\s/g, "");
}
if (!version || version == "") {
version = "dev";
}
// /EHsc: the C++ standard library assumes unwinding; /bigobj: the
// generated parser action files exceed the default section limit.
// ZEND_ENABLE_STATIC_TSRMLS_CACHE: ZTS builds resolve EG()/CG() through
// the per-thread cache main.cpp defines (a no-op on NTS builds).
// The version is passed as a bare token (main.cpp stringizes it) —
// quote characters do not survive the configure-to-nmake pipeline.
var flags = "/std:c++17 /EHsc /bigobj /DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 /DPHPSTANTURBO_VERSION_RAW=" + version;
// backslash-separated paths: confutils' ADD_SOURCES derives the object
// directory by splitting on backslashes only — with forward slashes the
// objects compile flat while the link list expects the subpath
var core = PHP_ZTS == "yes" ? "phpstan_turbo_core-zts" : "phpstan_turbo_core";
if (PHP_PHPSTAN_TURBO == "core") {
EXTENSION("phpstan_turbo_core",
phpstan_turbo_sources("src", "src\\", false),
true,
flags + " /DPHPSTANTURBO_SPLIT /DPHPSTANTURBO_CORE_BUILD",
core + ".dll");
ADD_SOURCES(configure_module_dirname + "/src/parser",
phpstan_turbo_sources("src\\parser", ""),
"phpstan_turbo_core");
} else if (PHP_PHPSTAN_TURBO == "extension") {
EXTENSION("phpstan_turbo",
phpstan_turbo_sources("src", "src\\", true),
true,
flags + " /DPHPSTANTURBO_SPLIT");
ADD_FLAG("LIBS_PHPSTAN_TURBO", configure_module_dirname + "\\" + core + ".lib delayimp.lib");
ADD_FLAG("LDFLAGS_PHPSTAN_TURBO", "/DELAYLOAD:" + core + ".dll");
} else {
EXTENSION("phpstan_turbo",
phpstan_turbo_sources("src", "src\\"),
true,
flags);
ADD_SOURCES(configure_module_dirname + "/src/parser",
phpstan_turbo_sources("src\\parser", ""),
"phpstan_turbo");
}
}