From 2b0b678e256e8aa959d011ae360ac29acfcd40b2 Mon Sep 17 00:00:00 2001 From: GruelingPine185 <66073333+GruelingPine185@users.noreply.github.com> Date: Fri, 23 Sep 2022 18:11:04 -0400 Subject: [PATCH 1/6] added Bear ignores --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d554959..fff098f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.suo *.ncb *.user +compile_commands.json #Directories Release/ @@ -12,6 +13,7 @@ Out/ release/ debug/ out/ +.cache/ #Project generated files *.db @@ -26,4 +28,4 @@ out #Shell files *.bat -*.sh \ No newline at end of file +*.sh From ecbfcc28b5ff2269248d306e65947c2e2c22e802 Mon Sep 17 00:00:00 2001 From: GruelingPine185 <66073333+GruelingPine185@users.noreply.github.com> Date: Fri, 23 Sep 2022 18:16:53 -0400 Subject: [PATCH 2/6] resolved line ending warnings --- repl/lib_standard.c | 1 - source/ast_node.h | 2 +- source/builtin.h | 1 - source/common.c | 2 +- source/common.h | 2 +- source/console_colors.h | 2 +- source/keyword_types.c | 2 +- source/keyword_types.h | 2 +- source/lexer.c | 2 +- source/lexer.h | 2 +- source/literal_array.c | 2 +- 11 files changed, 9 insertions(+), 11 deletions(-) diff --git a/repl/lib_standard.c b/repl/lib_standard.c index 6da3166..d86e979 100644 --- a/repl/lib_standard.c +++ b/repl/lib_standard.c @@ -96,4 +96,3 @@ int hookStandard(Interpreter* interpreter, Literal identifier, Literal alias) { return 0; } - diff --git a/source/ast_node.h b/source/ast_node.h index 7d09e97..042613f 100644 --- a/source/ast_node.h +++ b/source/ast_node.h @@ -172,4 +172,4 @@ void emitASTNodePrefixIncrement(ASTNode** nodeHandle, Literal identifier, int in void emitASTNodePostfixIncrement(ASTNode** nodeHandle, Literal identifier, int increment); void emitASTNodeImport(ASTNode** nodeHandle, ASTNodeType mode, Literal identifier, Literal alias); void emitASTNodeIndex(ASTNode** nodeHandle, ASTNode* first, ASTNode* second, ASTNode* third); -void emitASTNodeDot(ASTNode** nodeHandle, ASTNode* first); \ No newline at end of file +void emitASTNodeDot(ASTNode** nodeHandle, ASTNode* first); diff --git a/source/builtin.h b/source/builtin.h index aa95220..dd234df 100644 --- a/source/builtin.h +++ b/source/builtin.h @@ -9,4 +9,3 @@ int _push(Interpreter* interpreter, LiteralArray* arguments); int _pop(Interpreter* interpreter, LiteralArray* arguments); int _length(Interpreter* interpreter, LiteralArray* arguments); int _clear(Interpreter* interpreter, LiteralArray* arguments); - diff --git a/source/common.c b/source/common.c index 10f8f77..2412396 100644 --- a/source/common.c +++ b/source/common.c @@ -122,4 +122,4 @@ void copyrightCommand(int argc, const char* argv[]) { printf("3. This notice may not be removed or altered from any source distribution.\n\n"); } -#endif \ No newline at end of file +#endif diff --git a/source/common.h b/source/common.h index f22df01..335007e 100644 --- a/source/common.h +++ b/source/common.h @@ -40,4 +40,4 @@ void copyrightCommand(int argc, const char* argv[]); #endif //NOTE: assigning to a byte from a short loses data -#define AS_USHORT(value) (*(unsigned short*)(&(value))) \ No newline at end of file +#define AS_USHORT(value) (*(unsigned short*)(&(value))) diff --git a/source/console_colors.h b/source/console_colors.h index 42d1f19..ae7bfa8 100644 --- a/source/console_colors.h +++ b/source/console_colors.h @@ -27,4 +27,4 @@ #define NOTICE FONT_GREEN BACK_BLACK #define WARN FONT_YELLOW BACK_BLACK #define ERROR FONT_RED BACK_BLACK -#define RESET "\033[0m" \ No newline at end of file +#define RESET "\033[0m" diff --git a/source/keyword_types.c b/source/keyword_types.c index cd4d1a7..d024b73 100644 --- a/source/keyword_types.c +++ b/source/keyword_types.c @@ -73,4 +73,4 @@ TokenType findTypeByKeyword(const char* keyword) { } return TOKEN_EOF; -} \ No newline at end of file +} diff --git a/source/keyword_types.h b/source/keyword_types.h index 5469f6a..a691910 100644 --- a/source/keyword_types.h +++ b/source/keyword_types.h @@ -11,4 +11,4 @@ extern KeywordType keywordTypes[]; char* findKeywordByType(TokenType type); -TokenType findTypeByKeyword(const char* keyword); \ No newline at end of file +TokenType findTypeByKeyword(const char* keyword); diff --git a/source/lexer.c b/source/lexer.c index 205551f..4895347 100644 --- a/source/lexer.c +++ b/source/lexer.c @@ -345,4 +345,4 @@ void printToken(Token* token) { } printf("\n"); -} \ No newline at end of file +} diff --git a/source/lexer.h b/source/lexer.h index 3a37b29..5df11a0 100644 --- a/source/lexer.h +++ b/source/lexer.h @@ -23,4 +23,4 @@ TOY_API void initLexer(Lexer* lexer, char* source); Token scanLexer(Lexer* lexer); //for debugging -void printToken(Token* token); \ No newline at end of file +void printToken(Token* token); diff --git a/source/literal_array.c b/source/literal_array.c index 3c97302..a460944 100644 --- a/source/literal_array.c +++ b/source/literal_array.c @@ -97,4 +97,4 @@ Literal getLiteralArray(LiteralArray* array, Literal index) { } return copyLiteral(array->literals[idx]); -} \ No newline at end of file +} From 32aad5eecc57e4e782d8570574cbf085f0b8e4bc Mon Sep 17 00:00:00 2001 From: GruelingPine185 <66073333+GruelingPine185@users.noreply.github.com> Date: Fri, 23 Sep 2022 18:17:09 -0400 Subject: [PATCH 3/6] cleanup files --- makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/makefile b/makefile index 5512d8c..f4c06cf 100644 --- a/makefile +++ b/makefile @@ -45,6 +45,16 @@ else ifeq ($(shell uname),Linux) find . -empty -type d -delete else ifeq ($(OS),Windows_NT) $(RM) *.o *.a *.exe +else ifeq ($(shell uname),Darwin) + find . -type f -name '*.o' -exec rm -f -r -v {} \; + find . -type f -name '*.a' -exec rm -f -r -v {} \; + find . -type f -name '*.exe' -exec rm -f -r -v {} \; + find . -type f -name '*.dll' -exec rm -f -r -v {} \; + find . -type f -name '*.lib' -exec rm -f -r -v {} \; + find . -type f -name '*.dylib' -exec rm -f -r -v {} \; + find . -type f -name '*.so' -exec rm -f -r -v {} \; + rm -rf out + find . -empty -type d -delete else @echo "Deletion failed - what platform is this?" endif From 57e7acf97aed2c2863fdf679640422965d325637 Mon Sep 17 00:00:00 2001 From: GruelingPine185 <66073333+GruelingPine185@users.noreply.github.com> Date: Fri, 23 Sep 2022 18:18:46 -0400 Subject: [PATCH 4/6] updated README.md Building section --- README.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 79cd282..6147070 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,9 @@ Special thanks to http://craftinginterpreters.com/ for their fantastic book that ## Building -For windows, simply run `make` in the root directory. +For Windows and MacOS, simply run `make` in the root directory. -For linux, run `make repl-static` in the root directory (see [this issue for details](https://github.com/Ratstail91/Toy/issues/26)). - -For mac, good luck. +For Linux, run `make repl-static` in the root directory (see [this issue for details](https://github.com/Ratstail91/Toy/issues/26)). ## Syntax @@ -70,4 +68,4 @@ Permission is granted to anyone to use this software for any purpose, including 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. \ No newline at end of file +3. This notice may not be removed or altered from any source distribution. From d77711da7b90d69eb975e1ae702f71be94204a33 Mon Sep 17 00:00:00 2001 From: GruelingPine185 <66073333+GruelingPine185@users.noreply.github.com> Date: Fri, 23 Sep 2022 18:22:20 -0400 Subject: [PATCH 5/6] build library --- source/makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/makefile b/source/makefile index 8276fae..e3287e5 100644 --- a/source/makefile +++ b/source/makefile @@ -21,6 +21,9 @@ else ifeq ($(shell uname),Linux) else ifeq ($(OS),Windows_NT) LIBLINE =-Wl,--out-implib=../$(TOY_OUTDIR)/lib$(OUTNAME).dll.a -Wl,--export-all-symbols -Wl,--enable-auto-import -Wl,--whole-archive $(OBJ) -Wl,--no-whole-archive OUT=../$(TOY_OUTDIR)/$(OUTNAME).dll +else ifeq ($(shell uname),Darwin) + LIBLINE = $(OBJ) + OUT=../$(TOY_OUTDIR)/lib$(OUTNAME).dylib else @echo "Platform test failed - what platform is this?" exit 1 From 48dbbfaa243af0fa8a6de08d38f9e4a41b63d671 Mon Sep 17 00:00:00 2001 From: GruelingPine185 <66073333+GruelingPine185@users.noreply.github.com> Date: Fri, 23 Sep 2022 18:22:42 -0400 Subject: [PATCH 6/6] build repl --- repl/makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/repl/makefile b/repl/makefile index 3bd4970..b3ddf7c 100644 --- a/repl/makefile +++ b/repl/makefile @@ -7,11 +7,16 @@ LIBS+=-ltoy ODIR = obj SRC = $(wildcard *.c) OBJ = $(addprefix $(ODIR)/,$(SRC:.c=.o)) - +OUTNAME=toy OUT=../$(TOY_OUTDIR)/toyrepl all: $(OBJ) +ifeq ($(shell uname),Darwin) + cp $(PWD)/$(TOY_OUTDIR)/lib$(OUTNAME).dylib /usr/local/lib/ + $(CC) -DTOY_IMPORT $(CFLAGS) -o $(OUT) $(OBJ) $(LIBS) +else $(CC) -DTOY_IMPORT $(CFLAGS) -o $(OUT) $(OBJ) -L$(realpath $(shell pwd)/../$(TOY_OUTDIR)) $(LIBS) +endif $(OBJ): | $(ODIR) @@ -25,3 +30,4 @@ $(ODIR)/%.o: %.c clean: $(RM) $(ODIR) + rm /usr/local/lib/lib$(OUTNAME).dylib