def __init__(self): self.include_dirs = [] self._build_env_prepared = False self._sdk_dir = None self._ndk_dir = None self._android_api = None self._ndk_api = None self.ndk = None self.toolchain_prefix = None self.toolchain_version = None self.local_recipes = None self.copy_libs = False # this list should contain all Archs, it is pruned later self.archs = ( ArchARM(self), ArchARMv7_a(self), Archx86(self), Archx86_64(self), ArchAarch_64(self), ) self.root_dir = realpath(dirname(__file__)) # remove the most obvious flags that can break the compilation self.env.pop("LDFLAGS", None) self.env.pop("ARCHFLAGS", None) self.env.pop("CFLAGS", None) self.python_recipe = None # Set by TargetPythonRecipe
def test_arch_x86(self, mock_ensure_dir, mock_find_executable): """ Test that class :class:`~pythonforandroid.archs.Archx86` returns some expected attributes and environment variables. .. note:: Here we mock the same functions than :meth:`TestArchARM.test_arch_arm` """ mock_find_executable.return_value = "arm-linux-androideabi-gcc" mock_ensure_dir.return_value = True arch = Archx86(self.ctx) self.assertEqual(arch.arch, "x86") self.assertEqual(arch.__str__(), "x86") self.assertEqual(arch.toolchain_prefix, "x86") self.assertEqual(arch.command_prefix, "i686-linux-android") self.assertEqual(arch.target, "i686-none-linux-android") self.assertEqual(arch.platform_dir, "arch-x86") # For x86 we expect some extra cflags in our `environment` env = arch.get_env() self.assertIn( " -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32", env["CFLAGS"], )
def __init__(self): super(Context, self).__init__() self.include_dirs = [] self._build_env_prepared = False self._sdk_dir = None self._ndk_dir = None self._android_api = None self._ndk_ver = None self.toolchain_prefix = None self.toolchain_version = None self.local_recipes = None # root of the toolchain self.setup_dirs() # this list should contain all Archs, it is pruned later self.archs = (ArchARM(self), ArchARMv7_a(self), Archx86(self)) ensure_dir(join(self.build_dir, 'bootstrap_builds')) ensure_dir(join(self.build_dir, 'other_builds')) # other_builds: where everything else is built # remove the most obvious flags that can break the compilation self.env.pop("LDFLAGS", None) self.env.pop("ARCHFLAGS", None) self.env.pop("CFLAGS", None)
def test_arch_x86(self, mock_ensure_dir, mock_find_executable, mock_glob): """ Test that class :class:`~pythonforandroid.archs.Archx86` returns some expected attributes and environment variables. .. note:: Here we mock the same functions than :meth:`TestArchARM.test_arch_arm` plus `glob`, so we make sure that the glob result is the expected even if the folder doesn't exist, which is probably the case. This has to be done because here we tests the `get_env` with clang """ mock_find_executable.return_value = self.expected_compiler mock_ensure_dir.return_value = True mock_glob.return_value = ["llvm"] arch = Archx86(self.ctx) self.assertEqual(arch.arch, "x86") self.assertEqual(arch.__str__(), "x86") self.assertEqual(arch.toolchain_prefix, "x86") self.assertEqual(arch.command_prefix, "i686-linux-android") self.assertEqual(arch.target, "i686-linux-android21") self.assertEqual(arch.platform_dir, "arch-x86") env = arch.get_env() # check glob and find_executable calls self.assertEqual(mock_glob.call_count, 4) for glob_call, kw in mock_glob.call_args_list: self.assertEqual( glob_call[0], "{ndk_dir}/toolchains/llvm*".format(ndk_dir=self.ctx._ndk_dir), ) mock_find_executable.assert_called_once_with(self.expected_compiler, path=environ["PATH"]) # For x86 we expect some extra cflags in our `environment` self.assertIn( " -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32", env["CFLAGS"], )