Build1 and Build2
This commit is contained in:
@@ -174,6 +174,12 @@ RegisterVariable(Int, TrimTrailingWhitespace, 1);
|
||||
// Set at the beginning of the program to current directory
|
||||
RegisterVariable(String, ProjectDirectory, "");
|
||||
|
||||
// PLUGIN_BUILD_WINDOW
|
||||
RegisterVariable(String, Build1OnWindows, "build.bat");
|
||||
RegisterVariable(String, Build1OnUnix, "sh build.sh");
|
||||
RegisterVariable(String, Build2OnWindows, "build.bat release");
|
||||
RegisterVariable(String, Build2OnUnix, "sh build.sh release");
|
||||
|
||||
// PLUGIN_LOAD_VCVARS
|
||||
RegisterVariable(String, VCVarsPath, "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat");
|
||||
|
||||
|
||||
@@ -31,42 +31,37 @@ void LayoutBuildWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
||||
window->document_rect = window->total_rect = CutBottom(rect, barsize);
|
||||
}
|
||||
|
||||
BSet ExecBuild(String cmd, String working_dir = ProjectDirectory) {
|
||||
BSet ExecBuild(String windows_cmd, String unix_cmd, String working_dir = ProjectDirectory) {
|
||||
CMD_SaveAll();
|
||||
BSet build = GetBSet(BuildWindowID);
|
||||
BSet main = GetBSet(PrimaryWindowID);
|
||||
SelectRange(build.view, Range{});
|
||||
ResetBuffer(build.buffer);
|
||||
Exec(build.view->id, true, cmd, working_dir);
|
||||
if (OS_WINDOWS) {
|
||||
Exec(build.view->id, true, windows_cmd, working_dir);
|
||||
} else {
|
||||
Exec(build.view->id, true, unix_cmd, working_dir);
|
||||
}
|
||||
main.window->active_goto_list = build.view->id;
|
||||
main.window->goto_list_pos = 0;
|
||||
build.window->visible = true;
|
||||
return build;
|
||||
}
|
||||
|
||||
void CMD_Build() {
|
||||
CMD_SaveAll();
|
||||
#if OS_WINDOWS
|
||||
ExecBuild("build.bat");
|
||||
#else
|
||||
ExecBuild("sh build.sh");
|
||||
#endif
|
||||
BSet main = GetBSet(BuildWindowID);
|
||||
main.window->visible = true;
|
||||
} RegisterCommand(CMD_Build, "f1", "Run build.sh or build.bat in working directory, output is printed in a popup console and a special build buffer");
|
||||
void CMD_Build1() {
|
||||
ExecBuild(Build1OnWindows, Build1OnUnix);
|
||||
} RegisterCommand(CMD_Build1, "f1", "Run Build1OnWindows or OnUnix in working directory, output is printed in a popup console and a special build buffer");
|
||||
|
||||
void CMD_Build2() {
|
||||
ExecBuild(Build2OnWindows, Build2OnUnix);
|
||||
} RegisterCommand(CMD_Build2, "f2", "Run Build2OnWindows or OnUnix in working directory, output is printed in a popup console and a special build buffer");
|
||||
|
||||
void CMD_RunFile() {
|
||||
Scratch scratch;
|
||||
BSet primary = GetBSet(PrimaryWindowID);
|
||||
BSet build = GetBSet(BuildWindowID);
|
||||
SaveBuffer(primary.buffer);
|
||||
|
||||
if (OS_WINDOWS) {
|
||||
String cmd = Format(scratch, "cl %S -Fe:cfile.exe /Zi /FC /nologo /WX /W3 /wd4200 /wd4334 /diagnostics:column && cfile.exe && del cfile.*", primary.buffer->name);
|
||||
ExecBuild(cmd, GetDirectory(primary.buffer));
|
||||
} else {
|
||||
String cmd = Format(scratch, "bash <<EOF\nclang %S -o cfile.exe -g -Wall -Wno-missing-braces -Wno-writable-strings -Wno-writable-strings -fsanitize=address -fdiagnostics-absolute-paths -lm \n./cfile.exe \nrm cfile.exe\nEOF", primary.buffer->name);
|
||||
ExecBuild(cmd, GetDirectory(primary.buffer));
|
||||
}
|
||||
build.window->visible = true;
|
||||
String windows_command = Format(scratch, "cl %S -Fe:cfile.exe /Zi /FC /nologo /WX /W3 /wd4200 /wd4334 /diagnostics:column && cfile.exe && del cfile.*", primary.buffer->name);
|
||||
String unix_command = Format(scratch, "bash <<EOF\nclang %S -o cfile.exe -g -Wall -Wno-missing-braces -Wno-writable-strings -Wno-writable-strings -fsanitize=address -fdiagnostics-absolute-paths -lm \n./cfile.exe \nrm cfile.exe\nEOF", primary.buffer->name);
|
||||
ExecBuild(windows_command, unix_command, GetDirectory(primary.buffer));
|
||||
} RegisterCommand(CMD_RunFile, "", "Run and build current file, currently only C/C++ supported");
|
||||
|
||||
void CMD_ShowBuildWindow() {
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
WindowID CommandWindowID;
|
||||
|
||||
void CMD_ShowCommands() {
|
||||
// @todo: maybe redo this, similar behavior but use View stored information
|
||||
// if (ActiveWindowID == CommandWindowID && LastExecutedManualCommand == CMD_ShowCommands) {
|
||||
// NextActiveWindowID = PrimaryWindowID;
|
||||
// return;
|
||||
// }
|
||||
|
||||
BSet command_bar = GetBSet(CommandWindowID);
|
||||
command_bar.window->visible = true;
|
||||
NextActiveWindowID = command_bar.window->id;
|
||||
@@ -22,12 +16,6 @@ void CMD_ShowCommands() {
|
||||
} RegisterCommand(CMD_ShowCommands, "ctrl-shift-p", "List available commands and their documentation inside the command window");
|
||||
|
||||
void CMD_ShowDebugBufferList() {
|
||||
// @todo: maybe redo this, similar behavior but use View stored information
|
||||
// if (ActiveWindowID == CommandWindowID && LastExecutedManualCommand == CMD_ShowDebugBufferList) {
|
||||
// NextActiveWindowID = PrimaryWindowID;
|
||||
// return;
|
||||
// }
|
||||
|
||||
BSet command_bar = GetBSet(CommandWindowID);
|
||||
command_bar.window->visible = true;
|
||||
NextActiveWindowID = command_bar.window->id;
|
||||
@@ -47,11 +35,6 @@ void CMD_ShowDebugBufferList() {
|
||||
} RegisterCommand(CMD_ShowDebugBufferList, "ctrl-shift-alt-p", "Show full list of buffers, including the special ones that normally just clutter list");
|
||||
|
||||
void CMD_ShowBufferList() {
|
||||
// @todo: maybe redo this, similar behavior but use View stored information
|
||||
// if (ActiveWindowID == CommandWindowID && LastExecutedManualCommand == CMD_ShowBufferList) {
|
||||
// NextActiveWindowID = PrimaryWindowID;
|
||||
// return;
|
||||
// }
|
||||
BSet command_bar = GetBSet(CommandWindowID);
|
||||
command_bar.window->visible = true;
|
||||
NextActiveWindowID = command_bar.window->id;
|
||||
|
||||
Reference in New Issue
Block a user