bug 462004 - JavaScript shell should provide line editing facilities. r=bsmedberg
authorTed Mielczarek <ted.mielczarek@gmail.com>
Wed, 03 Dec 2008 08:55:27 -0500
changeset 23648 19e319a0647b8b7ce10de15c0b642d6af75fedc9
parent 23647 a940f7f8b4b8aa24aaedda8e7d36e8247c321f90
child 23649 98806c8d1c03f86d5a71f9f1b32025f985f85d7c
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs462004
milestone1.9.2a1pre
bug 462004 - JavaScript shell should provide line editing facilities. r=bsmedberg
config/autoconf.mk.in
configure.in
js/src/Makefile.in
js/src/config/autoconf.mk.in
js/src/configure.in
js/src/editline/Makefile.in
js/src/js.cpp
js/src/shell/Makefile.in
js/src/shell/js.cpp
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -127,17 +127,16 @@ MOZ_UNIVERSALCHARDET = @MOZ_UNIVERSALCHA
 ACCESSIBILITY = @ACCESSIBILITY@
 MOZ_VIEW_SOURCE = @MOZ_VIEW_SOURCE@
 MOZ_XPINSTALL = @MOZ_XPINSTALL@
 MOZ_JSLOADER  = @MOZ_JSLOADER@
 MOZ_USE_NATIVE_UCONV = @MOZ_USE_NATIVE_UCONV@
 MOZ_BRANDING_DIRECTORY = @MOZ_BRANDING_DIRECTORY@
 XPCOM_USE_LEA = @XPCOM_USE_LEA@
 JS_ULTRASPARC_OPTS = @JS_ULTRASPARC_OPTS@
-JS_STATIC_BUILD = @JS_STATIC_BUILD@
 MOZ_ENABLE_POSTSCRIPT = @MOZ_ENABLE_POSTSCRIPT@
 MOZ_INSTALLER	= @MOZ_INSTALLER@
 MOZ_UPDATER	= @MOZ_UPDATER@
 MOZ_UPDATE_PACKAGING	= @MOZ_UPDATE_PACKAGING@
 MOZ_NO_ACTIVEX_SUPPORT = @MOZ_NO_ACTIVEX_SUPPORT@
 MOZ_ACTIVEX_SCRIPTING_SUPPORT = @MOZ_ACTIVEX_SCRIPTING_SUPPORT@
 MOZ_DISABLE_VISTA_SDK_REQUIREMENTS = @MOZ_DISABLE_VISTA_SDK_REQUIREMENTS@
 MOZ_DISABLE_PARENTAL_CONTROLS = @MOZ_DISABLE_PARENTAL_CONTROLS@
--- a/configure.in
+++ b/configure.in
@@ -4376,17 +4376,16 @@ MOZ_XTF=1
 MOZ_XUL=1
 MOZ_XUL_APP=1
 MOZ_ZIPWRITER=1
 NS_PRINTING=1
 NECKO_COOKIES=1
 NECKO_DISK_CACHE=1
 NECKO_PROTOCOLS_DEFAULT="about data file ftp gopher http res viewsource"
 NECKO_SMALL_BUFFERS=
-JS_STATIC_BUILD=
 XPC_IDISPATCH_SUPPORT=
 
 
 case "$target_os" in
 darwin*)
     ACCESSIBILITY=
     ;;
 *)
@@ -4469,17 +4468,16 @@ basic)
   MOZ_XPINSTALL=
   MOZ_XTF=
   MOZ_ZIPWRITER=
   NECKO_DISK_CACHE=
   NECKO_PROTOCOLS_DEFAULT="about data http file res"
   NECKO_SMALL_BUFFERS=1
   NS_DISABLE_LOGGING=1
   NS_PRINTING=
-  JS_STATIC_BUILD=1
   ;;
 
 minimal)
   MOZ_EMBEDDING_LEVEL_DEFAULT=
   MOZ_EMBEDDING_LEVEL_BASIC=
   MOZ_EMBEDDING_LEVEL_MINIMAL=1
   AC_DEFINE(MOZ_EMBEDDING_LEVEL_MINIMAL)
   ENABLE_TESTS=
@@ -4517,17 +4515,16 @@ minimal)
   MOZ_XUL=
   MOZ_ZIPWRITER=
   MOZ_RDF=
   NECKO_DISK_CACHE=
   NECKO_PROTOCOLS_DEFAULT="about data http file res"
   NECKO_SMALL_BUFFERS=1
   NS_DISABLE_LOGGING=1
   NS_PRINTING=
