]> granicus.if.org Git - php/commitdiff
Fix inclusion order for phpize builds on Windows
authorChristoph M. Becker <cmbecker69@gmx.de>
Sun, 4 Oct 2020 10:50:58 +0000 (12:50 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Wed, 18 Nov 2020 11:50:26 +0000 (12:50 +0100)
`configure` for `phpize` builds on Windows creates Makefile and
config.pickle.h and includes the latter via the command line option
`/FI`.  That implies that config.pickle.h is always included before
config.w32.h, which means that standard definitions always override
extension specific definitions, while it should be the other way round.

Therefore, we change the inclusion order by including config.pickle.h
at the end of config.w32.h if the former is available, and also make
sure to avoid any potential C4005 warnings by `#undef`ining the macros
before defining them.

Closes GH-6269.

NEWS
win32/build/confutils.js

diff --git a/NEWS b/NEWS
index b9e81b417f60c82b4f17ac9dc1b163d719a92c9c..2f1ff9e63aea7f034f2fd4fa9cb5f1c4a4ed506a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ PHP                                                                        NEWS
 |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
 ?? ??? ????, PHP 8.1.0alpha1
 
+- Core:
+  . Fixed inclusion order for phpize builds on Windows. (cmb)
+
 - FTP:
   . Convert resource<ftp> to object \FTPConnection. (Sara)
 
index d080140d03beda91de05aab44dc3be82cd86adc3..1871e582abc210fbb92590996e46d9276af14b8b 100644 (file)
@@ -1542,7 +1542,6 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir)
                        var _tmp = FSO.CreateTextFile(PHP_DIR + "/include/main/config.pickle.h", true);
                        _tmp.Close();
                }
-               cflags = "/FI main/config.pickle.h " + cflags;
        }
        ADD_FLAG("CFLAGS_" + EXT, cflags);
 
@@ -2207,7 +2206,7 @@ function generate_config_pickle_h()
                        var ln = outfile.ReadLine();
 
                        for (var i in keys) {
-                               var reg = new RegExp("#define[\s ]+" + keys[i] + "[\s ]*.*", "g");
+                               var reg = new RegExp("#define[\s ]+" + keys[i] + "[\s ]*.*|#undef[\s ]+" + keys[i], "g");
 
                                if (ln.match(reg)) {
                                        found = true;
@@ -2233,6 +2232,7 @@ function generate_config_pickle_h()
                        continue;
                }*/
 
+               lines.push("#undef " + keys[i]);
                lines.push("#define " + keys[i] + " " + item[0]);
        }
 
@@ -2309,6 +2309,11 @@ function generate_config_h()
                outfile.WriteLine("#define " + keys[i] + " " + pieces);
        }
 
+       outfile.WriteBlankLines(1);
+       outfile.WriteLine("#if __has_include(\"main/config.pickle.h\")");
+       outfile.WriteLine("#include \"main/config.pickle.h\"");
+       outfile.WriteLine("#endif");
+
        outfile.Close();
 }