Skip to content

Commit 888fdde

Browse files
committed
use ccache for cross compilation
1 parent 9916cb5 commit 888fdde

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

pythonforandroid/archs.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ def get_env(self):
5252
env['TOOLCHAIN_PREFIX'] = toolchain_prefix
5353
env['TOOLCHAIN_VERSION'] = toolchain_version
5454

55+
ccache = ''
56+
if self.ctx.ccache and bool(int(environ.get('USE_CCACHE', '1'))):
57+
print('ccache found, will optimize builds')
58+
ccache = self.ctx.ccache + ' '
59+
env['USE_CCACHE'] = '1'
60+
env['NDK_CCACHE'] = self.ctx.ccache
61+
5562
print('path is', environ['PATH'])
5663
cc = find_executable('{command_prefix}-gcc'.format(
5764
command_prefix=command_prefix), path=environ['PATH'])
@@ -62,11 +69,13 @@ def get_env(self):
6269
'installed. Exiting.')
6370
exit(1)
6471

65-
env['CC'] = '{command_prefix}-gcc {cflags}'.format(
72+
env['CC'] = '{ccache}{command_prefix}-gcc {cflags}'.format(
6673
command_prefix=command_prefix,
74+
ccache=ccache,
6775
cflags=env['CFLAGS'])
68-
env['CXX'] = '{command_prefix}-g++ {cxxflags}'.format(
76+
env['CXX'] = '{ccache}{command_prefix}-g++ {cxxflags}'.format(
6977
command_prefix=command_prefix,
78+
ccache=ccache,
7079
cxxflags=env['CXXFLAGS'])
7180

7281
env['AR'] = '{}-ar'.format(command_prefix)

0 commit comments

Comments
 (0)