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.
This commit is contained in:
Calvin Rose 2019-03-22 14:31:20 -04:00
parent 1e299632e4
commit cb2caecbb3
5 changed files with 60 additions and 9 deletions

View File

@ -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)

View File

@ -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 <windows.h>

View File

@ -20,15 +20,13 @@
* IN THE SOFTWARE.
*/
/* Compiler feature test macros for things */
#define _DEFAULT_SOURCE
#define _BSD_SOURCE
#ifndef JANET_AMALG
#include <janet.h>
#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

View File

@ -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"

46
src/include/janetconf.h Normal file
View File

@ -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 */