diff options
author | Hidehiko Abe <hidehiko@google.com> | 2018-04-17 04:31:44 +0900 |
---|---|---|
committer | Hidehiko Abe <hidehiko@google.com> | 2018-04-17 08:54:40 +0900 |
commit | 0325b56b0518f5ca16701e5048fcf81cc96fd725 (patch) | |
tree | 0ad18a9bb27c3ae19e66e933d51725763e2011b4 | |
parent | fd1f9007ea17b652f860835390cdcdb36231a9d2 (diff) | |
download | libmojo-0325b56b0518f5ca16701e5048fcf81cc96fd725.tar.gz |
Bundle libraries into python_host_binary.
In Chrome, we run scripts on the source tree.
To follow that pattern, bundle needed libraries into python_host_binary.
In this approach, most Android.bp can be removed, which
helps to merging libmojo into libchrome, because then we don't
need to put Android.bp in individual directories.
Bug: 73606903
Test: Built locally.
Change-Id: I66aacb5f4c8da5b7182b0e1cf91b451efe944247
-rw-r--r-- | Android.bp | 40 | ||||
-rw-r--r-- | build/Android.bp | 12 | ||||
-rw-r--r-- | build/android/Android.bp | 13 | ||||
-rw-r--r-- | build/android/gyp/Android.bp | 13 | ||||
-rw-r--r-- | build/android/gyp/util/build_utils.py | 9 | ||||
-rw-r--r-- | mojo/public/tools/bindings/Android.bp | 27 | ||||
-rw-r--r-- | mojo/public/tools/bindings/pylib/Android.bp | 12 | ||||
-rwxr-xr-x | soong/mojom_source_generator.sh | 9 | ||||
-rw-r--r-- | third_party/Android.bp | 17 | ||||
-rw-r--r-- | third_party/catapult/devil/Android.bp | 12 |
10 files changed, 36 insertions, 128 deletions
@@ -19,12 +19,9 @@ filegroup { ], } -// TODO(risan): move this to third_party/catapult/Android.bp and enable embedded_launcher. -python_library_host { - name: "catapult", - srcs: [ - "third_party/catapult/devil/devil/**/*.py", - ], +// Python in Chrome repository requires still Python 2. +python_defaults { + name: "libmojo_scripts", version: { py2: { enabled: true, @@ -35,25 +32,34 @@ python_library_host { }, } -// TODO(risan): split this into python_libraries. python_binary_host { name: "jni_generator", main: "base/android/jni_generator/jni_generator.py", srcs: [ "base/android/jni_generator/jni_generator.py", "build/**/*.py", + "third_party/catapult/devil/devil/**/*.py", ], - version: { - py2: { - enabled: true, - }, - py3: { - enabled: false, - }, - }, - libs: [ - "catapult", + defaults: ["libmojo_scripts"], +} + +python_binary_host { + name: "mojom_bindings_generator", + main: "mojo/public/tools/bindings/mojom_bindings_generator.py", + srcs: [ + "mojo/public/tools/bindings/**/*.py", + "build/**/*.py", + "third_party/catapult/devil/**/*.py", + "third_party/jinja2/**/*.py", + "third_party/markupsafe/**/*.py", + "third_party/ply/**/*.py", + ], + data: [ + "mojo/public/tools/bindings/generators/cpp_templates/*.tmpl", + "mojo/public/tools/bindings/generators/java_templates/*.tmpl", + "mojo/public/tools/bindings/generators/js_templates/*.tmpl", ], + defaults: ["libmojo_scripts"], } cc_prebuilt_binary { diff --git a/build/Android.bp b/build/Android.bp deleted file mode 100644 index afb4997..0000000 --- a/build/Android.bp +++ /dev/null @@ -1,12 +0,0 @@ -python_library_host { - name: "mojom_build", - srcs: ["gn_helpers.py"], - version: { - py2: { - enabled: true, - }, - py3: { - enabled: false, - }, - }, -} diff --git a/build/android/Android.bp b/build/android/Android.bp deleted file mode 100644 index d015454..0000000 --- a/build/android/Android.bp +++ /dev/null @@ -1,13 +0,0 @@ -python_library_host { - name: "mojom_build_android", - srcs: ["pylib/**/*.py"], - libs: ["mojom_build_android_gyp"], - version: { - py2: { - enabled: true, - }, - py3: { - enabled: false, - }, - }, -} diff --git a/build/android/gyp/Android.bp b/build/android/gyp/Android.bp deleted file mode 100644 index 75d3238..0000000 --- a/build/android/gyp/Android.bp +++ /dev/null @@ -1,13 +0,0 @@ -python_library_host { - name: "mojom_build_android_gyp", - srcs: ["**/*.py"], - libs: ["mojom_build"], - version: { - py2: { - enabled: true, - }, - py3: { - enabled: false, - }, - }, -} diff --git a/build/android/gyp/util/build_utils.py b/build/android/gyp/util/build_utils.py index 7b2f48d..abd2dfc 100644 --- a/build/android/gyp/util/build_utils.py +++ b/build/android/gyp/util/build_utils.py @@ -20,7 +20,13 @@ import zipfile # Some clients do not add //build/android/gyp to PYTHONPATH. import md5_check # pylint: disable=relative-import -sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) +# pylib conflicts with mojo/public/tools/bindings/pylib. Prioritize +# build/android/pylib. +# PYTHONPATH wouldn't help in this case, because soong put source files under +# temp directory for each build, so the abspath is unknown until the +# execution. +# sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) +sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)) from pylib.constants import host_paths sys.path.append(os.path.join(os.path.dirname(__file__), @@ -581,4 +587,3 @@ def CallAndWriteDepfileIfStale(function, options, record_path=None, output_paths=output_paths, force=force, pass_changes=True) - diff --git a/mojo/public/tools/bindings/Android.bp b/mojo/public/tools/bindings/Android.bp deleted file mode 100644 index 16af6b4..0000000 --- a/mojo/public/tools/bindings/Android.bp +++ /dev/null @@ -1,27 +0,0 @@ -python_binary_host { - name: "mojom_bindings_generator", - main: "mojom_bindings_generator.py", - libs: [ - "mojom_build_android", - "mojom_bindings_pylib", - "mojom_third_party", - ], - srcs: [ - "generators/*.py", - "*.py", - ], - data: [ - "generators/js_templates/*.tmpl", - "generators/java_templates/*.tmpl", - "generators/cpp_templates/*.tmpl", - ], - version: { - py2: { - enabled: true, - }, - py3: { - enabled: false, - }, - }, -} - diff --git a/mojo/public/tools/bindings/pylib/Android.bp b/mojo/public/tools/bindings/pylib/Android.bp deleted file mode 100644 index 2dd4c58..0000000 --- a/mojo/public/tools/bindings/pylib/Android.bp +++ /dev/null @@ -1,12 +0,0 @@ -python_library_host { - name: "mojom_bindings_pylib", - srcs: ["**/*.py"], - version: { - py2: { - enabled: true, - }, - py3: { - enabled: false, - }, - }, -} diff --git a/soong/mojom_source_generator.sh b/soong/mojom_source_generator.sh index f1fac9e..118d513 100755 --- a/soong/mojom_source_generator.sh +++ b/soong/mojom_source_generator.sh @@ -81,7 +81,8 @@ for arg in "$@"; do done cd "${package}" -"${mojom_bindings_generator}" precompile -o "${output_dir}" +"${mojom_bindings_generator}" --use_bundled_pylibs precompile \ + -o "${output_dir}" for file in "${files[@]}"; do # Java source generations depends on zipfile that assumes the output directory @@ -95,12 +96,14 @@ for file in "${files[@]}"; do # libmojo root directory as part of searchable directory for imports. With # this, we can have a mojo file located in some arbitrary directories that # imports a mojo file under external/libmojo. - "${mojom_bindings_generator}" generate -o "${output_dir}" "${args[@]}" \ + "${mojom_bindings_generator}" --use_bundled_pylibs generate \ + -o "${output_dir}" "${args[@]}" \ --bytecode_path="${bytecode_path}" \ -I "${private_mojo_root}:${private_mojo_root}" \ --generators=${generators} "${file}" if [[ "${generators}" =~ .*c\+\+.* ]] ; then - "${mojom_bindings_generator}" generate -o "${output_dir}" \ + "${mojom_bindings_generator}" --use_bundled_pylibs generate \ + -o "${output_dir}" \ --generate_non_variant_code "${args[@]}" \ -I "${private_mojo_root}:${private_mojo_root}" \ --bytecode_path="${bytecode_path}" --generators=${generators} \ diff --git a/third_party/Android.bp b/third_party/Android.bp deleted file mode 100644 index 9ea21c3..0000000 --- a/third_party/Android.bp +++ /dev/null @@ -1,17 +0,0 @@ -python_library_host { - name: "mojom_third_party", - srcs: [ - "jinja2/**/*.py", - "markupsafe/**/*.py", - "ply/**/*.py", - ], - libs: ["mojom_third_party_devil"], - version: { - py2: { - enabled: true, - }, - py3: { - enabled: false, - }, - }, -} diff --git a/third_party/catapult/devil/Android.bp b/third_party/catapult/devil/Android.bp deleted file mode 100644 index d466196..0000000 --- a/third_party/catapult/devil/Android.bp +++ /dev/null @@ -1,12 +0,0 @@ -python_library_host { - name: "mojom_third_party_devil", - srcs: ["devil/**/*.py"], - version: { - py2: { - enabled: true, - }, - py3: { - enabled: false, - }, - }, -} |