summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Hector Chavez <lhchavez@google.com>2018-08-10 10:11:44 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-08-10 10:11:44 -0700
commit2940c890d760be6198261bcb3b968b80a468ab76 (patch)
tree9bf5d433dcb28d3aeb4f1b4a4cd7a1891ee12817
parent2f5cbc83e63383bc20516df7730b98ce3979f34e (diff)
parent1c89c68e61486efbf0007ad2f83861a112e12538 (diff)
downloadlibchrome-2940c890d760be6198261bcb3b968b80a468ab76.tar.gz
libchrome: Update mojom_source_generator.sh to support pickle files
am: 1c89c68e61 Change-Id: I579227d17f18622bdcb27751abc7bea663fdb104
-rwxr-xr-xlibchrome_tools/mojom_source_generator.sh50
1 files changed, 35 insertions, 15 deletions
diff --git a/libchrome_tools/mojom_source_generator.sh b/libchrome_tools/mojom_source_generator.sh
index a60658feee..a0feb1f65c 100755
--- a/libchrome_tools/mojom_source_generator.sh
+++ b/libchrome_tools/mojom_source_generator.sh
@@ -23,12 +23,13 @@ set -e
args=()
files=()
+includes=()
+gen_dirs=()
mojom_bindings_generator=""
package=""
output_dir=""
generators=""
-private_mojo_root="$(pwd)/external/libchrome"
# Given a path to directory or file, return the absolute path.
get_abs_path() {
@@ -62,7 +63,7 @@ for arg in "$@"; do
--typemap=*)
typemap="${arg#'--typemap='}"
typemap="$(get_abs_path ${typemap})"
- args=("${args[@]}" "--typemap=${typemap}")
+ args+=("--typemap=${typemap}")
;;
--bytecode_path=*)
bytecode_path="${arg#'--bytecode_path='}"
@@ -75,42 +76,61 @@ for arg in "$@"; do
srcjar="${arg#'--srcjar='}"
srcjar="$(get_abs_path ${srcjar})"
;;
+ -I=*)
+ includes+=("$(get_abs_path "${arg#'-I='}")")
+ ;;
--*)
- args=("${args[@]}" "${arg}")
+ args+=("${arg}")
;;
- *)
- files=("${files[@]}" "$(get_abs_path ${arg})")
+ *.mojom)
+ # Add all .mojom files directly as files.
+ files+=("$(get_abs_path ${arg})")
;;
+ *.p)
+ # Get the gen/ dir of any pickle (.p) file so that the bindings
+ # generator
+ # can get the correct path.
+ gen_dirs+=("$(get_abs_path "${arg}" | sed -e 's@/gen/.*$@/gen@')")
esac
done
-cd "${package}"
+# Add the current package as include path, and then rewrite all the include
+# paths so that the bindings generator can relativize the paths correctly.
+includes+=("$(pwd)/${package}")
+includes=($(printf -- "%q\n" "${includes[@]}" | sed -e 's/.*/-I=&:&/'))
+
+# Remove duplicates from the list of gen/ directories that contain the pickle
+# files.
+if [[ "${#gen_dirs[@]}" -ge 1 ]]; then
+ gen_dirs=($(printf -- "--gen_dir=%q\n" "${gen_dirs[@]}" | sort -u))
+fi
+
"${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
# already exists. So, we need to create the directory beforehand.
- rel_path="${file#`pwd`/}"
+ rel_path="${file#`pwd`/$package/}"
rel_dir="${rel_path%/*}"
mkdir -p "${output_dir}/${rel_dir}"
- # The calls to mojom_bindings_generator below uses -I option to include the
- # 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/libchrome.
"${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}"
+ "${gen_dirs[@]}" \
+ -d "${package}" \
+ "${includes[@]}" \
+ --generators="${generators}" "${file}"
if [[ "${generators}" =~ .*c\+\+.* ]] ; then
"${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} \
+ "${gen_dirs[@]}" \
+ -d "${package}" \
+ "${includes[@]}" \
+ --bytecode_path="${bytecode_path}" --generators="${generators}" \
"${file}"
fi
if [[ "${generators}" =~ .*java.* ]] ; then