| ... | ... | @@ -242,7 +242,7 @@ pub const Compilation = struct { |
| 242 | 242 | |
| 243 | 243 | c_int_types: [CInt.list.len]*Type.Int, |
| 244 | 244 | |
| 245 | | fs_watch: *fs.Watch(*Scope.Root), |
| 245 | // fs_watch: *fs.Watch(*Scope.Root), |
| 246 | 246 | |
| 247 | 247 | const IntTypeTable = std.HashMap(*const Type.Int.Key, *Type.Int, Type.Int.Key.hash, Type.Int.Key.eql); |
| 248 | 248 | const ArrayTypeTable = std.HashMap(*const Type.Array.Key, *Type.Array, Type.Array.Key.hash, Type.Array.Key.eql); |
| ... | ... | @@ -462,7 +462,7 @@ pub const Compilation = struct { |
| 462 | 462 | .have_err_ret_tracing = false, |
| 463 | 463 | .primitive_type_table = undefined, |
| 464 | 464 | |
| 465 | | .fs_watch = undefined, |
| 465 | // .fs_watch = undefined, |
| 466 | 466 | }; |
| 467 | 467 | comp.link_libs_list = ArrayList(*LinkLib).init(comp.arena()); |
| 468 | 468 | comp.primitive_type_table = TypeTable.init(comp.arena()); |
| ... | ... | @@ -531,8 +531,8 @@ pub const Compilation = struct { |
| 531 | 531 | comp.root_package = try Package.create(comp.arena(), ".", ""); |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | | comp.fs_watch = try fs.Watch(*Scope.Root).create(16); |
| 535 | | defer comp.fs_watch.destroy(); |
| 534 | // comp.fs_watch = try fs.Watch(*Scope.Root).create(16); |
| 535 | // defer comp.fs_watch.destroy(); |
| 536 | 536 | |
| 537 | 537 | try comp.initTypes(); |
| 538 | 538 | defer comp.primitive_type_table.deinit(); |
| ... | ... | @@ -791,46 +791,47 @@ pub const Compilation = struct { |
| 791 | 791 | self.events.put(Event{ .Error = err }); |
| 792 | 792 | } |
| 793 | 793 | |
| 794 | | // First, get an item from the watch channel, waiting on the channel. |
| 795 | | var group = event.Group(BuildError!void).init(self.gpa()); |
| 796 | | { |
| 797 | | const ev = (self.fs_watch.channel.get()) catch |err| { |
| 798 | | build_result = err; |
| 799 | | continue; |
| 800 | | }; |
| 801 | | const root_scope = ev.data; |
| 802 | | group.call(rebuildFile, self, root_scope) catch |err| { |
| 803 | | build_result = err; |
| 804 | | continue; |
| 805 | | }; |
| 806 | | } |
| 807 | | // Next, get all the items from the channel that are buffered up. |
| 808 | | while (self.fs_watch.channel.getOrNull()) |ev_or_err| { |
| 809 | | if (ev_or_err) |ev| { |
| 810 | | const root_scope = ev.data; |
| 811 | | group.call(rebuildFile, self, root_scope) catch |err| { |
| 812 | | build_result = err; |
| 813 | | continue; |
| 814 | | }; |
| 815 | | } else |err| { |
| 816 | | build_result = err; |
| 817 | | continue; |
| 818 | | } |
| 819 | | } |
| 820 | | build_result = group.wait(); |
| 794 | // // First, get an item from the watch channel, waiting on the channel. |
| 795 | // var group = event.Group(BuildError!void).init(self.gpa()); |
| 796 | // { |
| 797 | // const ev = (self.fs_watch.channel.get()) catch |err| { |
| 798 | // build_result = err; |
| 799 | // continue; |
| 800 | // }; |
| 801 | // const root_scope = ev.data; |
| 802 | // group.call(rebuildFile, self, root_scope) catch |err| { |
| 803 | // build_result = err; |
| 804 | // continue; |
| 805 | // }; |
| 806 | // } |
| 807 | // // Next, get all the items from the channel that are buffered up. |
| 808 | // while (self.fs_watch.channel.getOrNull()) |ev_or_err| { |
| 809 | // if (ev_or_err) |ev| { |
| 810 | // const root_scope = ev.data; |
| 811 | // group.call(rebuildFile, self, root_scope) catch |err| { |
| 812 | // build_result = err; |
| 813 | // continue; |
| 814 | // }; |
| 815 | // } else |err| { |
| 816 | // build_result = err; |
| 817 | // continue; |
| 818 | // } |
| 819 | // } |
| 820 | // build_result = group.wait(); |
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | 823 | |
| 824 | 824 | async fn rebuildFile(self: *Compilation, root_scope: *Scope.Root) !void { |
| 825 | 825 | const tree_scope = blk: { |
| 826 | | const source_code = fs.readFile( |
| 827 | | root_scope.realpath, |
| 828 | | max_src_size, |
| 829 | | ) catch |err| { |
| 830 | | try self.addCompileErrorCli(root_scope.realpath, "unable to open: {}", @errorName(err)); |
| 831 | | return; |
| 832 | | }; |
| 833 | | errdefer self.gpa().free(source_code); |
| 826 | const source_code = ""; |
| 827 | // const source_code = fs.readFile( |
| 828 | // root_scope.realpath, |
| 829 | // max_src_size, |
| 830 | // ) catch |err| { |
| 831 | // try self.addCompileErrorCli(root_scope.realpath, "unable to open: {}", @errorName(err)); |
| 832 | // return; |
| 833 | // }; |
| 834 | // errdefer self.gpa().free(source_code); |
| 834 | 835 | |
| 835 | 836 | const tree = try std.zig.parse(self.gpa(), source_code); |
| 836 | 837 | errdefer { |
| ... | ... | @@ -972,7 +973,7 @@ pub const Compilation = struct { |
| 972 | 973 | }; |
| 973 | 974 | defer root_scope.base.deref(self); |
| 974 | 975 | |
| 975 | | assert((try self.fs_watch.addFile(root_scope.realpath, root_scope)) == null); |
| 976 | // assert((try self.fs_watch.addFile(root_scope.realpath, root_scope)) == null); |
| 976 | 977 | try self.rebuildFile(root_scope); |
| 977 | 978 | } |
| 978 | 979 | } |