| ... | ... | @@ -4827,13 +4827,10 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 4827 | 4827 | .root = .{ .root_dir = build_root }, |
| 4828 | 4828 | .root_src_path = build_zig_basename, |
| 4829 | 4829 | }; |
| 4830 | var dependencies_zig_src = std.ArrayList(u8).init(gpa); |
| 4831 | defer dependencies_zig_src.deinit(); |
| 4830 | 4832 | if (build_options.only_core_functionality) { |
| 4831 | | const deps_mod = try Package.createFilePkg(gpa, local_cache_directory, "dependencies.zig", |
| 4832 | | \\pub const packages = struct {}; |
| 4833 | | \\pub const root_deps: []const struct { []const u8, []const u8 } = &.{}; |
| 4834 | | \\ |
| 4835 | | ); |
| 4836 | | try main_mod.deps.put(arena, "@dependencies", deps_mod); |
| 4833 | try Package.Fetch.createEmptyDependenciesModule(&dependencies_zig_src); |
| 4837 | 4834 | } else { |
| 4838 | 4835 | var http_client: std.http.Client = .{ .allocator = gpa }; |
| 4839 | 4836 | defer http_client.deinit(); |
| ... | ... | @@ -4887,19 +4884,39 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi |
| 4887 | 4884 | process.exit(1); |
| 4888 | 4885 | } |
| 4889 | 4886 | |
| 4890 | | var buf = std.ArrayList(u8).init(gpa); |
| 4891 | | defer buf.deinit(); |
| 4892 | | try job_queue.createDependenciesModule(&buf); |
| 4893 | | if (true) { |
| 4894 | | std.debug.print("dependencies source:\n\n{s}\n", .{buf.items}); |
| 4895 | | @panic("TODO"); |
| 4887 | try job_queue.createDependenciesModule(&dependencies_zig_src); |
| 4888 | } |
| 4889 | { |
| 4890 | // Atomically create the file in a directory named after the hash of its contents. |
| 4891 | const basename = "dependencies.zig"; |
| 4892 | const rand_int = std.crypto.random.int(u64); |
| 4893 | const tmp_dir_sub_path = "tmp" ++ fs.path.sep_str ++ Package.Manifest.hex64(rand_int); |
| 4894 | { |
| 4895 | var tmp_dir = try local_cache_directory.handle.makeOpenPath(tmp_dir_sub_path, .{}); |
| 4896 | defer tmp_dir.close(); |
| 4897 | try tmp_dir.writeFile(basename, dependencies_zig_src.items); |
| 4896 | 4898 | } |
| 4897 | | //const deps_mod = try job_queue.createDependenciesModule( |
| 4898 | | // arena, |
| 4899 | | // local_cache_directory, |
| 4900 | | // "dependencies.zig", |
| 4901 | | //); |
| 4902 | | //try main_mod.deps.put(arena, "@dependencies", deps_mod); |
| 4899 | |
| 4900 | var hh: Cache.HashHelper = .{}; |
| 4901 | hh.addBytes(build_options.version); |
| 4902 | hh.addBytes(dependencies_zig_src.items); |
| 4903 | const hex_digest = hh.final(); |
| 4904 | |
| 4905 | const o_dir_sub_path = try arena.dupe(u8, "o" ++ fs.path.sep_str ++ hex_digest); |
| 4906 | try Package.Fetch.renameTmpIntoCache( |
| 4907 | local_cache_directory.handle, |
| 4908 | tmp_dir_sub_path, |
| 4909 | o_dir_sub_path, |
| 4910 | ); |
| 4911 | |
| 4912 | const deps_mod = try Package.Module.create(arena, .{ |
| 4913 | .root = .{ |
| 4914 | .root_dir = local_cache_directory, |
| 4915 | .sub_path = o_dir_sub_path, |
| 4916 | }, |
| 4917 | .root_src_path = basename, |
| 4918 | }); |
| 4919 | try main_mod.deps.put(arena, "@dependencies", deps_mod); |
| 4903 | 4920 | } |
| 4904 | 4921 | try main_mod.deps.put(arena, "@build", &build_mod); |
| 4905 | 4922 | |