CMD_RunFile
This commit is contained in:
3
build.sh
3
build.sh
@@ -4,9 +4,6 @@ mkdir build
|
|||||||
cd build
|
cd build
|
||||||
|
|
||||||
FLAGS="-Wall -Wno-missing-braces -Wno-writable-strings -nostdlib++ -fsanitize=address -fno-exceptions -fdiagnostics-absolute-paths -g -Wno-writable-strings -I../src -DDEBUG_BUILD=1"
|
FLAGS="-Wall -Wno-missing-braces -Wno-writable-strings -nostdlib++ -fsanitize=address -fno-exceptions -fdiagnostics-absolute-paths -g -Wno-writable-strings -I../src -DDEBUG_BUILD=1"
|
||||||
# clang -o metaprogram $FLAGS ../src/metaprogram/metaprogram.cpp
|
|
||||||
# ./metaprogram
|
|
||||||
|
|
||||||
I="-I../src/external/SDL/include -I../src/external/lua/src -I../src/external/glad"
|
I="-I../src/external/SDL/include -I../src/external/lua/src -I../src/external/glad"
|
||||||
clang -o te $FLAGS ../src/text_editor/text_editor.cpp $I -lSDL3 -lm -lbacktrace
|
clang -o te $FLAGS ../src/text_editor/text_editor.cpp $I -lSDL3 -lm -lbacktrace
|
||||||
|
|
||||||
|
|||||||
@@ -31,12 +31,12 @@ void LayoutBuildWindow(Rect2I *rect, int16_t wx, int16_t wy) {
|
|||||||
window->document_rect = window->total_rect = CutBottom(rect, barsize);
|
window->document_rect = window->total_rect = CutBottom(rect, barsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
BSet ExecBuild(String cmd) {
|
BSet ExecBuild(String cmd, String working_dir = ProjectDirectory) {
|
||||||
BSet build = GetBSet(BuildWindowID);
|
BSet build = GetBSet(BuildWindowID);
|
||||||
BSet main = GetBSet(PrimaryWindowID);
|
BSet main = GetBSet(PrimaryWindowID);
|
||||||
SelectRange(build.view, Range{});
|
SelectRange(build.view, Range{});
|
||||||
ResetBuffer(build.buffer);
|
ResetBuffer(build.buffer);
|
||||||
Exec(build.view->id, true, cmd, ProjectDirectory);
|
Exec(build.view->id, true, cmd, working_dir);
|
||||||
main.window->active_goto_list = build.view->id;
|
main.window->active_goto_list = build.view->id;
|
||||||
main.window->goto_list_pos = 0;
|
main.window->goto_list_pos = 0;
|
||||||
return build;
|
return build;
|
||||||
@@ -53,6 +53,22 @@ void CMD_Build() {
|
|||||||
main.window->visible = true;
|
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");
|
} 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_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", primary.buffer->name);
|
||||||
|
ExecBuild(cmd, GetDir(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\nEOF", primary.buffer->name);
|
||||||
|
ExecBuild(cmd, GetDir(primary.buffer));
|
||||||
|
}
|
||||||
|
build.window->visible = true;
|
||||||
|
} RegisterCommand(CMD_RunFile, "", "Run and build current file, currently only C/C++ supported");
|
||||||
|
|
||||||
void CMD_ShowBuildWindow() {
|
void CMD_ShowBuildWindow() {
|
||||||
BSet main = GetBSet(BuildWindowID);
|
BSet main = GetBSet(BuildWindowID);
|
||||||
if (ActiveWindowID != BuildWindowID) {
|
if (ActiveWindowID != BuildWindowID) {
|
||||||
|
|||||||
Reference in New Issue
Block a user