just kernel32 things (#4354)

* just kernel32 things

* more

* Update linux_c.zig

* Update windows_c.zig

* Add workaround

Workaround https://github.com/ziglang/zig/issues/16980

* Rename http.zig to bun_dev_http_server.zig

* Rename usages

* more

* more

* more

* thanks tigerbeetle

* Rename `JSC.Node.Syscall` -> `bun.sys`

* more

* woops

* more!

* hmm

* it says there are only 37 errors, but that's not true

* populate argv

* it says 32 errors!

* 24 errors

* fix regular build

* 12 left!

* Still 12 left!

* more

* 2 errors left...

* 1 more error

* Add link to Tigerbeetle

* Fix the remainign error

* Fix test timeout

* Update syscall.zig

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
Jarred Sumner
2023-08-28 04:39:16 -07:00
committed by GitHub
parent efe987e8d1
commit e2a17344dc
92 changed files with 9360 additions and 1358 deletions

View File

@@ -554,7 +554,7 @@ pub const CreateCommand = struct {
progress.refresh();
package_json_contents = plucker.contents;
package_json_file = std.fs.File{ .handle = plucker.fd };
package_json_file = std.fs.File{ .handle = bun.fdcast(plucker.fd) };
}
}
},
@@ -615,9 +615,13 @@ pub const CreateCommand = struct {
var infile = try entry.dir.dir.openFile(entry.basename, .{ .mode = .read_only });
defer infile.close();
// Assumption: you only really care about making sure something that was executable is still executable
const stat = infile.stat() catch continue;
_ = C.fchmod(outfile.handle, stat.mode);
if (comptime Environment.isPosix) {
// Assumption: you only really care about making sure something that was executable is still executable
const stat = infile.stat() catch continue;
_ = C.fchmod(outfile.handle, stat.mode);
} else {
bun.todo(@src(), void{});
}
CopyFile.copyFile(infile.handle, outfile.handle) catch |err| {
Output.prettyErrorln("<r><red>{s}<r>: copying file {s}", .{ @errorName(err), entry.path });
@@ -633,24 +637,33 @@ pub const CreateCommand = struct {
read_package_json: {
if (package_json_file) |pkg| {
const stat = pkg.stat() catch |err| {
node.end();
const size = brk: {
if (comptime Environment.isWindows) {
break :brk try pkg.getEndPos();
}
progress.refresh();
const stat = pkg.stat() catch |err| {
node.end();
package_json_file = null;
Output.prettyErrorln("Error reading package.json: <r><red>{s}", .{@errorName(err)});
break :read_package_json;
progress.refresh();
package_json_file = null;
Output.prettyErrorln("Error reading package.json: <r><red>{s}", .{@errorName(err)});
break :read_package_json;
};
if (stat.kind != .file or stat.size == 0) {
package_json_file = null;
node.end();
progress.refresh();
break :read_package_json;
}
break :brk stat.size;
};
if (stat.kind != .file or stat.size == 0) {
package_json_file = null;
node.end();
progress.refresh();
break :read_package_json;
}
package_json_contents = try MutableString.init(ctx.allocator, stat.size);
package_json_contents = try MutableString.init(ctx.allocator, size);
package_json_contents.list.expandToCapacity();
_ = pkg.preadAll(package_json_contents.list.items, 0) catch |err| {
@@ -1717,36 +1730,36 @@ pub const Example = struct {
{
var folders = [3]std.fs.IterableDir{
.{
.dir = .{ .fd = 0 },
.dir = .{ .fd = bun.fdcast(bun.invalid_fd) },
},
.{
.dir = .{ .fd = 0 },
.dir = .{ .fd = bun.fdcast(bun.invalid_fd) },
},
.{ .dir = .{ .fd = 0 } },
.{ .dir = .{ .fd = bun.fdcast(bun.invalid_fd) } },
};
if (env_loader.map.get("BUN_CREATE_DIR")) |home_dir| {
var parts = [_]string{home_dir};
var outdir_path = filesystem.absBuf(&parts, &home_dir_buf);
folders[0] = std.fs.cwd().openIterableDir(outdir_path, .{}) catch .{ .dir = .{ .fd = 0 } };
folders[0] = std.fs.cwd().openIterableDir(outdir_path, .{}) catch .{ .dir = .{ .fd = bun.fdcast(bun.invalid_fd) } };
}
{
var parts = [_]string{ filesystem.top_level_dir, BUN_CREATE_DIR };
var outdir_path = filesystem.absBuf(&parts, &home_dir_buf);
folders[1] = std.fs.cwd().openIterableDir(outdir_path, .{}) catch .{ .dir = .{ .fd = 0 } };
folders[1] = std.fs.cwd().openIterableDir(outdir_path, .{}) catch .{ .dir = .{ .fd = bun.fdcast(bun.invalid_fd) } };
}
if (env_loader.map.get("HOME")) |home_dir| {
var parts = [_]string{ home_dir, BUN_CREATE_DIR };
var outdir_path = filesystem.absBuf(&parts, &home_dir_buf);
folders[2] = std.fs.cwd().openIterableDir(outdir_path, .{}) catch .{ .dir = .{ .fd = 0 } };
folders[2] = std.fs.cwd().openIterableDir(outdir_path, .{}) catch .{ .dir = .{ .fd = bun.fdcast(bun.invalid_fd) } };
}
// subfolders with package.json
for (folders) |folder__| {
const folder_ = folder__.dir;
if (folder_.fd != 0) {
if (folder_.fd != bun.fdcast(bun.invalid_fd)) {
const folder: std.fs.Dir = folder_;
var iter = (std.fs.IterableDir{ .dir = folder }).iterate();