Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hardcoded entries (build platform) for core modules: archs and python #1597

Merged
merged 3 commits into from
Jan 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pythonforandroid/archs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from distutils.spawn import find_executable

from pythonforandroid.recipe import Recipe
from pythonforandroid.util import BuildInterruptingException
from pythonforandroid.util import BuildInterruptingException, build_platform


class Arch(object):
Expand Down Expand Up @@ -51,7 +51,8 @@ def get_env(self, with_flags_in_cc=True, clang=False):
toolchain = '{android_host}-{toolchain_version}'.format(
android_host=self.ctx.toolchain_prefix,
toolchain_version=self.ctx.toolchain_version)
toolchain = join(self.ctx.ndk_dir, 'toolchains', toolchain, 'prebuilt', 'linux-x86_64')
toolchain = join(self.ctx.ndk_dir, 'toolchains', toolchain,
'prebuilt', build_platform)
cflags.append('-gcc-toolchain {}'.format(toolchain))

env['CFLAGS'] = ' '.join(cflags)
Expand Down Expand Up @@ -106,7 +107,7 @@ def get_env(self, with_flags_in_cc=True, clang=False):
llvm_dirname = split(
glob(join(self.ctx.ndk_dir, 'toolchains', 'llvm*'))[-1])[-1]
clang_path = join(self.ctx.ndk_dir, 'toolchains', llvm_dirname,
'prebuilt', 'linux-x86_64', 'bin')
'prebuilt', build_platform, 'bin')
environ['PATH'] = '{clang_path}:{path}'.format(
clang_path=clang_path, path=environ['PATH'])
exe = join(clang_path, 'clang')
Expand Down
6 changes: 3 additions & 3 deletions pythonforandroid/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pythonforandroid.logger import logger, info, shprint
from pythonforandroid.util import (
current_directory, ensure_dir, walk_valid_filens,
BuildInterruptingException)
BuildInterruptingException, build_platform)


class GuestPythonRecipe(TargetPythonRecipe):
Expand Down Expand Up @@ -107,12 +107,12 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
toolchain_prefix=self.ctx.toolchain_prefix,
toolchain_version=self.ctx.toolchain_version)
toolchain = join(self.ctx.ndk_dir, 'toolchains',
toolchain, 'prebuilt', 'linux-x86_64')
toolchain, 'prebuilt', build_platform)

env['CC'] = (
'{clang} -target {target} -gcc-toolchain {toolchain}').format(
clang=join(self.ctx.ndk_dir, 'toolchains', 'llvm', 'prebuilt',
'linux-x86_64', 'bin', 'clang'),
build_platform, 'bin', 'clang'),
target=arch.target,
toolchain=toolchain)
env['AR'] = join(toolchain, 'bin', android_host) + '-ar'
Expand Down
9 changes: 8 additions & 1 deletion pythonforandroid/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import contextlib
from os.path import exists, join
from os import getcwd, chdir, makedirs, walk
from os import getcwd, chdir, makedirs, walk, uname
import io
import json
import shutil
Expand All @@ -24,6 +24,13 @@ class WgetDownloader(FancyURLopener):
urlretrieve = WgetDownloader().retrieve


build_platform = '{system}-{machine}'.format(
system=uname()[0], machine=uname()[-1]).lower()
"""the build platform in the format `system-machine`. We use
this string to define the right build system when compiling some recipes or
to get the right path for clang compiler"""


@contextlib.contextmanager
def current_directory(new_dir):
cur_dir = getcwd()
Expand Down