コード例 #1
0
ファイル: detectsys.py プロジェクト: erbodega/openMSX
def getCompilerMachine():
	# Note: Recent GCC and Clang versions support this option.
	machine = captureStdout(sys.stderr, 'cc -dumpmachine')
	if machine is not None:
		machineParts = machine.split('-')
		if len(machineParts) >= 3:
			return machineParts[0], machineParts[2]
	return None, None
コード例 #2
0
ファイル: version.py プロジェクト: meesokim/openMSX
def countGitCommits():
	if not isdir('derived'):
		makedirs('derived')
	log = open('derived/commitCountVersion.log', 'w')
	print >> log, 'Extracting commit count...'
	try:
		commitCount = captureStdout(log, 'git rev-list HEAD --count')
		print >> log, 'Commit count: %s' % commitCount
	finally:
		log.close()
	return commitCount
コード例 #3
0
ファイル: version.py プロジェクト: meesokim/openMSX
def _extractRevisionFromStdout(log, command, regex):
	text = captureStdout(log, command)
	if text is None:
		# Error logging already done by captureStdout().
		return None
	# pylint 0.18.0 somehow thinks captureStdout() returns a list, not a string.
	lines = text.split('\n') # pylint: disable-msg=E1103
	for revision, in filterLines(lines, regex):
		print >> log, 'Revision number found by "%s": %s' % (command, revision)
		return revision
	else:
		print >> log, 'Revision number not found in "%s" output:' % command
		print >> log, text
		return None
コード例 #4
0
ファイル: sizestats.py プロジェクト: Libertium/openmsx
def parseSymbolSize(objectFile):
	text = captureStdout(sys.stderr, 'nm -CSl "%s"' % objectFile)
	if text is not None:
		for line in text.split('\n'):
			if line:
				match = _reSymbolInfo.match(line)
				assert match is not None, line
				addr_, sizeStr, typ, name, originStr = match.groups()
				if originStr is None:
					origin = (None, None)
				else:
					source, lineNo = originStr.lstrip().rsplit(':', 1)
					origin = (normpath(source), int(lineNo))
				if sizeStr is not None:
					if typ not in 'Bb':
						# Symbols in BSS (uninitialized data section) do not
						# contribute to executable size, so ignore them.
						yield name, typ, int(sizeStr, 16), origin
コード例 #5
0
ファイル: libraries.py プロジェクト: erbodega/openMSX
	def evalTclConfigExpr(cls, platform, distroRoot, expr, description):
		tclConfig = cls.getTclConfig(platform, distroRoot)
		if tclConfig is None:
			return None
		log = open('derived/tcl-search.log', 'a')
		try:
			print >> log, 'Getting Tcl %s...' % description
			text = captureStdout(
				log,
				shjoin([
					'sh', '-c',
						'. %s && eval "echo \\"%s\\""' % (tclConfig, expr)
					])
				)
			if text is not None:
				print >> log, 'Result: %s' % text.strip()
		finally:
			log.close()
		return None if text is None else text.strip()
コード例 #6
0
ファイル: probe.py プロジェクト: meesokim/openMSX
def evaluateBackticks(log, expression):
	parts = []
	index = 0
	while True:
		start = expression.find('`', index)
		if start == -1:
			parts.append(expression[index : ])
			break
		end = expression.find('`', start + 1)
		if end == -1:
			raise ValueError('Unmatched backtick: %s' % expression)
		parts.append(expression[index : start])
		command = expression[start + 1 : end].strip()
		result = captureStdout(log, command)
		if result is None:
			raise IOError('Backtick evaluation failed; see log')
		parts.append(result)
		index = end + 1
	return ''.join(parts)
