bulk changes

This commit is contained in:
2025-08-24 15:11:47 -04:00
parent ac7b2e6e9e
commit f59a3e4957
7 changed files with 3350 additions and 44 deletions

View File

@@ -1,4 +1,4 @@
PREFIX = /usr/bin PREFIX = /usr/bin/
YAIT_SRCS := $(wildcard src/*.c) YAIT_SRCS := $(wildcard src/*.c)
YAIT_OBJS := $(patsubst src/%.c,build/obj/%.o,$(YAIT_SRCS)) YAIT_OBJS := $(patsubst src/%.c,build/obj/%.o,$(YAIT_SRCS))
@@ -28,8 +28,7 @@ $(YAIT): $(YAIT_OBJS)
endif endif
install: $(YAIT) install: $(YAIT)
mkdir -p $(DESTDIR)$(PREFIX)/bin cp $(YAIT) $(PREFIX)
cp $(YAIT) $(DESTDIR)$(PREFIX)/bin/
uninstall: uninstall:
$(RM) $(DESTDIR)$(PREFIX)/bin/yait $(RM) $(DESTDIR)$(PREFIX)/bin/yait

6
TODO
View File

@@ -2,10 +2,12 @@ VX yait --- TODO
Todo: Todo:
* Polish for v1 release * Polish for v1 release
* Finish implementing IDEA
* --extra * --extra
* --extra-build * --extra-build
* --extra-build=nob * --extra-build=nob
* Project formats * --extra-tools
* LIBRARY * --extra-tools=format
* --extra-tools=Cleanup
end of file TODO end of file TODO

View File

@@ -6,6 +6,7 @@
* <https://opensource.org/licence/bsd-3-clause> * <https://opensource.org/licence/bsd-3-clause>
*/ */
#include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@@ -14,6 +15,8 @@
#include "../include/yait.h" #include "../include/yait.h"
#include "posix_contents.h" #include "posix_contents.h"
#include "library_contents.h"
#include "licences/licences.h"
#include "util.h" #include "util.h"
int create_project(manifest_t manifest) int create_project(manifest_t manifest)
@@ -117,6 +120,27 @@ int create_project(manifest_t manifest)
manifest.project, manifest.name); manifest.project, manifest.name);
main_source = "src/main.c"; 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; break;
default: default:
abort(); abort();
@@ -133,6 +157,23 @@ int create_project(manifest_t manifest)
if (manifest.libraries.linenoise) if (manifest.libraries.linenoise)
system("git submodule add --quiet https://github.com/antirez/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) { if (manifest.flags.editor) {
snprintf(buffer, BUFSIZ, "nvim %s", main_source); snprintf(buffer, BUFSIZ, "nvim %s", main_source);
system(buffer); system(buffer);

40
src/library_contents.h Normal file
View 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

File diff suppressed because it is too large Load Diff

View File

@@ -68,7 +68,7 @@ static int parse_arguments(manifest_t *conf, int argc, char **argv)
switch (opt) { switch (opt) {
case 's': case 's':
if (strcmp(optarg, "list") == 0) { if (strcmp(optarg, "list") == 0) {
puts("posix\nsimple\nGNU\nlib\nfasm"); puts("posix\nsimple\nGNU\nlib\nfasm\nlib");
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
conf->style = TOstyle(optarg); conf->style = TOstyle(optarg);

View File

@@ -7,8 +7,8 @@
*/ */
// clang-format off // clang-format off
#ifndef CONTENTS_H #ifndef POSIX_CONTENTS_H
#define CONTENTS_H #define POSIX_CONTENTS_H
#define line(ln) ln "\n" #define line(ln) ln "\n"
@@ -127,42 +127,6 @@ char *makefile =
char *clang_format = char *clang_format =
line ("BasedOnStyle: GNU"); 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 = char *config_h =
line ("#ifndef CONFIG_H") line ("#ifndef CONFIG_H")
line ("#define CONFIG_H") line ("#define CONFIG_H")