-  JS_STATIC_BUILD=1
   ;;
 
 *)
   AC_MSG_ERROR([Unrecognized value: --with-embedding-profile=$MOZ_EMBEDDING_PROFILE])
   ;;
 esac
 
 AC_SUBST(MOZ_EMBEDDING_LEVEL_DEFAULT)
@@ -7214,35 +7211,16 @@ if test -n "$MOZ_ENABLE_LIBXUL"; then
 else
     if test -n "$BUILD_STATIC_LIBS"; then
         AC_DEFINE(MOZ_STATIC_BUILD)
     fi
     XPCOM_LIBS="$DYNAMIC_XPCOM_LIBS"
 fi
 
 dnl ========================================================
-dnl = Force JS to be a static lib
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(js-static-build,
-[  --enable-js-static-build  Force js to be a static lib],
-    JS_STATIC_BUILD=1,
-    JS_STATIC_BUILD= )
-
-AC_SUBST(JS_STATIC_BUILD)
-        
-if test -n "$JS_STATIC_BUILD"; then
-    AC_DEFINE(EXPORT_JS_API)
-
-if test -z "$BUILD_STATIC_LIBS"; then
-    AC_MSG_ERROR([--enable-js-static-build is only compatible with --enable-static])
-fi
-
-fi
-
-dnl ========================================================
 dnl =
 dnl = Standalone module options
 dnl = 
 dnl ========================================================
 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
 
 dnl Check for GLib and libIDL.
 dnl ========================================================
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -44,25 +44,28 @@ srcdir		= @srcdir@
 include $(DEPTH)/config/autoconf.mk
 
 DIRS		= config
 
 ifdef DEHYDRA_PATH
 DIRS += analysis-tests
 endif
 
-MODULE		= js
-LIBRARY_NAME	= mozjs
-GRE_MODULE	= 1
+ifdef JS_NATIVE_EDITLINE
+DIRS += editline
+endif
 
-PROGRAM         = js$(BIN_SUFFIX)
-# The shell uses some 'HIDDEN' symbols to produce statistics, so we
-# link directly against the .o files, not against the JS shared
-# library.
-PROGOBJS	= js.$(OBJ_SUFFIX) $(OBJS)
+# editline needs to get built before the shell
+DIRS += shell
+
+MODULE		    = js
+LIBRARY_NAME	    = mozjs
+STATIC_LIBRARY_NAME = js_static
+GRE_MODULE	    = 1
+
 LIBS		= $(NSPR_LIBS)
 
 ifdef GNU_CXX
 ifdef INTEL_CXX
 # icc gets special optimize flags
 ifdef MOZ_PROFILE_GENERATE
 MODULE_OPTIMIZE_FLAGS = -O0
 else
@@ -92,20 +95,22 @@ endif
 ifeq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
 LIBRARY_NAME	= js$(MOZ_BITS)$(VERSION_NUMBER)
 endif
 
 # JavaScript must be built shared, even for static builds, as it is used by
 # other modules which are always built shared. Failure to do so results in
 # the js code getting copied into xpinstall and jsd as well as mozilla-bin,
 # and then the static data cells used for locking no longer work.
+#
+# In fact, we now build both a static and a shared library, as the
+# JS shell would like to link to the static library.
 
-ifndef JS_STATIC_BUILD
 FORCE_SHARED_LIB = 1
-endif
+FORCE_STATIC_LIB = 1
 
 VPATH		= $(srcdir)
 
 CPPSRCS		= \
 		jsapi.cpp \
 		jsarena.cpp \
 		jsarray.cpp \
 		jsatom.cpp \
@@ -229,19 +234,17 @@ CPPSRCS += \
 		avmplus.cpp    \
 		Native$(NANOJIT_ARCH).cpp \
 		jsbuiltins.cpp         \
 		$(NULL)
 
 ifdef DEBUG
 CPPSRCS += TraceTreeDrawer.cpp
 endif
-
-DEFINES += -DFEATURE_NANOJIT -DJS_TRACER
-endif
+endif # ENABLE_JIT
 
 ifdef HAVE_DTRACE
 INSTALLED_HEADERS += \
 		jsdtracef.h \
 		$(CURDIR)/javascript-trace.h \
 		$(NULL)
 endif
 
