Merge pull request #30 from GruelingPine185/0.6.0

Mac Support
This commit is contained in:
2022-09-24 14:52:43 +10:00
committed by GitHub
16 changed files with 35 additions and 18 deletions

4
.gitignore vendored
View File

@@ -4,6 +4,7 @@
*.suo *.suo
*.ncb *.ncb
*.user *.user
compile_commands.json
#Directories #Directories
Release/ Release/
@@ -12,6 +13,7 @@ Out/
release/ release/
debug/ debug/
out/ out/
.cache/
#Project generated files #Project generated files
*.db *.db
@@ -26,4 +28,4 @@ out
#Shell files #Shell files
*.bat *.bat
*.sh *.sh

View File

@@ -19,11 +19,9 @@ Special thanks to http://craftinginterpreters.com/ for their fantastic book that
## Building ## 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 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.
## Syntax ## 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. 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. 3. This notice may not be removed or altered from any source distribution.

View File

@@ -45,6 +45,16 @@ else ifeq ($(shell uname),Linux)
find . -empty -type d -delete find . -empty -type d -delete
else ifeq ($(OS),Windows_NT) else ifeq ($(OS),Windows_NT)
$(RM) *.o *.a *.exe $(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 else
@echo "Deletion failed - what platform is this?" @echo "Deletion failed - what platform is this?"
endif endif

View File

@@ -96,4 +96,3 @@ int hookStandard(Interpreter* interpreter, Literal identifier, Literal alias) {
return 0; return 0;
} }

View File

@@ -7,11 +7,16 @@ LIBS+=-ltoy
ODIR = obj ODIR = obj
SRC = $(wildcard *.c) SRC = $(wildcard *.c)
OBJ = $(addprefix $(ODIR)/,$(SRC:.c=.o)) OBJ = $(addprefix $(ODIR)/,$(SRC:.c=.o))
OUTNAME=toy
OUT=../$(TOY_OUTDIR)/toyrepl OUT=../$(TOY_OUTDIR)/toyrepl
all: $(OBJ) 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) $(CC) -DTOY_IMPORT $(CFLAGS) -o $(OUT) $(OBJ) -L$(realpath $(shell pwd)/../$(TOY_OUTDIR)) $(LIBS)
endif
$(OBJ): | $(ODIR) $(OBJ): | $(ODIR)
@@ -25,3 +30,4 @@ $(ODIR)/%.o: %.c
clean: clean:
$(RM) $(ODIR) $(RM) $(ODIR)
rm /usr/local/lib/lib$(OUTNAME).dylib

View File

@@ -172,4 +172,4 @@ void emitASTNodePrefixIncrement(ASTNode** nodeHandle, Literal identifier, int in
void emitASTNodePostfixIncrement(ASTNode** nodeHandle, Literal identifier, int increment); void emitASTNodePostfixIncrement(ASTNode** nodeHandle, Literal identifier, int increment);
void emitASTNodeImport(ASTNode** nodeHandle, ASTNodeType mode, Literal identifier, Literal alias); void emitASTNodeImport(ASTNode** nodeHandle, ASTNodeType mode, Literal identifier, Literal alias);
void emitASTNodeIndex(ASTNode** nodeHandle, ASTNode* first, ASTNode* second, ASTNode* third); void emitASTNodeIndex(ASTNode** nodeHandle, ASTNode* first, ASTNode* second, ASTNode* third);
void emitASTNodeDot(ASTNode** nodeHandle, ASTNode* first); void emitASTNodeDot(ASTNode** nodeHandle, ASTNode* first);

View File

@@ -9,4 +9,3 @@ int _push(Interpreter* interpreter, LiteralArray* arguments);
int _pop(Interpreter* interpreter, LiteralArray* arguments); int _pop(Interpreter* interpreter, LiteralArray* arguments);
int _length(Interpreter* interpreter, LiteralArray* arguments); int _length(Interpreter* interpreter, LiteralArray* arguments);
int _clear(Interpreter* interpreter, LiteralArray* arguments); int _clear(Interpreter* interpreter, LiteralArray* arguments);

View File

@@ -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"); printf("3. This notice may not be removed or altered from any source distribution.\n\n");
} }
#endif #endif

View File

@@ -40,4 +40,4 @@ void copyrightCommand(int argc, const char* argv[]);
#endif #endif
//NOTE: assigning to a byte from a short loses data //NOTE: assigning to a byte from a short loses data
#define AS_USHORT(value) (*(unsigned short*)(&(value))) #define AS_USHORT(value) (*(unsigned short*)(&(value)))

View File

@@ -27,4 +27,4 @@
#define NOTICE FONT_GREEN BACK_BLACK #define NOTICE FONT_GREEN BACK_BLACK
#define WARN FONT_YELLOW BACK_BLACK #define WARN FONT_YELLOW BACK_BLACK
#define ERROR FONT_RED BACK_BLACK #define ERROR FONT_RED BACK_BLACK
#define RESET "\033[0m" #define RESET "\033[0m"

View File

@@ -73,4 +73,4 @@ TokenType findTypeByKeyword(const char* keyword) {
} }
return TOKEN_EOF; return TOKEN_EOF;
} }

View File

@@ -11,4 +11,4 @@ extern KeywordType keywordTypes[];
char* findKeywordByType(TokenType type); char* findKeywordByType(TokenType type);
TokenType findTypeByKeyword(const char* keyword); TokenType findTypeByKeyword(const char* keyword);

View File

@@ -345,4 +345,4 @@ void printToken(Token* token) {
} }
printf("\n"); printf("\n");
} }

View File

@@ -23,4 +23,4 @@ TOY_API void initLexer(Lexer* lexer, char* source);
Token scanLexer(Lexer* lexer); Token scanLexer(Lexer* lexer);
//for debugging //for debugging
void printToken(Token* token); void printToken(Token* token);

View File

@@ -97,4 +97,4 @@ Literal getLiteralArray(LiteralArray* array, Literal index) {
} }
return copyLiteral(array->literals[idx]); return copyLiteral(array->literals[idx]);
} }

View File

@@ -21,6 +21,9 @@ else ifeq ($(shell uname),Linux)
else ifeq ($(OS),Windows_NT) 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 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 OUT=../$(TOY_OUTDIR)/$(OUTNAME).dll
else ifeq ($(shell uname),Darwin)
LIBLINE = $(OBJ)
OUT=../$(TOY_OUTDIR)/lib$(OUTNAME).dylib
else else
@echo "Platform test failed - what platform is this?" @echo "Platform test failed - what platform is this?"
exit 1 exit 1