Skip to content

Commit fc55a59

Browse files
committed
Misc genconfig changes: Makefile, README, dist
1 parent 5f23b0f commit fc55a59

8 files changed

Lines changed: 77 additions & 36 deletions

File tree

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ DUKTAPE_SOURCES_SEPARATE = \
137137
$(DISTSRCSEP)/duk_bi_array.c \
138138
$(DISTSRCSEP)/duk_bi_boolean.c \
139139
$(DISTSRCSEP)/duk_bi_date.c \
140+
$(DISTSRCSEP)/duk_bi_date_unix.c \
141+
$(DISTSRCSEP)/duk_bi_date_windows.c \
140142
$(DISTSRCSEP)/duk_bi_error.c \
141143
$(DISTSRCSEP)/duk_bi_function.c \
142144
$(DISTSRCSEP)/duk_bi_global.c \
@@ -183,6 +185,7 @@ CCOPTS_FEATURES =
183185
#CCOPTS_FEATURES += -DDUK_OPT_NO_VOLUNTARY_GC
184186
CCOPTS_FEATURES += -DDUK_OPT_SEGFAULT_ON_PANIC # segfault on panic allows valgrind to show stack trace on panic
185187
CCOPTS_FEATURES += -DDUK_OPT_DPRINT_COLORS
188+
CCOPTS_FEATURES += -DDUK_OPT_DPRINT_RDTSC
186189
#CCOPTS_FEATURES += -DDUK_OPT_NO_FILE_IO
187190
#CCOPTS_FEATURES += '-DDUK_OPT_PANIC_HANDLER(code,msg)={printf("*** %d:%s\n",(code),(msg));abort();}'
188191
CCOPTS_FEATURES += -DDUK_OPT_SELF_TESTS

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Introduction
77
[Duktape](http://duktape.org/) is an **embeddable Javascript** engine,
88
with a focus on **portability** and **compact** footprint.
99

10-
Duktape is easy to integrate into a C/C++ project: add `duktape.c` and
11-
`duktape.h` to your build, and use the Duktape API to call Ecmascript
12-
functions from C code and vice versa.
10+
Duktape is easy to integrate into a C/C++ project: add `duktape.c`,
11+
`duktape.h`, and `duk_config.h` to your build, and use the Duktape API
12+
to call Ecmascript functions from C code and vice versa.
1313

1414
Main features:
1515

@@ -75,7 +75,8 @@ the website, run test cases, etc:
7575

7676
# Install required packages (exact packages depend on distribution)
7777
$ sudo apt-get install nodejs nodejs-legacy npm perl ant openjdk-7-jdk \
78-
libreadline6-dev libncurses-dev python-rdflib python-bs4 clang llvm
78+
libreadline6-dev libncurses-dev python-rdflib python-bs4 python-yaml \
79+
clang llvm
7980

8081
# Compile the command line tool ('duk')
8182
$ git clone https://github.com/svaarala/duktape.git

dist-files/Makefile.cmdline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ DUKTAPE_CMDLINE_SOURCES = \
1010

1111
CC = gcc
1212
CCOPTS = -Os -pedantic -std=c99 -Wall -fstrict-aliasing -fomit-frame-pointer
13-
CCOPTS += -I./src
13+
CCOPTS += -I./src # duktape.h and duk_config.h must be in include path
1414
CCLIBS = -lm
1515

1616
# If you have readline, you may want to enable these. On some platforms

dist-files/Makefile.hello

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#
22
# Example Makefile for building a program with embedded Duktape.
33
#
4-
# There are two source sets in the distribution: combined sources where
5-
# you only need duktape.c and duktape.h, and separate sources where you
6-
# have a bunch of source and header files. Whichever you use, simply
7-
# include the relevant sources into your C project. This Makefile uses
8-
# the combined source file.
4+
# There are two source sets in the distribution: (1) combined sources where
5+
# you only need duktape.c, duktape.h, and duk_config.h, and (2) separate
6+
# sources where you have a bunch of source and header files. Whichever
7+
# you use, simply include the relevant sources into your C project. This
8+
# Makefile uses the combined source file.
99
#
1010

1111
DUKTAPE_SOURCES = src/duktape.c

dist-files/README.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,14 @@ To build an example command line tool, use the following::
5252

5353
This distributable contains:
5454

55-
* ``src/``: main Duktape library in a "single file" format (duktape.c and
56-
duktape.h)
55+
* ``src/``: main Duktape library in a "single file" format (duktape.c,
56+
duktape.h, and duk_config.h).
5757

5858
* ``src-separate/``: main Duktape library in multiple files format.
5959

60+
* ``config/``: genconfig utility for creating duk_config.h configuration
61+
files for non-mainline platforms, and some prebuilt config headers.
62+
6063
* ``examples/``: further examples for using Duktape. Although Duktape
6164
itself is widely portable, some of the examples are Linux only.
6265
For instance the ``eventloop`` example illustrates how ``setTimeout()``

util/check_code_policy.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(self, filename, linenumber, line, reason):
3333
re_nonascii = re.compile(r'^.*?[\x80-\xff].*?$')
3434
re_func_decl_or_def = re.compile(r'^(\w+)\s+(?:\w+\s+)*(\w+)\(.*?.*?$') # may not finish on same line
3535

36-
# These identifiers are wrapped in duk_features.h.in, and should only be used
36+
# These identifiers are wrapped in duk_config.h, and should only be used
3737
# through the wrappers elsewhere.
3838
rejected_plain_identifiers_list = [
3939
# math classification
@@ -254,8 +254,7 @@ def checkIdentifiers(lines, idx, filename):
254254
line = lines[idx]
255255
# XXX: this now executes for every line which is pointless
256256
bn = os.path.basename(filename)
257-
excludePlain = (bn == 'duk_features.h.in' or \
258-
bn[0:5] == 'test-')
257+
excludePlain = (bn[0:5] == 'test-')
259258

260259
for m in re.finditer(re_identifier, line):
261260
if rejected_plain_identifiers.has_key(m.group(0)):
@@ -296,9 +295,7 @@ def checkNoSymbolVisibility(lines, idx, filename):
296295
return
297296

298297
# Special exceptions
299-
if bn == 'duk_features.h.in' and 'static __inline__' in line:
300-
# duk_rdtsc(), gcc specific
301-
return
298+
# (None now)
302299

303300
raise Exception('missing symbol visibility macro')
304301

util/combine_src.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ def createCombined(files, extinc, intinc, duk_version, git_commit, git_describe,
136136

137137
emit_state = [ None, None ] # curr_filename, curr_lineno
138138

139-
# Because duktape.c/duktape.h are often distributed or included in project
140-
# sources as is, add a license reminder and Duktape version information
141-
# to the duktape.c header (duktape.h already contains them).
139+
# Because duktape.c/duktape.h/duk_config.h are often distributed or
140+
# included in project sources as is, add a license reminder and
141+
# Duktape version information to the duktape.c header (duktape.h
142+
# already contains them).
142143

143144
duk_major = duk_version / 10000
144145
duk_minor = duk_version / 100 % 100

util/make_dist.sh

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ while [ $# -gt 0 ]; do
3131
shift
3232
done
3333

34+
ENTRYPWD=`pwd`
3435
DIST=`pwd`/dist
3536
DISTSRCSEP=$DIST/src-separate
3637
DISTSRCCOM=$DIST/src
@@ -56,6 +57,7 @@ rm -rf $DIST
5657
mkdir $DIST
5758
mkdir $DIST/src-separate
5859
mkdir $DIST/src
60+
mkdir $DIST/config
5961
mkdir $DIST/extras
6062
mkdir $DIST/polyfills
6163
#mkdir $DIST/doc
@@ -76,6 +78,7 @@ mkdir $DIST/examples/alloc-torture
7678
mkdir $DIST/examples/alloc-hybrid
7779
mkdir $DIST/examples/debug-trans-socket
7880
mkdir $DIST/examples/codepage-conv
81+
mkdir $DIST/examples/dummy-date-provider
7982

8083
# Copy most files directly
8184

@@ -98,6 +101,8 @@ for i in \
98101
duk_bi_boolean.c \
99102
duk_bi_buffer.c \
100103
duk_bi_date.c \
104+
duk_bi_date_unix.c \
105+
duk_bi_date_windows.c \
101106
duk_bi_duktape.c \
102107
duk_bi_error.c \
103108
duk_bi_function.c \
@@ -200,6 +205,21 @@ for i in \
200205
cp src/$i $DISTSRCSEP/
201206
done
202207

208+
cd $ENTRYPWD/config
209+
tar cfz $DIST/config/genconfig_metadata.tar.gz \
210+
tags.yaml \
211+
feature-options \
212+
config-options \
213+
header-snippets \
214+
other-defines
215+
cd $ENTRYPWD
216+
for i in \
217+
README.rst \
218+
genconfig.py \
219+
; do
220+
cp config/$i $DIST/config/
221+
done
222+
203223
for i in \
204224
README.rst \
205225
Makefile \
@@ -349,6 +369,13 @@ for i in \
349369
cp examples/codepage-conv/$i $DIST/examples/codepage-conv/
350370
done
351371

372+
for i in \
373+
README.rst \
374+
dummy_date_provider.c \
375+
; do
376+
cp examples/dummy-date-provider/$i $DIST/examples/dummy-date-provider/
377+
done
378+
352379
cp extras/README.rst $DIST/extras/
353380
# XXX: copy extras
354381

@@ -395,6 +422,23 @@ echo '/*' > $DIST/AUTHORS.rst.tmp
395422
cat AUTHORS.rst | python util/make_ascii.py | sed -e 's/^/ \* /' >> $DIST/AUTHORS.rst.tmp
396423
echo ' */' >> $DIST/AUTHORS.rst.tmp
397424

425+
# Build duk_config.h from snippets using genconfig.
426+
python config/genconfig.py --metadata config --output $DIST/duk_config.h.tmp \
427+
generate-autodetect-header
428+
cp $DIST/duk_config.h.tmp $DISTSRCCOM/duk_config.h
429+
cp $DIST/duk_config.h.tmp $DISTSRCSEP/duk_config.h
430+
cp $DIST/duk_config.h.tmp $DIST/config/duk_config.h-autodetect
431+
432+
# Generate a few barebones config examples
433+
python config/genconfig.py --metadata config --emit-legacy-feature-check --emit-config-sanity-check --omit-removed-config-options --omit-unused-config-options \
434+
--output $DIST/config/duk_config.h-linux-gcc-x64 \
435+
--platform linux --compiler gcc --architecture x64 \
436+
generate-barebones-header
437+
python config/genconfig.py --metadata config --emit-legacy-feature-check --emit-config-sanity-check --omit-removed-config-options --omit-unused-config-options \
438+
--output $DIST/config/duk_config.h-linux-gcc-x86 \
439+
--platform linux --compiler gcc --architecture x86 \
440+
generate-barebones-header
441+
398442
# Build duktape.h from parts, with some git-related replacements.
399443
# The only difference between single and separate file duktape.h
400444
# is the internal DUK_SINGLE_FILE define.
@@ -415,18 +459,10 @@ cat src/duktape.h.in | sed -e '
415459
r dist/AUTHORS.rst.tmp
416460
d
417461
}
418-
/^@DUK_FEATURES_H@$/ {
419-
r src/duk_features.h.in
420-
d
421-
}
422462
/^@DUK_API_PUBLIC_H@$/ {
423463
r src/duk_api_public.h.in
424464
d
425465
}
426-
/^@DUK_FEATURES_SANITY_H@$/ {
427-
r src/duk_features_sanity.h.in
428-
d
429-
}
430466
/^@DUK_DBLUNION_H@$/ {
431467
r src/duk_dblunion.h.in
432468
d
@@ -737,13 +773,13 @@ done
737773
rm $DISTSRCSEP/caseconv.txt
738774

739775
# Create a combined source file, duktape.c, into a separate combined source
740-
# directory. This allows user to just include "duktape.c" and "duktape.h"
741-
# into a project and maximizes inlining and size optimization opportunities
742-
# even with older compilers. Because some projects include these files into
743-
# their repository, the result should be deterministic and diffable. Also,
744-
# it must retain __FILE__/__LINE__ behavior through preprocessor directives.
745-
# Whitespace and comments can be stripped as long as the other requirements
746-
# are met.
776+
# directory. This allows user to just include "duktape.c", "duktape.h", and
777+
# "duk_config.h" into a project and maximizes inlining and size optimization
778+
# opportunities even with older compilers. Because some projects include
779+
# these files into their repository, the result should be deterministic and
780+
# diffable. Also, it must retain __FILE__/__LINE__ behavior through
781+
# preprocessor directives. Whitespace and comments can be stripped as long
782+
# as the other requirements are met.
747783

748784
python util/combine_src.py $DISTSRCSEP $DISTSRCCOM/duktape.c \
749785
"$DUK_VERSION" "$GIT_COMMIT" "$GIT_DESCRIBE" \

0 commit comments

Comments
 (0)