Example #1
0
def link_main_executable(file_system: FileSystem, resources: StageResources,
                         cache: Dict[str, Any], program_arguments: Dict[str,
                                                                        Any],
                         configuration: Dict[str,
                                             Any], remote_proxy: RemoteProxy):
    project_directory = resources['project_directory']
    pralinefile = resources['pralinefile']
    organization = pralinefile['organization']
    artifact = pralinefile['artifact']
    version = pralinefile['version']
    compiler = resources['compiler']
    main_objects = resources['main_objects']
    external_libraries_root = resources['external_libraries_root']
    external_libraries_interfaces_root = resources[
        'external_libraries_interfaces_root']
    external_libraries = resources['external_libraries']
    external_libraries_interfaces = resources['external_libraries_interfaces']
    executables_root = join(project_directory, 'target', 'executables')
    symbols_tables_root = join(project_directory, 'target', 'symbols_tables')

    (resources['main_executable'],
     resources['main_executable_symbols_table']) = link_executable_using_cache(
         file_system, compiler, executables_root, symbols_tables_root,
         external_libraries_root, external_libraries_interfaces_root,
         main_objects, external_libraries, external_libraries_interfaces,
         organization, artifact, version, cache)
Example #2
0
    def test_link_executable_using_cache_with_changed_external_library_interface(
            self):
        objects_root = 'objects/'
        executables_root = 'executables/'
        symbols_tables_root = 'symbols_tables/'
        external_libraries_root = 'external/libraries'
        external_libraries_interfaces_root = 'external/libraries_interfaces'
        file_system = FileSystemMock(
            {
                objects_root, executables_root, symbols_tables_root,
                external_libraries_root, external_libraries_interfaces_root
            }, {
                'objects/a.obj':
                b'object-a.',
                'external/libraries/b.dll':
                b'external-library-b.',
                'external/libraries_interfaces/c.lib':
                b'updated-external-library-interface-c.',
                'executables/my-executable.exe':
                b'object-a.external-library-b.external-library-interface-c.exe',
                'symbols_tables/my-executable.pdb':
                b'object-a.external-library-b.external-library-interface-c.pbd'
            })
        compiler = CompilerMock(file_system)
        objects = ['objects/a.obj']
        external_libraries = ['external/libraries/b.dll']
        external_libraries_interfaces = ['external/libraries_interfaces/c.lib']
        name = 'my-executable'
        cache = {
            'input': {
                'objects/a.obj':
                'a6cc476fe402432f09d3e66d73b6382421ee1a855ac6bde79357fc1483878463',
                'external/libraries/b.dll':
                '440602105d9abfce75656e19197e74539add8cb0dd002f4a550d46d7e8c1e837',
                'external/libraries_interfaces/c.lib':
                '8c777213d1130643127d77653c90f5d6784f6f95dac361afb454a3e6db084f4e'
            },
            'output': ('executables/my-executable.exe',
                       'symbols_tables/my-executable.pdb')
        }

        executable, symbols_table = link_executable_using_cache(
            file_system, compiler, executables_root, symbols_tables_root,
            external_libraries_root, external_libraries_interfaces_root,
            objects, external_libraries, external_libraries_interfaces,
            organization, artifact, version, cache)

        self.assertEqual(
            executable,
            'executables/org-art-x32-windows-compmock-debug-1.0.0.exe')

        self.assertEqual(
            symbols_table,
            'symbols_tables/org-art-x32-windows-compmock-debug-1.0.0.pdb')

        new_files = {
            'objects/a.obj':
            b'object-a.',
            'external/libraries/b.dll':
            b'external-library-b.',
            'external/libraries_interfaces/c.lib':
            b'updated-external-library-interface-c.',
            'executables/org-art-x32-windows-compmock-debug-1.0.0.exe':
            b'object-a.external-library-b.updated-external-library-interface-c.exe',
            'symbols_tables/org-art-x32-windows-compmock-debug-1.0.0.pdb':
            b'object-a.external-library-b.updated-external-library-interface-c.pbd'
        }

        self.assertEqual(file_system.files,
                         {normpath(p): data
                          for p, data in new_files.items()})

        new_cache = {
            'input': {
                'objects/a.obj':
                'a6cc476fe402432f09d3e66d73b6382421ee1a855ac6bde79357fc1483878463',
                'external/libraries/b.dll':
                '440602105d9abfce75656e19197e74539add8cb0dd002f4a550d46d7e8c1e837',
                'external/libraries_interfaces/c.lib':
                '4655380785da55ddee626b49e92bf336911a4f8ea828b1693ecbf1d12714d8f8'
            },
            'output':
            ('executables/org-art-x32-windows-compmock-debug-1.0.0.exe',
             'symbols_tables/org-art-x32-windows-compmock-debug-1.0.0.pdb')
        }

        self.assertEqual(cache, new_cache)