Skip to contentSkip to conversation

Added fake configure.h generation to Python-based build system

PATCH In review Samuli Seppänen 2 participants 4 messages Nov 26, 2010 – Nov 30, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added fake configure.h generation to Python-based build system

From 38489e6179a357626d9233f9b1204bf6bc93341a Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Samuli=20Sepp=C3=A4nen?= <[email protected]>
Date: Fri, 26 Nov 2010 16:32:47 +0200
Subject: [PATCH] Added fake configure.h generation to Python-based build system
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Building OpenVPN using the Python-based build system fails because of missing configure.h file. This patch adds code to win/wb.py and win/config.py to automatically generate a fake configure.h file which contains build parameters parsed from win/settings.in in CONFIGURE_DEFINES, as well as a more proper value for the CONFIGURE_CALL variable.

---
 win/config.py |    3 ++-
 win/wb.py     |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletions(-)
win/config.py +2 -1
index cf38cac..c9956cc 100644
@@ -1,6 +1,7 @@
-from wb import preprocess, autogen, mod_fn, home_fn, build_autodefs, make_headers_objs, dict_def
+from wb import preprocess, autogen, mod_fn, home_fn, build_configure_h, build_autodefs, make_headers_objs, dict_def
 
 def main(config):
+    build_configure_h(config, mod_fn(home_fn('configure.h')), head_comment='/* %s */\n\n' % autogen)
     build_autodefs(config, mod_fn('autodefs.h.in'), home_fn('autodefs.h'))
     ho = make_headers_objs(home_fn('Makefile.am'))
 
win/wb.py +20 -0
index f7f4f4a..a368712 100644
@@ -70,6 +70,26 @@ def build_autodefs(kv, autodefs_in, autodefs_out):
                quote_end='@',
                head_comment='/* %s */\n\n' % autogen)
 
+'''Generate a fake configure.h dynamically'''
+def build_configure_h(kv, configure_h_out, head_comment):
+    fout = open(configure_h_out, 'w')
+    configure_defines='#define CONFIGURE_DEFINES \"'
+    configure_call='#define CONFIGURE_CALL \" config_all.py \"'
+
+    fout.write(head_comment)
+
+    dict = get_config()
+
+    for key, value in dict.iteritems():
+        configure_defines = configure_defines + " " + key + "=" + value + ","
+
+    configure_defines = configure_defines + "\"" + "\n"
+
+    fout.write(configure_defines)
+    fout.write(configure_call)
+    fout.close()
+
+
 def preprocess(kv, in_fn, out_fn, quote_begin=None, quote_end=None, if_prefix=None, head_comment=None):
     def repfn(m):
         var, = m.groups()
Signature · 1 line
1.6.3.3
#1 lore raw

One clarification... this is how configure.h will look:

/* Automatically generated by OpenVPN Windows build system */

#define CONFIGURE_DEFINES " DIST=dist, PRODUCT_TAP_RELDATE=04/19/2010, PRODUCT_TAP_MINOR_VER=7, DDKVER=7600.16385.1, OPENVPN_GUI_DIR=../openvpn-gui, PRODUCT_TAP_DEVICE_DESCRIPTION=TAP-Win32 Adapter V9, OUTFILE_LABEL=, PRODUCT_NAME=OpenVPN, TISRC=../tapinstall, PRODUCT_TAP_CHARACTERISTICS=0x81, PRODUCT_TAP_MAJOR_VER=9, SIGNTOOL=../signtool, TITLE_LABEL=, PRODUCT_UNIX_NAME=openvpn, PRODUCT_TAP_ID=tap0901, PRODUCT_VERSION=2.2-beta, PRODUCT_TAP_PROVIDER=TAP-Win32 Provider V9, OPENSSL_DIR=../openssl, PRODUCT_FILE_EXT=ovpn, DDK_PATH=c:/winddk/7600.16385.1, DDKVER_MAJOR=7600, MSVC=C:/Program Files/Microsoft Visual Studio 9.0, LZO_DIR=../lzo, OPENVPN_GUI=openvpn-gui-1.0.3.exe, TAP_DIST=tap_dist, PRODUCT_TAP_WIN32_MIN_MINOR=1, PKCS11_HELPER_DIR=../pkcs11-helper, PRODUCT_SIGN_CN=openvpn, PRODUCT_TAP_WIN32_MIN_MAJOR=9, MSVC_CRT=../Microsoft.VC90.CRT,"
#define CONFIGURE_CALL " config_all.py "

This information is stored in the openvpn executable and can be read with "openvpn --version".

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock
#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 20 lines · Samuli Seppänen

One clarification... this is how configure.h will look:

/* Automatically generated by OpenVPN Windows build system */

