Browse Source

Switch configure/dist to Node.js wrappers

Refactor tools/configure.py and util/dist.py to be just wrappers to
executing the Node.js based tooling.  The wrapper .py files are both
Py2 and Py3 compatible.  Node.js version must be >= 14.x.
pull/2385/head
Sami Vaarala 4 years ago
parent
commit
bc64401eba
  1. 8
      .gitignore
  2. 125
      Makefile
  3. 11
      README.md
  4. 171
      appveyor.yml
  5. 2
      dist-files/README.rst
  6. 1
      tests/configure/test_minimal.sh
  7. 1025
      tools/configure.py
  8. 883
      util/dist.py
  9. 2
      util/makeduk_base.yaml

8
.gitignore

@ -34,3 +34,11 @@ ms_print.*
/references/ECMA-262 5.1 edition June 2011.pdf /references/ECMA-262 5.1 edition June 2011.pdf
/references/ECMA-262.pdf /references/ECMA-262.pdf
/tests/octane/octane /tests/octane/octane
/src-tools/from-xml
/src-tools/js-yaml
/src-tools/node_modules
/src-tools/lib/extdeps
/src-tools/lib/extdeps/from-xml.js
/src-tools/lib/extdeps/js-yaml.js
/src-tools/package-lock.json
/src-tools/duktool.js

125
Makefile

