Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add cp builtin to shell for Windows #10174

Merged
merged 55 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
e0eca4f
Initial impl
zackradisic Apr 10, 2024
da35efc
more stuff
zackradisic Apr 11, 2024
70f8b81
Make it work on windows
zackradisic Apr 11, 2024
2482924
Merge branch 'main' into zack/shell-cp
zackradisic Apr 11, 2024
0036299
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 11, 2024
03d5402
remove vtable
zackradisic Apr 11, 2024
692d42f
Merge branch 'main' into zack/shell-cp
zackradisic Apr 11, 2024
529e3fc
Add way to enable these on posix
Jarred-Sumner Apr 12, 2024
a0469d7
Merge branch 'main' into zack/shell-cp
Jarred-Sumner Apr 12, 2024
303ba67
Lint
Jarred-Sumner Apr 12, 2024
492b4fc
Make AsyncCpTask a comptime fn and have two variations
zackradisic Apr 15, 2024
f2373b9
clean up
zackradisic Apr 11, 2024
848ccad
Make mini work
zackradisic Apr 15, 2024
4a57456
Fix mini event loop crash and allow mini event loop to be tested in T…
zackradisic Apr 15, 2024
29213ba
[autofix.ci] apply automated fixes
autofix-ci[bot] Apr 15, 2024
d6b83cf
yoops
zackradisic Apr 15, 2024
5d4e3a3
make get runtime feature flag atomic
zackradisic Apr 15, 2024
0293ba5
fix tests
zackradisic Apr 15, 2024
14b725f
fix tests again
zackradisic Apr 15, 2024
4950554
fix tests again for real this time
zackradisic Apr 15, 2024
28390fd
Merge branch 'main' into zack/shell-cp
Jarred-Sumner Apr 16, 2024
c0daac0
Merge branch 'main' into zack/shell-cp
zackradisic Apr 16, 2024
52fecf9
Fix merge problems
zackradisic Apr 16, 2024
e4d505e
Merge branch 'main' into zack/shell-cp
zackradisic Apr 22, 2024
ba60d79
Merge branch 'main' into zack/shell-cp
Jarred-Sumner Apr 23, 2024
45b693c
Apply formatting changes
Jarred-Sumner Apr 23, 2024
7ce2e78
Merge branch 'main' into zack/shell-cp
zackradisic Apr 23, 2024
9dddc13
Merge branch 'main' into zack/shell-cp
Jarred-Sumner Apr 24, 2024
081e2aa
Fix EBUSY problem
zackradisic Apr 24, 2024
45a62c8
accidentally comitted some debug stuff
zackradisic Apr 24, 2024
f29b8f3
Apply formatting changes
zackradisic Apr 24, 2024
db7ed85
Merge branch 'main' into zack/shell-cp
zackradisic Apr 24, 2024
a6cc409
change `print` -> `debug`
zackradisic Apr 25, 2024
a7e5c8f
resolve comments
zackradisic Apr 25, 2024
72563fd
Apply formatting changes
zackradisic Apr 25, 2024
fe4e317
resolve some comments
zackradisic Apr 25, 2024
d4d59ca
Merge branch 'main' into zack/shell-cp
zackradisic Apr 25, 2024
b9fa0a4
woops
zackradisic Apr 25, 2024
d5f62c6
Apply formatting changes
zackradisic Apr 25, 2024
0b56f81
Fix
zackradisic Apr 25, 2024
eccd2ab
yoops
zackradisic Apr 25, 2024
b5c8a3a
remove debug stuff
zackradisic Apr 25, 2024
f842d69
deleted stuff by accident
zackradisic Apr 25, 2024
d5547ef
Apply formatting changes
zackradisic Apr 25, 2024
6ab458e
Fix hang
zackradisic Apr 26, 2024
d29b95d
Apply formatting changes
zackradisic Apr 26, 2024
4b59b0e
Merge branch 'main' into zack/shell-cp
zackradisic Apr 26, 2024
efeb53c
Merge branch 'main' into zack/shell-cp
zackradisic Apr 29, 2024
52d6ac0
Merge branch 'main' into zack/shell-cp
zackradisic Apr 29, 2024
26852b6
Merge branch 'main' into zack/shell-cp
zackradisic Apr 30, 2024
8d79986
Merge branch 'main' into zack/shell-cp
zackradisic May 1, 2024
c6fc84d
Merge branch 'main' into zack/shell-cp
zackradisic May 8, 2024
5974622
Fix lint
zackradisic May 8, 2024
36727bf
resolve comments
zackradisic May 8, 2024
ec8eabe
add comment
zackradisic May 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 44 additions & 6 deletions src/bun.js/event_loop.zig
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,14 @@ pub const AnyTaskWithExtraContext = struct {
callback: *const (fn (*anyopaque, *anyopaque) void) = undefined,
next: ?*AnyTaskWithExtraContext = null,

pub fn fromCallbackAutoDeinit(of: anytype, comptime callback: anytype) *AnyTaskWithExtraContext {
const TheTask = NewManaged(std.meta.Child(@TypeOf(of)), void, @field(std.meta.Child(@TypeOf(of)), callback));
const task = bun.default_allocator.create(AnyTaskWithExtraContext) catch bun.outOfMemory();
task.* = TheTask.init(of);
return task;
}

pub fn from(this: *@This(), of: anytype, comptime field: []const u8) *@This() {
// this.* = .{
// .ctx = of,
// .callback = @field(std.meta.Child(@TypeOf(of)), field),
// .next = null,
// };
// return this;
const TheTask = New(std.meta.Child(@TypeOf(of)), void, @field(std.meta.Child(@TypeOf(of)), field));
this.* = TheTask.init(of);
return this;
Expand Down Expand Up @@ -266,6 +267,30 @@ pub const AnyTaskWithExtraContext = struct {
}
};
}

