Ejemplo n.º 1
0
    def test_installed_library(self):
        with tempfile.TemporaryDirectory() as bbmp_interop_build_dir:
            with tempfile.TemporaryDirectory() as cmake_install_prefix:
                install(bbmp_interop_build_dir, cmake_install_prefix)

                with tempfile.TemporaryDirectory() as importing_lib_dir:
                    create_project_using_installed_bbmp_interop(
                        importing_lib_dir)
                    build_dir = os.path.join(importing_lib_dir, "build")
                    commands = [
                        VCVARSALL_COMMAND,
                        [
                            "cmake",
                            "-S",
                            importing_lib_dir,
                            "-B",
                            build_dir,
                            f"-DCMAKE_PREFIX_PATH={cmake_install_prefix}",
                            *PLATFORM_SPECIFIC_CMAKE_PARAMETERS,
                        ],
                        ["cmake", "--build", build_dir],
                    ]
                    bbmp_subprocess.run_in_shell(commands)

                    # We need to run this in a subprocess, because you can't unload a module (DLL), so if
                    # this process loaded the extension, the TMP directories couldn't be cleaned up
                    native_module_test_command = [
                        sys.executable,
                        "-c",
                        f"import sys;sys.path.append('{as_posix(build_dir)}');import pyhello;assert pyhello.eight() == 8",
                    ]
                    bbmp_subprocess.run_in_shell([native_module_test_command])
Ejemplo n.º 2
0
def install(build_dir, cmake_install_prefix):
    commands = [
        VCVARSALL_COMMAND,
        [
            "cmake",
            "-S",
            PROJECT_DIR,
            "-B",
            build_dir,
            f"-DCMAKE_INSTALL_PREFIX={cmake_install_prefix}",
            *PLATFORM_SPECIFIC_CMAKE_PARAMETERS,
        ],
        ["cmake", "--build", build_dir, "--target", "install"],
    ]
    bbmp_subprocess.run_in_shell(commands)
Ejemplo n.º 3
0
    def test_using_as_subdir(self):
        with tempfile.TemporaryDirectory() as importing_lib_dir:
            create_project_using_subdirectory_bbmp_interop(importing_lib_dir)
            items_to_copy = [
                os.path.join(PROJECT_DIR, "cmake"),
                os.path.join(PROJECT_DIR, "extern"),
                os.path.join(PROJECT_DIR, "src"),
                os.path.join(PROJECT_DIR, "tests"),
                os.path.join(PROJECT_DIR, ".clang-format"),
                os.path.join(PROJECT_DIR, ".gitignore"),
                os.path.join(PROJECT_DIR, "bbmp_interop-config.cmake.in"),
                os.path.join(PROJECT_DIR, "CMakeLists.txt"),
                os.path.join(PROJECT_DIR, "README.md"),
            ]
            subdir_path = os.path.join(importing_lib_dir, "extern",
                                       "bbmp_interop")
            pathlib.Path(subdir_path).mkdir(parents=True, exist_ok=True)
            for item in items_to_copy:
                if os.path.isdir(item):
                    shutil.copytree(
                        item,
                        os.path.join(subdir_path,
                                     pathlib.PurePath(item).name))
                else:
                    shutil.copy2(item, subdir_path)
            build_dir = os.path.join(importing_lib_dir, "build")
            commands = [
                VCVARSALL_COMMAND,
                [
                    "cmake",
                    "-S",
                    importing_lib_dir,
                    "-B",
                    build_dir,
                    *PLATFORM_SPECIFIC_CMAKE_PARAMETERS,
                ],
                ["cmake", "--build", build_dir],
            ]
            bbmp_subprocess.run_in_shell(commands)

            # We need to run this in a subprocess, because you can't unload a module (DLL), so if
            # this process loaded the extension, the TMP directories couldn't be cleaned up
            native_module_test_command = [
                sys.executable,
                "-c",
                f"import sys;sys.path.append('{as_posix(build_dir)}');import pyhello;assert pyhello.eight() == 8",
            ]
            bbmp_subprocess.run_in_shell([native_module_test_command])
Ejemplo n.º 4
0
def _run_ctests():
    with tempfile.TemporaryDirectory() as cmake_build_dir:
        bbmp_subprocess.run_in_shell([
            [
                "cmake",
                "-S",
                PROJECT_DIR,
                "-B",
                cmake_build_dir,
            ],
            [
                "cmake",
                "--build",
                cmake_build_dir,
                "--target",
                "test",
                "--",
                'ARGS="--verbose"',
            ],
        ])
Ejemplo n.º 5
0
def run_ctests():
    with tempfile.TemporaryDirectory() as cmake_build_dir:
        commands = [
            VCVARSALL_COMMAND,
            [
                "cmake",
                "-S",
                PROJECT_DIR,
                "-B",
                cmake_build_dir,
                *PLATFORM_SPECIFIC_CMAKE_PARAMETERS,  # selects generator on Windows
            ],
            [
                "cmake",
                "--build",
                cmake_build_dir,
                "--target",
                "test",
                "--",
                'ARGS="--verbose"',
            ],
        ]
        bbmp_subprocess.run_in_shell(commands)
Ejemplo n.º 6
0
                PROJECT_DIR,
                "-B",
                cmake_build_dir,
                *PLATFORM_SPECIFIC_CMAKE_PARAMETERS,  # selects generator on Windows
            ],
            [
                "cmake",
                "--build",
                cmake_build_dir,
                "--config",
                "Release",
                "--target",
                "install",
            ],
        ]
        bbmp_subprocess.run_in_shell(commands)

    # Prepare files in order the user has InnoSetup and wants to create an installer
    os.rename(
        os.path.join(install_dir, "Bebump Coolth.exe"),
        os.path.join(install_dir, "coolth.exe"),
    )
    shutil.copy(
        rel_to_py("..", "installer", "coolth.iss"),
        os.path.join(install_dir),
    )
    shutil.copy(
        rel_to_py("..", "installer", "license.txt"),
        os.path.join(install_dir),
    )