#define CONFIGURE_DEFINES " DIST=dist, PRODUCT_TAP_RELDATE=04/19/2010, PRODUCT_TAP_MINOR_VER=7, DDKVER=7600.16385.1, OPENVPN_GUI_DIR=../openvpn-gui, PRODUCT_TAP_DEVICE_DESCRIPTION=TAP-Win32 Adapter V9, OUTFILE_LABEL=, PRODUCT_NAME=OpenVPN, TISRC=../tapinstall, PRODUCT_TAP_CHARACTERISTICS=0x81, PRODUCT_TAP_MAJOR_VER=9, SIGNTOOL=../signtool, TITLE_LABEL=, PRODUCT_UNIX_NAME=openvpn, PRODUCT_TAP_ID=tap0901, PRODUCT_VERSION=2.2-beta, PRODUCT_TAP_PROVIDER=TAP-Win32 Provider V9, OPENSSL_DIR=../openssl, PRODUCT_FILE_EXT=ovpn, DDK_PATH=c:/winddk/7600.16385.1, DDKVER_MAJOR=7600, MSVC=C:/Program Files/Microsoft Visual Studio 9.0, LZO_DIR=../lzo, OPENVPN_GUI=openvpn-gui-1.0.3.exe, TAP_DIST=tap_dist, PRODUCT_TAP_WIN32_MIN_MINOR=1, PKCS11_HELPER_DIR=../pkcs11-helper, PRODUCT_SIGN_CN=openvpn, PRODUCT_TAP_WIN32_MIN_MAJOR=9, MSVC_CRT=../Microsoft.VC90.CRT,"
#define CONFIGURE_CALL " config_all.py "

Quoted 2 lines

This information is stored in the openvpn executable and can be read with "openvpn --version".

In general, the patch looks fine. What I'm wondering about is this information we're collecting here.

My question is more: To rebuild a binary with the exact same featureset as a already prebuilt binary have, is this information sufficient? And is it the right information?

The generated configure.h file when running via autotools will extract ENABLE and DISABLE macros from config.h. That defines the features being built into OpenVPN. For Windows builds outside autotools that's another file, config-win32.h iirc. This is not auto-generated as config.h is with autotools.

I do see that this information here can also be important and relevant, but maybe not as a CONFIGURE_DEFINES macro. This is more WINBUILD_PARAMS information.

As a user may edit config-win32.h to enable or disable features, would it be an idea to implement a config-win32.h parser which would extract the relevant information? Look at configure_h.awk for more information.

kind regards,

David Sommerseth
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkzv1FcACgkQDC186MBRfrrIGACdFwezw3Emrk5v0wiZqTjSTBLL Ux8An3nYTQsiB2De4aS9bZEUzzX0Vcbm
=kWFp
-----END PGP SIGNATURE-----

#3 lore raw

Hi David,

Quoted 24 lines · Samuli Seppänen
Quoted 20 lines

One clarification... this is how configure.h will look:

/* Automatically generated by OpenVPN Windows build system */

#define CONFIGURE_DEFINES " DIST=dist, PRODUCT_TAP_RELDATE=04/19/2010, PRODUCT_TAP_MINOR_VER=7, DDKVER=7600.16385.1, OPENVPN_GUI_DIR=../openvpn-gui, PRODUCT_TAP_DEVICE_DESCRIPTION=TAP-Win32 Adapter V9, OUTFILE_LABEL=, PRODUCT_NAME=OpenVPN, TISRC=../tapinstall, PRODUCT_TAP_CHARACTERISTICS=0x81, PRODUCT_TAP_MAJOR_VER=9, SIGNTOOL=../signtool, TITLE_LABEL=, PRODUCT_UNIX_NAME=openvpn, PRODUCT_TAP_ID=tap0901, PRODUCT_VERSION=2.2-beta, PRODUCT_TAP_PROVIDER=TAP-Win32 Provider V9, OPENSSL_DIR=../openssl, PRODUCT_FILE_EXT=ovpn, DDK_PATH=c:/winddk/7600.16385.1, DDKVER_MAJOR=7600, MSVC=C:/Program Files/Microsoft Visual Studio 9.0, LZO_DIR=../lzo, OPENVPN_GUI=openvpn-gui-1.0.3.exe, TAP_DIST=tap_dist, PRODUCT_TAP_WIN32_MIN_MINOR=1, PKCS11_HELPER_DIR=../pkcs11-helper, PRODUCT_SIGN_CN=openvpn, PRODUCT_TAP_WIN32_MIN_MAJOR=9, MSVC_CRT=../Microsoft.VC90.CRT,"
#define CONFIGURE_CALL " config_all.py "

Quoted 2 lines

This information is stored in the openvpn executable and can be read with "openvpn --version".

Quoted 6 lines

In general, the patch looks fine. What I'm wondering about is this information we're collecting here.

My question is more: To rebuild a binary with the exact same featureset as a already prebuilt binary have, is this information sufficient? And is it the right information?

Not sure, I'm not that far in the build process yet :).

Quoted 6 lines

The generated configure.h file when running via autotools will extract ENABLE and DISABLE macros from config.h. That defines the features being built into OpenVPN. For Windows builds outside autotools that's another file, config-win32.h iirc. This is not auto-generated as config.h is with autotools.

Oh, I somehow managed to miss config-win32.h...

Quoted 9 lines

I do see that this information here can also be important and relevant, but maybe not as a CONFIGURE_DEFINES macro. This is more WINBUILD_PARAMS information.

As a user may edit config-win32.h to enable or disable features, would it be an idea to implement a config-win32.h parser which would extract the relevant information? Look at configure_h.awk for more information.

I agree it's better to use config-win32.h to populate CONFIGURE_DEFINES. I'll make the modification and send in another patch. Regarding WINBUILD_PARAMS... is that variable used anywhere currently? A quick "grep -r" gave zero results.

Signature · 5 lines
Samuli Seppänen
Community Manager
OpenVPN Technologies, Inc

irc freenode net: mattock