From cb2caecbb390bea9a30da90ed375fe79e05f2df4 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Fri, 22 Mar 2019 14:31:20 -0400 Subject: [PATCH] Add janetconf.h for configuring builds. Rather than edit the Makefile or the janet.h header yourself, use janetconf.h to configure builds. This has the benefit of making it easier to configure janet in a persitent but easy way. --- Makefile | 7 ++++--- src/core/corelib.c | 2 +- src/core/typedarray.c | 8 +++---- src/include/janet.h | 6 +++++- src/include/janetconf.h | 46 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 src/include/janetconf.h diff --git a/Makefile b/Makefile index 3968a661..f5c19a1f 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,7 @@ JANET_BOOT_OBJECTS=$(patsubst src/%.c,build/%.boot.o,$(JANET_CORE_SOURCES) $(JAN build/core.gen.o \ build/boot.gen.o -build/%.boot.o: src/%.c +build/%.boot.o: src/%.c $(JANET_HEADERS) $(JANET_LOCAL_HEADERS) $(CC) $(CFLAGS) -DJANET_BOOTSTRAP -o $@ -c $< build/janet_boot: $(JANET_BOOT_OBJECTS) @@ -191,7 +191,8 @@ callgrind: $(JANET_TARGET) dist: build/janet-dist.tar.gz -build/janet-%.tar.gz: $(JANET_TARGET) src/include/janet.h \ +build/janet-%.tar.gz: $(JANET_TARGET) \ + src/include/janet.h src/include/janetconf.h \ janet.1 LICENSE CONTRIBUTING.md $(JANET_LIBRARY) \ build/doc.html README.md build/janet.c tar -czvf $@ $^ @@ -230,8 +231,8 @@ install: $(JANET_TARGET) cp $(JANET_HEADERS) $(INCLUDEDIR) mkdir -p $(INCLUDEDIR)/janet mkdir -p $(JANET_PATH) - ln -sf $(INCLUDEDIR)/janet.h $(INCLUDEDIR)/janet/janet.h ln -sf $(INCLUDEDIR)/janet.h $(JANET_PATH)/janet.h + ln -sf $(INCLUDEDIR)/janetconf.h $(JANET_PATH)/janetconf.h cp tools/cook.janet $(JANET_PATH) cp tools/highlight.janet $(JANET_PATH) cp tools/bars.janet $(JANET_PATH) diff --git a/src/core/corelib.c b/src/core/corelib.c index 1f86c77a..81b47c89 100644 --- a/src/core/corelib.c +++ b/src/core/corelib.c @@ -41,7 +41,7 @@ extern size_t janet_core_image_size; #if defined(JANET_NO_DYNAMIC_MODULES) typedef int Clib; #define load_clib(name) ((void) name, 0) -#define symbol_clib(lib, sym) ((void) lib, (void) sym, 0) +#define symbol_clib(lib, sym) ((void) lib, (void) sym, NULL) #define error_clib() "dynamic libraries not supported" #elif defined(JANET_WINDOWS) #include diff --git a/src/core/typedarray.c b/src/core/typedarray.c index 7260384e..7400ad3e 100644 --- a/src/core/typedarray.c +++ b/src/core/typedarray.c @@ -20,15 +20,13 @@ * IN THE SOFTWARE. */ -/* Compiler feature test macros for things */ -#define _DEFAULT_SOURCE -#define _BSD_SOURCE - #ifndef JANET_AMALG #include #include "util.h" #endif +#ifdef JANET_TYPED_ARRAY + static char *ta_type_names[] = { "uint8", "int8", @@ -559,3 +557,5 @@ void janet_lib_typed_array(JanetTable *env) { janet_register_abstract_type(&ta_buffer_type); janet_register_abstract_type(&ta_view_type); } + +#endif diff --git a/src/include/janet.h b/src/include/janet.h index 8f983749..088d1b14 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -29,7 +29,11 @@ extern "C" { /***** START SECTION CONFIG *****/ -#define JANET_VERSION "0.4.1" +#include "janetconf.h" + +#ifndef JANET_VERSION +#define JANET_VERSION "latest" +#endif #ifndef JANET_BUILD #define JANET_BUILD "local" diff --git a/src/include/janetconf.h b/src/include/janetconf.h new file mode 100644 index 00000000..267b8036 --- /dev/null +++ b/src/include/janetconf.h @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2019 Calvin Rose +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +/* Configure Janet. Edit this file to customize the build */ + +#ifndef JANETCONF_H +#define JANETCONF_H + +#define JANET_VERSION "0.4.1" + +/* #define JANET_BUILD "local" */ +/* #define JANET_SINGLE_THREADED */ +/* #define JANET_NO_DYNAMIC_MODULES */ +/* #define JANET_NO_ASSEMBLER */ +/* #define JANET_NO_PEG */ +/* #define JANET_NO_TYPED_ARRAY */ +/* #define JANET_NO_INT_TYPES */ +/* #define JANET_API __attribute__((visibility ("default"))) */ +/* #define JANET_OUT_OF_MEMORY do { printf("janet out of memory\n"); exit(1); } while (0) */ +/* #define JANET_RECURSION_GUARD 1024 */ +/* #define JANET_MAX_PROTO_DEPTH 200 */ +/* #define JANET_MAX_MACRO_EXPAND 200 */ +/* #define JANET_STACK_MAX 16384 */ +/* #define JANET_NO_NANBOX */ +/* #define JANET_WALIGN 8 */ + +#endif /* end of include guard: JANETCONF_H */