--- a/js/src/config/autoconf.mk.in
+++ b/js/src/config/autoconf.mk.in
@@ -101,17 +101,16 @@ EAZEL_PROFILER_CFLAGS=@EAZEL_PROFILER_CF
 EAZEL_PROFILER_LIBS=@EAZEL_PROFILER_LIBS@
 GC_LEAK_DETECTOR = @GC_LEAK_DETECTOR@
 NS_TRACE_MALLOC = @NS_TRACE_MALLOC@
 INCREMENTAL_LINKER = @INCREMENTAL_LINKER@
 MACOSX_DEPLOYMENT_TARGET = @MACOSX_DEPLOYMENT_TARGET@
 BUILD_STATIC_LIBS = @BUILD_STATIC_LIBS@
 ENABLE_TESTS	= @ENABLE_TESTS@
 JS_ULTRASPARC_OPTS = @JS_ULTRASPARC_OPTS@
-JS_STATIC_BUILD = @JS_STATIC_BUILD@
 
 TAR=@TAR@
 
 # The MOZ_UI_LOCALE var is used to build a particular locale. Do *not*
 # use the var to change any binary files. Do *not* use this var unless you
 # write rules for the "clean-locale" and "locale" targets.
 MOZ_UI_LOCALE = @MOZ_UI_LOCALE@
 
@@ -264,16 +263,19 @@ SDP		= @SDP@
 NSINSTALL_BIN	= @NSINSTALL_BIN@
 
 NSPR_CONFIG	= @NSPR_CONFIG@
 NSPR_CFLAGS	= @NSPR_CFLAGS@
 NSPR_LIBS	= @NSPR_LIBS@
 
 USE_DEPENDENT_LIBS = @USE_DEPENDENT_LIBS@
 
+JS_NATIVE_EDITLINE = @JS_NATIVE_EDITLINE@
+EDITLINE_LIBS      = @EDITLINE_LIBS@
+
 # MKSHLIB_FORCE_ALL is used to force the linker to include all object
 # files present in an archive. MKSHLIB_UNFORCE_ALL reverts the linker
 # to normal behavior. Makefile's that create shared libraries out of
 # archives use these flags to force in all of the .o files in the
 # archives into the shared library.
 WRAP_MALLOC_LIB         = @WRAP_MALLOC_LIB@
 WRAP_MALLOC_CFLAGS      = @WRAP_MALLOC_CFLAGS@
 DSO_CFLAGS              = @DSO_CFLAGS@
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -2474,16 +2474,19 @@ arm*-*)
 esac
 
 MOZ_ARG_DISABLE_BOOL(jit,
 [  --disable-jit           Disable JIT support],
   ENABLE_JIT=)
 
 if test "$ENABLE_JIT"; then
 
+AC_DEFINE(FEATURE_NANOJIT)
+AC_DEFINE(JS_TRACER)
+
 case "$target" in
 i?86-*)
     AC_DEFINE(AVMPLUS_IA32)
     ;;
 
 arm*-*)
     AC_DEFINE(AVMPLUS_ARM)
     ;;
@@ -3886,17 +3889,16 @@ dnl = Application
 dnl =
 dnl ========================================================
 
 MOZ_ARG_HEADER(Application)
 
 BUILD_STATIC_LIBS=
 ENABLE_TESTS=1
 MOZ_DBGRINFO_MODULES=
-JS_STATIC_BUILD=
 
 dnl ========================================================
 dnl =
 dnl = Components & Features
 dnl = 
 dnl ========================================================
 MOZ_ARG_HEADER(Components and Features)
 
@@ -4835,33 +4837,43 @@ dnl ====================================
 MOZ_ARG_HEADER(Static build options)
 
 MOZ_ARG_ENABLE_BOOL(static,
 [  --enable-static         Enable building of internal static libs],
     BUILD_STATIC_LIBS=1,
     BUILD_STATIC_LIBS=)
 
 dnl ========================================================
-dnl = Force JS to be a static lib
+dnl = Link js shell to system readline
 dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(js-static-build,
-[  --enable-js-static-build  Force js to be a static lib],
-    JS_STATIC_BUILD=1,
-    JS_STATIC_BUILD= )
-
-AC_SUBST(JS_STATIC_BUILD)
-        
-if test -n "$JS_STATIC_BUILD"; then
-    AC_DEFINE(EXPORT_JS_API)
-
-if test -z "$BUILD_STATIC_LIBS"; then
-    AC_MSG_ERROR([--enable-js-static-build is only compatible with --enable-static])
+MOZ_ARG_ENABLE_BOOL(readline,
+[  --enable-readline  Link js shell to system readline library],
+    JS_WANT_READLINE=1,
+    JS_WANT_READLINE= )
+
+JS_NATIVE_EDITLINE=
+EDITLINE_LIBS=
+
+dnl Conveniently, Win32 sets SKIP_LIBRARY_CHECKS...
+if test -z "$SKIP_LIBRARY_CHECKS"; then
+  if test -n "$JS_WANT_READLINE"; then
+    AC_CHECK_LIB(readline, readline,
+                 EDITLINE_LIBS="-lreadline",
+                 AC_MSG_ERROR([No system readline library found.]))
+  else
+    dnl By default, we use editline
+    JS_NATIVE_EDITLINE=1
+    EDITLINE_LIBS='$(DEPTH)/editline/$(LIB_PREFIX)editline.$(LIB_SUFFIX)'
+  fi
+
+  dnl Either way, we want to build with line editing support.
+  AC_DEFINE(EDITLINE)
 fi
-
-fi
+AC_SUBST(JS_NATIVE_EDITLINE)
+AC_SUBST(EDITLINE_LIBS)
 
 dnl ========================================================
 dnl =
 dnl = Standalone module options
 dnl = 
 dnl ========================================================
 MOZ_ARG_HEADER(Standalone module options (Not for building Mozilla))
 
@@ -5236,21 +5248,28 @@ egrep -v "$_EGREP_PATTERN" confdefs.h.sa
 AC_OUTPUT_MAKE_DEFS()
 MOZ_DEFINES=$DEFS
 AC_SUBST(MOZ_DEFINES)
 rm -f confdefs.h
 mv confdefs.h.save confdefs.h
 
 MAKEFILES="
   Makefile
+  shell/Makefile
   config/Makefile
   config/autoconf.mk
   config/mkdepend/Makefile
 "
 
+if test -n "$JS_NATIVE_EDITLINE"; then
+   MAKEFILES="$MAKEFILES
+editline/Makefile
+"
+fi
+
 dnl 
 dnl Run a perl script to quickly create the makefiles.
 dnl If it succeeds, it outputs a shell command to set CONFIG_FILES
 dnl   for the files it cannot handle correctly. This way, config.status
 dnl   will handle these files.
 dnl If it fails, nothing is set and config.status will run as usual.
 dnl
 dnl This does not change the $MAKEFILES variable.
new file mode 100644
--- /dev/null
+++ b/js/src/editline/Makefile.in
@@ -0,0 +1,55 @@
+# -*- Mode: makefile -*-
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Spidermonkey build system.
+#
+# The Initial Developer of the Original Code is
+# The Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2008
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Ted Mielczarek <ted.mielczarek@gmail.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH = ..
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH           = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+LIBRARY_NAME = editline
+FORCE_STATIC_LIB = 1
+
+CSRCS = editline.c sysunix.c
+
+DEFINES += -DANSI_ARROWS -DHAVE_TCGETATTR -DHIDE -DUSE_DIRENT -DSYS_UNIX \
+	-DHAVE_STDLIB -DUNIQUE_HISTORY
+
+include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/js/src/shell/Makefile.in
@@ -0,0 +1,60 @@
+# -*- Mode: makefile -*-
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Spidermonkey build system.
+#
+# The Initial Developer of the Original Code is
+# The Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2008
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Ted Mielczarek <ted.mielczarek@gmail.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either of the GNU General Public License Version 2 or later (the "GPL"),
+# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+DEPTH		= ..
+topsrcdir	= @top_srcdir@
+srcdir		= @srcdir@
+VPATH		= @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+PROGRAM         = js$(BIN_SUFFIX)
+CPPSRCS		= js.cpp
+
+DEFINES         += -DEXPORT_JS_API
+
+LIBS      = $(NSPR_LIBS) $(EDITLINE_LIBS) $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX)
+
+LOCAL_INCLUDES += -I$(topsrcdir) -I..
+
+include $(topsrcdir)/config/rules.mk
+
+# People expect the js shell to wind up in the top-level JS dir.
+libs::
+	$(INSTALL) $(IFLAGS2) $(PROGRAM) $(DEPTH)
rename from js/src/js.cpp
rename to js/src/shell/js.cpp