コード例 #7
0
ファイル: libraries.py プロジェクト: erbodega/openMSX
	def getTclConfig(cls, platform, distroRoot):
		'''Tcl has a config script that is unlike the typical lib-config script.
		Information is gathered by sourcing the config script, instead of
		executing it and capturing the queried value from stdout. This script
		is located in a library directory, not in a directory in the PATH.
		Also, it does not have the executable bit set.
		This method returns the location of the Tcl config script, or None if
		it could not be found.
		'''
		if hasattr(cls, 'tclConfig'):
			# Return cached value.
			return cls.tclConfig

		def iterLocations():
			if platform == 'android':
				# Under Android, the tcl set-up apparently differs from
				# other cross-platform setups. the search algorithm to find the
				# directory that will contain the tclConfig.sh script and the shared libs
				# is not applicable to Android. Instead, immediately return the correct
				# subdirectories to the routine that invokes iterLocations()
				sdl_android_port_path = environ['SDL_ANDROID_PORT_PATH']
				libpath = sdl_android_port_path + '/project/libs/armeabi'
				yield libpath
				tclpath = sdl_android_port_path + '/project/jni/tcl8.5/unix'
				yield tclpath
			else:
				if distroRoot is None or cls.isSystemLibrary(platform):
					if msysActive():
						roots = (msysPathToNative('/mingw32'), )
					else:
						roots = ('/usr/local', '/usr')
				else:
					roots = (distroRoot, )
				for root in roots:
					if isdir(root):
						for libdir in ('lib', 'lib64', 'lib/tcl'):
							libpath = root + '/' + libdir
							if isdir(libpath):
								yield libpath
								for entry in listdir(libpath):
									if entry.startswith('tcl8.'):
										tclpath = libpath + '/' + entry
										if isdir(tclpath):
											yield tclpath

		tclConfigs = {}
		log = open('derived/tcl-search.log', 'w')
		print >> log, 'Looking for Tcl...'
		try:
			for location in iterLocations():
				path = location + '/tclConfig.sh'
				if isfile(path):
					print >> log, 'Config script:', path
					text = captureStdout(
						log,
						"sh -c '. %s && echo %s'" % (
							path, '$TCL_MAJOR_VERSION $TCL_MINOR_VERSION'
							)
						)
					if text is not None:
						try:
							# pylint: disable-msg=E1103
							major, minor = text.split()
							version = int(major), int(minor)
						except ValueError:
							pass
						else:
							print >> log, 'Found: version %d.%d' % version
							tclConfigs[path] = version
			try:
				# Minimum required version is 8.5.
				# Pick the oldest possible version to minimize the risk of
				# running into incompatible changes.
				tclConfig = min(
					( version, path )
					for path, version in tclConfigs.iteritems()
					if version >= (8, 5)
					)[1]
			except ValueError:
				tclConfig = None
				print >> log, 'No suitable versions found.'
			else:
				print >> log, 'Selected:', tclConfig
		finally:
			log.close()

		cls.tclConfig = tclConfig
		return tclConfig
コード例 #8
0
ファイル: libraries.py プロジェクト: meesokim/openMSX
	def getTclConfig(cls, platform, distroRoot):
		'''Tcl has a config script that is unlike the typical lib-config script.
		Information is gathered by sourcing the config script, instead of
		executing it and capturing the queried value from stdout. This script
		is located in a library directory, not in a directory in the PATH.
		Also, it does not have the executable bit set.
		This method returns the location of the Tcl config script, or None if
		it could not be found.
		'''
		if hasattr(cls, 'tclConfig'):
			# Return cached value.
			return cls.tclConfig

		def iterLocations():
			# Allow the user to specify the location we should search first,
			# by setting an environment variable.
			tclpath = environ.get('TCL_CONFIG')
			if tclpath is not None:
				yield tclpath

			if distroRoot is None or cls.isSystemLibrary(platform):
				if msysActive():
					roots = (msysPathToNative('/mingw32'), )
				else:
					roots = ('/usr/local', '/usr')
			else:
				roots = (distroRoot, )
			for root in roots:
				if isdir(root):
					for libdir in ('lib', 'lib64', 'lib/tcl'):
						libpath = root + '/' + libdir
						if isdir(libpath):
							yield libpath
							for entry in listdir(libpath):
								if entry.startswith('tcl8.'):
									tclpath = libpath + '/' + entry
									if isdir(tclpath):
										yield tclpath

		tclConfigs = {}
		log = open('derived/tcl-search.log', 'w')
		print >> log, 'Looking for Tcl...'
		try:
			for location in iterLocations():
				path = location + '/tclConfig.sh'
				if isfile(path):
					print >> log, 'Config script:', path
					text = captureStdout(
						log,
						"sh -c '. %s && echo %s'" % (
							path, '$TCL_MAJOR_VERSION $TCL_MINOR_VERSION'
							)
						)
					if text is not None:
						try:
							# pylint: disable-msg=E1103
							major, minor = text.split()
							version = int(major), int(minor)
						except ValueError:
							pass
						else:
							print >> log, 'Found: version %d.%d' % version
							tclConfigs[path] = version
			try:
				# Minimum required version is 8.5.
				# Pick the oldest possible version to minimize the risk of
				# running into incompatible changes.
				tclConfig = min(
					( version, path )
					for path, version in tclConfigs.iteritems()
					if version >= (8, 5)
					)[1]
			except ValueError:
				tclConfig = None
				print >> log, 'No suitable versions found.'
			else:
				print >> log, 'Selected:', tclConfig
		finally:
			log.close()

		cls.tclConfig = tclConfig
		return tclConfig
