1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 from __future__
import absolute_import
, print_function
7 from contextlib
import contextmanager
12 from mozbuild
.util
import (
16 import mozpack
.path
as mozpath
20 def gradle_lock(topobjdir
, max_wait_seconds
=600):
21 # Building the same Gradle root project with multiple concurrent processes
22 # is not well supported, so we use a simple lock file to serialize build
24 lock_path
= "{}/gradle/mach_android.lockfile".format(topobjdir
)
25 ensureParentDir(lock_path
)
26 lock_instance
= lock_file(lock_path
, max_wait
=max_wait_seconds
)
34 def android(verb
, *args
):
37 with
gradle_lock(buildconfig
.topobjdir
):
40 mozpath
.join(buildconfig
.topsrcdir
, "mach"),
45 env
= dict(os
.environ
)
46 # Confusingly, `MACH` is set only within `mach build`.
48 env
["GRADLE_INVOKED_WITHIN_MACH_BUILD"] = "1"
49 if env
.get("LD_LIBRARY_PATH"):
50 del env
["LD_LIBRARY_PATH"]
51 subprocess
.check_call(cmd
, env
=env
)
56 def assemble_app(dummy_output_file
, *inputs
):
57 return android("assemble-app")
60 def generate_sdk_bindings(dummy_output_file
, *args
):
61 return android("generate-sdk-bindings", *args
)
64 def generate_generated_jni_wrappers(dummy_output_file
, *args
):
65 return android("generate-generated-jni-wrappers", *args
)