Exemplo n.º 1
0
    def setUp(self):
        # Setup workspace
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, 'ninja'))

        self.workspace = Workspace(source_root=tmpdir1, build_root=tmpdir2)

        # Setup toolchain
        self.toolchain = host_toolchain()
        self.toolchain.cc = '/path/to/cc'
        self.toolchain.cxx = '/path/to/cxx'

        # Setup args
        self.args = argparse.Namespace(build_ninja=True,
                                       darwin_deployment_version_osx="10.9")

        # Setup shell
        shell.dry_run = True
        self._orig_stdout = sys.stdout
        self._orig_stderr = sys.stderr
        self.stdout = StringIO()
        self.stderr = StringIO()
        sys.stdout = self.stdout
        sys.stderr = self.stderr
Exemplo n.º 2
0
    def setUp(self):
        # Setup workspace
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, 'cmark'))

        self.workspace = Workspace(source_root=tmpdir1,
                                   build_root=tmpdir2)

        self.host = StdlibDeploymentTarget.host_target()

        # Setup toolchain
        self.toolchain = host_toolchain()
        self.toolchain.cc = '/path/to/cc'
        self.toolchain.cxx = '/path/to/cxx'

        self.cross_compile_hosts = ["macosx-arm64", "linux-x86_64", "linux-aarch64"]

        # Setup args
        self.args = argparse.Namespace(
            cross_compile_hosts=self.cross_compile_hosts)

        # Setup shell
        shell.dry_run = True
        self._orig_stdout = sys.stdout
        self._orig_stderr = sys.stderr
        self.stdout = StringIO()
        self.stderr = StringIO()
        sys.stdout = self.stdout
        sys.stderr = self.stderr
Exemplo n.º 3
0
    def setUp(self):
        # Setup workspace
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, 'llvm'))

        self.workspace = Workspace(source_root=tmpdir1,
                                   build_root=tmpdir2)

        # Setup toolchain
        self.toolchain = host_toolchain()
        self.toolchain.cc = '/path/to/cc'
        self.toolchain.cxx = '/path/to/cxx'

        # Setup args
        self.args = argparse.Namespace(
            llvm_targets_to_build='X86;ARM;AArch64;PowerPC;SystemZ',
            llvm_assertions='true',
            compiler_vendor='none',
            clang_compiler_version=None,
            clang_user_visible_version=None,
            darwin_deployment_version_osx='10.9')

        # Setup shell
        shell.dry_run = True
        self._orig_stdout = sys.stdout
        self._orig_stderr = sys.stderr
        self.stdout = StringIO()
        self.stderr = StringIO()
        sys.stdout = self.stdout
        sys.stderr = self.stderr
Exemplo n.º 4
0
    def setUp(self):
        # Setup workspace
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, 'ninja'))

        self.workspace = Workspace(source_root=tmpdir1,
                                   build_root=tmpdir2)

        # Setup toolchain
        self.toolchain = host_toolchain()
        self.toolchain.cc = '/path/to/cc'
        self.toolchain.cxx = '/path/to/cxx'

        # Setup args
        self.args = argparse.Namespace(
            build_ninja=True,
            darwin_deployment_version_osx="10.9")

        # Setup shell
        shell.dry_run = True
        self._orig_stdout = sys.stdout
        self._orig_stderr = sys.stderr
        self.stdout = StringIO()
        self.stderr = StringIO()
        sys.stdout = self.stdout
        sys.stderr = self.stderr
Exemplo n.º 5
0
    def setUp(self):
        # Setup workspace
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, 'swift'))

        self.workspace = Workspace(source_root=tmpdir1, build_root=tmpdir2)

        # Setup toolchain
        self.toolchain = host_toolchain()
        self.toolchain.cc = '/path/to/cc'
        self.toolchain.cxx = '/path/to/cxx'

        # Setup args
        self.args = argparse.Namespace(enable_tsan_runtime=False,
                                       compiler_vendor='none',
                                       swift_compiler_version=None,
                                       clang_compiler_version=None,
                                       swift_user_visible_version=None,
                                       darwin_deployment_version_osx="10.9",
                                       benchmark=False,
                                       benchmark_num_onone_iterations=3,
                                       benchmark_num_o_iterations=3,
                                       enable_sil_ownership=False)

        # Setup shell
        shell.dry_run = True
        self._orig_stdout = sys.stdout
        self._orig_stderr = sys.stderr
        self.stdout = StringIO()
        self.stderr = StringIO()
        sys.stdout = self.stdout
        sys.stderr = self.stderr
Exemplo n.º 6
0
    def test_workspace(self):
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, "foo"))

        workspace = Workspace(source_root=tmpdir1, build_root=tmpdir2)

        self.assertEqual(workspace.source_root, tmpdir1)
        self.assertEqual(workspace.build_root, tmpdir2)

        # source_dir
        self.assertEqual(workspace.source_dir("foo"), os.path.join(tmpdir1, "foo"))

        # build_dir
        self.assertEqual(workspace.build_dir("target", "product"), os.path.join(tmpdir2, "product-target"))

        shutil.rmtree(tmpdir1)
        shutil.rmtree(tmpdir2)
Exemplo n.º 7
0
    def test_workspace(self):
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, 'foo'))

        workspace = Workspace(source_root=tmpdir1, build_root=tmpdir2)

        self.assertEqual(workspace.source_root, tmpdir1)
        self.assertEqual(workspace.build_root, tmpdir2)

        # source_dir
        self.assertEqual(workspace.source_dir('foo'),
                         os.path.join(tmpdir1, 'foo'))

        # build_dir
        self.assertEqual(workspace.build_dir('target', 'product'),
                         os.path.join(tmpdir2, 'product-target'))

        shutil.rmtree(tmpdir1)
        shutil.rmtree(tmpdir2)
Exemplo n.º 8
0
    def setUp(self):
        # Setup workspace
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, 'cmark'))

        self.workspace = Workspace(source_root=tmpdir1,
                                   build_root=tmpdir2)

        self.host = StdlibDeploymentTarget.host_target()

        # Setup toolchain
        self.toolchain = host_toolchain()
        self.toolchain.cc = '/path/to/cc'
        self.toolchain.cxx = '/path/to/cxx'

        # Setup args
        self.args = argparse.Namespace(
            build_cmark=True,
            cmake_generator="Ninja",
            cmark_build_type="Release",
            rebuild=False,
            extra_cmake_options=[],
            skip_build=False,
            darwin_deployment_version_osx="10.9",
            cmark_build_variant="Debug",
            export_compile_commands=False,
            reconfigure=False,
            distcc=None,
            sccache=None,
            cmake_c_launcher=None,
            cmake_cxx_launcher=None,
            clang_user_visible_version=None,
            build_ninja=False,
            enable_asan=False,
            enable_lsan=False,
            enable_sanitize_coverage=False,
            enable_tsan=False,
            enable_ubsan=False)

        # Setup shell
        shell.dry_run = True
        self._orig_stdout = sys.stdout
        self._orig_stderr = sys.stderr
        self.stdout = StringIO()
        self.stderr = StringIO()
        sys.stdout = self.stdout
        sys.stderr = self.stderr
Exemplo n.º 9
0
    def setUp(self):
        # Setup workspace
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, 'swift'))

        self.workspace = Workspace(source_root=tmpdir1, build_root=tmpdir2)

        # Setup toolchain
        self.toolchain = host_toolchain()
        self.toolchain.cc = '/path/to/cc'
        self.toolchain.cxx = '/path/to/cxx'

        # Setup args
        self.args = argparse.Namespace(
            enable_tsan_runtime=False,
            compiler_vendor='none',
            swift_compiler_version=None,
            clang_compiler_version=None,
            swift_user_visible_version=None,
            darwin_deployment_version_osx="10.9",
            benchmark=False,
            benchmark_num_onone_iterations=3,
            benchmark_num_o_iterations=3,
            disable_guaranteed_normal_arguments=True,
            force_optimized_typechecker=False,
            enable_stdlibcore_exclusivity_checking=False,
            enable_experimental_differentiable_programming=False,
            enable_experimental_concurrency=False,
            enable_experimental_distributed=False,
            build_swift_stdlib_static_print=False,
            build_swift_stdlib_unicode_data=True,
            swift_freestanding_is_darwin=False,
            build_swift_private_stdlib=True,
            swift_tools_ld64_lto_codegen_only_for_supporting_targets=False)

        # Setup shell
        shell.dry_run = True
        self._orig_stdout = sys.stdout
        self._orig_stderr = sys.stderr
        self.stdout = StringIO()
        self.stderr = StringIO()
        sys.stdout = self.stdout
        sys.stderr = self.stderr
Exemplo n.º 10
0
class NinjaTestCase(unittest.TestCase):
    def setUp(self):
        # Setup workspace
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, 'ninja'))

        self.workspace = Workspace(source_root=tmpdir1, build_root=tmpdir2)

        # Setup toolchain
        self.toolchain = host_toolchain()
        self.toolchain.cc = '/path/to/cc'
        self.toolchain.cxx = '/path/to/cxx'

        # Setup args
        self.args = argparse.Namespace(build_ninja=True,
                                       darwin_deployment_version_osx="10.9")

        # Setup shell
        shell.dry_run = True
        self._orig_stdout = sys.stdout
        self._orig_stderr = sys.stderr
        self.stdout = StringIO()
        self.stderr = StringIO()
        sys.stdout = self.stdout
        sys.stderr = self.stderr

    def tearDown(self):
        shutil.rmtree(self.workspace.build_root)
        shutil.rmtree(self.workspace.source_root)
        sys.stdout = self._orig_stdout
        sys.stderr = self._orig_stderr
        shell.dry_run = False
        self.workspace = None
        self.toolchain = None
        self.args = None

    def test_ninja_bin_path(self):
        ninja_build = Ninja(args=self.args,
                            toolchain=self.toolchain,
                            source_dir='/path/to/src',
                            build_dir='/path/to/build')

        self.assertEqual(ninja_build.ninja_bin_path, '/path/to/build/ninja')

    def test_do_build(self):
        ninja_build = Ninja(args=self.args,
                            toolchain=self.toolchain,
                            source_dir=self.workspace.source_dir('ninja'),
                            build_dir=self.workspace.build_dir(
                                'build', 'ninja'))

        ninja_build.do_build()

        expect_env = ""
        if platform.system() == "Darwin":
            expect_env = (
                "env "
                "'CFLAGS=-isysroot {sysroot} -mmacosx-version-min=10.9' "
                "CXX={cxx} "
                "LDFLAGS=-mmacosx-version-min=10.9 ").format(
                    cxx=self.toolchain.cxx, sysroot=xcrun.sdk_path('macosx'))

        self.assertEqual(
            self.stdout.getvalue(), """\
+ rm -rf {build_dir}
+ cp -r {source_dir} {build_dir}
+ pushd {build_dir}
+ {expect_env}{python} configure.py --bootstrap
+ popd
""".format(source_dir=os.path.join(self.workspace.source_root, 'ninja'),
           build_dir=os.path.join(self.workspace.build_root, 'ninja-build'),
           expect_env=expect_env,
           python=sys.executable))
Exemplo n.º 11
0
class NinjaTestCase(unittest.TestCase):

    def setUp(self):
        # Setup workspace
        tmpdir1 = os.path.realpath(tempfile.mkdtemp())
        tmpdir2 = os.path.realpath(tempfile.mkdtemp())
        os.makedirs(os.path.join(tmpdir1, 'ninja'))

        self.workspace = Workspace(source_root=tmpdir1,
                                   build_root=tmpdir2)

        # Setup toolchain
        self.toolchain = host_toolchain()
        self.toolchain.cc = '/path/to/cc'
        self.toolchain.cxx = '/path/to/cxx'

        # Setup args
        self.args = argparse.Namespace(
            build_ninja=True,
            darwin_deployment_version_osx="10.9")

        # Setup shell
        shell.dry_run = True
        self._orig_stdout = sys.stdout
        self._orig_stderr = sys.stderr
        self.stdout = StringIO()
        self.stderr = StringIO()
        sys.stdout = self.stdout
        sys.stderr = self.stderr

    def tearDown(self):
        shutil.rmtree(self.workspace.build_root)
        shutil.rmtree(self.workspace.source_root)
        sys.stdout = self._orig_stdout
        sys.stderr = self._orig_stderr
        shell.dry_run = False
        self.workspace = None
        self.toolchain = None
        self.args = None

    def test_ninja_bin_path(self):
        ninja_build = Ninja(
            args=self.args,
            toolchain=self.toolchain,
            source_dir='/path/to/src',
            build_dir='/path/to/build')

        self.assertEqual(ninja_build.ninja_bin_path, '/path/to/build/ninja')

    def test_do_build(self):
        ninja_build = Ninja(
            args=self.args,
            toolchain=self.toolchain,
            source_dir=self.workspace.source_dir('ninja'),
            build_dir=self.workspace.build_dir('build', 'ninja'))

        ninja_build.do_build()

        expect_env = ""
        if platform.system() == "Darwin":
            expect_env = (
                "env "
                "'CFLAGS=-isysroot {sysroot} -mmacosx-version-min=10.9' "
                "CXX={cxx} "
                "LDFLAGS=-mmacosx-version-min=10.9 "
            ).format(
                cxx=self.toolchain.cxx,
                sysroot=xcrun.sdk_path('macosx')
            )

        self.assertEqual(self.stdout.getvalue(), """\
+ rm -rf {build_dir}
+ cp -r {source_dir} {build_dir}
+ pushd {build_dir}
+ {expect_env}{python} configure.py --bootstrap
+ popd
""".format(
            source_dir=os.path.join(self.workspace.source_root, 'ninja'),
            build_dir=os.path.join(self.workspace.build_root, 'ninja-build'),
            expect_env=expect_env,
            python=sys.executable))