コード例 #9
0
ファイル: libraries.py プロジェクト: retrocant/openMSX_TSX
    def getTclConfig(cls, platform, distroRoot):
        '''Tcl has a config script that is unlike the typical lib-config script.
		Information is gathered by sourcing the config script, instead of
		executing it and capturing the queried value from stdout. This script
		is located in a library directory, not in a directory in the PATH.
		Also, it does not have the executable bit set.
		This method returns the location of the Tcl config script, or None if
		it could not be found.
		'''
        if hasattr(cls, 'tclConfig'):
            # Return cached value.
            return cls.tclConfig

        def iterLocations():
            if platform == 'android':
                # Under Android, the tcl set-up apparently differs from
                # other cross-platform setups. the search algorithm to find the
                # directory that will contain the tclConfig.sh script and the shared libs
                # is not applicable to Android. Instead, immediately return the correct
                # subdirectories to the routine that invokes iterLocations()
                sdl_android_port_path = environ['SDL_ANDROID_PORT_PATH']
                libpath = sdl_android_port_path + '/project/libs/armeabi'
                yield libpath
                tclpath = sdl_android_port_path + '/project/jni/tcl8.5/unix'
                yield tclpath
            else:
                if distroRoot is None or cls.isSystemLibrary(platform):
                    if msysActive():
                        roots = (msysPathToNative('/mingw32'), )
                    else:
                        roots = ('/usr/local', '/usr')
                else:
                    roots = (distroRoot, )
                for root in roots:
                    if isdir(root):
                        for libdir in ('lib', 'lib64', 'lib/tcl'):
                            libpath = root + '/' + libdir
                            if isdir(libpath):
                                yield libpath
                                for entry in listdir(libpath):
                                    if entry.startswith('tcl8.'):
                                        tclpath = libpath + '/' + entry
                                        if isdir(tclpath):
                                            yield tclpath

        tclConfigs = {}
        log = open('derived/tcl-search.log', 'w')
        print >> log, 'Looking for Tcl...'
        try:
            for location in iterLocations():
                path = location + '/tclConfig.sh'
                if isfile(path):
                    print >> log, 'Config script:', path
                    text = captureStdout(
                        log, "sh -c '. %s && echo %s'" %
                        (path, '$TCL_MAJOR_VERSION $TCL_MINOR_VERSION'))
                    if text is not None:
                        try:
                            # pylint: disable-msg=E1103
                            major, minor = text.split()
                            version = int(major), int(minor)
                        except ValueError:
                            pass
                        else:
                            print >> log, 'Found: version %d.%d' % version
                            tclConfigs[path] = version
            try:
                # Minimum required version is 8.5.
                # Pick the oldest possible version to minimize the risk of
                # running into incompatible changes.
                tclConfig = min((version, path)
                                for path, version in tclConfigs.iteritems()
                                if version >= (8, 5))[1]
            except ValueError:
                tclConfig = None
                print >> log, 'No suitable versions found.'
            else:
                print >> log, 'Selected:', tclConfig
        finally:
            log.close()

        cls.tclConfig = tclConfig
        return tclConfig
コード例 #10
0
    def getTclConfig(cls, platform, distroRoot):
        '''Tcl has a config script that is unlike the typical lib-config script.
		Information is gathered by sourcing the config script, instead of
		executing it and capturing the queried value from stdout. This script
		is located in a library directory, not in a directory in the PATH.
		Also, it does not have the executable bit set.
		This method returns the location of the Tcl config script, or None if
		it could not be found.
		'''
        if hasattr(cls, 'tclConfig'):
            # Return cached value.
            return cls.tclConfig

        def iterLocations():
            # Allow the user to specify the location we should search first,
            # by setting an environment variable.
            tclpath = environ.get('TCL_CONFIG')
            if tclpath is not None:
                yield tclpath

            if distroRoot is None or cls.isSystemLibrary(platform):
                if msysActive():
                    roots = (msysPathToNative('/mingw32'), )
                else:
                    roots = ('/usr/local', '/usr')
            else:
                roots = (distroRoot, )
            for root in roots:
                if isdir(root):
                    for libdir in ('lib', 'lib64', 'lib/tcl'):
                        libpath = root + '/' + libdir
                        if isdir(libpath):
                            yield libpath
                            for entry in listdir(libpath):
                                if entry.startswith('tcl8.'):
                                    tclpath = libpath + '/' + entry
                                    if isdir(tclpath):
                                        yield tclpath

        tclConfigs = {}
        log = open('derived/tcl-search.log', 'w')
        print >> log, 'Looking for Tcl...'
        try:
            for location in iterLocations():
                path = location + '/tclConfig.sh'
                if isfile(path):
                    print >> log, 'Config script:', path
                    text = captureStdout(
                        log, "sh -c '. %s && echo %s'" %
                        (path, '$TCL_MAJOR_VERSION $TCL_MINOR_VERSION'))
                    if text is not None:
                        try:
                            # pylint: disable-msg=E1103
                            major, minor = text.split()
                            version = int(major), int(minor)
                        except ValueError:
                            pass
                        else:
                            print >> log, 'Found: version %d.%d' % version
                            tclConfigs[path] = version
            try:
                # Minimum required version is 8.5.
                # Pick the oldest possible version to minimize the risk of
                # running into incompatible changes.
                tclConfig = min((version, path)
                                for path, version in tclConfigs.iteritems()
                                if version >= (8, 5))[1]
            except ValueError:
                tclConfig = None
                print >> log, 'No suitable versions found.'
            else:
                print >> log, 'Selected:', tclConfig
        finally:
            log.close()

        cls.tclConfig = tclConfig
        return tclConfig