new project maker works now
This commit is contained in:
parent
d1dd4961a5
commit
39ad2ffd70
|
|
@ -22,6 +22,7 @@ pub const SubprocessTask = struct {
|
||||||
success: bool = false,
|
success: bool = false,
|
||||||
|
|
||||||
workingDir: ?[]const u8 = null,
|
workingDir: ?[]const u8 = null,
|
||||||
|
|
||||||
stdout: std.ArrayListUnmanaged(u8) = .{},
|
stdout: std.ArrayListUnmanaged(u8) = .{},
|
||||||
stderr: std.ArrayListUnmanaged(u8) = .{},
|
stderr: std.ArrayListUnmanaged(u8) = .{},
|
||||||
|
|
||||||
|
|
@ -32,10 +33,12 @@ pub const SubprocessTask = struct {
|
||||||
pub fn func(ctx: @This(), _: *core.JobContext) void {
|
pub fn func(ctx: @This(), _: *core.JobContext) void {
|
||||||
const self = ctx.self;
|
const self = ctx.self;
|
||||||
self.mutex.lock();
|
self.mutex.lock();
|
||||||
|
self.stderr = .{};
|
||||||
|
self.stdout = .{};
|
||||||
debugPrint("running task", .{});
|
debugPrint("running task", .{});
|
||||||
self.child = std.process.Child.init(self.args, self.allocator);
|
self.child = std.process.Child.init(self.args, self.allocator);
|
||||||
self.child.?.stdout_behavior = .Pipe;
|
self.child.?.stdout_behavior = .Inherit;
|
||||||
self.child.?.stderr_behavior = .Pipe;
|
self.child.?.stderr_behavior = .Inherit;
|
||||||
self.child.?.cwd = self.workingDir;
|
self.child.?.cwd = self.workingDir;
|
||||||
|
|
||||||
_ = self.child.?.spawn() catch {};
|
_ = self.child.?.spawn() catch {};
|
||||||
|
|
@ -91,7 +94,7 @@ pub const SubprocessTask = struct {
|
||||||
pub fn waitInner(self: *@This()) !void {
|
pub fn waitInner(self: *@This()) !void {
|
||||||
self.mutex.lock();
|
self.mutex.lock();
|
||||||
if (self.child.?.stdout_behavior == .Pipe) {
|
if (self.child.?.stdout_behavior == .Pipe) {
|
||||||
try self.child.?.collectOutput(self.allocator, &self.stdout, &self.stderr, 150 * 1024 * 1024);
|
try self.child.?.collectOutput(self.allocator, &self.stdout, &self.stderr, 1 * 1024 * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint("task completed stdout: {s}", .{self.stdout.items});
|
debugPrint("task completed stdout: {s}", .{self.stdout.items});
|
||||||
|
|
|
||||||
|
|
@ -195,26 +195,10 @@ pub fn createProject(self: *@This(), targetDir: []const u8) !void {
|
||||||
targetDir,
|
targetDir,
|
||||||
) });
|
) });
|
||||||
|
|
||||||
try self.commandQueue.pushLocked(.{ .func = fingerprintGeneratePostbuild });
|
|
||||||
try self.commandQueue.pushLocked(.{ .func = copyShaders });
|
try self.commandQueue.pushLocked(.{ .func = copyShaders });
|
||||||
try self.commandQueue.pushLocked(.{ .func = displayInstructions });
|
try self.commandQueue.pushLocked(.{ .func = displayInstructions });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fingerprintGeneratePostbuild(self: *@This()) void {
|
|
||||||
const task = sys.runCommand(
|
|
||||||
self.allocator,
|
|
||||||
&.{ "zig", "build", "install" },
|
|
||||||
self.targetDir.?,
|
|
||||||
) catch return;
|
|
||||||
defer task.destroy();
|
|
||||||
|
|
||||||
task.wait();
|
|
||||||
|
|
||||||
task.mutex.lock();
|
|
||||||
core.engine_log("task stdout: {s}", .{task.stdout.items});
|
|
||||||
task.mutex.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn copyShaders(self: *@This()) void {
|
fn copyShaders(self: *@This()) void {
|
||||||
self.copyShadersWrap() catch {};
|
self.copyShadersWrap() catch {};
|
||||||
}
|
}
|
||||||
|
|
@ -239,7 +223,7 @@ fn loadFileAllocFromCwd(allocator: std.mem.Allocator, dir: std.fs.Dir, path: []c
|
||||||
var file = try dir.openFile(path, .{});
|
var file = try dir.openFile(path, .{});
|
||||||
defer file.close();
|
defer file.close();
|
||||||
const filesize = (try file.stat()).size + 1; // add null byte
|
const filesize = (try file.stat()).size + 1; // add null byte
|
||||||
const buffer: []u8 = try allocator.alignedAlloc(u8, 8, filesize);
|
const buffer: []u8 = try allocator.alloc(u8, filesize);
|
||||||
errdefer allocator.free(buffer);
|
errdefer allocator.free(buffer);
|
||||||
try file.reader().readNoEof(buffer[0 .. buffer.len - 1]);
|
try file.reader().readNoEof(buffer[0 .. buffer.len - 1]);
|
||||||
buffer[buffer.len - 1] = 0;
|
buffer[buffer.len - 1] = 0;
|
||||||
|
|
@ -261,6 +245,7 @@ fn updateBuildZig(self: *@This()) void {
|
||||||
|
|
||||||
const buildZigContents = loadFileAllocFromCwd(self.allocator, workingDir, buildZigZonPath) catch return;
|
const buildZigContents = loadFileAllocFromCwd(self.allocator, workingDir, buildZigZonPath) catch return;
|
||||||
defer self.allocator.free(buildZigContents);
|
defer self.allocator.free(buildZigContents);
|
||||||
|
core.engine_log("{s}", .{buildZigContents});
|
||||||
|
|
||||||
// walk forward until we find the fingerprint value
|
// walk forward until we find the fingerprint value
|
||||||
var window: []const u8 = buildZigContents[0..];
|
var window: []const u8 = buildZigContents[0..];
|
||||||
|
|
@ -370,11 +355,11 @@ fn writeBuildZigZon(self: *@This(), workingDir: *std.fs.Dir) !void {
|
||||||
try writer.print(".{{\n", .{});
|
try writer.print(".{{\n", .{});
|
||||||
|
|
||||||
try writer.print(
|
try writer.print(
|
||||||
\\ .name = .MyProjects,
|
\\ .name = .{s},
|
||||||
\\ .version = "0.0.0",
|
\\ .version = "0.0.0",
|
||||||
\\ .dependencies = .{{
|
\\ .dependencies = .{{
|
||||||
\\ .Backlog = .{{ .path = "{s}" }},
|
\\ .Backlog = .{{ .path = "{s}" }},
|
||||||
, .{self.engineRelative.?});
|
, .{ std.fs.path.basename(self.targetDir.?), self.engineRelative.? });
|
||||||
|
|
||||||
for (entries) |entry| {
|
for (entries) |entry| {
|
||||||
try writer.print(" .{s} = .{{ .path = \"{s}/{s}\" }},\n", .{ entry.name, self.engineRelative.?, entry.path });
|
try writer.print(" .{s} = .{{ .path = \"{s}/{s}\" }},\n", .{ entry.name, self.engineRelative.?, entry.path });
|
||||||
|
|
@ -478,8 +463,8 @@ fn updateFingerPrint(self: *@This(), zonEntry: []const u8) void {
|
||||||
var left: usize = 0;
|
var left: usize = 0;
|
||||||
while (zonEntry[left] != '0') : (left += 1) {}
|
while (zonEntry[left] != '0') : (left += 1) {}
|
||||||
|
|
||||||
core.engine_log(">> FINGERPRINT '{s}'", .{zonEntry[left .. zonEntry.len - 1]});
|
core.engine_log(">> FINGERPRINT '{s}'", .{zonEntry[left..zonEntry.len]});
|
||||||
self.fingerprint = zonEntry[left .. zonEntry.len - 1];
|
self.fingerprint = zonEntry[left..zonEntry.len];
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn onFolderSelected(
|
pub fn onFolderSelected(
|
||||||
|
|
@ -523,7 +508,7 @@ fn copyRecursiveDir(
|
||||||
|
|
||||||
pub fn main() anyerror!void {
|
pub fn main() anyerror!void {
|
||||||
var spec = try api.getSpec("New Project Dialogue");
|
var spec = try api.getSpec("New Project Dialogue");
|
||||||
// try spec.put("useGPA", .{ .boolean = false });
|
try spec.put("useGPA", .{ .boolean = false });
|
||||||
_ = api.startEngine(&NeonObjectTable, &spec);
|
_ = api.startEngine(&NeonObjectTable, &spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue