Exemple #1
0
    def hello(self):
        '''Check compiler with the most famous program.
		'''
        compileCommand = CompileCommand.fromLine(self.compileCommandStr, '')
        ok = checkCompiler(self.log, compileCommand, self.outDir)
        print >> self.log, 'Compiler %s: %s' % ('works' if ok else 'broken',
                                                compileCommand)
        self.outVars['COMPILER'] = str(ok).lower()
Exemple #2
0
    def checkFunc(self, func):
        '''Probe for function.
		'''
        compileCommand = CompileCommand.fromLine(self.compileCommandStr, '')
        ok = checkFunc(self.log, compileCommand, self.outDir, func.name,
                       func.getFunctionName(), func.iterHeaders(self.platform))
        print >> self.log, '%s function: %s' % ('Found' if ok else 'Missing',
                                                func.getFunctionName())
        self.functionResults[func.getMakeName()] = ok
Exemple #3
0
	def hello(self):
		'''Check compiler with the most famous program.
		'''
		compileCommand = CompileCommand.fromLine(self.compileCommandStr, '')
		ok = checkCompiler(self.log, compileCommand, self.outDir)
		print >> self.log, 'Compiler %s: %s' % (
			'works' if ok else 'broken',
			compileCommand
			)
		self.outVars['COMPILER'] = str(ok).lower()
Exemple #4
0
	def checkFunc(self, func):
		'''Probe for function.
		'''
		compileCommand = CompileCommand.fromLine(self.compileCommandStr, '')
		ok = checkFunc(
			self.log, compileCommand, self.outDir,
			func.name, func.getFunctionName(), func.iterHeaders(self.platform)
			)
		print >> self.log, '%s function: %s' % (
			'Found' if ok else 'Missing',
			func.getFunctionName()
			)
		self.functionResults[func.getMakeName()] = ok
Exemple #5
0
	def checkTypeTraits(self):
		'''Probe for <type_traits>.
		'''
		def testNoTR1():
			yield '#include <type_traits>'
			yield 'const bool value = std::is_abstract<int>::value;'
		def testTR1():
			yield '#include <tr1/type_traits>'
			yield 'const bool value = std::tr1::is_abstract<int>::value;'
		compileCommand = CompileCommand.fromLine(self.compileCommandStr, '')
		outPath = self.outDir + '/type_traits.cc'
		if tryCompile(self.log, compileCommand, outPath, testNoTR1()):
			self.typeTraitsResult = 'std'
		elif tryCompile(self.log, compileCommand, outPath, testTR1()):
			self.typeTraitsResult = 'tr1'
		else:
			self.typeTraitsResult = 'missing'
Exemple #6
0
    def checkLibrary(self, makeName):
        library = librariesByName[makeName]
        cflags = resolve(
            self.log,
            library.getCompileFlags(self.platform,
                                    self.configuration.linkStatic(),
                                    self.distroRoot))
        ldflags = resolve(
            self.log,
            library.getLinkFlags(self.platform,
                                 self.configuration.linkStatic(),
                                 self.distroRoot))
        if self.platform == 'android':
            # This works around SDL 1.2's trickery with main().
            # If also weakens the probe considerably, since missing symbols
            # are no longer considered errors.
            # Remove this when we migrate to SDL2.
            ldflags += ' -shared'
        compileCommand = CompileCommand.fromLine(self.compileCommandStr,
                                                 cflags)
        linkCommand = LinkCommand.fromLine(self.compileCommandStr, ldflags)
        self.outVars['%s_CFLAGS' % makeName] = cflags
        self.outVars['%s_LDFLAGS' % makeName] = ldflags

        sourcePath = self.outDir + '/' + makeName + '.cc'
        objectPath = self.outDir + '/' + makeName + '.o'
        binaryPath = self.outDir + '/' + makeName + '.bin'
        if self.platform == 'android':
            binaryPath = self.outDir + '/' + makeName + '.so'

        funcName = library.function
        headers = library.getHeaders(self.platform)

        def takeFuncAddr():
            # Try to include the necessary headers and get the function address.
            for header in headers:
                yield '#include %s' % header
            yield 'void (*f)() = reinterpret_cast<void (*)()>(%s);' % funcName
            yield 'int main(int argc, char** argv) {'
            yield '  return 0;'
            yield '}'

        writeFile(sourcePath, takeFuncAddr())
        try:
            compileOK = compileCommand.compile(self.log, sourcePath,
                                               objectPath)
            print >> self.log, '%s: %s header' % (makeName, 'Found'
                                                  if compileOK else 'Missing')
            if compileOK:
                linkOK = linkCommand.link(self.log, [objectPath], binaryPath)
                print >> self.log, '%s: %s lib' % (makeName, 'Found'
                                                   if linkOK else 'Missing')
            else:
                linkOK = False
                print >> self.log, (
                    '%s: Cannot test linking because compile failed' %
                    makeName)
        finally:
            remove(sourcePath)
            if isfile(objectPath):
                remove(objectPath)
            if isfile(binaryPath):
                remove(binaryPath)

        self.outVars['HAVE_%s_H' % makeName] = 'true' if compileOK else ''
        self.outVars['HAVE_%s_LIB' % makeName] = 'true' if linkOK else ''
        if linkOK:
            versionGet = library.getVersion(self.platform,
                                            self.configuration.linkStatic(),
                                            self.distroRoot)
            if callable(versionGet):
                version = versionGet(compileCommand, self.log)
            else:
                version = resolve(self.log, versionGet)
            if version is None:
                version = 'error'
            self.outVars['VERSION_%s' % makeName] = version
