def generate_tags(filename): _makefile = open(filename, 'r') tags = [] for line in _makefile: # key=value key, value = tuple(line.rstrip().split('=')) if key == "SOCKET": if value == "std": tags.append("!ssl") else: tags.append("ssl") if value == "gnutls": tags.append("gnutls") else: tags.append("!gnutls") elif key == "NETLIB": tags.append(value) else: if value == "true": tags.append(key) else: tags.append("!" + key) _makefile.close() arch = Arch() tags.append(arch.platform) tags_string = ",".join(tags) open('testsuite.tags', 'w').write(tags_string.lower() + "\n") print "Generating testsuite.tags with: \n" + tags_string.lower()
def __init__(self): """Env constructor. On first instantiation, build attribute will be computed and host and target set to the build attribute. """ if 'build' not in Env._instance: self.build = Arch() self.host = self.build self.target = self.host self.environ = None self.cwd = None self.main_options = None # Command line switches
def set_target(self, target_name=None, target_version=None, target_machine=None, target_mode=None): """Set target platform. :param target_name: a string that identify the system to be considered as the host. If None then host is set to the host one. If set to 'build' or 'host' then target is set respectively to current 'build' or 'host' value. In that case target_version and target_machine are ignored. :type target_name: str | None :param target_version: a string containing the system version. If set to None the version is either a default or autodetected when possible. :type target_version: str | None :param target_machine: a string containing the name of the target machine. :type target_machine: str | None :param target_mode: a string containing the name of the mode. This notion is needed on some targets such as VxWorks to switch between kernel mode and other modes such as rtp The target parameters are ignored if the target_name is equal to the host platform. """ # Handle special values if target_name is not None: if target_name == 'host': target_name = self.host.platform target_version = self.host.os.version target_machine = self.host.machine elif target_name == 'build': target_name = self.build.platform target_version = self.build.os.version target_machine = self.build.machine if target_name is not None and target_name != self.host.platform: self.target = Arch(platform_name=target_name, version=target_version, machine=target_machine, mode=target_mode) else: self.target = self.host
def set_host(self, host_name=None, host_version=None): """Set host platform. :param host_name: a string that identify the system to be considered as the host. If None then host is set to the build one (the autodetected platform). If set to 'build' or 'target' then host is set respectively to current 'build' or 'target' value :type host_name: str | None :param host_version: a string containing the system version. If set to None the version is either a default or autodetected when possible :type host_version: str | None When calling set_host, the target system is reset to the host one. Thus you should call set_host before set_target otherwise your call to set_target will be ignored. Note also that is the host_name is equal to the build platform, host_version will be ignored. """ # Handle special parameters 'target' and 'build' if host_name is not None: if host_name == 'target': host_name = self.target.platform host_version = self.target.os.version elif host_name == 'build': host_name = self.build.platform host_version = self.target.os.version if host_name is not None and host_name != self.build.platform: is_host = False if (self.build.platform, host_name) in CANADIAN_EXCEPTIONS: # We are not in a canadian configuration, so we can invoke # our methods to guess some information such as os version,... is_host = True self.host = Arch(platform_name=host_name, is_host=is_host, version=host_version, machine=self.build.machine) else: self.host = self.build self.target = self.host
def __init__(self, build=None, host=None, target=None): """BaseEnv constructor. On first instantiation, build attribute will be computed and host and target set to the build attribute. :param build: build architecture. If None then it is set to default build :type build: Arch | None :param host: host architecture. If None then it is set to build :type host: Arch | None :param target: target architecture. If None then it is set to target :type target: Arch | None """ # class variable that holds the current environment self._instance = {} # class variable that holds the stack of saved environments state self._context = [] if build is None: self.build = Arch() else: self.build = build if host is None: self.host = self.build else: self.host = host if target is None: self.target = self.host else: self.target = target self.environ = None self.cwd = None self.main_options = None # Command line switches
def set_build(self, build_name=None, build_version=None): """Set build platform. :param build_name: a string that identify the system to be considered as the build. If None then build is unchanged. Note that passing an empty value will force the autodetection and possibly reset to the default value. :type build_name: str | None :param build_version: a string containing the system version. If set to None the version is either a default or autodetected when possible :type build_version: str | None When calling set_build, the target and host systems are reset to the build one. Thus you should call set_build before calling either set_host or set_target. """ if build_name is not None: self.build = Arch(platform_name=build_name, is_host=True, version=build_version) self.host = self.build self.target = self.build
def create_fake_ada_compiler(comp_dir, comp_target, gnat_version, gcc_version, comp_is_cross=False, runtimes=["native", "sjlj"], create_symlink=False, create_ada_object_path=False): """ Create directory defined by the comp_dir parameter and put fake Ada compiler directory tree there. If comp_is_cross is true, the compiler tools 'gnatmake', 'gcc', and 'gnatls' will be prefixed by the comp_target. If create_symlink is true, the first runtime from the runtimes will be made available as default through an 'adalib' symbolic link. If create_ada_object_path is true, that file will be created to simulate a Windows install. """ if comp_is_cross: comp_prefix = comp_target + '-' else: comp_prefix = "" arch = Arch() comp_dict = { 'comp_target': comp_target, 'gnat_version': gnat_version, 'gcc_version': gcc_version, 'comp_prefix': comp_prefix, 'exeext': arch.os.exeext } mkdir(os.path.join(comp_dir, 'bin')) gnatls_adb = open(os.path.join(comp_dir, 'bin', 'gnatls.adb'), 'w') gnatls_adb.write(""" with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; use Ada.Command_Line; procedure gnatls is begin if Argument_Count >= 1 and Argument (1) = "-v" then Put_Line ("GNATLS Pro %(gnat_version)s (20190507-89)"); else Put ("Running gnatls"); for J in 1 .. Argument_Count loop Put (" " & Argument (J)); end loop; end if; end gnatls; """ % comp_dict) gnatls_adb.close() gcc_adb = open(os.path.join(comp_dir, 'bin', 'gcc.adb'), 'w') gcc_adb.write(""" with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; use Ada.Command_Line; procedure gcc is begin if Argument_Count >= 1 and then Argument (1) = "-v" then Put_Line ("gcc version %(gcc_version)s 20131008 for GNAT Pro"); elsif Argument_Count >= 1 and then Argument (1) = "--version" then Put_Line ("gcc (GCC) %(gcc_version)s"); elsif Argument_Count >= 1 and then Argument (1) = "-dumpmachine" then Put_Line ("%(comp_target)s"); else Put ("Running gcc"); for J in 1 .. Argument_Count loop Put (" " & Argument (J)); end loop; end if; end gcc; """ % comp_dict) gcc_adb.close() gnatmake_adb = open(os.path.join(comp_dir, 'bin', 'gnatmake.adb'), 'w') gnatmake_adb.write(""" with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; use Ada.Command_Line; procedure gnatmake is begin Put ("Running gcc"); for J in 1 .. Argument_Count loop Put (" " & Argument (J)); end loop; end gnatmake; """) gnatmake_adb.close() for tool in ['gnatmake', 'gcc', 'gnatls']: comp_dict['bin'] = tool # Do not run gnatmake in the same directory with the fake tools sources # to avoid using just created fake tools in the build process. Run([ 'gnatmake', os.path.join('bin', tool + '.adb'), '-o', os.path.join('bin', '%(comp_prefix)s%(bin)s%(exeext)s' % comp_dict) ], cwd=comp_dir) if comp_target == "dotnet": for dir in ("adalib", "adainclude"): mkdir(os.path.join(comp_dir, 'lib', 'dotgnat', dir)) else: for runtime in runtimes: for dir in ("adalib", "adainclude"): mkdir( os.path.join(comp_dir, 'lib', 'gcc', comp_target, gcc_version, 'rts-%s' % runtime, dir)) libdir = os.path.join(comp_dir, 'lib', 'gcc', comp_target, gcc_version) # On Unix systems, we have a symbolic link for the default # runtime. gprconfig should automatically detect these are # the same two runtimes and only list "native". if create_symlink: os.symlink(os.path.join('rts-%s' % runtimes[0], 'adalib'), os.path.join(libdir, 'adalib')) # Simulate windows system, with an ada_object_path file if create_ada_object_path: with open(os.path.join(libdir, 'ada_object_path'), 'w') as ada_obj: ada_obj.write("rts-%s/adalib" % runtimes[0])