bulk changes
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
* <https://opensource.org/licence/bsd-3-clause>
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
@@ -14,6 +15,8 @@
|
||||
|
||||
#include "../include/yait.h"
|
||||
#include "posix_contents.h"
|
||||
#include "library_contents.h"
|
||||
#include "licences/licences.h"
|
||||
#include "util.h"
|
||||
|
||||
int create_project(manifest_t manifest)
|
||||
@@ -117,6 +120,27 @@ int create_project(manifest_t manifest)
|
||||
manifest.project, manifest.name);
|
||||
|
||||
main_source = "src/main.c";
|
||||
break;
|
||||
case LIBRARY:
|
||||
snprintf(buffer, BUFSIZ, "include/%s.h", manifest.project);
|
||||
char *file_name_buffer = str_dup(buffer);
|
||||
|
||||
snprintf(buffer, BUFSIZ, "%s", manifest.project);
|
||||
for (int i = 0; buffer[i] != '\0'; ++i)
|
||||
buffer[i] = toupper((unsigned char)buffer[i]);
|
||||
|
||||
cfprintf(file_name_buffer, "#ifndef %s\n#define %s\n#endif",
|
||||
buffer, buffer);
|
||||
|
||||
snprintf(buffer, BUFSIZ, "src/%s.c", manifest.project);
|
||||
main_source = str_dup(buffer);
|
||||
cfprintf(buffer, "");
|
||||
|
||||
cfprintf("Makefile", makefile_lib, manifest.project,
|
||||
manifest.project);
|
||||
|
||||
cfprintf("README", "%s", manifest.project);
|
||||
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
@@ -133,6 +157,23 @@ int create_project(manifest_t manifest)
|
||||
if (manifest.libraries.linenoise)
|
||||
system("git submodule add --quiet https://github.com/antirez/linenoise");
|
||||
|
||||
switch (manifest.licence) {
|
||||
case MIT:
|
||||
cfprintf("COPYING", "%s", MIT_txt);
|
||||
break;
|
||||
case GPL:
|
||||
cfprintf("COPYING", "%s", GPL_3_0_txt);
|
||||
break;
|
||||
case BSD:
|
||||
cfprintf("COPYING", "%s", BSD_3_Clause_txt);
|
||||
break;
|
||||
case UNL:
|
||||
cfprintf("COPYING", "%s", UNLICENSE_txt);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
|
||||
if (manifest.flags.editor) {
|
||||
snprintf(buffer, BUFSIZ, "nvim %s", main_source);
|
||||
system(buffer);
|
||||
|
||||
40
src/library_contents.h
Normal file
40
src/library_contents.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* Copyright (C) vx-clutch
|
||||
*
|
||||
* This file is part of yait
|
||||
*
|
||||
* This project and file is licenced under the BSD-3-Clause licecne
|
||||
* <https://opensource.org/licence/bsd-3-clause>
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
#ifndef LIBRARY_CONTENTS_H
|
||||
#define LIBRARY_CONTENTS_H
|
||||
|
||||
#define line(ln) ln "\n"
|
||||
|
||||
char *makefile_lib =
|
||||
line ("CC = gcc")
|
||||
line ("CLFAGS = -Wall -Wextra -O2 -fPIC -Iinclude")
|
||||
line ("AR = ar rcs")
|
||||
line ("BUILD = build")
|
||||
line ("")
|
||||
line ("SRC = $(wildcard src/*.c)")
|
||||
line ("OBJ = $(SRC:src/%%.c=$(BUILD)/obj/%%.o)")
|
||||
line ("")
|
||||
line ("STATIC = $(BUILD)/%s.a")
|
||||
line ("SHARED = $(BUILD)/%s.so")
|
||||
line ("")
|
||||
line ("all: $(STAITC) $(SHARED)")
|
||||
line ("")
|
||||
line ("$(STATIC): $(OBJ)\n\t$(AR) $@ $^")
|
||||
line ("")
|
||||
line ("$(SHARED): $(OBJ)\n\t$(CC) -shared -o $@ $^")
|
||||
line ("")
|
||||
line ("$(BUILD)/%%.o: src/%%.c | $(BUILD)\n\t$(CC) $(CFLAGS) -c $< -o $@")
|
||||
line ("")
|
||||
line ("$(BUILD):\n\tmkdir -p $(BUILD)/obj")
|
||||
line ("")
|
||||
line ("clean:\n\t$(RM) -r $(BUILD)");
|
||||
|
||||
#endif
|
||||
// clang-format on
|
||||
3260
src/licences/licences.h
Normal file
3260
src/licences/licences.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -68,7 +68,7 @@ static int parse_arguments(manifest_t *conf, int argc, char **argv)
|
||||
switch (opt) {
|
||||
case 's':
|
||||
if (strcmp(optarg, "list") == 0) {
|
||||
puts("posix\nsimple\nGNU\nlib\nfasm");
|
||||
puts("posix\nsimple\nGNU\nlib\nfasm\nlib");
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
conf->style = TOstyle(optarg);
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
#ifndef CONTENTS_H
|
||||
#define CONTENTS_H
|
||||
#ifndef POSIX_CONTENTS_H
|
||||
#define POSIX_CONTENTS_H
|
||||
|
||||
#define line(ln) ln "\n"
|
||||
|
||||
@@ -127,42 +127,6 @@ char *makefile =
|
||||
char *clang_format =
|
||||
line ("BasedOnStyle: GNU");
|
||||
|
||||
char *bsd3_license =
|
||||
line ("BSD 3-Clause License")
|
||||
line ()
|
||||
line ("Copyright (c) %d, %s")
|
||||
line ()
|
||||
line ("Redistribution and use in source and binary forms, with or without")
|
||||
line ("modification, are permitted provided that the following conditions are met:")
|
||||
line ()
|
||||
line ("1. Redistributions of source code must retain the above copyright notice, this")
|
||||
line (" list of conditions and the following disclaimer.")
|
||||
line ()
|
||||
line ("2. Redistributions in binary form must reproduce the above copyright notice,")
|
||||
line (" this list of conditions and the following disclaimer in the documentation")
|
||||
line (" and/or other materials provided with the distribution.")
|
||||
line ()
|
||||
line ("3. Neither the name of the copyright holder nor the names of its")
|
||||
line (" contributors may be used to endorse or promote products derived from")
|
||||
line (" this software without specific prior written permission.")
|
||||
line ()
|
||||
line ("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"")
|
||||
line ("AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE")
|
||||
line ("IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE")
|
||||
line ("DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE")
|
||||
line ("FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL")
|
||||
line ("DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR")
|
||||
line ("SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER")
|
||||
line ("CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,")
|
||||
line ("OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE")
|
||||
line ("OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.");
|
||||
|
||||
char *mit_license =
|
||||
line ("THIS IS THE MIT LICENSE");
|
||||
|
||||
char *gplv3_license =
|
||||
line ("THIS IS THE GPLv3 LICENSE");
|
||||
|
||||
char *config_h =
|
||||
line ("#ifndef CONFIG_H")
|
||||
line ("#define CONFIG_H")
|
||||
|
||||
Reference in New Issue
Block a user