pub fn NewManaged(comptime Type: type, comptime ContextType: type, comptime Callback: anytype) type {
return struct {
pub fn init(ctx: *Type) AnyTaskWithExtraContext {
return AnyTaskWithExtraContext{
.callback = wrap,
.ctx = ctx,
};
}

pub fn wrap(this: ?*anyopaque, extra: ?*anyopaque) void {
@call(
.always_inline,
Callback,
.{
@as(*Type, @ptrCast(@alignCast(this.?))),
@as(*ContextType, @ptrCast(@alignCast(extra.?))),
},
);
const anytask: *AnyTaskWithExtraContext = @fieldParentPtr(AnyTaskWithExtraContext, "ctx", @as(*?*anyopaque, @ptrCast(@alignCast(this.?))));
bun.default_allocator.destroy(anytask);
}
};
}
};

pub const CppTask = opaque {
Expand Down Expand Up @@ -363,6 +388,7 @@ const ShellMvCheckTargetTask = bun.shell.Interpreter.Builtin.Mv.ShellMvCheckTarg
const ShellMvBatchedTask = bun.shell.Interpreter.Builtin.Mv.ShellMvBatchedTask;
const ShellMkdirTask = bun.shell.Interpreter.Builtin.Mkdir.ShellMkdirTask;
const ShellTouchTask = bun.shell.Interpreter.Builtin.Touch.ShellTouchTask;
const ShellCpTask = bun.shell.Interpreter.Builtin.Cp.ShellCpTask;
const ShellCondExprStatTask = bun.shell.Interpreter.CondExpr.ShellCondExprStatTask;
const ShellAsync = bun.shell.Interpreter.Async;
// const ShellIOReaderAsyncDeinit = bun.shell.Interpreter.IOReader.AsyncDeinit;
Expand Down Expand Up @@ -443,6 +469,7 @@ pub const Task = TaggedPointerUnion(.{
ShellLsTask,
ShellMkdirTask,
ShellTouchTask,
ShellCpTask,
ShellCondExprStatTask,
ShellAsync,
ShellAsyncSubprocessDone,
Expand Down Expand Up @@ -918,6 +945,10 @@ pub const EventLoop = struct {
var shell_ls_task: *ShellCondExprStatTask = task.get(ShellCondExprStatTask).?;
shell_ls_task.task.runFromMainThread();
},
@field(Task.Tag, typeBaseName(@typeName(ShellCpTask))) => {
var shell_ls_task: *ShellCpTask = task.get(ShellCpTask).?;
shell_ls_task.runFromMainThread();
},
@field(Task.Tag, typeBaseName(@typeName(ShellTouchTask))) => {
var shell_ls_task: *ShellTouchTask = task.get(ShellTouchTask).?;
shell_ls_task.runFromMainThread();
Expand Down Expand Up @@ -2094,6 +2125,13 @@ pub const EventLoopHandle = union(enum) {
js: *JSC.EventLoop,
mini: *MiniEventLoop,

pub fn globalObject(this: EventLoopHandle) ?*JSC.JSGlobalObject {
return switch (this) {
.js => this.js.global,
.mini => null,
};
}

pub fn stdout(this: EventLoopHandle) *JSC.WebCore.Blob.Store {
return switch (this) {
.js => this.js.virtual_machine.rareData().stdout(),
Expand Down
Loading
Loading