8000 Merge pull request #1597 from opacam/fix-build-platform · onlyskin/python-for-android@a31f9f1 · GitHub
[go: up one dir, main page]

Skip to content

Commit a31f9f1

Browse files
authored
Merge pull request kivy#1597 from opacam/fix-build-platform
Fix hardcoded entries (build platform) for core modules: archs and python
2 parents cbab936 + 49deb1c commit a31f9f1

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

pythonforandroid/archs.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from distutils.spawn import find_executable
66

77
from pythonforandroid.recipe import Recipe
8-
from pythonforandroid.util import BuildInterruptingException
8+
from pythonforandroid.util import BuildInterruptingException, build_platform
99

1010

1111
class Arch(object):
@@ -51,7 +51,8 @@ def get_env(self, with_flags_in_cc=True, clang=False):
5151
toolchain = '{android_host}-{toolchain_version}'.format(
5252
android_host=self.ctx.toolchain_prefix,
5353
toolchain_version=self.ctx.toolchain_version)
54-
toolchain = join(self.ctx.ndk_dir, 'toolchains', toolchain, 'prebuilt', 'linux-x86_64')
54+
toolchain = join(self.ctx.ndk_dir, 'toolchains', toolchain,
55+
'prebuilt', build_platform)
5556
cflags.append('-gcc-toolchain {}'.format(toolchain))
5657

5758
env['CFLAGS'] = ' '.join(cflags)
@@ -106,7 +107,7 @@ def get_env(self, with_flags_in_cc=True, clang=False):
106107
llvm_dirname = split(
107108
glob(join(self.ctx.ndk_dir, 'toolchains', 'llvm*'))[-1])[-1]
108109
clang_path = join(self.ctx.ndk_dir, 'toolchains', llvm_dirname,
109-
'prebuilt', 'linux-x86_64', 'bin')
110+
'prebuilt', build_platform, 'bin')
110111
environ['PATH'] = '{clang_path}:{path}'.format(
111112
clang_path=clang_path, path=environ['PATH'])
112113
exe = join(clang_path, 'clang')

pythonforandroid/python.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from pythonforandroid.logger import logger, info, shprint
1414
from pythonforandroid.util import (
1515
current_directory, ensure_dir, walk_valid_filens,
16-
BuildInterruptingException)
16+
BuildInterruptingException, build_platform)
1717

1818

1919
class GuestPythonRecipe(TargetPythonRecipe):
@@ -107,12 +107,12 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True):
107107
toolchain_prefix=self.ctx.toolchain_prefix,
108108
toolchain_version=self.ctx.toolchain_version)
109109
toolchain = join(self.ctx.ndk_dir, 'toolchains',
110-
toolchain, 'prebuilt', 'linux-x86_64')
110+
toolchain, 'prebuilt', build_platform)
111111

112112
env['CC'] = (
113113
'{clang} -target {target} -gcc-toolchain {toolchain}').format(
114114
clang=join(self.ctx.ndk_dir, 'toolchains', 'llvm', 'prebuilt',
115-
'linux-x86_64', 'bin', 'clang'),
115+
build_platform, 'bin', 'clang'),
116116
target=arch.target,
117117
toolchain=toolchain)
118118
env['AR'] = join(toolchain, 'bin', android_host) + '-ar'

pythonforandroid/util.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import contextlib
22
from os.path import exists, join
3-
from os import getcwd, chdir, makedirs, walk
3+
from os import getcwd, chdir, makedirs, walk, uname
44
import io
55
import json
66
import shutil
@@ -24,6 +24,13 @@ class WgetDownloader(FancyURLopener):
2424
urlretrieve = WgetDownloader().retrieve
2525

2626

27+
build_platform = '{system}-{machine}'.format(
28+
system=uname()[0], machine=uname()[-1]).lower()
29+
"""the build platform in the format `system-machine`. We use
30+
this string to define the right build system when compiling some recipes or
31+
to get the right path for clang compiler"""
32+
33+
2734
@contextlib.contextmanager
2835
def current_directory(new_dir):
2936
cur_dir = getcwd()

0 commit comments

Comments
 (0)
0