Commit 8b45921664

Andrew Kelley <andrew@ziglang.org>
2019-10-11 23:21:13
merge targets of generated docs
1 parent 30a555e
Changed files (3)
lib
std
special
docs
src
tools
lib/std/special/docs/main.js
@@ -305,7 +305,7 @@
 
     function renderInfo() {
         domTdZigVer.textContent = zigAnalysis.params.zigVersion;
-        domTdTarget.textContent = zigAnalysis.params.target;
+        domTdTarget.textContent = zigAnalysis.params.builds[0].target;
 
         domSectInfo.classList.remove("hidden");
     }
src/dump_analysis.cpp
@@ -1207,10 +1207,16 @@ void zig_print_analysis_dump(CodeGen *g, FILE *f, const char *one_indent, const
         jw_object_field(jw, "zigVersion");
         jw_string(jw, ZIG_VERSION_STRING);
 
+        jw_object_field(jw, "builds");
+        jw_begin_array(jw);
+        jw_array_elem(jw);
+        jw_begin_object(jw);
         jw_object_field(jw, "target");
         Buf triple_buf = BUF_INIT;
         target_triple_zig(&triple_buf, g->zig_target);
         jw_string(jw, buf_ptr(&triple_buf));
+        jw_end_object(jw);
+        jw_end_array(jw);
 
         jw_object_field(jw, "rootName");
         jw_string(jw, buf_ptr(g->root_out_name));
tools/merge_anal_dumps.zig
@@ -79,10 +79,12 @@ const Dump = struct {
         try mergeSameStrings(&self.zig_version, zig_version);
         try mergeSameStrings(&self.root_name, root_name);
 
-        const target = params.get("target").?.value.String;
-        try self.targets.append(target);
+        for (params.get("builds").?.value.Array.toSliceConst()) |json_build| {
+            const target = json_build.Object.get("target").?.value.String;
+            try self.targets.append(target);
+        }
 
-        // Merge files
+        // Merge files. If the string matches, it's the same file.
         const other_files = root.Object.get("files").?.value.Array.toSliceConst();
         var other_file_to_mine = std.AutoHashMap(usize, usize).init(self.a());
         for (other_files) |other_file, i| {
@@ -94,7 +96,7 @@ const Dump = struct {
             try other_file_to_mine.putNoClobber(i, gop.kv.value);
         }
 
-        // Merge ast nodes
+        // Merge AST nodes. If the file id, line, and column all match, it's the same AST node.
         const other_ast_nodes = root.Object.get("astNodes").?.value.Array.toSliceConst();
         var other_ast_node_to_mine = std.AutoHashMap(usize, usize).init(self.a());
         for (other_ast_nodes) |other_ast_node_json, i| {
@@ -125,6 +127,8 @@ const Dump = struct {
                 }
             }
         }
+
+        // Merge errors. If the AST Node matches, it's the same error value.
     }
 
     fn render(self: *Dump, stream: var) !void {
@@ -139,6 +143,31 @@ const Dump = struct {
         }
         try jw.endArray();
 
+        try jw.objectField("params");
+        try jw.beginObject();
+
+        try jw.objectField("zigId");
+        try jw.emitString(self.zig_id.?);
+
+        try jw.objectField("zigVersion");
+        try jw.emitString(self.zig_version.?);
+
+        try jw.objectField("rootName");
+        try jw.emitString(self.root_name.?);
+
+        try jw.objectField("builds");
+        try jw.beginArray();
+        for (self.targets.toSliceConst()) |target| {
+            try jw.arrayElem();
+            try jw.beginObject();
+            try jw.objectField("target");
+            try jw.emitString(target);
+            try jw.endObject();
+        }
+        try jw.endArray();
+
+        try jw.endObject();
+
         try jw.objectField("astNodes");
         try jw.beginArray();
         for (self.node_list.toSliceConst()) |node| {