Beispiel #1
0
def test_create_exe():
    if not os.name == 'nt':
        py.test.skip('Windows only test')

    dst_name = udir.join('dst/pypy.exe')
    src_name = udir.join('src/dydy2.exe')
    dll_name = udir.join('src/pypy.dll')
    lib_name = udir.join('src/pypy.lib')
    pdb_name = udir.join('src/pypy.pdb')
    src_name.ensure()
    src_name.write('exe')
    dll_name.ensure()
    dll_name.write('dll')
    lib_name.ensure()
    lib_name.write('lib')
    pdb_name.ensure()
    pdb_name.write('pdb')
    dst_name.ensure()

    class CBuilder(object):
        shared_library_name = dll_name 

    td = TranslationDriver(exe_name=str(dst_name))
    td.c_entryp = str(src_name)
    td.cbuilder = CBuilder()
    td.create_exe()
    assert dst_name.read() == 'exe'
    assert dst_name.new(ext='dll').read() == 'dll'
    assert dst_name.new(purebasename='python27',ext='lib').read() == 'lib'
Beispiel #2
0
def test_create_exe():
    if not os.name == 'nt':
        py.test.skip('Windows only test')

    dst_name = udir.join('dst/pypy.exe')
    src_name = udir.join('src/dydy2.exe')
    wsrc_name = udir.join('src/dydy2w.exe')
    dll_name = udir.join('src/pypy.dll')
    lib_name = udir.join('src/pypy.lib')
    pdb_name = udir.join('src/pypy.pdb')
    src_name.ensure()
    src_name.write('exe')
    wsrc_name.ensure()
    wsrc_name.write('wexe')
    dll_name.ensure()
    dll_name.write('dll')
    lib_name.ensure()
    lib_name.write('lib')
    pdb_name.ensure()
    pdb_name.write('pdb')
    # Create the dst directory
    dst_name.ensure()

    class CBuilder(object):
        shared_library_name = dll_name

    td = TranslationDriver(exe_name=str(dst_name))
    td.c_entryp = str(src_name)
    td.cbuilder = CBuilder()
    td.create_exe()
    assert dst_name.read() == 'exe'
    assert dst_name.new(ext='dll').read() == 'dll'
    assert dst_name.new(ext='lib').read() == 'lib'
    assert dst_name.new(purebasename=dst_name.purebasename +
                        'w').read() == 'wexe'
Beispiel #3
0
def test_compile_c(host, suffix):

    exe_name = 'pypy-%(backend)s'
    # Created by the fake "compile" function
    # Create the dst directory to be tested
    dst_name = udir.join('dst/pypy-c' + suffix)
    dst_name.ensure()

    class CBuilder(object):
        def compile(self, exe_name):
            from rpython.translator.tool.cbuild import ExternalCompilationInfo

            # CBuilder.gen_makefile is called via CBuilder.generate_source
            # in driver.task_source_c. We are faking parts of it here
            targetdir = udir.join('src')
            exe_name = targetdir.join(exe_name)
            platform = host(cc='not_really_going_to_compile')
            mk = platform.gen_makefile(
                [],
                ExternalCompilationInfo(),
                exe_name=exe_name,
                path=targetdir,
                shared=True,
            )
            # "compile" the needed outputs
            src_name = udir.join('src/pypy-c' + suffix)
            src_name.ensure()
            src_name.write('exe')
            dll_name = udir.join('src/pypy-c.dll')
            dll_name.ensure()
            dll_name.write('dll')
            self.shared_library_name = dll_name

            # mock the additional windows artifacts as well
            wsrc_name = udir.join('src/pypy-cw.exe')
            wsrc_name.ensure()
            wsrc_name.write('wexe')
            self.executable_name_w = wsrc_name
            lib_name = udir.join('src/pypy-c.lib')
            lib_name.ensure()
            lib_name.write('lib')
            pdb_name = udir.join('src/pypy-c.pdb')
            pdb_name.ensure()
            pdb_name.write('pdb')
            self.executable_name = mk.exe_name

    td = TranslationDriver(exe_name=str(exe_name))
    # Normally done in the database_c task
    td.cbuilder = CBuilder()
    # Normally done when creating the driver via from_targetspec
    td.standalone = True

    cwd = os.getcwd()

    # This calls compile(), sets td.c_entryp to CBuilder.executable_name,
    # and calls create_exe(). We must cd into the target directory since
    # create_exe() copies back to the current directory

    try:
        os.chdir(dst_name.dirname)
        td.task_compile_c()
    finally:
        os.chdir(cwd)

    assert dst_name.read() == 'exe'
    assert dst_name.new(ext='dll').read() == 'dll'
    if host is windows.MsvcPlatform:
        assert dst_name.new(ext='lib').read() == 'lib'
        assert dst_name.new(purebasename=dst_name.purebasename +
                            'w').read() == 'wexe'