[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/devtools/waf
From:       Thomas Nagy <tnagyemail-mail () yahoo ! fr>
Date:       2006-09-12 0:05:00
Message-ID: 1158019500.896453.18290.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 583315 by tnagy:

The test set should be complete now.


 M  +36 -66    demos/adv/wscript  
 M  +9 -8      wafadmin/Configure.py  
 M  +53 -1     wafadmin/Tools/checks.py  


--- trunk/playground/devtools/waf/demos/adv/wscript #583314:583315
@@ -186,41 +186,40 @@
 		functionfind = conf.create_function_enumerator()
 		#functionfind.mandatory = 1 # stop when a function is not found
 		functionfind.headers = headers_found
-		#functionfind.include_paths = ['/usr/include']
 		functionfind.function = pair[0]
 		functionfind.define = pair[1]
 		functionfind.run()
 
-def bub():
 
-
 	code = """
 #include <time.h>
 struct tm t; t.tm_gmtoff = 0;
 """
-	#if conf.TryBuild(code):
-	#	conf.addDefine('HAVE_TM_GMTON', 1)
+	if conf.try_build(code):
+		print "NOTE: define HAVE_TM_GMTON ok"
+		conf.addDefine('HAVE_TM_GMTON', 1)
 
 	code = """
 #include <sys/time.h>
 struct timeval tv; timerisset(&tv); timerclear(&tv); timercmp(&tv, &tv, <);
 timeradd(&tv, &tv, &tv); timersub(&tv, &tv, &tv);
 """
-	#if conf.TryBuild(code):
-	#	conf.addDefine('HAVE_TIMEOPS', 1)
+	if conf.try_build(code):
+		print "NOTE: define HAVE_TIMEOPS ok"
+		conf.addDefine('HAVE_TIMEOPS', 1)
 
 	code = """
 #include <termios.h>
 struct termios t; cfsetspeed(&t, B9600);
 """
-	if 1: #conf.TryBuild(code):
+	if conf.try_build(code, msg='HAVE_CFSETSPEED'):
 		conf.addDefine('HAVE_CFSETSPEED', 1)
 	else:
 		code = """
 #include <termios.h>
 struct termios t; cfsetispeed(&t, B9600);  cfsetospeed(&t, B9600);
 """
-		if conf.TryBuild(code):
+		if conf.try_build(code, msg='HAVE_CFSETISPEED'):
 			conf.addDefine('HAVE_CFSETISPEED', 1)
 			conf.addDefine('HAVE_CFSETOSPEED', 1)
 		else:
@@ -228,7 +227,7 @@
  #include <termios.h>
  struct termios t; t.c_iflag = B9600; t.c_oflag = B9600;
 """
-			if conf.TryBuild(code):
+			if conf.try_build(code, msg='HAVE_TERMIOS_CSPEED'):
 				conf.addDefine('HAVE_TERMIOS_CSPEED', 1)
 
 	code = """
@@ -237,8 +236,8 @@
 #include <sys/socket.h>
 struct msghdr msg; msg.msg_control;
 """
-	#if conf.TryBuild(code):
-	#	conf.addDefine('HAVE_MSGHDR_MSG_CONTROL', 1)
+	if conf.try_build(code, msg='HAVE_MSGHDR_MSG_CONTROL'):
+		conf.addDefine('HAVE_MSGHDR_MSG_CONTROL', 1)
 
 	code = """
 #define  _XOPEN_SOURCE 500
@@ -270,108 +269,79 @@
     exit(0);
 }																										
 """
-	#if conf.TryBuild(code):
-	#	conf.addDefine('USE_UNIX98PTYS', 1)
+	if conf.try_build(code, msg='USE_UNIX98PTYS'):
+		conf.addDefine('USE_UNIX98PTYS', 1)
 
-
-
-
-	headerconf=conf.create_header_configurator()
-
 	# This demonstrates that after testing the specified paths, the compiler is given a \
chance  # to see if it can find the header by itself
-
-
-	headerconf.uselib_name='STDL'
-	headerconf.names=['stdlib.h']
-	headerconf.paths=['/zapp/brannigan']
+	headerconf=conf.create_header_configurator()
+	headerconf.define='STDL'
+	headerconf.name='stdlib.h'
+	headerconf.path=['/zapp/brannigan']
 	headerconf.run()
 
 	# Finds GL/gl.h
-
-	headerconf.uselib_name='GL'
-	headerconf.names=['GL/gl.h']
-	headerconf.paths=['/usr/X11R6/include','/usr/include']
+	headerconf.define='GL'
+	headerconf.name='GL/gl.h'
+	headerconf.path=['/usr/X11R6/include','/usr/include']
 	headerconf.run()
 
 
 
-
-
-	# First column: name of the function
-	# Second column (optional): defines to be set in the config.h autogenerated header
-
-	glxprocs=[
-		['glXGetProcAddressARB','HAVE_GLX_GLXGETPROCADDRESS_ARB'],
-		['glXGetProcAddress','HAVE_GLX_GLXGETPROCADDRESS'],
-	]
-
-	functionfind = conf.create_function_enumerator()
-
-	# Tries to find one of the specified functions
-	
-	functionfind.function_calls = glxprocs
-	functionfind.headers = ['GL/glx.h']
-	functionfind.include_paths = ['/usr/X11R6/include','/usr/include']
-	functionfind.libs = ['GL']
-	functionfind.run()
-
-
-
-
-
-	pkgconf = conf.create_pkgconfig_configurator()
-
 	# Looks for pkg-config package "blah5000" (should fail unless you really have such \
                a package)
-	pkgconf.uselib_name = 'BLAH5000'
+	pkgconf = conf.create_pkgconfig_configurator()
+	pkgconf.define = 'BLAH5000'
 	pkgconf.name = 'blah5000'
 	pkgconf.run()
 
 	# Looks for pkg-config packages "gtkmm-2.4" and sets the uselib variables with name \
                "GTKMM"
-	pkgconf.uselib_name = 'GTKMM'
+	pkgconf.define = 'GTKMM'
 	pkgconf.name = 'gtkmm-2.4'
 	pkgconf.run()
 
-	pkgconf.uselib_name = 'BLUETOOTH'
+	pkgconf.define = 'BLUETOOTH'
 	pkgconf.name = 'bluez'
 	if pkgconf.run():
 		conf.addDefine('HAVE_BLUETOOTH_BLUEZ', 1)
 	
-	pkgconf.uselib_name = 'GLIB'
+	pkgconf.define = 'GLIB'
 	pkgconf.name = 'glib-2.0'
 	pkgconf.run()
 
 
 
-
-	toolconf = conf.create_cfgtool_configurator()
-
 	# Tries to use the "unobtainium-config" tool
-	toolconf.uselib_name = 'UNOBTAINIUM'
+	toolconf = conf.create_cfgtool_configurator()
+	toolconf.uselib = 'UNOBTAINIUM'
+	toolconf.define = 'HAVE_UNO'
 	toolconf.binary = 'unobtainium-config'
 	toolconf.run()
 
 	# Tries to use the "wx-config" tool and passes the resulting libs, cppflags etc. to \
the WX uselib  # variables
 	toolconf.uselib_name = 'WX'
+	toolconf.define = 'HAVE_WX'
+	toolconf.uselib = 'WX'
 	toolconf.binary = 'wx-config'
 	toolconf.run()
 
 
 	# Looks for the GL lib in the specified directories
 	libconf = conf.create_library_configurator()
-	libconf.uselib_name = 'GL'
-	libconf.names = ['GL']
+	libconf.uselib = 'GL'
+	libconf.name   = 'GL'
 	libconf.paths = ['/usr/X11R6/lib','/usr/lib','/usr/local/lib']
 	libconf.run()	
 
 	# Looks for one of the specified libs in the directories
 	# The first match will be used
+	libconf = conf.create_library_configurator()
 	libconf.uselib_name = 'WX_GL'
-	libconf.names = ['wx_gtk_gl','wx_gtk2_gl','wx_gtk2u_gl','wx_gtk_gl-2.6','wx_gtk2_gl-2.6','wx_gtk2u_gl-2.6']
 +	libconf.name = 'wx_gtk_gl'
 	libconf.paths = ['/usr/lib']
-	libconf.run()	
+	libconf.run()
 
+
 	# finally, write the configuration header
 	conf.writeConfigHeader('config.h')
 
--- trunk/playground/devtools/waf/wafadmin/Configure.py #583314:583315
@@ -309,17 +309,18 @@
 	def __init__(self,conf):
 		configurator_base.__init__(self, conf)
 
-		self.define_name   = ''
-		self.binary        = ''
+		self.uselib   = ''
+		self.define   = ''
+		self.binary   = ''
 
-		self.tests = {}
+		self.tests    = {}
 		self.uselib_name   = ''
 
 	def error(self):
 		fatal('%s cannot be found' % self.binary)
 
 	def validate(self):
-		if not self.define_name: self.define_name = 'HAVE_'+self.uselib_name
+		if not self.define: self.define = 'HAVE_'+self.uselib
 
 		if not self.tests:
 			self.tests['--cflags'] = 'CCFLAGS'
@@ -329,9 +330,9 @@
 	def run_cache(self, retval):
 		if retval:
 			self.update_env(retval)
-			self.conf.addDefine(self.define_name, 1)
+			self.conf.addDefine(self.define, 1)
 		else:
-			self.conf.addDefine(self.define_name, 0)
+			self.conf.addDefine(self.define, 0)
 		self.conf.checkMessage('config-tool %s (cached)' % self.binary, '', retval, \
option='')  
 	def run_test(self):
@@ -343,7 +344,7 @@
 			if ret: raise "error"
 
 			for flag in self.tests:
-				var = self.tests[flag]+'_'+self.uselib_name
+				var = self.tests[flag]+'_'+self.uselib
 				cmd = '%s %s 2>/dev/null' % (self.binary, flag)
 				retval[var] = [os.popen(cmd).read().strip()]
 
@@ -352,7 +353,7 @@
 			retval = {}
 			found = 0
 
-		self.conf.addDefine(self.define_name, found)
+		self.conf.addDefine(self.define, found)
 		self.conf.checkMessage('config-tool '+self.binary, '', found, option='')
 		return retval
 
--- trunk/playground/devtools/waf/wafadmin/Tools/checks.py #583314:583315
@@ -2,7 +2,7 @@
 # encoding: utf-8
 # Thomas Nagy, 2006 (ita)
 
-import Utils
+import Utils, Configure
 from Params import error
 
 endian_str = """
