[Pkg-voip-commits] [janus] 141/163: Integrate support for building JavaScript modules within the build system.

Jonas Smedegaard dr at jones.dk
Sat Oct 28 01:22:24 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to annotated tag debian/0.2.5-1
in repository janus.

commit 3b856ed37bbc684c24ba3591aac86719851f169e
Author: Johan Ouwerkerk <jm.ouwerkerk at gmail.com>
Date:   Thu Oct 12 13:52:58 2017 +0200

    Integrate support for building JavaScript modules within the build system.
    
    Building JavaScript modules is opt-in, i.e. disabled by default.
    Various 'flavours' of JavaScript module syntax are supported:
    
     - ECMAScript (es)
     - CommonJS (cjs)
     - Immediately Invoked Function Expression (iife)
     - Universal Module Definition (umd)
    
    To enable a particular flavour one of the --enable-javascript-*-module flags may be passed with an argument of 'yes' during ./configure:
    
     - --enable-javascript-es-module
     - --enable-javascript-common-js-module
     - --enable-javascript-iife-module
     - --enable-javascript-umd-module
    
    Additionally, configure.ac is extended to lookup for an available version of npm if any of the supported module flavours is enabled.
    If no npm can be found and a module flavour is enabled, ./configure will now fail with an error message accordingly.
    Nota bene: this check for npm applies if and only if modules are actually enabled, therefore by default Janus will still build without npm.
    
    When modules are enabled, generated modules will be built in ./npm/bundles (during make) and installed to $PREFIX/share/janus/javascript (during make install)
    Additionally janus.js itself is now always installed to $PREFIX/share/janus/javascript as well (even if no modules are enabled).
    The idea is that $PREFIX/share/janus/javascript acts as the installation location for the generically re-usable JavaScript libraries which are part of Janus.
---
 Makefile.am  | 37 ++++++++++++++++++++++++++++++++++
 configure.ac | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 6215e70..b877bd2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -67,6 +67,9 @@ recordings_DATA = $(NULL)
 demosdir = $(datadir)/janus/demos
 demos_DATA = $(NULL)
 
+jsmodulesdir = $(datadir)/janus/javascript
+jsmodules_DATA = html/janus.js
+
 %.sample: %.sample.in
 	$(MKDIR_P) $(@D)
 	$(AM_V_GEN) sed -e "\
@@ -440,6 +443,40 @@ SUBDIRS += docs
 endif
 
 ##
+# JavaScript module flavours for janus.js
+##
+
+if ENABLE_JAVASCRIPT_ES_MODULE
+jsmodules_DATA += npm/bundles/janus.es.js
+CLEANFILES += npm/bundles/janus.es.js
+endif
+
+if ENABLE_JAVASCRIPT_UMD_MODULE
+jsmodules_DATA += npm/bundles/janus.umd.js
+CLEANFILES += npm/bundles/janus.umd.js
+endif
+
+if ENABLE_JAVASCRIPT_IIFE_MODULE
+jsmodules_DATA += npm/bundles/janus.iife.js
+CLEANFILES += npm/bundles/janus.iife.js
+endif
+
+if ENABLE_JAVASCRIPT_COMMON_JS_MODULE
+jsmodules_DATA += npm/bundles/janus.cjs.js
+CLEANFILES += npm/bundles/janus.cjs.js
+endif
+
+if ENABLE_JAVASCRIPT_MODULES
+
+npm/node_modules/rollup/bin/rollup: npm/package.json
+	cd npm && $(NPM) install && touch node_modules/rollup/bin/rollup
+
+npm/bundles/janus.%.js: html/janus.js npm/node_modules/rollup/bin/rollup npm/rollup.config.js npm/module.js
+	cd npm && $(NPM) run rollup -- --o $(patsubst npm/%,%,$@) --f $*
+
+endif
+
+##
 # Configuration
 ##
 
diff --git a/configure.ac b/configure.ac
index 79ca165..546335f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -169,6 +169,54 @@ AC_ARG_ENABLE([sample-event-handler],
                      [enable_sample_event_handler=no])],
               [enable_sample_event_handler=maybe])
 