@ -39,6 +39,7 @@ NODE := $(shell { command -v nodejs || command -v node; } 2>/dev/null)
WGET := $(shell command -v wget 2>/dev/null) WGET := $(shell command -v wget 2>/dev/null)
JAVA := $(shell command -v java 2>/dev/null) JAVA := $(shell command -v java 2>/dev/null)
VALGRIND := $(shell command -v valgrind 2>/dev/null) VALGRIND := $(shell command -v valgrind 2>/dev/null)
#PYTHON := $(shell { command -v python3 || command -v python; } 2>/dev/null)
PYTHON := $(shell { command -v python2 || command -v python; } 2>/dev/null) PYTHON := $(shell { command -v python2 || command -v python; } 2>/dev/null)
DOCKER := docker DOCKER := docker
SCAN_BUILD := scan-build-7 SCAN_BUILD := scan-build-7
@ -249,6 +250,7 @@ clean:
@rm -rf oprofile_data/ @rm -rf oprofile_data/
@rm -f /tmp/duk-test-eval-file-temp.js # used by tests/api/test-eval-file.js @rm -f /tmp/duk-test-eval-file-temp.js # used by tests/api/test-eval-file.js
@rm -f a.out @rm -f a.out
@cd src-tools; make clean
.PHONY: cleanall .PHONY: cleanall
cleanall: clean cleanall: clean
@ -257,6 +259,7 @@ cleanall: clean
@rm -f "references/ECMA-262 5th edition December 2009.pdf" @rm -f "references/ECMA-262 5th edition December 2009.pdf"
@rm -f "references/ECMA-262 5.1 edition June 2011.pdf" @rm -f "references/ECMA-262 5.1 edition June 2011.pdf"
@rm -f "references/ECMA-262.pdf" @rm -f "references/ECMA-262.pdf"
@cd src-tools; make cleanall
# External dependencies. # External dependencies.
deps: deps:
@ -274,63 +277,72 @@ build:
dist: dist:
@mkdir -p $@ @mkdir -p $@
# Duktape configurations.
prep:
@mkdir -p prep
# Targets for tooling. # Targets for tooling.
build/duktool.js: | build build/duktool.js: | build
make -C src-tools make -C src-tools
cp src-tools/duktool.js $@ cp src-tools/duktool.js $@
# Targets for preparing different Duktape configurations. # Targets for preparing different Duktape configurations.
prep: .PHONY: prep-duktool
@mkdir -p prep prep-duktool: src-tools/duktool.js
prep/nondebug: prep src-tools/duktool.js:
@cd src-tools && make
@touch $@
.PHONY: configure-deps
configure-deps: prep-duktool
prep/nondebug: configure-deps | prep
@rm -rf ./prep/nondebug @rm -rf ./prep/nondebug
$(PYTHON) tools/configure.py --output-directory ./prep/nondebug --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/nondebug --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG) --line-directives
prep/nondebug-scanbuild: prep prep/nondebug-scanbuild: configure-deps | prep
@rm -rf ./prep/nondebug-scanbuild @rm -rf ./prep/nondebug-scanbuild
$(PYTHON) tools/configure.py --output-directory ./prep/nondebug-scanbuild --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_SCANBUILD) --separate-sources --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/nondebug-scanbuild --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_SCANBUILD) --separate-sources --line-directives
prep/nondebug-perf: prep prep/nondebug-perf: configure-deps | prep
@rm -rf ./prep/nondebug-perf @rm -rf ./prep/nondebug-perf
$(PYTHON) tools/configure.py --output-directory ./prep/nondebug-perf --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_PERF) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/nondebug-perf --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_PERF) --line-directives
prep/nondebug-size: prep prep/nondebug-size: configure-deps | prep
@rm -rf ./prep/nondebug-size @rm -rf ./prep/nondebug-size
$(PYTHON) tools/configure.py --output-directory ./prep/nondebug-size --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_SIZE) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/nondebug-size --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_SIZE) --line-directives
prep/nondebug-rom: prep prep/nondebug-rom: configure-deps | prep
@rm -rf ./prep/nondebug-rom @rm -rf ./prep/nondebug-rom
$(PYTHON) tools/configure.py --output-directory ./prep/nondebug-rom --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_ROM) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/nondebug-rom --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_ROM) --line-directives
prep/debug: prep prep/debug: configure-deps | prep
@rm -rf ./prep/debug @rm -rf ./prep/debug
$(PYTHON) tools/configure.py --output-directory ./prep/debug --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/debug --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG) --line-directives
prep/fuzz: prep prep/fuzz: | prep
@rm -rf ./prep/fuzz @rm -rf ./prep/fuzz
$(PYTHON) tools/configure.py --output-directory ./prep/fuzz --source-directory src-input --config-metadata config $(CONFIGOPTS_FUZZ) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/fuzz --source-directory src-input --config-metadata config $(CONFIGOPTS_FUZZ) --line-directives
prep/debug-scanbuild: prep prep/debug-scanbuild: configure-deps | prep
@rm -rf ./prep/debug-scanbuild @rm -rf ./prep/debug-scanbuild
$(PYTHON) tools/configure.py --output-directory ./prep/debug-scanbuild --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG_SCANBUILD) --separate-sources --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/debug-scanbuild --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG_SCANBUILD) --separate-sources --line-directives
prep/debug-rom: prep prep/debug-rom: configure-deps | prep
@rm -rf ./prep/debug-rom @rm -rf ./prep/debug-rom
$(PYTHON) tools/configure.py --output-directory ./prep/debug-rom --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG_ROM) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/debug-rom --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG_ROM) --line-directives
prep/emduk: prep prep/emduk: configure-deps | prep
@rm -rf ./prep/emduk @rm -rf ./prep/emduk
$(PYTHON) tools/configure.py --output-directory ./prep/emduk --source-directory src-input --config-metadata config $(CONFIGOPTS_EMDUK) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/emduk --source-directory src-input --config-metadata config $(CONFIGOPTS_EMDUK) --line-directives
prep/dukweb: prep prep/dukweb: configure-deps | prep
@rm -rf ./prep/dukweb @rm -rf ./prep/dukweb
$(PYTHON) tools/configure.py --output-directory ./prep/dukweb --source-directory src-input --config-metadata config $(CONFIGOPTS_DUKWEB) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/dukweb --source-directory src-input --config-metadata config $(CONFIGOPTS_DUKWEB) --line-directives
prep/duklow-nondebug: prep prep/duklow-nondebug: configure-deps | prep
@rm -rf ./prep/duklow-nondebug @rm -rf ./prep/duklow-nondebug
$(PYTHON) tools/configure.py --output-directory ./prep/duklow-nondebug --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_DUKLOW) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/duklow-nondebug --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_DUKLOW) --line-directives
prep/duklow-debug: prep prep/duklow-debug: configure-deps | prep
@rm -rf ./prep/duklow-debug @rm -rf ./prep/duklow-debug
$(PYTHON) tools/configure.py --output-directory ./prep/duklow-debug --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG_DUKLOW) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/duklow-debug --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG_DUKLOW) --line-directives
prep/duklow-nondebug-rom: prep prep/duklow-nondebug-rom: configure-deps | prep
@rm -rf ./prep/duklow-nondebug-rom @rm -rf ./prep/duklow-nondebug-rom
$(PYTHON) tools/configure.py --output-directory ./prep/duklow-nondebug-rom --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_DUKLOW_ROM) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/duklow-nondebug-rom --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_DUKLOW_ROM) --line-directives
prep/duklow-debug-rom: prep prep/duklow-debug-rom: configure-deps | prep
@rm -rf ./prep/duklow-debug-rom @rm -rf ./prep/duklow-debug-rom
$(PYTHON) tools/configure.py --output-directory ./prep/duklow-debug-rom --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG_DUKLOW_ROM) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/duklow-debug-rom --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG_DUKLOW_ROM) --line-directives
prep/duklow-nondebug-norefc: prep prep/duklow-nondebug-norefc: configure-deps | prep
@rm -rf ./prep/duklow-nondebug-norefc @rm -rf ./prep/duklow-nondebug-norefc
$(PYTHON) tools/configure.py --output-directory ./prep/duklow-nondebug-norefc --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_DUKLOW_NOREFC) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/duklow-nondebug-norefc --source-directory src-input --config-metadata config $(CONFIGOPTS_NONDEBUG_DUKLOW_NOREFC) --line-directives
prep/duklow-debug-norefc: prep prep/duklow-debug-norefc: configure-deps | prep
@rm -rf ./prep/duklow-debug-norefc @rm -rf ./prep/duklow-debug-norefc
$(PYTHON) tools/configure.py --output-directory ./prep/duklow-debug-norefc --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG_DUKLOW_NOREFC) --line-directives $(PYTHON) tools/configure.py --output-directory ./prep/duklow-debug-norefc --source-directory src-input --config-metadata config $(CONFIGOPTS_DEBUG_DUKLOW_NOREFC) --line-directives
@ -351,11 +363,11 @@ DUK_SOURCE_DEPS=$(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(LINENOISE_HEAD
duk: build/duk # Convenience target. duk: build/duk # Convenience target.
cp $< $@ cp $< $@
build/duk: prep/nondebug $(DUK_SOURCE_DEPS) | build build/duk: $(DUK_SOURCE_DEPS) | build prep/nondebug
$(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-pgo: prep/nondebug $(DUK_SOURCE_DEPS) | build build/duk-pgo: $(DUK_SOURCE_DEPS) | build prep/nondebug
@echo "Compiling with -fprofile-generate..." @echo "Compiling with -fprofile-generate..."
@rm -f *.gcda @rm -f *.gcda
$(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -fprofile-generate prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -fprofile-generate prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ -369,31 +381,31 @@ build/duk-pgo: prep/nondebug $(DUK_SOURCE_DEPS) | build
$(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -fprofile-use prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -fprofile-use prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-perf: prep/nondebug-perf $(DUK_SOURCE_DEPS) | build build/duk-perf: $(DUK_SOURCE_DEPS) | build prep/nondebug-perf
$(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-size: prep/nondebug-size $(DUK_SOURCE_DEPS) | build build/duk-size: $(DUK_SOURCE_DEPS) | build prep/nondebug-size
$(CC) -o $@ -Iprep/nondebug-size $(CCOPTS_NONDEBUG) prep/nondebug-size/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug-size $(CCOPTS_NONDEBUG) prep/nondebug-size/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-rom: prep/nondebug-rom $(DUK_SOURCE_DEPS) | build build/duk-rom: $(DUK_SOURCE_DEPS) | build prep/nondebug-rom
$(CC) -o $@ -Iprep/nondebug-rom $(CCOPTS_NONDEBUG) prep/nondebug-rom/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug-rom $(CCOPTS_NONDEBUG) prep/nondebug-rom/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/dukd: prep/debug $(DUK_SOURCE_DEPS) | build build/dukd: $(DUK_SOURCE_DEPS) | build prep/debug
$(CC) -o $@ -Iprep/debug $(CCOPTS_DEBUG) prep/debug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/debug $(CCOPTS_DEBUG) prep/debug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/dukd-rom: prep/debug-rom $(DUK_SOURCE_DEPS) | build build/dukd-rom: $(DUK_SOURCE_DEPS) | build prep/debug-rom
$(CC) -o $@ -Iprep/debug-rom $(CCOPTS_DEBUG) prep/debug-rom/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/debug-rom $(CCOPTS_DEBUG) prep/debug-rom/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk.O2: prep/nondebug $(DUK_SOURCE_DEPS) | build build/duk.O2: $(DUK_SOURCE_DEPS) | build prep/nondebug
$(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -O2 prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -O2 prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-pgo.O2: prep/nondebug $(DUK_SOURCE_DEPS) | build build/duk-pgo.O2: $(DUK_SOURCE_DEPS) | build prep/nondebug
@echo "Compiling with -fprofile-generate..." @echo "Compiling with -fprofile-generate..."
@rm -f *.gcda @rm -f *.gcda
$(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -O2 -fprofile-generate prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -O2 -fprofile-generate prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ -407,11 +419,11 @@ build/duk-pgo.O2: prep/nondebug $(DUK_SOURCE_DEPS) | build
$(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -O2 -fprofile-use prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -O2 -fprofile-use prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-perf.O2: prep/nondebug-perf $(DUK_SOURCE_DEPS) | build build/duk-perf.O2: $(DUK_SOURCE_DEPS) | build prep/nondebug-perf
$(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) -O2 prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) -O2 prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-perf-pgo.O2: prep/nondebug-perf $(DUK_SOURCE_DEPS) | build build/duk-perf-pgo.O2: $(DUK_SOURCE_DEPS) | build prep/nondebug-perf
@echo "Compiling with -fprofile-generate..." @echo "Compiling with -fprofile-generate..."
@rm -f *.gcda @rm -f *.gcda
$(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) -O2 -fprofile-generate prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) -O2 -fprofile-generate prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ -423,59 +435,59 @@ build/duk-perf-pgo.O2: prep/nondebug-perf $(DUK_SOURCE_DEPS) | build
@rm -f $@ @rm -f $@
@echo "Recompiling with -fprofile-use..." @echo "Recompiling with -fprofile-use..."
$(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) -O2 -fprofile-use prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) -O2 -fprofile-use prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
build/duk.O3: prep/nondebug $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) | deps/linenoise build/duk.O3: $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) | deps/linenoise prep/nondebug
$(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -O3 prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -O3 prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-perf.O3: prep/nondebug-perf $(DUK_SOURCE_DEPS) | build build/duk-perf.O3: $(DUK_SOURCE_DEPS) | build prep/nondebug-perf
$(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) -O3 prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) -O3 prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk.O4: prep/nondebug $(DUK_SOURCE_DEPS) | build build/duk.O4: $(DUK_SOURCE_DEPS) | build prep/nondebug
$(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -O4 prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug $(CCOPTS_NONDEBUG) -O4 prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-perf.O4: prep/nondebug-perf $(DUK_SOURCE_DEPS) | build build/duk-perf.O4: $(DUK_SOURCE_DEPS) | build prep/nondebug-perf
$(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) -O4 prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CC) -o $@ -Iprep/nondebug-perf $(CCOPTS_NONDEBUG) -O4 prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-clang: prep/nondebug $(DUK_SOURCE_DEPS) | build build/duk-clang: $(DUK_SOURCE_DEPS) | build prep/nondebug
@# Use -Wcast-align to trigger issues like: https://github.com/svaarala/duktape/issues/270 @# Use -Wcast-align to trigger issues like: https://github.com/svaarala/duktape/issues/270
@# Use -Wshift-sign-overflow to trigger issues like: https://github.com/svaarala/duktape/issues/812 @# Use -Wshift-sign-overflow to trigger issues like: https://github.com/svaarala/duktape/issues/812
@# -Weverything @# -Weverything
$(CLANG) -o $@ -Wcast-align -Wshift-sign-overflow -Iprep/nondebug $(CLANG_CCOPTS_NONDEBUG) prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CLANG) -o $@ -Wcast-align -Wshift-sign-overflow -Iprep/nondebug $(CLANG_CCOPTS_NONDEBUG) prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-sanitize-clang: prep/nondebug $(DUK_SOURCE_DEPS) | build build/duk-sanitize-clang: $(DUK_SOURCE_DEPS) | build prep/nondebug
$(CLANG) -o $@ -Wcast-align -Wshift-sign-overflow -fsanitize=undefined -Iprep/nondebug $(CLANG_CCOPTS_NONDEBUG) prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CLANG) -o $@ -Wcast-align -Wshift-sign-overflow -fsanitize=undefined -Iprep/nondebug $(CLANG_CCOPTS_NONDEBUG) prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-fuzzilli: prep/fuzz $(DUK_SOURCE_DEPS) | build build/duk-fuzzilli: $(DUK_SOURCE_DEPS) | build prep/fuzz
# Target for fuzzilli. Adds in the appropriate debug flags, without doing the debug prints. # Target for fuzzilli. Adds in the appropriate debug flags, without doing the debug prints.
$(CLANG) -O3 -o $@ -Wall -Wextra -Wcast-align -Wshift-sign-overflow -fsanitize=undefined -fsanitize-coverage=trace-pc-guard -Iprep/fuzz $(CLANG_CCOPTS_DEBUG) prep/fuzz/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CLANG) -O3 -o $@ -Wall -Wextra -Wcast-align -Wshift-sign-overflow -fsanitize=undefined -fsanitize-coverage=trace-pc-guard -Iprep/fuzz $(CLANG_CCOPTS_DEBUG) prep/fuzz/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-perf-clang: prep/nondebug-perf $(DUK_SOURCE_DEPS) | build build/duk-perf-clang: $(DUK_SOURCE_DEPS) | build prep/nondebug-perf
$(CLANG) -o $@ -Wcast-align -Wshift-sign-overflow -Iprep/nondebug-perf $(CLANG_CCOPTS_NONDEBUG) prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(CLANG) -o $@ -Wcast-align -Wshift-sign-overflow -Iprep/nondebug-perf $(CLANG_CCOPTS_NONDEBUG) prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-g++: prep/nondebug $(DUK_SOURCE_DEPS) | build build/duk-g++: $(DUK_SOURCE_DEPS) | build prep/nondebug
$(GXX) -o $@ -Iprep/nondebug $(GXXOPTS_NONDEBUG) prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS) $(GXX) -o $@ -Iprep/nondebug $(GXXOPTS_NONDEBUG) prep/nondebug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-perf-g++: prep/nondebug-perf $(DUK_SOURCE_DEPS) | build build/duk-perf-g++: $(DUK_SOURCE_DEPS) | build prep/nondebug-perf
$(GXX) -o $@ -Iprep/nondebug-perf $(GXXOPTS_NONDEBUG) prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS) $(GXX) -o $@ -Iprep/nondebug-perf $(GXXOPTS_NONDEBUG) prep/nondebug-perf/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/dukd-g++: prep/debug $(DUK_SOURCE_DEPS) | build build/dukd-g++: $(DUK_SOURCE_DEPS) | build prep/debug
$(GXX) -o $@ -Iprep/debug $(GXXOPTS_DEBUG) prep/debug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS) $(GXX) -o $@ -Iprep/debug $(GXXOPTS_DEBUG) prep/debug/duktape.c $(DUKTAPE_CMDLINE_SOURCES) $(CCLIBS)
@ls -l $@ @ls -l $@
-@size $@ -@size $@
.PHONY: dukscanbuild .PHONY: dukscanbuild
build/dukscanbuild: prep/nondebug-scanbuild $(DUK_SOURCE_DEPS) | build tmp build/dukscanbuild: $(DUK_SOURCE_DEPS) | build tmp prep/nondebug-scanbuild
$(SCAN_BUILD) $(GCC) -otmp/duk.scanbuild -Iprep/nondebug-scanbuild $(CCOPTS_NONDEBUG) prep/nondebug-scanbuild/*.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(SCAN_BUILD) $(GCC) -otmp/duk.scanbuild -Iprep/nondebug-scanbuild $(CCOPTS_NONDEBUG) prep/nondebug-scanbuild/*.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
.PHONY: dukdscanbuild .PHONY: dukdscanbuild
build/dukdscanbuild: prep/debug-scanbuild $(DUK_SOURCE_DEPS) | build tmp build/dukdscanbuild: $(DUK_SOURCE_DEPS) | build tmp prep/debug-scanbuild
$(SCAN_BUILD) $(GCC) -otmp/dukd.scanbuild -Iprep/debug-scanbuild $(CCOPTS_DEBUG) prep/debug-scanbuild/*.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS) $(SCAN_BUILD) $(GCC) -otmp/dukd.scanbuild -Iprep/debug-scanbuild $(CCOPTS_DEBUG) prep/debug-scanbuild/*.c $(DUKTAPE_CMDLINE_SOURCES) $(LINENOISE_SOURCES) $(CCLIBS)
# Command line with a simple pool allocator, for low memory testing. # Command line with a simple pool allocator, for low memory testing.
# The pool sizes only make sense with -m32, so force that. This forces # The pool sizes only make sense with -m32, so force that. This forces
@ -486,7 +498,7 @@ DUKTAPE_CMDLINE_LOWMEM_SOURCES=\
extras/alloc-pool/duk_alloc_pool.c extras/alloc-pool/duk_alloc_pool.c
DUK_LOWMEM_SOURCE_DEPS=$(DUKTAPE_CMDLINE_LOWMEM_SOURCES) $(LINENOISE_SOURCES) $(LINENOISE_HEADERS) DUK_LOWMEM_SOURCE_DEPS=$(DUKTAPE_CMDLINE_LOWMEM_SOURCES) $(LINENOISE_SOURCES) $(LINENOISE_HEADERS)
build/duk-low: prep/duklow-nondebug $(DUK_LOWMEM_SOURCE_DEPS) | build build/duk-low: $(DUK_LOWMEM_SOURCE_DEPS) | build prep/duklow-nondebug
$(CC) -o $@ \ $(CC) -o $@ \
-Iextras/alloc-pool/ -Iprep/duklow-nondebug \ -Iextras/alloc-pool/ -Iprep/duklow-nondebug \
$(CCOPTS_NONDEBUG) $(CCOPTS_DUKLOW) \ $(CCOPTS_NONDEBUG) $(CCOPTS_DUKLOW) \
@ -495,7 +507,7 @@ build/duk-low: prep/duklow-nondebug $(DUK_LOWMEM_SOURCE_DEPS) | build
@echo "*** SUCCESS:" @echo "*** SUCCESS:"
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/dukd-low: prep/duklow-debug $(DUK_LOWMEM_SOURCE_DEPS) | build build/dukd-low: $(DUK_LOWMEM_SOURCE_DEPS) | build prep/duklow-debug
$(CC) -o $@ \ $(CC) -o $@ \
-Iextras/alloc-pool/ -Iprep/duklow-debug \ -Iextras/alloc-pool/ -Iprep/duklow-debug \
$(CCOPTS_DEBUG) $(CCOPTS_DUKLOW) \ $(CCOPTS_DEBUG) $(CCOPTS_DUKLOW) \
@ -504,7 +516,7 @@ build/dukd-low: prep/duklow-debug $(DUK_LOWMEM_SOURCE_DEPS) | build
@echo "*** SUCCESS:" @echo "*** SUCCESS:"
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-low-rom: prep/duklow-nondebug-rom $(DUK_LOWMEM_SOURCE_DEPS) | build build/duk-low-rom: $(DUK_LOWMEM_SOURCE_DEPS) | build prep/duklow-nondebug-rom
$(CC) -o $@ \ $(CC) -o $@ \
-Iextras/alloc-pool/ -Iprep/duklow-nondebug-rom \ -Iextras/alloc-pool/ -Iprep/duklow-nondebug-rom \
$(CCOPTS_NONDEBUG) $(CCOPTS_DUKLOW) \ $(CCOPTS_NONDEBUG) $(CCOPTS_DUKLOW) \
@ -513,7 +525,7 @@ build/duk-low-rom: prep/duklow-nondebug-rom $(DUK_LOWMEM_SOURCE_DEPS) | build
@echo "*** SUCCESS:" @echo "*** SUCCESS:"
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/dukd-low-rom: prep/duklow-debug-rom $(DUK_LOWMEM_SOURCE_DEPS) | build build/dukd-low-rom: $(DUK_LOWMEM_SOURCE_DEPS) | build prep/duklow-debug-rom
$(CC) -o $@ \ $(CC) -o $@ \
-Iextras/alloc-pool/ -Iprep/duklow-debug-rom \ -Iextras/alloc-pool/ -Iprep/duklow-debug-rom \
$(CCOPTS_DEBUG) $(CCOPTS_DUKLOW) \ $(CCOPTS_DEBUG) $(CCOPTS_DUKLOW) \
@ -522,7 +534,7 @@ build/dukd-low-rom: prep/duklow-debug-rom $(DUK_LOWMEM_SOURCE_DEPS) | build
@echo "*** SUCCESS:" @echo "*** SUCCESS:"
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/duk-low-norefc: prep/duklow-nondebug-norefc $(DUK_LOWMEM_SOURCE_DEPS) | build build/duk-low-norefc: $(DUK_LOWMEM_SOURCE_DEPS) | build prep/duklow-nondebug-norefc
$(CC) -o $@ \ $(CC) -o $@ \
-Iextras/alloc-pool/ -Iprep/duklow-nondebug-norefc \ -Iextras/alloc-pool/ -Iprep/duklow-nondebug-norefc \
$(CCOPTS_NONDEBUG) $(CCOPTS_DUKLOW) \ $(CCOPTS_NONDEBUG) $(CCOPTS_DUKLOW) \
@ -531,7 +543,7 @@ build/duk-low-norefc: prep/duklow-nondebug-norefc $(DUK_LOWMEM_SOURCE_DEPS) | bu
@echo "*** SUCCESS:" @echo "*** SUCCESS:"
@ls -l $@ @ls -l $@
-@size $@ -@size $@
build/dukd-low-norefc: prep/duklow-debug-norefc $(DUK_LOWMEM_SOURCE_DEPS) | build build/dukd-low-norefc: $(DUK_LOWMEM_SOURCE_DEPS) | build prep/duklow-debug-norefc
$(CC) -o $@ \ $(CC) -o $@ \
-Iextras/alloc-pool/ -Iprep/duklow-debug-norefc \ -Iextras/alloc-pool/ -Iprep/duklow-debug-norefc \
$(CCOPTS_DEBUG) $(CCOPTS_DUKLOW) \ $(CCOPTS_DEBUG) $(CCOPTS_DUKLOW) \
@ -547,7 +559,7 @@ build/dukd-low-norefc: prep/duklow-debug-norefc $(DUK_LOWMEM_SOURCE_DEPS) | buil
build/emduk: emduk.js | build build/emduk: emduk.js | build
cat util/emduk_wrapper.sh | sed "s|WORKDIR|$(shell pwd)|" > $@ cat util/emduk_wrapper.sh | sed "s|WORKDIR|$(shell pwd)|" > $@
chmod ugo+x $@ chmod ugo+x $@
build/emduk.js: prep/emduk examples/cmdline/duk_cmdline.c extras/print-alert/duk_print_alert.c | build tmp build/emduk.js: examples/cmdline/duk_cmdline.c extras/print-alert/duk_print_alert.c | build tmp prep/emduk
$(EMCC) $(EMCCOPTS) -Iprep/emduk -Iexamples/cmdline -Iextras/print-alert \ $(EMCC) $(EMCCOPTS) -Iprep/emduk -Iexamples/cmdline -Iextras/print-alert \
$(EMDUKOPTS) \ $(EMDUKOPTS) \
prep/emduk/duktape.c examples/cmdline/duk_cmdline.c extras/print-alert/duk_print_alert.c \ prep/emduk/duktape.c examples/cmdline/duk_cmdline.c extras/print-alert/duk_print_alert.c \
@ -558,13 +570,13 @@ build/emduk.js: prep/emduk examples/cmdline/duk_cmdline.c extras/print-alert/duk
# This is a prototype of running Duktape in a web environment with Emscripten, # This is a prototype of running Duktape in a web environment with Emscripten,
# and providing an eval() facility from both sides. This is a placeholder now # and providing an eval() facility from both sides. This is a placeholder now
# and doesn't do anything useful yet. # and doesn't do anything useful yet.
build/dukweb.js: prep/dukweb dukweb/dukweb_extra.js dukweb/dukweb.c | build build/dukweb.js: dukweb/dukweb_extra.js dukweb/dukweb.c | build prep/dukweb
@rm -f build/dukweb.js build/dukweb.asm @rm -f build/dukweb.js build/dukweb.asm
$(EMCC) $(EMCCOPTS_DUKVM_WASM) $(EMCCOPTS_DUKWEB_EXPORT) --post-js dukweb/dukweb_extra.js \ $(EMCC) $(EMCCOPTS_DUKVM_WASM) $(EMCCOPTS_DUKWEB_EXPORT) --post-js dukweb/dukweb_extra.js \
-Iprep/dukweb prep/dukweb/duktape.c dukweb/dukweb.c -o $@ -Iprep/dukweb prep/dukweb/duktape.c dukweb/dukweb.c -o $@
@wc build/dukweb.js build/dukweb.wasm @wc build/dukweb.js build/dukweb.wasm
build/literal_intern_test: prep/nondebug misc/literal_intern_test.c | build build/literal_intern_test: misc/literal_intern_test.c | build prep/nondebug
$(CC) -o $@ -std=c99 -O2 -fstrict-aliasing -Wall -Wextra \ $(CC) -o $@ -std=c99 -O2 -fstrict-aliasing -Wall -Wextra \
-Iprep/nondebug prep/nondebug/duktape.c misc/literal_intern_test.c -lm -Iprep/nondebug prep/nondebug/duktape.c misc/literal_intern_test.c -lm
.PHONY: literalinterntest .PHONY: literalinterntest
@ -652,8 +664,8 @@ apitest: runtestsdeps build/libduktape.so.1.0.0 | tmp
@echo "### apitest" @echo "### apitest"
"$(NODE)" runtests/runtests.js $(RUNTESTSOPTS) --num-threads 1 --log-file=tmp/duk-api-test.log tests/api/ "$(NODE)" runtests/runtests.js $(RUNTESTSOPTS) --num-threads 1 --log-file=tmp/duk-api-test.log tests/api/
# Configure.py test. # Configure tests.
configuretest: configuretest: configure-deps
@echo "### configuretest" @echo "### configuretest"
bash tests/configure/test_minimal.sh bash tests/configure/test_minimal.sh
@ -997,8 +1009,9 @@ doc/%.html: doc/%.txt
rst2html $< $@ rst2html $< $@
# Source distributable for end users. # Source distributable for end users.
dist/source: | codepolicycheck dist dist/source: prep-duktool | codepolicycheck dist
$(PYTHON) util/dist.py $(PYTHON) util/dist.py --output-directory $@
cp src-tools/duktool.js $@/tools/
dist/duktape-$(DUK_VERSION_FORMATTED).tar: dist/source | dist dist/duktape-$(DUK_VERSION_FORMATTED).tar: dist/source | dist
rm -rf dist/duktape-$(DUK_VERSION_FORMATTED) dist/duktape-$(DUK_VERSION_FORMATTED).* rm -rf dist/duktape-$(DUK_VERSION_FORMATTED) dist/duktape-$(DUK_VERSION_FORMATTED).*
mkdir dist/duktape-$(DUK_VERSION_FORMATTED) && cp -r dist/source/* dist/duktape-$(DUK_VERSION_FORMATTED)/ mkdir dist/duktape-$(DUK_VERSION_FORMATTED) && cp -r dist/source/* dist/duktape-$(DUK_VERSION_FORMATTED)/

11
README.md

@ -86,7 +86,8 @@ For example, to enable fastint support (example for Linux):
# src-custom/ will now contain: duktape.c, duktape.h, duk_config.h. # src-custom/ will now contain: duktape.c, duktape.h, duk_config.h.
You can download and install duktape using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager: You can download and install Duktape using the
[vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
$ git clone https://github.com/Microsoft/vcpkg.git $ git clone https://github.com/Microsoft/vcpkg.git
$ cd vcpkg $ cd vcpkg
@ -94,7 +95,10 @@ You can download and install duktape using the [vcpkg](https://github.com/Micros
$ ./vcpkg integrate install $ ./vcpkg integrate install
$ vcpkg install duktape $ vcpkg install duktape
The duktape port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. The Duktape port in vcpkg is kept up to date by Microsoft team members
and community contributors. If the version is out of date, please
[create an issue or pull request](https://github.com/Microsoft/vcpkg) on
the vcpkg repository.
You can also clone this repository, make modifications, and build a source You can also clone this repository, make modifications, and build a source
distributable on Linux, macOS, and Windows using `python util/dist.py`. distributable on Linux, macOS, and Windows using `python util/dist.py`.
@ -107,16 +111,19 @@ If you intend to change Duktape internals and want to rebuild the source
distributable in Linux, macOS, or Windows: distributable in Linux, macOS, or Windows:
# Linux; can often install from packages or using 'pip' # Linux; can often install from packages or using 'pip'
# Install Node.js >= 14.x
$ sudo apt-get install python python-yaml $ sudo apt-get install python python-yaml
$ python util/dist.py $ python util/dist.py
# macOS # macOS
# Install Python 2.7.x # Install Python 2.7.x
# Install Node.js >= 14.x
$ pip install PyYAML $ pip install PyYAML
$ python util/dist.py $ python util/dist.py
# Windows # Windows
; Install Python 2.7.x from python.org, and add it to PATH ; Install Python 2.7.x from python.org, and add it to PATH
; Install Node.js >= 14.x
> pip install PyYAML > pip install PyYAML
> python util\dist.py > python util\dist.py

171
appveyor.yml

@ -1,171 +0,0 @@
version: "{build}"
clone_depth: 5
platform:
- x64
- x86
configuration:
- Release
matrix:
fast_finish: true
install:
- cmd: python -m pip install PyYAML
build_script:
# C:\projects\duktape
# https://en.wikipedia.org/wiki/Microsoft_Visual_Studio#History
#- cmd: set
#- cmd: dir "C:\Program Files\"
#- cmd: dir "C:\Program Files (x86)\"
# Make dist, ensure it works on Windows too.
- cmd: cd C:\projects\duktape
- cmd: mkdir dist
- cmd: python util\dist.py
# Prep a few variants of headers and sources.
- cmd: python tools\configure.py --line-directives --output-directory prep-nondll --source-directory src-input --config-metadata config
- cmd: dir prep-nondll
- cmd: python tools\configure.py --line-directives --output-directory prep-dll --source-directory src-input --config-metadata config --dll
- cmd: dir prep-dll
- cmd: python tools\configure.py --line-directives --output-directory prep-cpp --source-directory src-input --config-metadata config -DDUK_USE_CPP_EXCEPTIONS
- cmd: dir prep-cpp
# --- Visual Studio 2015 ---
# PATH doesn't include any 'cl' by default, not sure how to do this correctly.
# https://msdn.microsoft.com/en-us/library/f2ccy3wt.aspx
# Multi-line commands are run line-by-line (?).
- cmd: set VCPATH="\Program Files (x86)\Microsoft Visual Studio 14.0\VC"
- cmd: set VCPLATFORM=NONE
- cmd: set VCNAME=vs2015
- cmd: if "%PLATFORM%"=="x86" ( set VCPLATFORM=x86 )
- cmd: if "%PLATFORM%"=="x64" ( set VCPLATFORM=x86_amd64 )
- cmd: echo PLATFORM=%PLATFORM%, VCPLATFORM=%VCPLATFORM%
- cmd: "%VCPATH%\\vcvarsall %VCPLATFORM%"
- cmd: cl
# Normal build.
- cmd: cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-nondll /Iexamples\cmdline /Iextras\print-alert prep-nondll\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-%VCNAME%-%PLATFORM%.exe
# DLL build.
- cmd: cl /W3 /O2 /Iprep-dll /LD /Feduktape-%VCNAME%-%PLATFORM% prep-dll\duktape.c
- cmd: cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-dll /Iexamples\cmdline /Iextras\print-alert examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-dll-%VCNAME%-%PLATFORM%.exe duktape-%VCNAME%-%PLATFORM%.lib
# Build as C++, catches some static variable issues specific to C++.
# Also test C++ exceptions on Windows.
# /TP forces files to be interpreted as C++ despite their extension.
# /EHsc enables exception unwind support.
- cmd: cl /TP /EHsc /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-cpp /Iexamples\cmdline /Iextras\print-alert prep-cpp\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-cxx-%VCNAME%-%PLATFORM%.exe
# --- Visual Studio 2013 ---
- cmd: set VCPATH="\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
- cmd: set VCPLATFORM=NONE
- cmd: set VCNAME=vs2013
- cmd: if "%PLATFORM%"=="x86" ( set VCPLATFORM=x86 )
- cmd: if "%PLATFORM%"=="x64" ( set VCPLATFORM=x86_amd64 )
- cmd: echo PLATFORM=%PLATFORM%, VCPLATFORM=%VCPLATFORM%
- cmd: "%VCPATH%\\vcvarsall %VCPLATFORM%"
- cmd: cl
- cmd: cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-nondll /Iexamples\cmdline /Iextras\print-alert prep-nondll\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-%VCNAME%-%PLATFORM%.exe
- cmd: cl /W3 /O2 /Iprep-dll /LD /Feduktape-%VCNAME%-%PLATFORM% prep-dll\duktape.c
- cmd: cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-dll /Iexamples\cmdline /Iextras\print-alert examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-dll-%VCNAME%-%PLATFORM%.exe duktape-%VCNAME%-%PLATFORM%.lib
- cmd: cl /TP /EHsc /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-cpp /Iexamples\cmdline /Iextras\print-alert prep-cpp\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-cxx-%VCNAME%-%PLATFORM%.exe
# --- Visual Studio 2012 ---
# Use VS2012 (11.0) to catch https://github.com/svaarala/duktape/pull/595.
- cmd: set VCPATH="\Program Files (x86)\Microsoft Visual Studio 11.0\VC"
- cmd: set VCPLATFORM=NONE
- cmd: set VCNAME=vs2012
- cmd: if "%PLATFORM%"=="x86" ( set VCPLATFORM=x86 )
- cmd: if "%PLATFORM%"=="x64" ( set VCPLATFORM=x86_amd64 )
- cmd: echo PLATFORM=%PLATFORM%, VCPLATFORM=%VCPLATFORM%
- cmd: "%VCPATH%\\vcvarsall %VCPLATFORM%"
- cmd: cl
- cmd: cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-nondll /Iexamples\cmdline /Iextras\print-alert prep-nondll\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-%VCNAME%-%PLATFORM%.exe
- cmd: cl /W3 /O2 /Iprep-dll /LD /Feduktape-%VCNAME%-%PLATFORM% prep-dll\duktape.c
- cmd: cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-dll /Iexamples\cmdline /Iextras\print-alert examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-dll-%VCNAME%-%PLATFORM%.exe duktape-%VCNAME%-%PLATFORM%.lib
- cmd: cl /TP /EHsc /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-cpp /Iexamples\cmdline /Iextras\print-alert prep-cpp\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-cxx-%VCNAME%-%PLATFORM%.exe
# --- Visual Studio 2010 ---
- cmd: set VCPATH="\Program Files (x86)\Microsoft Visual Studio 10.0\VC"
- cmd: set VCPLATFORM=NONE
- cmd: set VCNAME=vs2010
- cmd: if "%PLATFORM%"=="x86" ( set VCPLATFORM=x86 )
- cmd: if "%PLATFORM%"=="x64" ( set VCPLATFORM=x86_amd64 )
- cmd: echo PLATFORM=%PLATFORM%, VCPLATFORM=%VCPLATFORM%
- cmd: "%VCPATH%\\vcvarsall %VCPLATFORM%"
- cmd: cl
- cmd: cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-nondll /Iexamples\cmdline /Iextras\print-alert prep-nondll\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-%VCNAME%-%PLATFORM%.exe
- cmd: cl /W3 /O2 /Iprep-dll /LD /Feduktape-%VCNAME%-%PLATFORM% prep-dll\duktape.c
- cmd: cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-dll /Iexamples\cmdline /Iextras\print-alert examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-dll-%VCNAME%-%PLATFORM%.exe duktape-%VCNAME%-%PLATFORM%.lib
- cmd: cl /TP /EHsc /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-cpp /Iexamples\cmdline /Iextras\print-alert prep-cpp\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-cxx-%VCNAME%-%PLATFORM%.exe
# --- Visual Studio 2008 ---
- cmd: set VCPATH="\Program Files (x86)\Microsoft Visual Studio 9.0\VC"
- cmd: set VCPLATFORM=NONE
- cmd: set VCNAME=vs2008
- cmd: if "%PLATFORM%"=="x86" ( set VCPLATFORM=x86 )
- cmd: if "%PLATFORM%"=="x64" ( set VCPLATFORM=x86_amd64 )
- cmd: echo PLATFORM=%PLATFORM%, VCPLATFORM=%VCPLATFORM%
- cmd: "%VCPATH%\\vcvarsall %VCPLATFORM%"
- cmd: cl
- cmd: cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-nondll /Iexamples\cmdline /Iextras\print-alert prep-nondll\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-%VCNAME%-%PLATFORM%.exe
- cmd: cl /W3 /O2 /Iprep-dll /LD /Feduktape-%VCNAME%-%PLATFORM% prep-dll\duktape.c
- cmd: cl /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-dll /Iexamples\cmdline /Iextras\print-alert examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-dll-%VCNAME%-%PLATFORM%.exe duktape-%VCNAME%-%PLATFORM%.lib
- cmd: cl /TP /EHsc /W3 /O2 /DDUK_CMDLINE_PRINTALERT_SUPPORT /Iprep-cpp /Iexamples\cmdline /Iextras\print-alert prep-cpp\duktape.c examples\cmdline\duk_cmdline.c extras\print-alert\duk_print_alert.c /Feduk-cxx-%VCNAME%-%PLATFORM%.exe
test_script:
- cmd: echo --- VS2015
- cmd: duk-vs2015-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: duk-vs2015-%PLATFORM%.exe -e "print(Date.now(), performance.now(), performance.now());"
- cmd: duk-dll-vs2015-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: duk-cxx-vs2015-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: echo --- VS2013
- cmd: duk-vs2013-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: duk-dll-vs2013-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: duk-cxx-vs2013-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: echo --- VS2012
- cmd: duk-vs2012-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: duk-dll-vs2012-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: duk-cxx-vs2012-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: echo --- VS2010
- cmd: duk-vs2010-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: duk-dll-vs2010-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: duk-cxx-vs2010-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: echo --- VS2008
- cmd: duk-vs2008-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: duk-dll-vs2008-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
- cmd: duk-cxx-vs2008-%PLATFORM%.exe -e "print(Duktape.env); print('Hello world!');"
after_build:
# Show what was built.
- cmd: dir
artifacts:
- path: duk-*.exe
name: Duk command line binary
- path: duktape-*.dll
name: Duktape DLL
- path: duktape-*.exp
name: Duktape EXP
- path: duktape-*.lib
name: Duktape LIB

2
dist-files/README.rst

@ -122,7 +122,7 @@ implementations, with no included code, of the following algorithms: Lua
string hash (MIT license), djb2 hash, Murmurhash2 (MIT license), Adi string hash (MIT license), djb2 hash, Murmurhash2 (MIT license), Adi
Shamir's three-op hash algorithm, xoroshiro128+ PRNG (public domain), Shamir's three-op hash algorithm, xoroshiro128+ PRNG (public domain),
SplitMix64 PRNG (public domain), and CommonJS module loading specification SplitMix64 PRNG (public domain), and CommonJS module loading specification
(MIT license). (MIT license). Duktape tooling relies on js-yaml (MIT license).
Have fun! Have fun!

1
tests/configure/test_minimal.sh

@ -12,7 +12,6 @@ reinit() {
fi fi
rm -rf /tmp/duk-configure-test rm -rf /tmp/duk-configure-test
mkdir /tmp/duk-configure-test
} }
# Test for command line -D with macro arguments, GH-2013 / GH-2014. # Test for command line -D with macro arguments, GH-2013 / GH-2014.

1025
tools/configure.py

File diff suppressed because it is too large

883
util/dist.py

@ -1,183 +1,38 @@
#!/usr/bin/env python2 #!/usr/bin/env python
# #
# Create a distributable Duktape package into a dist directory. The contents # Compatibility stub which now executes JS-based tooling.
# of this directory can then be packaged into a source distributable.
# #
# Should be Python2 and Python3 compatible.
import logging
import sys
logging.basicConfig(level=logging.INFO, stream=sys.stdout, format='%(name)-21s %(levelname)-7s %(message)s')
logger = logging.getLogger('dist.py')
logger.setLevel(logging.INFO)
import os import os
import re import sys
import json import time
import shutil
import glob
import optparse import optparse
import subprocess import subprocess
import logging
# Helpers.
def exec_get_stdout(cmd, input=None, default=None, print_stdout=False): def detect_nodejs():
try: try:
proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) cmd = [ 'nodejs', '-e', 'console.log("test")' ]
ret = proc.communicate(input=input) res = subprocess.check_output(cmd)
if print_stdout: if res[:4] == 'test'.encode('utf-8'):
sys.stdout.write(ret[0]) return 'nodejs'
sys.stdout.flush()
if proc.returncode != 0:
sys.stdout.write(ret[1]) # print stderr on error
sys.stdout.flush()
if default is not None:
logger.warning(' command %r failed, return default' % cmd)
return default
raise Exception('command failed, return code %d: %r' % (proc.returncode, cmd))
return ret[0]
except: except:
if default is not None: pass
logger.warning('command %r failed, return default' % cmd)
return default
raise
def exec_print_stdout(cmd, input=None):
ret = exec_get_stdout(cmd, input=input, print_stdout=True)
def mkdir(path):
os.mkdir(path)
def copy_file(src, dst):
with open(src, 'rb') as f_in:
with open(dst, 'wb') as f_out:
f_out.write(f_in.read())
def copy_files(filelist, srcdir, dstdir):
for i in filelist:
copy_file(os.path.join(srcdir, i), os.path.join(dstdir, i))
def copy_and_replace(src, dst, rules):
# Read and write separately to allow in-place replacement
keys = sorted(rules.keys())
res = []
with open(src, 'rb') as f_in:
for line in f_in:
for k in keys:
line = line.replace(k, rules[k])
res.append(line)
with open(dst, 'wb') as f_out:
f_out.write(''.join(res))
def copy_and_cquote(src, dst):
with open(src, 'rb') as f_in:
with open(dst, 'wb') as f_out:
f_out.write('/*\n')
for line in f_in:
line = line.decode('utf-8')
f_out.write(' * ')
for c in line:
if (ord(c) >= 0x20 and ord(c) <= 0x7e) or (c in '\x0a'):
f_out.write(c.encode('ascii'))
else:
f_out.write('\\u%04x' % ord(c))
f_out.write(' */\n')
def read_file(src, strip_last_nl=False):
with open(src, 'rb') as f:
data = f.read()
if len(data) > 0 and data[-1] == '\n':
data = data[:-1]
return data
def delete_matching_files(dirpath, cb):
for fn in os.listdir(dirpath):
if os.path.isfile(os.path.join(dirpath, fn)) and cb(fn):
logger.debug('Deleting %r' % os.path.join(dirpath, fn))
os.unlink(os.path.join(dirpath, fn))
#print('Deleting matching file: %r' % fn)
def glob_files(pattern):
return glob.glob(pattern)
def cstring(x):
return '"' + x + '"' # good enough for now
# Get Duktape version number as an integer. DUK_VERSION is grepped from
# duktape.h.in: it is needed for the public API and we want to avoid
# defining it in multiple places.
def get_duk_version():
r = re.compile(r'^#define\s+DUK_VERSION\s+(.*?)L?\s*$')
with open(os.path.join('src-input', 'duktape.h.in'), 'rb') as f:
for line in f:
m = r.match(line)
if m is not None:
duk_version = int(m.group(1))
duk_major = duk_version / 10000
duk_minor = (duk_version % 10000) / 100
duk_patch = duk_version % 100
duk_version_formatted = '%d.%d.%d' % (duk_major, duk_minor, duk_patch)
return duk_version, duk_major, duk_minor, duk_patch, duk_version_formatted
raise Exception('cannot figure out duktape version') try:
cmd = [ 'node', '-e', 'console.log("test")' ]
def create_dist_directories(dist): res = subprocess.check_output(cmd)
if os.path.exists(dist): if res[:4] == 'test'.encode('utf-8'):
raise Exception('dist target directory %s already exists, please delete first' % repr(dist)) return 'node'
mkdir(dist) except:
mkdir(os.path.join(dist, 'src-input')) pass
mkdir(os.path.join(dist, 'tools'))
mkdir(os.path.join(dist, 'config'))
mkdir(os.path.join(dist, 'extras'))
mkdir(os.path.join(dist, 'extras', 'duk-v1-compat'))
mkdir(os.path.join(dist, 'extras', 'print-alert'))
mkdir(os.path.join(dist, 'extras', 'console'))
mkdir(os.path.join(dist, 'extras', 'logging'))
mkdir(os.path.join(dist, 'extras', 'minimal-printf'))
mkdir(os.path.join(dist, 'extras', 'module-duktape'))
mkdir(os.path.join(dist, 'extras', 'module-node'))
mkdir(os.path.join(dist, 'extras', 'alloc-pool'))
mkdir(os.path.join(dist, 'extras', 'cbor'))
mkdir(os.path.join(dist, 'polyfills'))
#mkdir(os.path.join(dist, 'doc')) # Empty, so omit
mkdir(os.path.join(dist, 'licenses'))
mkdir(os.path.join(dist, 'debugger'))
mkdir(os.path.join(dist, 'debugger', 'static'))
mkdir(os.path.join(dist, 'examples'))
mkdir(os.path.join(dist, 'examples', 'hello'))
mkdir(os.path.join(dist, 'examples', 'eval'))
mkdir(os.path.join(dist, 'examples', 'cmdline'))
mkdir(os.path.join(dist, 'examples', 'eventloop'))
mkdir(os.path.join(dist, 'examples', 'guide'))
mkdir(os.path.join(dist, 'examples', 'coffee'))
mkdir(os.path.join(dist, 'examples', 'jxpretty'))
mkdir(os.path.join(dist, 'examples', 'sandbox'))
mkdir(os.path.join(dist, 'examples', 'alloc-logging'))
mkdir(os.path.join(dist, 'examples', 'alloc-torture'))
mkdir(os.path.join(dist, 'examples', 'alloc-hybrid'))
mkdir(os.path.join(dist, 'examples', 'debug-trans-socket'))
mkdir(os.path.join(dist, 'examples', 'debug-trans-dvalue'))
mkdir(os.path.join(dist, 'examples', 'codepage-conv'))
mkdir(os.path.join(dist, 'examples', 'dummy-date-provider'))
mkdir(os.path.join(dist, 'examples', 'cpp-exceptions'))
# Spot check a few files to ensure we're in Duktape repo root, as dist only
# works from there.
def check_cwd_duktape_repo_root():
if not (os.path.isfile(os.path.join('src-input', 'duktape.h.in')) and \
os.path.isfile(os.path.join('config', 'platforms.yaml'))):
sys.stderr.write('\n')
sys.stderr.write('*** Working directory must be Duktape repo checkout root!\n')
sys.stderr.write('\n')
raise Exception('Incorrect working directory')
# Option parsing. return None
def parse_options(): def parse_options():
parser = optparse.OptionParser() parser = optparse.OptionParser()
parser.add_option('--repo-directory', dest='repo_directory', default=None, help='Duktape repo directory (default is CWD)') parser.add_option('--repo-directory', dest='repo_directory', default=None, help='Duktape repo directory (default is CWD)')
parser.add_option('--output-directory', dest='output_directory', default=None, help='Dist output directory (created automatically, must not exist; default is <repo>/dist)') parser.add_option('--output-directory', dest='output_directory', default=None, help='Dist output directory (required)')
parser.add_option('--git-commit', dest='git_commit', default=None, help='Force git commit hash') parser.add_option('--git-commit', dest='git_commit', default=None, help='Force git commit hash')
parser.add_option('--git-describe', dest='git_describe', default=None, help='Force git describe') parser.add_option('--git-describe', dest='git_describe', default=None, help='Force git describe')
parser.add_option('--git-branch', dest='git_branch', default=None, help='Force git branch name') parser.add_option('--git-branch', dest='git_branch', default=None, help='Force git branch name')
@ -187,672 +42,76 @@ def parse_options():
parser.add_option('--user-builtin-metadata', dest='user_builtin_metadata', action='append', default=[], help=optparse.SUPPRESS_HELP) parser.add_option('--user-builtin-metadata', dest='user_builtin_metadata', action='append', default=[], help=optparse.SUPPRESS_HELP)
parser.add_option('--quiet', dest='quiet', action='store_true', default=False, help='Suppress info messages (show warnings)') parser.add_option('--quiet', dest='quiet', action='store_true', default=False, help='Suppress info messages (show warnings)')
parser.add_option('--verbose', dest='verbose', action='store_true', default=False, help='Show verbose debug messages') parser.add_option('--verbose', dest='verbose', action='store_true', default=False, help='Show verbose debug messages')
parser.add_option('--nodejs-command', dest='nodejs_command', default=None, help='Force Node.js command name')
(opts, args) = parser.parse_args() (opts, args) = parser.parse_args()
return opts, args return opts, args
# Python module check and friendly errors. def main():
def check_python_modules(opts):
# dist.py doesn't need yaml but other dist utils will; check for it and
# warn if it is missing.
failed = False
def _warning(module, aptPackage, pipPackage):
sys.stderr.write('\n')
sys.stderr.write('*** NOTE: Could not "import %s" needed for dist. Install it using e.g.:\n' % module)
sys.stderr.write('\n')
sys.stderr.write(' # Linux\n')
sys.stderr.write(' $ sudo apt-get install %s\n' % aptPackage)
sys.stderr.write('\n') sys.stderr.write('\n')
sys.stderr.write(' # Windows\n') sys.stderr.write('****************************************************************************\n')
sys.stderr.write(' > pip install %s\n' % pipPackage) sys.stderr.write('*** Duktape python tooling is obsolete, migrate to JS-based tooling! ***\n')
sys.stderr.write('*** This tool now internally invokes the JS-based tooling. ***\n')
try: sys.stderr.write('*** Minimum Node.js version is 14.x. ***\n')
import yaml sys.stderr.write('****************************************************************************\n')
except ImportError:
_warning('yaml', 'python-yaml', 'PyYAML')
failed = True
try:
if opts.create_spdx:
import rdflib
except:
# Tolerate missing rdflib, just warn about it.
_warning('rdflib', 'python-rdflib', 'rdflib')
#failed = True
if failed:
sys.stderr.write('\n') sys.stderr.write('\n')
raise Exception('Missing some required Python modules') time.sleep(2)
def main():
# Basic option parsing, Python module check, CWD check.
opts, args = parse_options()
# Log level.
forward_loglevel = []
if opts.quiet:
logger.setLevel(logging.WARNING)
forward_loglevel = [ '--quiet' ]
elif opts.verbose:
logger.setLevel(logging.DEBUG)
forward_loglevel = [ '--verbose' ]
check_python_modules(opts)
if opts.repo_directory is None:
opts.repo_directory = os.path.abspath('.')
logger.info('No --repo-directory option, defaulting to current directory %s' % opts.repo_directory)
check_cwd_duktape_repo_root()
opts.repo_directory = os.path.abspath(opts.repo_directory)
logger.debug('Using repo directory: %s' % opts.repo_directory)
if opts.output_directory is None:
opts.output_directory = os.path.abspath(os.path.join(opts.repo_directory, 'dist', 'source'))
logger.info('No --output-directory option, defaulting to repo/dist directory %s' % opts.output_directory)
opts.output_directory = os.path.abspath(opts.output_directory)
logger.debug('Using output directory: %s' % opts.output_directory)
# Obsolete options check.
if opts.rom_support or opts.rom_auto_lightfunc:
raise Exception('obsolete ROM support argument(s), use tools/configure.py instead')
if len(opts.user_builtin_metadata) > 0:
raise Exception('obsolete --user-builtin-metadata argument, use tools/configure.py and --builtin-file instead')
# Figure out directories, git info, Duktape version, etc.
entry_cwd = os.getcwd() entry_cwd = os.getcwd()
dist = opts.output_directory script_path = sys.path[0] # http://stackoverflow.com/questions/4934806/how-can-i-find-scripts-directory-with-python
os.chdir(opts.repo_directory)
duk_version, duk_major, duk_minor, duk_patch, duk_version_formatted = get_duk_version() opts, args = parse_options()
if opts.git_commit is not None: if opts.nodejs_command is None:
git_commit = opts.git_commit nodejs_command = detect_nodejs()
else:
git_commit = exec_get_stdout([ 'git', 'rev-parse', 'HEAD' ], default='external').strip()
if opts.git_describe is not None:
git_describe = opts.git_describe
else:
git_describe = exec_get_stdout([ 'git', 'describe', '--always', '--dirty' ], default='external').strip()
if opts.git_branch is not None:
git_branch = opts.git_branch
else: else:
git_branch = exec_get_stdout([ 'git', 'rev-parse', '--abbrev-ref', 'HEAD' ], default='external').strip() nodejs_command = opts.nodejs_command
if nodejs_command is None:
git_commit_cstring = cstring(git_commit) raise Exception('failed to detect Node.js, override with --nodejs-command')
git_describe_cstring = cstring(git_describe)
git_branch_cstring = cstring(git_branch)
logger.info('Dist for Duktape version %s, commit %s, describe %s, branch %s' % \
(duk_version_formatted, git_commit, git_describe, git_branch))
# Create dist directory structure, copy files.
logger.debug('Create dist directories and copy static files')
os.chdir(opts.repo_directory)
create_dist_directories(dist)
os.chdir(opts.repo_directory)
copy_files([
'builtins.yaml',
'duk_alloc_default.c',
'duk_api_buffer.c',
'duk_api_bytecode.c',
'duk_api_call.c',
'duk_api_codec.c',
'duk_api_compile.c',
'duk_api_debug.c',
'duk_api_heap.c',
'duk_api_internal.h',
'duk_api_inspect.c',
'duk_api_memory.c',
'duk_api_object.c',
'duk_api_random.c',
'duk_api_stack.c',
'duk_api_string.c',
'duk_api_time.c',
'duk_bi_array.c',
'duk_bi_boolean.c',
'duk_bi_buffer.c',
'duk_bi_cbor.c',
'duk_bi_date.c',
'duk_bi_date_unix.c',
'duk_bi_date_windows.c',
'duk_bi_duktape.c',
'duk_bi_encoding.c',
'duk_bi_error.c',
'duk_bi_function.c',
'duk_bi_global.c',
'duk_bi_json.c',
'duk_bi_math.c',
'duk_bi_number.c',
'duk_bi_object.c',
'duk_bi_performance.c',
'duk_bi_pointer.c',
'duk_bi_promise.c',
'duk_bi_protos.h',
'duk_bi_proxy.c',
'duk_bi_reflect.c',
'duk_bi_regexp.c',
'duk_bi_string.c',
'duk_bi_symbol.c',
'duk_bi_thread.c',
'duk_bi_thrower.c',
'duk_dblunion.h',
'duk_debug_fixedbuffer.c',
'duk_debugger.c',
'duk_debugger.h',
'duk_debug.h',
'duk_debug_macros.c',
'duk_debug_vsnprintf.c',
'duk_error_augment.c',
'duk_error.h',
'duk_error_longjmp.c',
'duk_error_macros.c',
'duk_error_misc.c',
'duk_error_throw.c',
'duk_exception.h',
'duk_fltunion.h',
'duk_forwdecl.h',
'duk_harray.h',
'duk_hboundfunc.h',
'duk_hbuffer_alloc.c',
'duk_hbuffer_assert.c',
'duk_hbuffer.h',
'duk_hbuffer_ops.c',
'duk_hbufobj.h',
'duk_hbufobj_misc.c',
'duk_hcompfunc.h',
'duk_heap_alloc.c',
'duk_heap.h',
'duk_heap_hashstring.c',
'duk_heaphdr.h',
'duk_heaphdr_assert.c',
'duk_heap_finalize.c',
'duk_heap_markandsweep.c',
'duk_heap_memory.c',
'duk_heap_misc.c',
'duk_heap_refcount.c',
'duk_heap_stringcache.c',
'duk_heap_stringtable.c',
'duk_henv.h',
'duk_hnatfunc.h',
'duk_hobject_alloc.c',
'duk_hobject_assert.c',
'duk_hobject_class.c',
'duk_hobject_enum.c',
'duk_hobject.h',
'duk_hobject_misc.c',
'duk_hobject_pc2line.c',
'duk_hobject_props.c',
'duk_hproxy.h',
'duk_hstring.h',
'duk_hstring_assert.c',
'duk_hstring_misc.c',
'duk_hthread_alloc.c',
'duk_hthread_builtins.c',
'duk_hthread.h',
'duk_hthread_misc.c',
'duk_hthread_stacks.c',
'duk_internal.h',
'duk_jmpbuf.h',
'duk_js_arith.c',
'duk_js_bytecode.h',
'duk_js_call.c',
'duk_js_compiler.c',
'duk_js_compiler.h',
'duk_js_executor.c',
'duk_js.h',
'duk_json.h',
'duk_js_ops.c',
'duk_js_var.c',
'duk_lexer.c',
'duk_lexer.h',
'duk_numconv.c',
'duk_numconv.h',
'duk_refcount.h',
'duk_regexp_compiler.c',
'duk_regexp_executor.c',
'duk_regexp.h',
'duk_replacements.c',
'duk_replacements.h',
'duk_selftest.c',
'duk_selftest.h',
'duk_strings.h',
'duktape.h.in',
'duk_tval.c',
'duk_tval.h',
'duk_unicode.h',
'duk_unicode_support.c',
'duk_unicode_tables.c',
'duk_util.h',
'duk_util_bitdecoder.c',
'duk_util_bitencoder.c',
'duk_util_bufwriter.c',
'duk_util_hashbytes.c',
'duk_util_tinyrandom.c',
'duk_util_double.c',
'duk_util_cast.c',
'duk_util_memory.c',
'duk_util_memrw.c',
'duk_util_misc.c',
'strings.yaml',
'SpecialCasing.txt',
'SpecialCasing-8bit.txt',
'UnicodeData.txt',
'UnicodeData-8bit.txt',
], 'src-input', os.path.join(dist, 'src-input'))
for fn in [ for fn in [
'tags.yaml', os.path.join(script_path, 'duktool.js'),
'platforms.yaml', os.path.join(script_path, '..', 'src-tools', 'index.js'),
'architectures.yaml', os.path.join(script_path, '..', 'src-tools', 'duktool.js')
'compilers.yaml',
'platforms',
'architectures',
'compilers',
'feature-options',
'config-options',
'helper-snippets',
'header-snippets',
'examples'
]: ]:
# Copy directories in their entirety if os.path.isfile(fn):
if os.path.isfile(os.path.join('config', fn)): duktool_path = fn
shutil.copyfile(os.path.join('config', fn), os.path.join(dist, 'config', fn)) break
else: if duktool_path is None:
shutil.copytree(os.path.join('config', fn), os.path.join(dist, 'config', fn)) raise Exception('could not find duktool.js or src-tools/index.js')
copy_files([
'configure.py',
'combine_src.py',
'create_spdx_license.py',
'duk_meta_to_strarray.py',
'dukutil.py',
'dump_bytecode.py',
'extract_caseconv.py',
'extract_chars.py',
'extract_unique_options.py',
'genbuiltins.py',
'genconfig.py',
'json2yaml.py',
'merge_debug_meta.py',
'prepare_unicode_data.py',
'resolve_combined_lineno.py',
'scan_strings.py',
'scan_used_stridx_bidx.py',
'yaml2json.py',
], 'tools', os.path.join(dist, 'tools'))
copy_files([
'README.rst'
], 'config', os.path.join(dist, 'config'))
copy_files([
'README.rst',
'Makefile',
'package.json',
'duk_debug.js',
'duk_debug_proxy.js',
'duk_classnames.yaml',
'duk_debugcommands.yaml',
'duk_debugerrors.yaml',
'duk_opcodes.yaml'
], 'debugger', os.path.join(dist, 'debugger'))
copy_files([
'index.html',
'style.css',
'webui.js'
], os.path.join('debugger', 'static'), os.path.join(dist, 'debugger', 'static'))
copy_files([
'console-minimal.js',
'global.js',
'object-prototype-definegetter.js',
'object-prototype-definesetter.js',
'object-assign.js',
'performance-now.js',
'duktape-isfastint.js',
'duktape-error-setter-writable.js',
'duktape-error-setter-nonwritable.js',
'duktape-buffer.js',
'promise.js'
], 'polyfills', os.path.join(dist, 'polyfills'))
copy_files([
'README.rst'
], 'examples', os.path.join(dist, 'examples'))
copy_files([
'README.rst',
'duk_cmdline.c',
'duk_cmdline.h',
'duk_cmdline_lowmem.c'
], os.path.join('examples', 'cmdline'), os.path.join(dist, 'examples', 'cmdline'))
copy_files([
'README.rst',
'c_eventloop.c',
'c_eventloop.h',
'c_eventloop.js',
'ecma_eventloop.js',
'main.c',
'poll.c',
'socket.c',
'fileio.c',
'basic-test.js',
'timer-test.js',
'server-socket-test.js',
'client-socket-test.js'
], os.path.join('examples', 'eventloop'), os.path.join(dist, 'examples', 'eventloop'))
copy_files([
'README.rst',
'hello.c'
], os.path.join('examples', 'hello'), os.path.join(dist, 'examples', 'hello'))
copy_files([
'README.rst',
'eval.c'
], os.path.join('examples', 'eval'), os.path.join(dist, 'examples', 'eval'))
copy_files([
'README.rst',
'fib.js',
'process.js',
'processlines.c',
'prime.js',
'primecheck.c',
'uppercase.c'
], os.path.join('examples', 'guide'), os.path.join(dist, 'examples', 'guide'))
copy_files([
'README.rst',
'globals.coffee',
'hello.coffee',
'mandel.coffee'
], os.path.join('examples', 'coffee'), os.path.join(dist, 'examples', 'coffee'))
copy_files([
'README.rst',
'jxpretty.c'
], os.path.join('examples', 'jxpretty'), os.path.join(dist, 'examples', 'jxpretty'))
copy_files([
'README.rst',
'sandbox.c'
], os.path.join('examples', 'sandbox'), os.path.join(dist, 'examples', 'sandbox'))
copy_files([
'README.rst',
'duk_alloc_logging.c',
'duk_alloc_logging.h',
'log2gnuplot.py'
], os.path.join('examples', 'alloc-logging'), os.path.join(dist, 'examples', 'alloc-logging'))
copy_files([
'README.rst',
'duk_alloc_torture.c',
'duk_alloc_torture.h'
], os.path.join('examples', 'alloc-torture'), os.path.join(dist, 'examples', 'alloc-torture'))
copy_files([
'README.rst',
'duk_alloc_hybrid.c',
'duk_alloc_hybrid.h'
], os.path.join('examples', 'alloc-hybrid'), os.path.join(dist, 'examples', 'alloc-hybrid'))
copy_files([
'README.rst',
'duk_trans_socket_unix.c',
'duk_trans_socket_windows.c',
'duk_trans_socket.h'
], os.path.join('examples', 'debug-trans-socket'), os.path.join(dist, 'examples', 'debug-trans-socket'))
copy_files([
'README.rst',
'duk_trans_dvalue.c',
'duk_trans_dvalue.h',
'test.c',
'Makefile'
], os.path.join('examples', 'debug-trans-dvalue'), os.path.join(dist, 'examples', 'debug-trans-dvalue'))
copy_files([
'README.rst',
'duk_codepage_conv.c',
'duk_codepage_conv.h',
'test.c'
], os.path.join('examples', 'codepage-conv'), os.path.join(dist, 'examples', 'codepage-conv'))
copy_files([
'README.rst',
'dummy_date_provider.c'
], os.path.join('examples', 'dummy-date-provider'), os.path.join(dist, 'examples', 'dummy-date-provider'))
copy_files([
'README.rst',
'cpp_exceptions.cpp'
], os.path.join('examples', 'cpp-exceptions'), os.path.join(dist, 'examples', 'cpp-exceptions'))
copy_files([
'README.rst'
], 'extras', os.path.join(dist, 'extras'))
copy_files([
'README.rst',
'duk_logging.c',
'duk_logging.h',
'test.c',
'Makefile'
], os.path.join('extras', 'logging'), os.path.join(dist, 'extras', 'logging'))
copy_files([
'README.rst',
'duk_v1_compat.c',
'duk_v1_compat.h',
'test.c',
'Makefile',
'test_eval1.js',
'test_eval2.js',
'test_compile1.js',
'test_compile2.js'
], os.path.join('extras', 'duk-v1-compat'), os.path.join(dist, 'extras', 'duk-v1-compat'))
copy_files([
'README.rst',
'duk_print_alert.c',
'duk_print_alert.h',
'test.c',
'Makefile'
], os.path.join('extras', 'print-alert'), os.path.join(dist, 'extras', 'print-alert'))
copy_files([
'README.rst',
'duk_console.c',
'duk_console.h',
'test.c',
'Makefile'
], os.path.join('extras', 'console'), os.path.join(dist, 'extras', 'console'))
copy_files([
'README.rst',
'duk_minimal_printf.c',
'duk_minimal_printf.h',
'Makefile',
'test.c'
], os.path.join('extras', 'minimal-printf'), os.path.join(dist, 'extras', 'minimal-printf'))
copy_files([
'README.rst',
'duk_module_duktape.c',
'duk_module_duktape.h',
'Makefile',
'test.c'
], os.path.join('extras', 'module-duktape'), os.path.join(dist, 'extras', 'module-duktape'))
copy_files([
'README.rst',
'duk_module_node.c',
'duk_module_node.h',
'Makefile',
'test.c'
], os.path.join('extras', 'module-node'), os.path.join(dist, 'extras', 'module-node'))
copy_files([
'README.rst',
'duk_alloc_pool.c',
'duk_alloc_pool.h',
'ptrcomp.yaml',
'ptrcomp_fixup.h',
'Makefile',
'test.c'
], os.path.join('extras', 'alloc-pool'), os.path.join(dist, 'extras', 'alloc-pool'))
copy_files([
'README.rst',
'cbordecode.py',
'duk_cbor.c',
'duk_cbor.h',
'jsoncbor.c',
'run_testvectors.js',
'Makefile'
], os.path.join('extras', 'cbor'), os.path.join(dist, 'extras', 'cbor'))
copy_files([
'Makefile.cmdline',
'Makefile.dukdebug',
'Makefile.eventloop',
'Makefile.hello',
'Makefile.eval',
'Makefile.coffee',
'Makefile.jxpretty',
'Makefile.jsoncbor',
'Makefile.sandbox',
'Makefile.codepage',
'mandel.js'
], 'dist-files', dist)
copy_and_replace(os.path.join('dist-files', 'Makefile.sharedlibrary'), os.path.join(dist, 'Makefile.sharedlibrary'), {
'@DUK_VERSION@': str(duk_version),
'@SONAME_VERSION@': str(int(duk_version / 100)) # 10500 -> 105
})
copy_and_replace(os.path.join('dist-files', 'README.rst'), os.path.join(dist, 'README.rst'), {
'@DUK_VERSION_FORMATTED@': duk_version_formatted,
'@DUK_MAJOR@': str(duk_major),
'@DUK_MINOR@': str(duk_minor),
'@DUK_PATCH@': str(duk_patch),
'@GIT_COMMIT@': git_commit,
'@GIT_DESCRIBE@': git_describe,
'@GIT_BRANCH@': git_branch
})
copy_files([
'LICENSE.txt', # not strict RST so keep .txt suffix
'AUTHORS.rst'
], '.', os.path.join(dist))
# RELEASES.rst is only updated in master. It's not included in the dist to
# make maintenance fixes easier to make.
copy_files([
'murmurhash2.txt',
'lua.txt',
'commonjs.txt',
'xoroshiro128plus.txt',
'splitmix64.txt'
], 'licenses', os.path.join(dist, 'licenses'))
# Merge debugger metadata.
merged = exec_print_stdout([
sys.executable, os.path.join('tools', 'merge_debug_meta.py'),
'--output', os.path.join(dist, 'debugger', 'duk_debug_meta.json'),
'--class-names', os.path.join('debugger', 'duk_classnames.yaml'),
'--debug-commands', os.path.join('debugger', 'duk_debugcommands.yaml'),
'--debug-errors', os.path.join('debugger', 'duk_debugerrors.yaml'),
'--opcodes', os.path.join('debugger', 'duk_opcodes.yaml')
] + forward_loglevel)
# Add a build metadata file.
doc = {
'type': 'duk_dist_meta',
'comment': 'Metadata for Duktape distributable',
'git_commit': git_commit,
'git_branch': git_branch,
'git_describe': git_describe,
'duk_version': duk_version,
'duk_version_string': duk_version_formatted
}
with open(os.path.join(dist, 'duk_dist_meta.json'), 'wb') as f:
f.write(json.dumps(doc, indent=4))
# Build prepared sources with default config. This is done using
# tools and metadata in the dist directory.
logger.debug('Create prepared sources for default configuration')
def prep_default_sources(dirname, extraopts):
cmd = [ cmd = [
sys.executable, os.path.join(dist, 'tools', 'configure.py'), nodejs_command,
'--source-directory', os.path.join(dist, 'src-input'), duktool_path,
'--output-directory', os.path.join(dist, dirname), 'dist'
'--config-metadata', os.path.join(dist, 'config'),
'--git-commit', git_commit, '--git-describe', git_describe, '--git-branch', git_branch,
'--omit-removed-config-options', '--omit-unused-config-options',
'--emit-config-sanity-check', '--emit-legacy-feature-check'
] ]
cmd += extraopts if opts.output_directory is not None:
cmd += [ '--output-directory', opts.output_directory ]
if opts.repo_directory is not None:
cmd += [ '--repo-directory', opts.repo_directory ]
if opts.git_commit is not None:
cmd += [ '--git-commit', opts.git_commit ]
if opts.git_describe is not None:
cmd += [ '--git-describe', opts.git_describe ]
if opts.git_branch is not None:
cmd += [ '--git-branch', opts.git_branch ]
if opts.create_spdx:
cmd += [ '--create-spdx' ]
if opts.rom_support: if opts.rom_support:
cmd.append('--rom-support') print('--rom-support ignored (now always enabled)')
if opts.rom_auto_lightfunc: if opts.rom_auto_lightfunc:
cmd.append('--rom-auto-lightfunc') raise Exception('--rom-auto-lightfunc no longer supported for dist (use it with configure)')
for i in opts.user_builtin_metadata: if len(opts.user_builtin_metadata) > 0:
cmd.append('--user-builtin-metadata') raise Exception('--user-builtin-metadata no longer supported for dist (use --builtin-file with configure')
cmd.append(i) if opts.quiet:
cmd += forward_loglevel print('--quiet ignored')
exec_print_stdout(cmd) if opts.verbose:
print('--verbose ignored')
prep_default_sources('src', []) if True:
cmd += [ '--validate-git' ]
# Duktape 2.x:
#prep_default_sources('src', [ '--line-directives' ]) sys.stderr.write('*** Executing JS-based tooling with command: ' + repr(cmd) + '\n\n')
#prep_default_sources('src-noline', []) subprocess.check_call(cmd)
#prep_default_sources('src-separate', [ '--separate-sources' ])
# Clean up remaining temp files.
delete_matching_files(dist, lambda x: x[-4:] == '.tmp')
delete_matching_files(os.path.join(dist, 'tools'), lambda x: x[-4:] == '.pyc')
# Create SPDX license once all other files are in place (and cleaned).
if opts.create_spdx:
logger.debug('Create SPDX license')
try:
exec_get_stdout([
sys.executable,
os.path.join('tools', 'create_spdx_license.py'),
os.path.join(dist, 'license.spdx')
])
except:
logger.warning('')
logger.warning('***')
logger.warning('*** WARNING: Failed to create SPDX license, this should not happen for an official release!')
logger.warning('***')
logger.warning('')
else:
logger.debug('Skip SPDX license creation')
logger.info('Dist finished successfully')
if __name__ == '__main__': if __name__ == '__main__':
main() main()

2
util/makeduk_base.yaml

@ -2,7 +2,7 @@
# Some commented out options are kept so that it's easy to # Some commented out options are kept so that it's easy to
# tweak common development time options manually. # tweak common development time options manually.
# If an unknown option is used, configure.py/genconfig.py will warn about it. # If an unknown option is used, configure will warn about it.
#DUK_USE_SOME_UNKNOWN_OPTION: true #DUK_USE_SOME_UNKNOWN_OPTION: true
DUK_USE_TARGET_INFO: "\"duk command built from Duktape repo\"" DUK_USE_TARGET_INFO: "\"duk command built from Duktape repo\""

Loading…
Cancel
Save