Skip to content

Commit 00a8627

Browse files
committed
Documentation changes for tools reorg
1 parent 9e8f16c commit 00a8627

6 files changed

Lines changed: 101 additions & 26 deletions

File tree

config/README.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ Usage
2525

2626
To create an autodetect duk_config.h header (compatible with Duktape 1.2.x)::
2727

28-
$ python config/genconfig.py --metadata config --output /tmp/duk_config.h \
29-
autodetect-header
28+
$ python tools/genconfig.py --metadata config --output /tmp/duk_config.h \
29+
duk-config-header
3030

3131
To create a barebones duk_config.h header for a specific platform (easier to
3232
edit manually)::
3333

34-
$ python config/genconfig.py --metadata config --output /tmp/duk_config.h \
34+
$ python tools/genconfig.py --metadata config --output /tmp/duk_config.h \
3535
--platform linux --compiler gcc --architecture x64 \
36-
barebones-header
36+
duk-config-header
3737

3838
There are further commands to e.g. autogenerate config option documentation;
3939
see ``genconfig.py`` for details.

dist-files/README.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,15 @@ This distributable contains:
6767

6868
* ``src-separate/``: main Duktape library in multiple files format.
6969

70-
* ``config/``: genconfig utility for creating duk_config.h configuration
70+
* ``src-input/``: raw input source files used for a config-and-prepare which
71+
recreates the combined/separate prepared sources with specific options.
72+
73+
* ``tools/``: various Python tools, such as prepare_sources.py for doing a
74+
config-and-prepare and genconfig.py for creating duk_config.h configuration
7175
files, see: http://wiki.duktape.org/Configuring.html.
7276

77+
* ``config/``: configuration metadata for genconfig.py.
78+
7379
* ``examples/``: further examples for using Duktape. Although Duktape
7480
itself is widely portable, some of the examples are Linux only.
7581
For instance the ``eventloop`` example illustrates how ``setTimeout()``

doc/duk-config.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Using genconfig
9494
Overview of genconfig
9595
---------------------
9696

97-
Genconfig (``config/genconfig.py``) is a helper script which provides
97+
Genconfig (``tools/genconfig.py``) is a helper script which provides
9898
several commands related to config handling:
9999

100100
* Generate a ``duk_config.h`` for a specified platform, compiler, and
@@ -121,16 +121,16 @@ To generate an autodetect header suitable for directly supported platforms
121121
# The --metadata option can point to a metadata directory or a tar.gz
122122
# file with packed metadata (included in end user distributable).
123123

124-
$ cd duktape-1.4.0
125-
$ python config/genconfig.py \
124+
$ cd duktape-2.0.0
125+
$ python tools/genconfig.py \
126126
--metadata config/genconfig_metadata.tar.gz \
127127
--output /tmp/duk_config.h \
128128
duk-config-header
129129

130130
# The same command using unpacked metadata present in Duktape source repo.
131131

132-
$ cd duktape
133-
$ python config/genconfig.py \
132+
$ cd duktape-2.0.0
133+
$ python tools/genconfig.py \
134134
--metadata config/ \
135135
--output /tmp/duk_config.h \
136136
duk-config-header
@@ -145,7 +145,7 @@ through a file or inline.
145145

146146
If you're building Duktape as a DLL, you should use the ``--dll`` option::
147147

148-
$ python config/genconfig.py \
148+
$ python tools/genconfig.py \
149149
--metadata config/ \
150150
--dll \
151151
--output /tmp/duk_config.h \
@@ -167,7 +167,7 @@ Generating a barebones duk_config.h
167167
To generate a barebones header you need to specify a platform, compiler, and
168168
architecture for genconfig::
169169

170-
$ python config/genconfig.py \
170+
$ python tools/genconfig.py \
171171
--metadata config/ \
172172
--platform linux \
173173
--compiler gcc \
@@ -229,7 +229,7 @@ file, and a few options are then tweaked using the C compiler format. An
229229
autodetect header is then generated::
230230

231231
$ cd duktape
232-
$ python config/genconfig.py \
232+
$ python tools/genconfig.py \
233233
--metadata config/ \
234234
--option-file low_memory.yaml \
235235
-DDUK_USE_TRACEBACK_DEPTH=100 \
@@ -254,7 +254,7 @@ This file, another override file, and a few inline YAML forced options
254254
could be used as follows to generate a barebones header::
255255

256256
$ cd duktape
257-
$ python config/genconfig.py \
257+
$ python tools/genconfig.py \
258258
--metadata config/ \
259259
--platform linux \
260260
--compiler gcc \
@@ -264,7 +264,7 @@ could be used as follows to generate a barebones header::
264264
--option-yaml 'DUK_USE_JX: false' \
265265
--option-yaml 'DUK_USE_JC: false' \
266266
--output /tmp/duk_config.h \
267-
barebones-header
267+
duk-config-header
268268

269269
For inline YAML, multiple forced options can be given either by using a YAML
270270
value with multiple keys, or by using multiple options::
@@ -335,15 +335,15 @@ sanity checks (if enabled).
335335