@@ -24,6 +24,46 @@
 }
 """
 
+
+# inheritance demo
+class compile_configurator(Configure.configurator_base):
+	def __init__(self, conf):
+		Configure.configurator_base.__init__(self, conf)
+		self.name = ''
+		self.code = ''
+		self.flags = ''
+		self.define = ''
+		self.uselib = ''
+		self.want_message = 0
+		self.msg = ''
+
+	def error(self):
+		fatal('test program would not run')
+
+	def run_cache(self, retval):
+		if self.want_message:
+			self.conf.checkMessage('compile code (cached)', '', 1, option=self.msg)
+
+	def validate(self):
+		if not self.code:
+			fatal('test configurator needs code to compile and run!')
+
+	def run_test(self):
+		obj = Configure.check_data()
+		obj.code = self.code
+		obj.env  = self.env
+		obj.uselib = self.uselib
+		obj.flags = self.flags
+		ret = self.conf.run_check(obj)
+
+		if self.want_message:
+			self.conf.checkMessage('compile code', '', ret, option=self.msg)
+
+		return ret
+
+def create_compile_configurator(self):
+	return compile_configurator(self)
+
 def checkEndian(self, define='', pathlst=[]):
 	if define == '': define = 'IS_BIGENDIAN'
 
@@ -131,6 +171,16 @@
 	if ret: return ret['result']
 	return None
 
+def try_build(self, code, uselib='', msg=''):
+	test = self.create_compile_configurator()
+	test.uselib = uselib
+        test.code = code
+	if msg:
+		test.want_message = 1
+		test.msg = msg
+	ret = test.run()
+	return ret
+
 def check_flags(self, flags, uselib='', options='', msg=1):
 	test = self.create_test_configurator()
 	test.uselib = uselib
@@ -152,6 +202,8 @@
 	conf.hook(checkEndian)
 	conf.hook(checkFeatures)
 	conf.hook(check_header)
+	conf.hook(create_compile_configurator)
+	conf.hook(try_build)
 	conf.hook(try_build_and_exec)
 	conf.hook(check_flags)
 	return 1


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic