diff options
| author | aspiring_aurelian <tom.wells46@protonmail.com> | 2023-12-08 17:18:44 -0600 |
|---|---|---|
| committer | aspiring_aurelian <tom.wells46@protonmail.com> | 2023-12-08 17:18:44 -0600 |
| commit | df86b89290402ddf3e22d7b2d3a5381da7a0aefc (patch) | |
| tree | 1ec329e3c0d3ab715af9b58e6b3d437f2fdae522 /main.c | |
| parent | 287f7ab35e5470a713523d777bbda7cf1e75467c (diff) | |
Merge create_make and create_src
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -30,21 +30,21 @@ void *f1_newer(void *arg) { pthread_exit(&ret); } -void *create_make() { - /* Create simple makefile */ - int fd = creat("makefile", 00644); +void *create_template(void *arg) { + /* Create simple main.c and makefile boilerplate */ + char *path = (char *) arg; + int fd = creat(path, 00644); FILE *file = fdopen(fd, "w"); - fprintf(file, "debug: main.c\n\tgcc -Wall main.c -o ./bin/debug\nrelease: main.c\n\tgcc -O2 -march=native main.c -o ./bin/release"); - fclose(file); - - return NULL; -} + switch(path[2]) { + case 'i': + fprintf(file, "#include <stdio.h>\n\nint main() {\n\tprintf(\"Hello world\\n\");\n}"); + break; + case 'k': + fprintf(file, "debug: main.c\n\tgcc -Wall main.c -o ./bin/debug\nrelease: main.c\n\tgcc -O2 -march=native main.c -o ./bin/release"); + break; + default: break; + } -void *create_src() { - /* Create simple main.c */ - int fd = creat("main.c", 00644); - FILE *file = fdopen(fd, "w"); - fprintf(file, "#include <stdio.h>\n\nint main() {\n\tprintf(\"Hello world\\n\");\n}"); fclose(file); return NULL; @@ -55,8 +55,8 @@ void new(char *argv[]) { mkdir(name, 0777); chdir(name); pthread_t s_thread, m_thread; - pthread_create(&s_thread, NULL, create_src, NULL); - pthread_create(&m_thread, NULL, create_make, NULL); + pthread_create(&s_thread, NULL, create_template, (void *) "main.c"); + pthread_create(&m_thread, NULL, create_template, (void *) "makefile"); pthread_join(s_thread, NULL); pthread_join(m_thread, NULL); @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) { * check age of source vs. bin */ pthread_t f_thread, check_thread; - pthread_create(&f_thread, NULL, create_make, NULL); + pthread_create(&f_thread, NULL, create_template, (void *) "makefile"); pthread_create(&check_thread, NULL, f1_newer, (void *)&files); mkdir("./bin", 0777); |