Skip to content

Commit 40ddbf3

Browse files
committed
FEAT: introducing user defined config file for compile options
CHANGE: using INCLUDE_* instead of USE_* definition names for optional parts
1 parent 61ab302 commit 40ddbf3

14 files changed

+211
-70
lines changed

make/make-settings.r

-36
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,3 @@ REBOL [
44

55
TOOLS-Win32: "x:/MingW/mingw32/bin/"
66
TOOLS-Win64: "x:/MingW/mingw64/bin/"
7-
8-
;@@ If you add or remove some of these defines bellow, you should `make clean`
9-
;@@ to make sure that all affected files will be recompiled!
10-
Defines: [
11-
USE_BMP_CODEC
12-
USE_PNG_CODEC
13-
USE_GIF_CODEC
14-
USE_JPG_CODEC
15-
;USE_WAV_CODEC ;-- deprecated; using Rebol codec instead
16-
;USE_NO_INFINITY ;-- use when you don't want to support IEEE infinity
17-
USE_LZMA ;-- adds support for LZMA [de]compression
18-
USE_MIDI_DEVICE ;-- includes MIDI device when possible (Windows & macOS)
19-
USE_IMAGE_NATIVES ;-- additional image native functions (for example `resize`)
20-
21-
;INCLUDE_TASK ;-- tasks are not implemented yet, so include it only on demand
22-
INCLUDE_BASE85 ;-- adds support for enbase/debase with base 85 (ASCII85)
23-
24-
;@@ optional fine tuning:
25-
;DO_NOT_NORMALIZE_MAP_KEYS
26-
; with above define you would get:
27-
; [a b:] = words-of make map! [a 1 b: 2]
28-
; [a 1 b: 2] = body-of make map! [a 1 b: 2]
29-
;
30-
; else:
31-
; [a b] = words-of make map! [a 1 b: 2]
32-
; [a: 1 b: 2] = body-of make map! [a 1 b: 2]
33-
34-
;USE_EMPTY_HASH_AS_NONE ;-- A single # means NONE, else error; Used in l-scan.c file
35-
;FORCE_ANSI_ESC_EMULATION_ON_WINDOWS ;-- would not try to use MS' built-in VIRTUAL_TERMINAL_PROCESSING
36-
;EXCLUDE_VECTOR_MATH ;-- don't include vector math support (like: 3 * #[vector! integer! 8 3 [1 2 3]])
37-
;EXCLUDE_CHACHA20POLY1305 ;-- chacha20 and poly1305 cipher/authentication is not used
38-
39-
;DEBUG_MIDI ;-- prints some of internal traces from MIDI device handler
40-
;DEBUG_DRAW_REGIONS ;-- draws clip region frame
41-
42-
]

src/core/b-init.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -727,19 +727,19 @@ extern const REBYTE Str_Banner[];
727727
{
728728
Register_Codec("text", Codec_Text);
729729
Register_Codec("markup", Codec_Markup);
730-
#ifdef USE_BMP_CODEC
730+
#ifdef INCLUDE_BMP_CODEC
731731
Init_BMP_Codec();
732732
#endif
733-
#ifdef USE_GIF_CODEC
733+
#ifdef INCLUDE_GIF_CODEC
734734
Init_GIF_Codec();
735735
#endif
736-
#ifdef USE_PNG_CODEC
736+
#ifdef INCLUDE_PNG_CODEC
737737
Init_PNG_Codec();
738738
#endif
739739
#ifdef USE_JPG_CODEC
740740
Init_JPEG_Codec();
741741
#endif
742-
#ifdef USE_WAV_CODEC
742+
#ifdef INCLUDE_WAV_CODEC
743743
Init_WAV_Codec();
744744
#endif
745745
}

src/core/n-image.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef USE_IMAGE_NATIVES
21
/***********************************************************************
32
**
43
** REBOL [R3] Language Interpreter and Run-time Environment
@@ -30,9 +29,12 @@
3029
***********************************************************************/
3130

3231
#include "sys-core.h"
32+
33+
#ifdef INCLUDE_IMAGE_NATIVES
34+
3335
#include "reb-codec.h"
3436
#include "sys-magick.h" // used for `resize` native
35-
#if defined(TO_WINDOWS) && defined(USE_NATIVE_IMAGE_CODECS)
37+
#if defined(TO_WINDOWS) && defined(USE_OS_IMAGE_CODECS)
3638
#include "winerror.h" // used for WINCODEC_ERR_COMPONENTNOTFOUND
3739
#endif
3840

@@ -371,7 +373,7 @@ typedef struct REBCLR {
371373
REBCNT length;
372374

373375

374-
#if defined(TO_WINDOWS) && defined(USE_NATIVE_IMAGE_CODECS)
376+
#if defined(TO_WINDOWS) && defined(USE_OS_IMAGE_CODECS)
375377
CLEARS(&codi);
376378
if (ref_as) {
377379
switch (VAL_WORD_CANON(val_type)) {
@@ -493,4 +495,4 @@ typedef struct REBCLR {
493495
return R_RET;
494496
}
495497

496-
#endif // USE_IMAGE_NATIVES
498+
#endif // INCLUDE_IMAGE_NATIVES

src/core/u-bmp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef USE_BMP_CODEC
21
/***********************************************************************
32
**
43
** REBOL [R3] Language Interpreter and Run-time Environment
@@ -38,6 +37,7 @@
3837
***********************************************************************/
3938

4039
#include "sys-core.h"
40+
#ifdef INCLUDE_BMP_CODEC
4141

4242
//**********************************************************************
4343

@@ -644,4 +644,4 @@ void Unmap_Bytes(void *srcp, REBYTE **dstp, char *map) {
644644
Register_Codec("bmp", Codec_BMP_Image);
645645
}
646646

647-
#endif //USE_BMP_CODEC
647+
#endif //INCLUDE_BMP_CODEC

src/core/u-compress.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828

2929
#include "sys-core.h"
3030
#include "sys-zlib.h"
31-
#ifdef USE_LZMA
31+
#ifdef INCLUDE_LZMA
3232
#include "sys-lzma.h"
33-
#endif // USE_LZMA
33+
#endif // INCLUDE_LZMA
3434

3535
static void *zalloc(void *opaque, unsigned nr, unsigned size)
3636
{
@@ -47,7 +47,7 @@ static void zfree(void *opaque, void *addr)
4747
free(addr);
4848
}
4949

50-
//#ifdef old_Sterlings_code
50+
//#ifdef old_Sterlings_code // used also in LZMA code at this moment
5151
/*
5252
* This number represents the top file size that,
5353
* if the data is random, will produce a larger output
@@ -220,7 +220,7 @@ void Trap_ZStream_Error(z_stream *stream, int err, REBOOL while_compression)
220220
return output;
221221
}
222222

223-
#ifdef USE_LZMA
223+
#ifdef INCLUDE_LZMA
224224

225225
static void *SzAlloc(ISzAllocPtr p, size_t size) { UNUSED(p); return malloc(size); }
226226
static void SzFree(ISzAllocPtr p, void *address) { UNUSED(p); free(address); }
@@ -340,4 +340,4 @@ static const ISzAlloc g_Alloc = { SzAlloc, SzFree };
340340
return output;
341341
}
342342

343-
#endif //USE_LZMA
343+
#endif //INCLUDE_LZMA

src/core/u-gif.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef USE_GIF_CODEC
21
/***********************************************************************
32
**
43
** REBOL [R3] Language Interpreter and Run-time Environment
@@ -38,7 +37,7 @@
3837
***********************************************************************/
3938

4039
#include "sys-core.h"
41-
40+
#ifdef INCLUDE_GIF_CODEC
4241

4342
#define MAX_STACK_SIZE 4096
4443
#define NULL_CODE (-1)
@@ -355,4 +354,4 @@ void Chrom_Key_Alpha(REBVAL *v,REBCNT col,REBINT blitmode) {
355354
Register_Codec("gif", Codec_GIF_Image);
356355
}
357356

358-
#endif //USE_GIF_CODEC
357+
#endif //INCLUDE_GIF_CODEC

src/core/u-image-resize.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef USE_IMAGE_NATIVES
21
/***********************************************************************
32
**
43
** REBOL [R3] Language Interpreter and Run-time Environment
@@ -80,13 +79,16 @@
8079
%
8180
%
8281
*/
83-
82+
8483
/*
8584
Include declarations.
8685
*/
8786
#include "sys-core.h"
87+
88+
#ifdef INCLUDE_IMAGE_NATIVES
89+
8890
#include "sys-magick.h"
89-
91+
9092
/*
9193
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9294
% %
@@ -744,4 +746,4 @@ REBSER *ResizeImage(const REBSER *image,const REBCNT columns,
744746
return(resized_image);
745747
}
746748

747-
#endif // USE_IMAGE_NATIVES
749+
#endif // INCLUDE_IMAGE_NATIVES

src/core/u-jpg.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef USE_JPG_CODEC
21
/***********************************************************************
32
**
43
** jdatasrc.c
@@ -34,9 +33,11 @@
3433
3534
***********************************************************************/
3635

36+
#include "reb-config.h"
37+
#ifdef INCLUDE_JPG_CODEC
38+
3739
#define JPEG_INTERNALS
3840
#define NO_GETENV
39-
#include "reb-config.h"
4041
#include "reb-c.h"
4142
#include <setjmp.h>
4243
#include "sys-jpg.h"

src/core/u-lzma.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
#ifdef USE_LZMA
1+
//* Options ************************************************************
2+
3+
#if !defined(REBOL_OPTIONS_FILE)
4+
#include "opt-config.h"
5+
#else
6+
#include REBOL_OPTIONS_FILE
7+
#endif
8+
9+
#ifdef INCLUDE_LZMA
210

311
#include "sys-lzma.h"
412

@@ -5054,4 +5062,4 @@ SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
50545062
return res;
50555063
}
50565064

5057-
#endif // USE_LZMA
5065+
#endif // INCLUDE_LZMA

src/core/u-png.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef USE_PNG_CODEC
21
/***********************************************************************
32
**
43
** REBOL [R3] Language Interpreter and Run-time Environment
@@ -38,6 +37,7 @@
3837
***********************************************************************/
3938

4039
#include "sys-core.h"
40+
#ifdef INCLUDE_PNG_CODEC
4141
#include "sys-zlib.h"
4242

4343
#if defined(ENDIAN_LITTLE)
@@ -867,4 +867,4 @@ static void emitchunk(unsigned char **cpp,char *type,char *data,int length) {
867867
Register_Codec("png", Codec_PNG_Image);
868868
}
869869

870-
#endif //USE_PNG_CODEC
870+
#endif //INCLUDE_PNG_CODEC

src/core/u-wav.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#ifdef USE_WAV_CODEC
21
/***********************************************************************
32
**
43
** REBOL [R3] Language Interpreter and Run-time Environment
@@ -44,6 +43,7 @@
4443
***********************************************************************/
4544

4645
#include "sys-core.h"
46+
#ifdef INCLUDE_WAV_CODEC
4747

4848
//**********************************************************************
4949

src/include/opt-config.h

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/***********************************************************************
2+
**
3+
** REBOL [R3] Language Interpreter and Run-time Environment
4+
**
5+
** Copyright 2012 REBOL Technologies
6+
** REBOL is a trademark of REBOL Technologies
7+
**
8+
** Licensed under the Apache License, Version 2.0 (the "License");
9+
** you may not use this file except in compliance with the License.
10+
** You may obtain a copy of the License at
11+
**
12+
** http://www.apache.org/licenses/LICENSE-2.0
13+
**
14+
** Unless required by applicable law or agreed to in writing, software
15+
** distributed under the License is distributed on an "AS IS" BASIS,
16+
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
** See the License for the specific language governing permissions and
18+
** limitations under the License.
19+
**
20+
************************************************************************
21+
**
22+
** Summary: Optional (default) build configuration
23+
** Module: opt-config.h
24+
** Author: Oldes
25+
** Notes:
26+
** This file may be used to specify, which parts should be used or excluded
27+
**
28+
***********************************************************************/
29+
30+
#ifndef REBOL_OPTIONS_H
31+
32+
// native codecs ******************************************************/
33+
#define INCLUDE_BMP_CODEC // used in u-bmp.c file
34+
#define INCLUDE_PNG_CODEC // used in u-png.c file
35+
#define INCLUDE_JPG_CODEC // used in u-jpg.c file
36+
#define INCLUDE_GIF_CODEC // used in u-gif.c file
37+
38+
// native WAV codec was just a prove of concept, don't use it
39+
// there is more feature full Rebol implementation instead
40+
//#define INCLUDE_WAV_CODEC // used in u-wav.c file
41+
42+
43+
// optional compression & encoding *************************************/
44+
#define INCLUDE_LZMA // used in u-lzma.c, n-string.c and u-compress.c files
45+
#define INCLUDE_BASE85 // adds support for enbase/debase with base 85 (ASCII85)
46+
47+
48+
// optional devices ***************************************************/
49+
#define INCLUDE_MIDI_DEVICE
50+
51+
52+
// optional natives ***************************************************/
53+
#define INCLUDE_IMAGE_NATIVES
54+
55+
56+
// otional checksums **************************************************/
57+
//#define INCLUDE_MBEDTLS // used for checksum implementation so far (for crypt later)
58+
#define INCLUDE_MD4 // checksum: MD4 (unsecure)
59+
#define INCLUDE_RIPEMD160 // checksum: RIPE-MD-160 (requires USE_MBEDTLS)
60+
61+
62+
// unfinished features ************************************************/
63+
//#define INCLUDE_TASK // tasks are not implemented yet, so include it only on demand
64+
65+
66+
67+
// other options ******************************************************/
68+
69+
//#define HAS_WIDGET_GOB // used in t-gob.c
70+
71+
//#define EXCLUDE_CHACHA20POLY1305 // don't include chacha20 and poly1305 cipher/authentication code
72+
73+
//#define USE_EMPTY_HASH_AS_NONE // a single # means NONE, else error; Used in l-scan.c file
74+
75+
//#define DO_NOT_NORMALIZE_MAP_KEYS
76+
// with above define you would get:
77+
// [a b:] = keys-of make map! [a 1 b: 2]
78+
// [a 1 b: 2] = body-of make map! [a 1 b: 2]
79+
//
80+
// else:
81+
// [a b] = keys-of make map! [a 1 b: 2]
82+
// [a: 1 b: 2] = body-of make map! [a 1 b: 2]
83+
84+
//#define FORCE_ANSI_ESC_EMULATION_ON_WINDOWS // would not try to use MS' built-in VIRTUAL_TERMINAL_PROCESSING
85+
//#define EXCLUDE_VECTOR_MATH // don't include vector math support (like: 3 * #[vector! integer! 8 3 [1 2 3]]); Used in t-vector.c file
86+
//#define WRITE_ANY_VALUE_TO_CLIPBOARD // https://github.com/Oldes/Rebol-issues/issues/1619
87+
88+
89+
//#define SERIES_LABELS // used for special debug purposes
90+
//#define SHOW_SIZEOFS // for debugging ports to some systems
91+
//#define NDEBUG // removes some asserts
92+
93+
94+
95+
//**************************************************************//
96+
#include "opt-dependencies.h" // checks for above options
97+
98+
#endif //REBOL_OPTIONS_H

0 commit comments

Comments
 (0)