[libxslt/distutils: 2/2] win32/configure.js: Support building Python bindings




commit b88d9d39be57eae77ce8f92e1e301dc39c8c8f26
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Mar 9 16:45:46 2022 +0800

    win32/configure.js: Support building Python bindings
    
    Add the python=yes option so that one can build the Python bindings.  This will
    configure python/setup.py, which one can use to build and package the bindings
    via distutils.

 win32/configure.js | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
---
diff --git a/win32/configure.js b/win32/configure.js
index 66986b04..91cb5692 100644
--- a/win32/configure.js
+++ b/win32/configure.js
@@ -48,6 +48,7 @@ var withZlib = false;
 var withCrypto = true;
 var withModules = false;
 var withProfiler = true;
+var withPython = false;
 /* Win32 build options. */
 var dirSep = "\\";
 var compiler = "msvc";
@@ -108,6 +109,7 @@ function usage()
        txt += "  crypto:     Enable Crypto support (" + (withCrypto? "yes" : "no") + ")\n";
        txt += "  modules:    Enable Module support (" + (withModules? "yes" : "no") + ")\n";
        txt += "  profiler:   Enable Profiler support (" + (withProfiler? "yes" : "no") + ")\n";
+       txt += "  python:     Build Python bindings (" + (withPython? "yes" : "no")  + ")\n";
        txt += "\nWin32 build options, default value given in parentheses:\n\n";
        txt += "  compiler:   Compiler to be used [msvc|mingw] (" + compiler + ")\n";
        txt += "  cruntime:   C-runtime compiler option (only msvc) (" + cruntime + ")\n";
@@ -181,6 +183,7 @@ function discoverVersion()
        vf.WriteLine("WITH_CRYPTO=" + (withCrypto? "1" : "0"));
        vf.WriteLine("WITH_MODULES=" + (withModules? "1" : "0"));
        vf.WriteLine("WITH_PROFILER=" + (withProfiler? "1" : "0"));
+       vf.WriteLine("WITH_PYTHON=" + (withPython? "1" : "0"));
        vf.WriteLine("DEBUG=" + (buildDebug? "1" : "0"));
        vf.WriteLine("STATIC=" + (buildStatic? "1" : "0"));
        vf.WriteLine("PREFIX=" + buildPrefix);
@@ -270,6 +273,49 @@ function configureExslt()
        of.Close();
 }
 
+/* Configures Python bindings. Otherwise identical to the above */
+function configureLibxsltPy()
+{
+       var pyOptsFileIn = baseDir + "\\python\\setup.py.in";
+       var pyOptsFile = baseDir + "\\python\\setup.py";
+       var fso, ofi, of, ln, s;
+       fso = new ActiveXObject("Scripting.FileSystemObject");
+       ofi = fso.OpenTextFile(pyOptsFileIn, 1);
+       of = fso.CreateTextFile(pyOptsFile, true);
+       while (ofi.AtEndOfStream != true) {
+               ln = ofi.ReadLine();
+               s = new String(ln);
+               if (s.search(/\@VERSION\@/) != -1) {
+                       of.WriteLine(s.replace(/\@VERSION\@/, 
+                               verMajorXslt + "." + verMinorXslt + "." + verMicroXslt));
+               } else if (s.search(/\@prefix\@/) != -1) {
+                       of.WriteLine(s.replace(/\@prefix\@/, buildPrefix));
+               } else if (s.search(/\@LIBXSLT_VERSION_NUMBER\@/) != -1) {
+                       of.WriteLine(s.replace(/\@LIBXSLT_VERSION_NUMBER\@/, 
+                               verMajorXslt*10000 + verMinorXslt*100 + verMicroXslt*1));
+               } else if (s.search(/\@LIBXSLT_VERSION_EXTRA\@/) != -1) {
+                       of.WriteLine(s.replace(/\@LIBXSLT_VERSION_EXTRA\@/, verCvs));
+               } else if (s.search(/\@WITH_TRIO\@/) != -1) {
+                       of.WriteLine(s.replace(/\@WITH_TRIO\@/, withTrio? "1" : "0"));
+               } else if (s.search(/\@WITH_XSLT_DEBUG\@/) != -1) {
+                       of.WriteLine(s.replace(/\@WITH_XSLT_DEBUG\@/, withXsltDebug? "1" : "0"));
+               } else if (s.search(/\@WITH_MEM_DEBUG\@/) != -1) {
+                       of.WriteLine(s.replace(/\@WITH_MEM_DEBUG\@/, withMemDebug? "1" : "0"));
+               } else if (s.search(/\@WITH_DEBUGGER\@/) != -1) {
+                       of.WriteLine(s.replace(/\@WITH_DEBUGGER\@/, withDebugger? "1" : "0"));
+               } else if (s.search(/\@WITH_MODULES\@/) != -1) {
+                       of.WriteLine(s.replace(/\@WITH_MODULES\@/, withModules? "1" : "0"));
+               } else if (s.search(/\@WITH_PROFILER\@/) != -1) {
+                       of.WriteLine(s.replace(/\@WITH_PROFILER\@/, withProfiler? "1" : "0"));
+               } else if (s.search(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/) != -1) {
+                       of.WriteLine(s.replace(/\@LIBXSLT_DEFAULT_PLUGINS_PATH\@/, "NULL"));
+               } else
+                       of.WriteLine(ln);
+       }
+       ofi.Close();
+       of.Close();
+}
+
 /* Creates the readme file for the binary distribution of 'bname', for the
    version 'ver' in the file 'file'. This one is called from the Makefile when
    generating a binary distribution. The parameters are passed by make. */
@@ -336,6 +382,8 @@ for (i = 0; (i < WScript.Arguments.length) && (error == 0); i++) {
                        withModules = strToBool(arg.substring(opt.length + 1, arg.length));
                else if (opt == "profiler")
                        withProfiler = strToBool(arg.substring(opt.length + 1, arg.length));
+               else if (opt == "python")
+                       withPython = strToBool(arg.substring(opt.length + 1, arg.length));
                else if (opt == "compiler")
                        compiler = arg.substring(opt.length + 1, arg.length);
                else if (opt == "cruntime")
@@ -432,6 +480,15 @@ if (error != 0) {
        WScript.Quit(error);
 }
 
+if (withPython == true) {
+       configureLibxsltPy();
+       if (error != 0) {
+               WScript.Echo("Configuration failed, aborting.");
+               WScript.Quit(error);
+       }
+
+}
+
 // Configure libexslt.
 configureExslt();
 if (error != 0) {
@@ -469,6 +526,7 @@ txtOut += "         With zlib: " + boolToStr(withZlib) + "\n";
 txtOut += "            Crypto: " + boolToStr(withCrypto) + "\n";
 txtOut += "           Modules: " + boolToStr(withModules) + "\n";
 txtOut += "          Profiler: " + boolToStr(withProfiler) + "\n";
+txtOut += "   Python bindings: " + boolToStr(withPython) + "\n";
 txtOut += "\n";
 txtOut += "Win32 build configuration\n";
 txtOut += "-------------------------\n";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]