Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf29e177

Browse files
committed
Environment variable cleanups
1 parentc7cdb98 commitf29e177

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

‎Android/android.py

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,30 @@ def run(command, *, host=None, env=None, log=True, **kwargs):
8282
ifenvisNone:
8383
env=os.environ.copy()
8484
ifhost:
85-
env.update(android_env(host))
85+
# The -I and -L arguments used when building Python should not be reused
86+
# when building third-party extension modules, so pass them via the
87+
# NODIST environment variables.
88+
host_env=android_env(host)
89+
fornamein ["CFLAGS","CXXFLAGS","LDFLAGS"]:
90+
flags= []
91+
nodist= []
92+
forwordinhost_env[name].split():
93+
(nodistifword.startswith(("-I","-L"))elseflags).append(word)
94+
host_env[name]=" ".join(flags)
95+
host_env[f"{name}_NODIST"]=" ".join(nodist)
96+
97+
print_env(host_env)
98+
env.update(host_env)
8699

87100
iflog:
88101
print(">"," ".join(map(str,command)))
89102
returnsubprocess.run(command,env=env,**kwargs)
90103

91104

92-
defprint_env(context):
93-
android_env(getattr(context,"host",None))
105+
# Format the environment so it can be pasted into a shell.
106+
defprint_env(env):
107+
forkey,valueinsorted(env.items()):
108+
print(f"export{key}={shlex.quote(value)}")
94109

95110

96111
defandroid_env(host):
@@ -126,10 +141,6 @@ def android_env(host):
126141
ifnotenv:
127142
raiseValueError(f"Found no variables in{env_script.name} output:\n"
128143
+env_output)
129-
130-
# Format the environment so it can be pasted into a shell.
131-
forkey,valueinsorted(env.items()):
132-
print(f"export{key}={shlex.quote(value)}")
133144
returnenv
134145

135146

@@ -220,9 +231,12 @@ def make_host_python(context):
220231
forpatternin ("include/python*","lib/libpython*","lib/python*"):
221232
delete_glob(f"{prefix_dir}/{pattern}")
222233

234+
# The Android environment variables were already captured in the Makefile by
235+
# `configure`, and passing them again when running `make` may cause some
236+
# flags to be duplicated. So we don't use the `host` argument here.
223237
os.chdir(host_dir)
224-
run(["make","-j",str(os.cpu_count())],host=context.host)
225-
run(["make","install",f"prefix={prefix_dir}"],host=context.host)
238+
run(["make","-j",str(os.cpu_count())])
239+
run(["make","install",f"prefix={prefix_dir}"])
226240

227241

228242
defbuild_all(context):
@@ -628,6 +642,10 @@ def package(context):
628642
print(f"Wrote{package_path}")
629643

630644

645+
defenv(context):
646+
print_env(android_env(getattr(context,"host",None)))
647+
648+
631649
# Handle SIGTERM the same way as SIGINT. This ensures that if we're terminated
632650
# by the buildbot worker, we'll make an attempt to clean up our subprocesses.
633651
definstall_signal_handler():
@@ -717,7 +735,7 @@ def main():
717735
"build-testbed":build_testbed,
718736
"test":run_testbed,
719737
"package":package,
720-
"env":print_env,
738+
"env":env,
721739
}
722740

723741
try:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp