gn2bp: simplify --proto-in-dir by hardcoding tree path

The tree path will not change very frequently (ever?), so it is okay to
hardcode it.

Test: //net:net
Change-Id: I3bb008c7cf8a5b9cb8e6f4a5df51f56d75cea107
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 5d9da5e..c2960c5 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -2029,7 +2029,7 @@
          "--protoc " +
          "$(location aprotoc) " +
          "--proto-in-dir " +
-         "`dirname $(location net/cert/root_store.proto)` " +
+         "external/chromium_org/net/cert " +
          "--cc-out-dir " +
          "$(genDir) " +
          " " +
@@ -2055,7 +2055,7 @@
          "--protoc " +
          "$(location aprotoc) " +
          "--proto-in-dir " +
-         "`dirname $(location net/cert/root_store.proto)` " +
+         "external/chromium_org/net/cert " +
          "--cc-out-dir " +
          "$(genDir) " +
          " " +
@@ -2269,7 +2269,7 @@
          "--protoc " +
          "$(location aprotoc) " +
          "--proto-in-dir " +
-         "`dirname $(location net/base/isolation_info.proto)` " +
+         "external/chromium_org/net/base " +
          "--cc-out-dir " +
          "$(genDir) " +
          " " +
@@ -2295,7 +2295,7 @@
          "--protoc " +
          "$(location aprotoc) " +
          "--proto-in-dir " +
-         "`dirname $(location net/base/isolation_info.proto)` " +
+         "external/chromium_org/net/base " +
          "--cc-out-dir " +
          "$(genDir) " +
          " " +
@@ -3082,7 +3082,7 @@
          "--protoc " +
          "$(location aprotoc) " +
          "--proto-in-dir " +
-         "`dirname $(location net/nqe/proto/network_id_proto.proto)` " +
+         "external/chromium_org/net/nqe/proto " +
          "--cc-out-dir " +
          "$(genDir) " +
          "--cc-options " +
@@ -3114,7 +3114,7 @@
          "--protoc " +
          "$(location aprotoc) " +
          "--proto-in-dir " +
-         "`dirname $(location net/nqe/proto/network_id_proto.proto)` " +
+         "external/chromium_org/net/nqe/proto " +
          "--cc-out-dir " +
          "$(genDir) " +
          "--cc-options " +
@@ -3345,7 +3345,7 @@
          "--protoc " +
          "$(location aprotoc) " +
          "--proto-in-dir " +
-         "`dirname $(location net/third_party/quiche/src/quiche/quic/core/proto/cached_network_parameters.proto)`/../../../../ " +
+         "external/chromium_org/net/third_party/quiche/src " +
          "--cc-out-dir " +
          "$(genDir) " +
          "--cc-options " +
@@ -3383,7 +3383,7 @@
          "--protoc " +
          "$(location aprotoc) " +
          "--proto-in-dir " +
-         "`dirname $(location net/third_party/quiche/src/quiche/quic/core/proto/cached_network_parameters.proto)`/../../../../ " +
+         "external/chromium_org/net/third_party/quiche/src " +
          "--cc-out-dir " +
          "$(genDir) " +
          "--cc-options " +
@@ -3472,7 +3472,7 @@
          "--protoc " +
          "$(location aprotoc) " +
          "--proto-in-dir " +
-         "`dirname $(location net/third_party/quiche/src/quiche/quic/test_tools/send_algorithm_test_result.proto)` " +
+         "external/chromium_org/net/third_party/quiche/src/quiche/quic/test_tools " +
          "--cc-out-dir " +
          "$(genDir) " +
          "--cc-options " +
@@ -3504,7 +3504,7 @@
          "--protoc " +
          "$(location aprotoc) " +
          "--proto-in-dir " +
-         "`dirname $(location net/third_party/quiche/src/quiche/quic/test_tools/send_algorithm_test_result.proto)` " +
+         "external/chromium_org/net/third_party/quiche/src/quiche/quic/test_tools " +
          "--cc-out-dir " +
          "$(genDir) " +
          "--cc-options " +
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 7c85f2d..67940af 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -89,7 +89,7 @@
 defaults_module = module_prefix + 'defaults'
 
 # Location of the project in the Android source tree.
-tree_path = 'external/perfetto'
+tree_path = 'external/chromium_org'
 
 # Path for the protobuf sources in the standalone build.
 buildtools_protobuf_src = '//buildtools/protobuf/src'
@@ -895,14 +895,11 @@
       if val == '--protoc':
         target.args[i + 1] = '$(location aprotoc)'
       elif val == '--proto-in-dir':
-        # Proto files in the cmd is relative path from --proto-in-dir
-        # Proto files are specified as filenames without directory except net_quic_proto_gen
-        # So getting directory from source file
-        proto_file = gn_utils.label_to_path(sorted(list(target.sources))[0])
-        target.args[i + 1] = '`dirname $(location %s)`' % proto_file
-        # Adjusting path for net_quic_proto_gen
-        if target.name == "//net/third_party/quiche:net_quic_proto_gen":
-          target.args[i + 1] += '/../../../../'
+        # --proto-in-dir is a relative directory from Android croot.
+        # TODO: deleting the leading ../../ is a very common operation -- put
+        # it in a function.
+        proto_path = re.sub('^\.\./\.\./', '', target.args[i + 1])
+        target.args[i + 1] = tree_path + '/' + proto_path
       elif val == '--cc-out-dir':
         target.args[i + 1] = '$(genDir)'
       elif val == 'dllexport_decl':