commit 0fa8ad12ca33a23f802b1af88ffdb9abca7780ee Author: Ian Moffett Date: Sat Mar 21 06:15:27 2026 -0400 initial commit Signed-off-by: Ian Moffett diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..db85004 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.o +*.d +/quip diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..cf7f679 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +BSD 3-Clause License + +Copyright (c) 2026, Ian Moffett + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f9d7574 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# +# Copyright (c) 2026, Mirocom Laboratories +# Provided under the BSD-3 clause +# + +CC = clang +CFLAGS = -Wall -Iinclude/ -pedantic + +CFILES = $(shell find core/ -name "*.c") +CFILES += $(shell find frontend/ -name "*.c") +OFILES = $(CFILES:.c=.o) + +.PHONY: all +all: quip + +.PHONY: quip +quip: $(OFILES) + $(CC) $^ -o $@ + +%.o: %.c + $(CC) -c $(CFLAGS) $< -o $@ diff --git a/READAME.md b/READAME.md new file mode 100644 index 0000000..ed35238 --- /dev/null +++ b/READAME.md @@ -0,0 +1,7 @@ +# The quip build system + +Quip is a modern build system for C projects aiming to be as simple as possible while balancing functionality. + +## Building + +To build quip, simply run ``make`` diff --git a/core/quip.c b/core/quip.c new file mode 100644 index 0000000..1e6cf2f --- /dev/null +++ b/core/quip.c @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * Provided under the BSD-3 clause + * + * Abstract: + * This is the main file implementing early and core logic. + * Author: + * Ian M. Moffett + */ + +#include +#include +#include "common/knobs.h" + +int +main(int argc, char **argv) +{ + if (access(QUIP_FILEPATH, F_OK) != 0) { + printf("fatal: No %s file found\n", QUIP_FILEPATH); + return -1; + } + + return 0; +} diff --git a/core/state.c b/core/state.c new file mode 100644 index 0000000..4a9f47a --- /dev/null +++ b/core/state.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * Provided under the BSD-3 clause + * + * Abstract: + * This file implements the quip state machine + * Author: + * Ian M. Moffett + */ + +#include +#include +#include +#include +#include +#include "common/state.h" + +int +quip_state_init(const char *build_file, struct quip_state *state) +{ + if (build_file == NULL || state == NULL) { + errno = -EINVAL; + return -1; + } + + + memset(state, 0, sizeof(*state)); + state->line_num = 1; + state->in_fd = open(build_file, O_RDONLY); + + if (state->in_fd < 0) { + return -1; + } + + return 0; +} + +void +quip_state_destroy(struct quip_state *state) +{ + if (state == NULL) { + return; + } + + close(state->in_fd); + state->in_fd = -1; +} diff --git a/include/common/knobs.h b/include/common/knobs.h new file mode 100644 index 0000000..cc1bf59 --- /dev/null +++ b/include/common/knobs.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * Provided under the BSD-3 clause + * + * Abstract: + * This header defines settings related to quips operation. + * Author: + * Ian M. Moffett + */ + +#ifndef COMMON_KNOBS_H +#define COMMON_KNOBS_H 1 + +#define QUIP_VERSION "0.0.1" +#define QUIP_FILEPATH "build.quip" + +#endif /* !_COMMON_KNOBS_H_ */ diff --git a/include/common/state.h b/include/common/state.h new file mode 100644 index 0000000..d7639bb --- /dev/null +++ b/include/common/state.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2026, Mirocom Laboratories + * Provided under the BSD-3 clause + * + * Abstract: + * This header defines the quip state machine + * Author: + * Ian M. Moffett + */ + +#ifndef COMMON_STATE_H +#define COMMON_STATE_H 1 + +#include +#include + +/* + * Represents the build state machine + * + * @in_fd: Input file descriptor of build file + * @line_num: Current line number + */ +struct quip_state { + int in_fd; + size_t line_num; +}; + +/* + * Initialize the quip state machine + * + * @build_file: Path to build file + * @state: State instance to initialize + * + * Returns zero on success + */ +int quip_state_init(const char *build_file, struct quip_state *state); + +/* + * Destroy a quip state + */ +void quip_state_destroy(struct quip_state *state); + +#endif /* !COMMON_STATE_H */