[buildj] generate config.{h,vapi}



commit bb4d61f51f640362f6ca402379ee82c64f0dd3d7
Author: Abderrahim Kitouni <a kitouni gmail com>
Date:   Mon Sep 13 12:23:54 2010 +0100

    generate config.{h,vapi}

 extra_tools.py |   38 ++++++++++++++++++++++++++++++++++++++
 wscript        |    5 ++++-
 2 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/extra_tools.py b/extra_tools.py
new file mode 100644
index 0000000..549c36d
--- /dev/null
+++ b/extra_tools.py
@@ -0,0 +1,38 @@
+import os
+
+from Configure import conf
+from Constants import *
+import Utils
+
+# Things here should probably go into waf at some point
+
+ conf
+def write_config_vapi(self, configfile='', env=''):
+	if not configfile: configfile = 'config.vapi'
+	if not env: env = self.env
+
+	vapi = '[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")] \n' + \
+	       'namespace Config {\n'
+
+	defs = self.env[DEFINES] or Utils.ordered_dict()
+	for key in defs.allkeys:
+		val = defs[key]
+		if isinstance(val, int):
+			vapi += "\tpublic const int %s;\n" % key
+		else:
+			vapi += "\tpublic const string %s;\n" % key
+
+	vapi += '}'
+
+	path = os.sep.join([self.blddir, env.variant(), configfile])
+	(dir, base) = os.path.split(path)
+	Utils.check_dir(dir)
+
+	dest = open(path, 'w')
+	dest.write(vapi)
+	env.append_unique(CFG_FILES, configfile)
+	dest.close()
+
+	env.append_unique('VALAFLAGS', "--vapidir=%s" % dir)
+	env.append_unique('VALAFLAGS', "--pkg=config")
+
diff --git a/wscript b/wscript
index 6379ab8..377dc1d 100644
--- a/wscript
+++ b/wscript
@@ -2,6 +2,7 @@ import os
 import Utils
 import Options
 from buildj import *
+import extra_tools
 
 APPNAME = None
 VERSION = None
@@ -91,7 +92,9 @@ def configure (conf):
 		if not conf.env.HAVE_GLIB_2_0:
 			conf.check_cfg (package="glib-2.0", mandatory=True)
 
-				
+	conf.write_config_header()
+	conf.write_config_vapi()
+
 def build(bld):
 	project = parse_project_file ()
 



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