336336
For example, to generate a barebones header with two fixup headers::
337337

338-
$ python config/genconfig.py \
338+
$ python tools/genconfig.py \
339339
--metadata config/ \
340340
--platform linux \
341341
--compiler gcc \
342342
--architecture x64 \
343343
--fixup-file my_env_strings.h \
344344
--fixup-file my_no_json_fastpath.h \
345345
--output /tmp/duk_config.h \
346-
barebones-header
346+
duk-config-header
347347

348348
The ``my_env_strings.h`` fixup header could be::
349349

@@ -476,7 +476,7 @@ header::
476476
# my_custom.h is applied after generated header; functionally similar
477477
# to Duktape 1.2.x duk_custom.h
478478

479-
$ python config/ genconfig.py [...] --fixup-file my_custom.h [...]
479+
$ python tools/genconfig.py [...] --fixup-file my_custom.h [...]
480480

481481
A genconfig-generated barebones header also has the following line near the end
482482
for detecting where to add override defines; this is easy to detect reliably::

doc/low-memory.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,12 @@ The following may be appropriate when even less memory is available
344344
is more memory efficient: it creates a writable (empty) global object
345345
which inherits from the ROM global object.
346346

347-
- Rerun ``make_dist.py`` with ``--rom-support`` to create a distributable
348-
with support for ROM builtins. ROM builtin support is not enabled by
349-
default because it increases the size of ``duktape.c`` considerably.
350-
Add the option ``--rom-auto-lightfunc`` to convert built-in function
351-
properties into lightfuncs to reduce ROM footprint. (See
352-
``util/example_rombuild.sh`` for some very simple examples.)
347+
- Rerun ``prepare_sources.py`` with ``--rom-support`` to create prepared
348+
sources with support for ROM builtins. ROM builtin support is not
349+
enabled by default because it increases the size of ``duktape.c``
350+
considerably. Add the option ``--rom-auto-lightfunc`` to convert
351+
built-in function properties into lightfuncs to reduce ROM footprint.
352+
(See ``util/example_rombuild.sh`` for some very simple examples.)
353353

354354
- Moving built-ins into ROM makes them read-only which has some side
355355
effects. Some side effects are technical compliance issues while
@@ -377,8 +377,8 @@ The following may be appropriate when even less memory is available
377377

378378
+ ``src/builtins.yaml``: documents some more format details
379379

380-
+ ``util/example_rombuild.sh``: illustrates how to run ``make_dist.py``
381-
with user builtins
380+
+ ``util/example_rombuild.sh``: illustrates how to run
381+
``prepare_sources.py`` with user builtins
382382

383383
* Consider using lightfuncs for representing function properties of ROM
384384
built-ins.

tools/README.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
=============
2+
Duktape tools
3+
=============
4+
5+
This directory contains various Duktape Python tools which are included in
6+
the end user distributable.
7+
8+
The main use case is config-and-prepare which simultaneously creates
9+
a ``duk_config.h`` configuration file and prepares source files for
10+
compilation. These two operations are combined because:
11+
12+
1. Configuration options may affect source file preparation.
13+
14+
2. Some features involve metaprogramming. For example, when using ROM
15+
built-ins YAML metadata is used for automatic code generation for the
16+
ROM object initializers.
17+
18+
There are also other miscellaneous tools, e.g. utilities to scan potential
19+
fixed strings from source files, dump bytecode, and resolving file/line
20+
from combined source.
21+
22+
Because this tooling is part of the end user distributable, the tooling must
23+
be as portable as possible. For example:
24+
25+
* Avoid Unix path separators.
26+
27+
* Avoid depending on Python executable name, use ``sys.executable`` instead
28+
to launch Python commands.
29+
30+
The tooling has been written for Python 2.x and there's no support for
31+
Python 3.x at present.
32+
33+
TODO
34+
====
35+
36+
- Go through all .py files once more and figure out what to move into tools
37+
38+
- Go through all moves, and git grep for "call sites"
39+
40+
- Add dist/config/genconfig.py copy for convenience?
41+
42+
STEPS
43+
=====
44+
45+
- Move all scripts that should be in the end user distributable into 'tools/'.
46+
47+
- Change all references for the scripts for their new location so that existing
48+
dist and build works. No other changes at this point.
49+
50+
- Split make_dist.py into two parts:
51+
52+
1. Revised dist part which first copies files into the end user distributable
53+
and then runs the prepare step *in the distributable* for the default
54+
configuration.
55+
56+
2. Separate config-and-prepare utility which does most of the current dist
57+
processing. This will take the --rom-auto-lightfunc and other stuff now.
58+
It also interfaces with genconfig.
59+
60+
- Update documentation: new locations (e.g. in genconfig docs, READMEs etc),
61+
new config process, ROM built-in stuff, etc.
62+
63+
- At this point the initial rework is complete.

util/README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
=======================
2+
Miscellaneous utilities
3+
=======================
4+
5+
This directory contains miscellaneous Python, Shell, and other utilities
6+
which are not part of the end user distributable.

0 commit comments

Comments
 (0)