vndk-def: Print source directory in deps-insight

With this commit, deps-insight will be able to print the module source
directory if `--module-info` is specified.

Bug: 62898574
Test: ./vndk_definition_tool.py deps-insight --module-info ...

Change-Id: Ib4741071c759e37bed24aeee4c318b3269faa450
Merged-In: I0934d51912c69df8200aca7ea548395b9425f497
(cherry picked from commit 0ccb0bc0652f7e4c70139f68100d69b99bba194f)
diff --git a/vndk/tools/definition-tool/assets/insight/insight-data.js b/vndk/tools/definition-tool/assets/insight/insight-data.js
index 9ef7a65..65bec05 100644
--- a/vndk/tools/definition-tool/assets/insight/insight-data.js
+++ b/vndk/tools/definition-tool/assets/insight/insight-data.js
@@ -8,14 +8,17 @@
         '/system/lib64/libdl.so',
         'll-ndk',
         'hl-ndk',
+        'bionic/libc',
+        'bionic/libm',
+        'bionic/libdl',
     ];
     var mods = [
-        [0, 32, [6], [[1, 2]], []],
-        [1, 32, [6], [], [0]],
-        [2, 32, [6], [], [0]],
-        [3, 64, [6], [[5], [4]], []],
-        [4, 64, [7], [[5]], [3]],
-        [5, 64, [7], [], [3, 4]],
+        [0, 32, [6], [[1, 2]], [], [8]],
+        [1, 32, [6], [], [0], [9]],
+        [2, 32, [6], [], [0], [10]],
+        [3, 64, [6], [[5], [4]], [], [8]],
+        [4, 64, [7], [[5]], [3], [9]],
+        [5, 64, [7], [], [3, 4], [9, 10]],
     ];
     insight.init(document, strs, mods);
 })();
diff --git a/vndk/tools/definition-tool/assets/insight/insight.css b/vndk/tools/definition-tool/assets/insight/insight.css
index 7cff186..1c5f709 100644
--- a/vndk/tools/definition-tool/assets/insight/insight.css
+++ b/vndk/tools/definition-tool/assets/insight/insight.css
@@ -101,3 +101,9 @@
 	background-color: #fffff0;
 	transition: background-color 800ms ease;
 }
+
+#module_tbody p.module_src_dir {
+	font-family: monospace;
+	font-size: 80%;
+	color: #aaaaaa;
+}
diff --git a/vndk/tools/definition-tool/assets/insight/insight.js b/vndk/tools/definition-tool/assets/insight/insight.js
index 5e08207..cd199a8 100644
--- a/vndk/tools/definition-tool/assets/insight/insight.js
+++ b/vndk/tools/definition-tool/assets/insight/insight.js
@@ -62,6 +62,7 @@
         this.tagIds = new Set(modData[2]);
         this.deps = modData[3];
         this.users = modData[4];
+        this.srcDirs = modData[5].map(function (x) { return strsData[x]; });
 
         [this.numDirectDeps, this.numIndirectDeps] = countDeps(this.deps);
         this.numUsers = this.users.length;
@@ -103,7 +104,14 @@
     }
 
     Module.prototype.createModulePathTdDom = function (parent) {
-        parent.appendChild(domNewElem('td', this.createModuleLinkDom(this)));
+        let domTd = domNewElem('td');
+        domTd.appendChild(domNewElem('p', this.createModuleLinkDom(this)));
+        for (let dir of this.srcDirs) {
+            let domP = domNewElem('p', 'source: ' + dir);
+            domP.setAttribute('class', 'module_src_dir');
+            domTd.appendChild(domP);
+        }
+        parent.appendChild(domTd);
     }
 
     Module.prototype.createTagsTdDom = function (parent) {
diff --git a/vndk/tools/definition-tool/vndk_definition_tool.py b/vndk/tools/definition-tool/vndk_definition_tool.py
index f6193c7..05dc20d 100755
--- a/vndk/tools/definition-tool/vndk_definition_tool.py
+++ b/vndk/tools/definition-tool/vndk_definition_tool.py
@@ -2103,12 +2103,16 @@
     def add_argparser_options(self, parser):
         super(DepsInsightCommand, self).add_argparser_options(parser)
 
+        parser.add_argument('--module-info')
+
         parser.add_argument(
                 '--output', '-o', help='output directory')
 
     def main(self, args):
         generic_refs, graph, tagged_paths = self.create_from_args(args)
 
+        module_info = ModuleInfo.load_from_path_or_default(args.module_info)
+
         # Compute vndk heuristics.
         vndk_lib = graph.compute_degenerated_vndk(
                 generic_refs, tagged_paths, args.action_ineligible_vndk_sp,
@@ -2157,6 +2161,10 @@
 
             return deps
 
+        def collect_source_dir_paths(lib):
+            return [get_str_idx(path)
+                    for path in module_info.get_module_path(lib.path)]
+
         def collect_tags(lib):
             tags = []
             for field_name in _VNDK_RESULT_FIELD_NAMES:
@@ -2170,7 +2178,8 @@
                          32 if lib.elf.is_32bit else 64,
                          collect_tags(lib),
                          collect_deps(lib),
-                         collect_path_sorted_lib_idxs(lib.users)])
+                         collect_path_sorted_lib_idxs(lib.users),
+                         collect_source_dir_paths(lib)])
 
         # Generate output files.
         makedirs(args.output, exist_ok=True)