@conf
def run_c_code(self, *k, **kw):
	test_f_name = kw['compile_filename']

	k = 0
	while k < 10000:
		# make certain to use a fresh folder - necessary for win32
		dir = os.path.join(self.blddir, '.conf_check_%d' % k)

		# if the folder already exists, remove it
		try:
			shutil.rmtree(dir)
		except __HOLE__:
			pass

		try:
			os.stat(dir)
		except OSError:
			break

		k += 1

	try:
		os.makedirs(dir)
	except:
		self.fatal('cannot create a configuration test folder %r' % dir)

	try:
		os.stat(dir)
	except:
		self.fatal('cannot use the configuration test folder %r' % dir)

	bdir = os.path.join(dir, 'testbuild')

	if not os.path.exists(bdir):
		os.makedirs(bdir)

	env = kw['env']

	dest = open(os.path.join(dir, test_f_name), 'w')
	dest.write(kw['code'])
	dest.close()

	back = os.path.abspath('.')

	bld = Build.BuildContext()
	bld.log = self.log
	bld.all_envs.update(self.all_envs)
	bld.all_envs['default'] = env
	bld.lst_variants = bld.all_envs.keys()
	bld.load_dirs(dir, bdir)

	os.chdir(dir)

	bld.rescan(bld.srcnode)

	if not 'features' in kw:
		# conf.check(features='cc cprogram pyext', ...)
		kw['features'] = [kw['compile_mode'], kw['type']] # "cprogram cc"

	o = bld(features=kw['features'], source=test_f_name, target='testprog')

	for k, v in kw.iteritems():
		setattr(o, k, v)

	self.log.write("==>\n%s\n<==\n" % kw['code'])

	# compile the program
	try:
		bld.compile()
	except Utils.WafError:
		ret = Utils.ex_stack()
	else:
		ret = 0

	# chdir before returning
	os.chdir(back)

	if ret:
		self.log.write('command returned %r' % ret)
		self.fatal(str(ret))

	# if we need to run the program, try to get its result
	# keep the name of the program to execute
	if kw['execute']:
		lastprog = o.link_task.outputs[0].abspath(env)

		args = Utils.to_list(kw.get('exec_args', []))
		proc = Utils.pproc.Popen([lastprog] + args, stdout=Utils.pproc.PIPE, stderr=Utils.pproc.PIPE)
		(out, err) = proc.communicate()
		w = self.log.write
		w(str(out))
		w('\n')
		w(str(err))
		w('\n')
		w('returncode %r' % proc.returncode)
		w('\n')
		if proc.returncode:
			self.fatal(Utils.ex_stack())
		ret = out

	return ret
dataset/ETHPy150Open appcelerator-archive/poc-nodejs-desktop/Resources/nodejs/builds/linux/node/lib/node/wafadmin/Tools/config_c.py/run_c_code