+AC_ARG_ENABLE([javascript-es-module],
+              [AS_HELP_STRING([--enable-javascript-es-module],
+                              [Enable generating an ECMAScript style module from janus.js])],
+              [AS_IF([test "x$enable_javascript_es_module" = "xyes"],
+                     [enable_javascript_es_module=yes])],
+              [enable_javascript_es_module=no])
+AM_CONDITIONAL([ENABLE_JAVASCRIPT_ES_MODULE], [test "x$enable_javascript_es_module" = "xyes" ])
+
+AC_ARG_ENABLE([javascript-umd-module],
+              [AS_HELP_STRING([--enable-javascript-umd-module],
+                              [Enable generating an UMD style module from janus.js])],
+              [AS_IF([test "x$enable_javascript_umd_module" = "xyes"],
+                     [enable_javascript_umd_module=yes])],
+              [enable_javascript_umd_module=no])
+AM_CONDITIONAL([ENABLE_JAVASCRIPT_UMD_MODULE], [test "x$enable_javascript_umd_module" = "xyes" ])
+
+AC_ARG_ENABLE([javascript-iife-module],
+              [AS_HELP_STRING([--enable-javascript-iife-module],
+                              [Enable generating an IIFE style wrapper around janus.js])],
+              [AS_IF([test "x$enable_javascript_iife_module" = "xyes"],
+                     [enable_javascript_iife_module=yes])],
+              [enable_javascript_iife_module=no])
+AM_CONDITIONAL([ENABLE_JAVASCRIPT_IIFE_MODULE], [test "x$enable_javascript_iife_module" = "xyes" ])
+
+AC_ARG_ENABLE([javascript-common-js-module],
+              [AS_HELP_STRING([--enable-javascript-common-js-module],
+                              [Enable generating an CommonJS style module from janus.js])],
+              [AS_IF([test "x$enable_javascript_common_js_module" = "xyes"],
+                     [enable_javascript_common_js_module=yes])],
+              [enable_javascript_common_js_module=no])
+AM_CONDITIONAL([ENABLE_JAVASCRIPT_COMMON_JS_MODULE], [test "x$enable_javascript_common_js_module" = "xyes" ])
+
+case "-${enable_javascript_common_js_module}-${enable_javascript_iife_module}-${enable_javascript_umd_module}-${enable_javascript_es_module}-" in
+    *-yes*)
+        AM_CONDITIONAL([ENABLE_JAVASCRIPT_MODULES], true)
+    ;;
+    *)
+        AM_CONDITIONAL([ENABLE_JAVASCRIPT_MODULES], false)
+    ;;
+esac
+
+AC_ARG_VAR(NPM,"npm executable to use")
+AC_PATH_PROG(NPM,npm,,)
+AM_CONDITIONAL([NPM_FOUND], [test "x$NPM" != "x" ])
+AM_COND_IF([ENABLE_JAVASCRIPT_MODULES],[
+    AM_COND_IF([NPM_FOUND],,[AC_MSG_ERROR([npm not found])])
+])
+
 PKG_CHECK_MODULES([JANUS],
                   [
                     glib-2.0 >= $glib_version
@@ -674,6 +722,23 @@ echo "Event handlers:"
 AM_COND_IF([ENABLE_SAMPLEEVH],
 	[echo "    Sample event handler:  yes"],
 	[echo "    Sample event handler:  no"])
+AM_COND_IF([ENABLE_JAVASCRIPT_MODULES], [
+	echo "JavaScript modules:        yes"
+	echo "    Using npm:             $NPM"
+	AM_COND_IF([ENABLE_JAVASCRIPT_ES_MODULE],
+		[echo "    ES syntax:             yes"],
+		[echo "    ES syntax:             no"])
+	AM_COND_IF([ENABLE_JAVASCRIPT_IIFE_MODULE],
+		[echo "    IIFE syntax:           yes"],
+		[echo "    IIFE syntax:           no"])
+	AM_COND_IF([ENABLE_JAVASCRIPT_UMD_MODULE],
+		[echo "    UMD syntax:            yes"],
+		[echo "    UMD syntax:            no"])
+	AM_COND_IF([ENABLE_JAVASCRIPT_COMMON_JS_MODULE],
+		[echo "    CommonJS syntax:       yes"],
+		[echo "    CommonJS syntax:       no"])
+	],
+	[echo "JavaScript modules:        no"])
 
 echo
 echo "If this configuration is ok for you, do a 'make' to start building Janus. A 'make install' will install Janus and its plugins to the specified prefix. Finally, a 'make configs' will install some sample configuration files too (something you'll only want to do the first time, though)."

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/janus.git



More information about the Pkg-voip-commits mailing list