Exemple #7
0
	def checkLibrary(self, makeName):
		library = librariesByName[makeName]
		cflags = resolve(
			self.log,
			library.getCompileFlags(
				self.platform, self.configuration.linkStatic(), self.distroRoot
				)
			)
		ldflags = resolve(
			self.log,
			library.getLinkFlags(
				self.platform, self.configuration.linkStatic(), self.distroRoot
				)
			)
		compileCommand = CompileCommand.fromLine(self.compileCommandStr, cflags)
		linkCommand = LinkCommand.fromLine(self.compileCommandStr, ldflags)
		self.outVars['%s_CFLAGS' % makeName] = cflags
		self.outVars['%s_LDFLAGS' % makeName] = ldflags

		sourcePath = self.outDir + '/' + makeName + '.cc'
		objectPath = self.outDir + '/' + makeName + '.o'
		binaryPath = self.outDir + '/' + makeName + '.bin'
		if self.platform == 'android':
			binaryPath = self.outDir + '/' + makeName + '.so'

		funcName = library.function
		headers = library.getHeaders(self.platform)
		def takeFuncAddr():
			# Try to include the necessary headers and get the function address.
			for header in headers:
				yield '#include %s' % header
			yield 'void (*f)() = reinterpret_cast<void (*)()>(%s);' % funcName
			yield 'int main(int argc, char** argv) {'
			yield '  return 0;'
			yield '}'
		writeFile(sourcePath, takeFuncAddr())
		try:
			compileOK = compileCommand.compile(self.log, sourcePath, objectPath)
			print >> self.log, '%s: %s header' % (
				makeName,
				'Found' if compileOK else 'Missing'
				)
			if compileOK:
				linkOK = linkCommand.link(self.log, [ objectPath ], binaryPath)
				print >> self.log, '%s: %s lib' % (
					makeName,
					'Found' if linkOK else 'Missing'
					)
			else:
				linkOK = False
				print >> self.log, (
					'%s: Cannot test linking because compile failed'
					% makeName
					)
		finally:
			remove(sourcePath)
			if isfile(objectPath):
				remove(objectPath)
			if isfile(binaryPath):
				remove(binaryPath)

		self.outVars['HAVE_%s_H' % makeName] = 'true' if compileOK else ''
		self.outVars['HAVE_%s_LIB' % makeName] = 'true' if linkOK else ''
		if linkOK:
			versionGet = library.getVersion(
				self.platform, self.configuration.linkStatic(), self.distroRoot
				)
			if callable(versionGet):
				version = versionGet(compileCommand, self.log)
			else:
				version = resolve(self.log, versionGet)
			if version is None:
				version = 'error'
			self.outVars['VERSION_%s' % makeName] = version