From 1f09e2c3d0f16540ffb2ff48f3863d1defe53e6c Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Mon, 18 Apr 2022 16:15:47 -0600 Subject: [PATCH] Include HOME in build environment Many of the tools run by p4a store intermediate files in the user's home directory. Passing the HOME environment variable to the build environment has 2 positive effects: 1. To completely encapsulate the build, HOME can be set to an alternate directory than the user's actual home directory. Many tools such as p4a have options to override these paths, but that must be done on a case by case basis and it would require that p4a pass through these options or environment variables. 2. In containerized environments the user may not be registered in the accounts database. If the user's home directory can't be found from the HOME environment variable or the accounts database, many tools will fail. An example of this is python2.7 when run by `ndk-build`. --- pythonforandroid/archs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pythonforandroid/archs.py b/pythonforandroid/archs.py index 95d94b5f1b..0281c9cb3f 100644 --- a/pythonforandroid/archs.py +++ b/pythonforandroid/archs.py @@ -140,6 +140,10 @@ def get_clang_exe(self, with_target=False, plus_plus=False): def get_env(self, with_flags_in_cc=True): env = {} + # HOME: User's home directory + if 'HOME' in environ: + env['HOME'] = environ['HOME'] + # CFLAGS/CXXFLAGS: the processor flags env['CFLAGS'] = ' '.join(self.common_cflags).format(target=self.target) if self.arch_cflags: