diff options
author | Olly Betts <olly@survex.com> | 2022-11-30 16:27:18 +1300 |
---|---|---|
committer | Olly Betts <olly@survex.com> | 2023-04-22 13:33:46 +1200 |
commit | 7bb7295a33c78e1739907bbebf151a2a27432a24 (patch) | |
tree | 1d1765fd732dd231a490c0ee7e3f2417eece4e4c | |
parent | b508598a42b80f9e63f6ebbaf04fdbfee30ea2a2 (diff) | |
download | swig-7bb7295a33c78e1739907bbebf151a2a27432a24.tar.gz |
[js] Improve default for JSENGINE
Previously the default was always "node", even if nodejs wasn't
detected by configure. This leads to a confusing failure from
"make check" if you have another support JS engine installed
but not node.
Now the default it picked based on which engines configure
found. If only one was detected, that should be used. If
multiple are, you can override the default choice by specifying
e.g. ENGINE=jsc on the make command line.
Fixes #2453
-rw-r--r-- | Examples/Makefile.in | 22 | ||||
-rw-r--r-- | Examples/javascript/example.mk | 12 | ||||
-rw-r--r-- | Examples/test-suite/javascript/Makefile.in | 23 |
3 files changed, 40 insertions, 17 deletions
diff --git a/Examples/Makefile.in b/Examples/Makefile.in index d69e20ca8..0849597a9 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -687,16 +687,34 @@ JSINCLUDES = @JSCOREINC@ @JSV8INC@ JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@ NODEJS = @NODEJS@ NODEGYP = @NODEGYP@ +ifneq (, $(ENGINE)) + JSENGINE=$(ENGINE) +else +ifneq (, $(NODEJS)) + JSENGINE=node +else +ifneq (, @JSCENABLED@) + JSENGINE=jsc +else +ifneq (, @JSV8ENABLED@) + JSENGINE=v8 +else + # Shouldn't happen, but avoid empty value if it does. + JSENGINE=node +endif +endif +endif +endif # ---------------------------------------------------------------- # Creating and building Javascript wrappers # ---------------------------------------------------------------- javascript_wrapper: - $(SWIG) -javascript $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH) + $(SWIG) -javascript $(SWIGOPT) -$(JSENGINE) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH) javascript_wrapper_cpp: $(SRCDIR_SRCS) - $(SWIG) -javascript -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cxx $(INTERFACEPATH) + $(SWIG) -javascript -c++ $(SWIGOPT) -$(JSENGINE) -o $(INTERFACEDIR)$(TARGET)_wrap.cxx $(INTERFACEPATH) javascript_build: $(SRCDIR_SRCS) $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(ISRCS) $(SRCDIR_SRCS) $(INCLUDES) $(JSINCLUDES) diff --git a/Examples/javascript/example.mk b/Examples/javascript/example.mk index 3ef012aa8..cce99fa25 100644 --- a/Examples/javascript/example.mk +++ b/Examples/javascript/example.mk @@ -1,12 +1,6 @@ # Note: as a convention an example must be in a child directory of this. # These paths are relative to such an example directory -ifneq (, $(ENGINE)) - JSENGINE=$(ENGINE) -else - JSENGINE=node -endif - ifneq (, $(V8_VERSION)) JSV8_VERSION=$(V8_VERSION) else @@ -19,10 +13,10 @@ SWIGEXE = $(SWIG_TOP)/swig SWIG_LIB_DIR = $(SWIG_TOP)/$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib TARGET = example INTERFACE = example.i -SWIGOPT = -$(JSENGINE) -DV8_VERSION=$(JSV8_VERSION) +SWIGOPT = -DV8_VERSION=$(JSV8_VERSION) check: build - $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' JSENGINE='$(JSENGINE)' TARGET='$(TARGET)' javascript_run + $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' javascript_run build: $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(SRCS)' \ @@ -30,7 +24,7 @@ build: SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_wrapper_cpp $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(SRCS)' \ SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' JSENGINE='$(JSENGINE)' javascript_build_cpp + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' javascript_build_cpp clean: $(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' javascript_clean diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in index a124a068f..b2acbd8f2 100644 --- a/Examples/test-suite/javascript/Makefile.in +++ b/Examples/test-suite/javascript/Makefile.in @@ -25,9 +25,22 @@ SWIGEXE = $(top_builddir)/swig SWIG_LIB_DIR = $(top_srcdir)/Lib ifneq (, $(ENGINE)) - JSENGINE=$(ENGINE) + JSENGINE=$(ENGINE) else - JSENGINE=node +ifneq (, $(NODEJS)) + JSENGINE=node +else +ifneq (, @JSCENABLED@) + JSENGINE=jsc +else +ifneq (, @JSV8ENABLED@) + JSENGINE=v8 +else + # Shouldn't happen, but avoid empty value if it does. + JSENGINE=node +endif +endif +endif endif ifneq (, $(V8_VERSION)) @@ -47,9 +60,9 @@ _setup = \ echo "$(ACTION)ing $(LANGUAGE) ($(JSENGINE)) testcase $*" ; \ fi; -ifeq (node,$(JSENGINE)) +SWIGOPT += -$(JSENGINE) - SWIGOPT += -node +ifeq (node,$(JSENGINE)) # shut up some warnings @@ -105,8 +118,6 @@ ifeq (node,$(JSENGINE)) else - SWIGOPT += -$(JSENGINE) - run_testcase = \ if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ $(RUNTOOL) $(top_builddir)/Tools/javascript/javascript -$(JSENGINE) $(srcdir)/$*$(SCRIPTSUFFIX); \ |