Initial commit
This commit is contained in:
commit
865a905081
BIN
.nob.c.swp
Normal file
BIN
.nob.c.swp
Normal file
Binary file not shown.
BIN
build/main
Executable file
BIN
build/main
Executable file
Binary file not shown.
36
nob.c
Normal file
36
nob.c
Normal file
@ -0,0 +1,36 @@
|
||||
#define NOB_IMPLEMENTATION
|
||||
#define NOB_STRIP_PREFIX
|
||||
#include "nob.h"
|
||||
|
||||
#define BUILD_FOLDER "build/"
|
||||
#define SRC_FOLDER "src/"
|
||||
#define SRC_FILE "src/main.c"
|
||||
|
||||
int main(int argc, char **argv){
|
||||
NOB_GO_REBUILD_URSELF(argc, argv);
|
||||
|
||||
Nob_Cmd cmd = {0};
|
||||
|
||||
if (!nob_mkdir_if_not_exists(BUILD_FOLDER)) return 1;
|
||||
if (!nob_mkdir_if_not_exists(SRC_FOLDER)) return 1;
|
||||
|
||||
if(!file_exists(SRC_FILE)) {
|
||||
String_Builder sb = {0};
|
||||
sb_append_cstr(&sb, "#include <stdio.h>\n");
|
||||
sb_append_cstr(&sb, "\nint main()\n");
|
||||
sb_append_cstr(&sb, "{\n printf(\"Hello, world\\n\");\n");
|
||||
sb_append_cstr(&sb, " return 0;\n}\n");
|
||||
/* const char *data = "#include <stdio.h>\n\nint main(){\n printf(\"Hello, world\\n\");\n return 0;\n}\n"; */
|
||||
write_entire_file(SRC_FILE, sb.items, sb.count);
|
||||
}
|
||||
|
||||
nob_cmd_append(&cmd, "cc");
|
||||
nob_cmd_append(&cmd, "-Wall", "-Wextra");
|
||||
nob_cmd_append(&cmd, "-o", BUILD_FOLDER"main", SRC_FOLDER"main.c");
|
||||
if(!nob_cmd_run(&cmd)) return 1;
|
||||
|
||||
nob_cmd_append(&cmd, BUILD_FOLDER"main");
|
||||
if(!nob_cmd_run(&cmd)) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
7
src/main.c
Normal file
7
src/main.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Hello, world\n");
|
||||
return 0;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user