Skip to content

Commit 292ff74

Browse files
committed
add option to not include cflags in cc
1 parent fdb2b5f commit 292ff74

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

pythonforandroid/archs.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def include_dirs(self):
3030
d.format(arch=self))
3131
for d in self.ctx.include_dirs]
3232

33-
def get_env(self):
33+
def get_env(self, with_flags_in_cc=True):
3434
env = {}
3535

3636
env["CFLAGS"] = " ".join([
@@ -72,14 +72,22 @@ def get_env(self):
7272
'installed. Exiting.')
7373
exit(1)
7474

75-
env['CC'] = '{ccache}{command_prefix}-gcc {cflags}'.format(
76-
command_prefix=command_prefix,
77-
ccache=ccache,
78-
cflags=env['CFLAGS'])
79-
env['CXX'] = '{ccache}{command_prefix}-g++ {cxxflags}'.format(
80-
command_prefix=command_prefix,
81-
ccache=ccache,
82-
cxxflags=env['CXXFLAGS'])
75+
if with_flags_in_cc:
76+
env['CC'] = '{ccache}{command_prefix}-gcc {cflags}'.format(
77+
command_prefix=command_prefix,
78+
ccache=ccache,
79+
cflags=env['CFLAGS'])
80+
env['CXX'] = '{ccache}{command_prefix}-g++ {cxxflags}'.format(
81+
command_prefix=command_prefix,
82+
ccache=ccache,
83+
cxxflags=env['CXXFLAGS'])
84+
else:
85+
env['CC'] = '{ccache}{command_prefix}-gcc'.format(
86+
command_prefix=command_prefix,
87+
ccache=ccache)
88+
env['CXX'] = '{ccache}{command_prefix}-g++'.format(
89+
command_prefix=command_prefix,
90+
ccache=ccache)
8391

8492
env['AR'] = '{}-ar'.format(command_prefix)
8593
env['RANLIB'] = '{}-ranlib'.format(command_prefix)
@@ -118,8 +126,8 @@ class ArchARM(Arch):
118126
class ArchARMv7_a(ArchARM):
119127
arch = 'armeabi-v7a'
120128

121-
def get_env(self):
122-
env = super(ArchARMv7_a, self).get_env()
129+
def get_env(self, with_flags_in_cc=True):
130+
env = super(ArchARMv7_a, self).get_env(with_flags_in_cc)
123131
env['CFLAGS'] = (env['CFLAGS'] +
124132
(' -march=armv7-a -mfloat-abi=softfp '
125133
'-mfpu=vfp -mthumb'))
@@ -133,8 +141,8 @@ class Archx86(Arch):
133141
command_prefix = 'i686-linux-android'
134142
platform_dir = 'arch-x86'
135143

136-
def get_env(self):
137-
env = super(Archx86, self).get_env()
144+
def get_env(self, with_flags_in_cc=True):
145+
env = super(Archx86, self).get_env(with_flags_in_cc)
138146
env['CFLAGS'] = (env['CFLAGS'] +
139147
' -march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32')
140148
env['CXXFLAGS'] = env['CFLAGS']
@@ -147,8 +155,8 @@ class Archx86_64(Arch):
147155
command_prefix = 'x86_64-linux-android'
148156
platform_dir = 'arch-x86'
149157

150-
def get_env(self):
151-
env = super(Archx86_64, self).get_env()
158+
def get_env(self, with_flags_in_cc=True):
159+
env = super(Archx86_64, self).get_env(with_flags_in_cc)
152160
env['CFLAGS'] = (env['CFLAGS'] +
153161
' -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel')
154162
env['CXXFLAGS'] = env['CFLAGS']

pythonforandroid/recipe.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,12 @@ def unpack(self, arch):
443443
else:
444444
info('{} is already unpacked, skipping'.format(self.name))
445445

446-
def get_recipe_env(self, arch=None):
446+
def get_recipe_env(self, arch=None, with_flags_in_cc=True):
447447
"""Return the env specialized for the recipe
448448
"""
449449
if arch is None:
450450
arch = self.filtered_archs[0]
451-
return arch.get_env()
451+
return arch.get_env(with_flags_in_cc=with_flags_in_cc)
452452

453453
def prebuild_arch(self, arch):
454454
'''Run any pre-build tasks for the Recipe. By default, this checks if
@@ -896,8 +896,8 @@ def build_cython_components(self, arch):
896896
# for filename in fnmatch.filter(filenames, "*.pyx"):
897897
# self.cythonize_file(join(root, filename))
898898

899-
def get_recipe_env(self, arch):
900-
env = super(CythonRecipe, self).get_recipe_env(arch)
899+
def get_recipe_env(self, arch, with_flags_in_cc=True):
900+
env = super(CythonRecipe, self).get_recipe_env(arch, with_flags_in_cc)
901901
env['LDFLAGS'] = env['LDFLAGS'] + ' -L{} '.format(
902902
self.ctx.get_libs_dir(arch.arch) +
903903
' -L{} '.format(self.ctx.libs_dir))

0 commit comments

Comments
 (0)