bug 462004 - JavaScript shell should provide line editing facilities. r=bsmedberg
☠☠ backed out by bac73f9f2d2b ☠ ☠
authorTed Mielczarek <ted.mielczarek@gmail.com>
Wed, 03 Dec 2008 08:55:27 -0500
changeset 23047 55e23c6471379101a0e8a8e1f1f0e0b39b26c711
parent 23046 73be1c836d7f066f200ad4565d74bbc9354d2689
child 23048 8ceeb8f5d1f2cd199cdd4bd8c54c5464005cb8ce
child 23126 bac73f9f2d2b28630201fe2a2511b3a5bce0f68e
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
@@ -4374,17 +4374,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=
     ;;
 *)
@@ -4467,17 +4466,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=
@@ -4515,17 +4513,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)
@@ -7183,35 +7180,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
@@ -47,25 +47,28 @@ include $(DEPTH)/config/autoconf.mk
 
 ifndef JS_MOZ_INSTALL
 # This is the appropriate behavior for GNU-style 'make install'.  For
 # Mozilla in-tree behavior, leaving NSDISTMODE unset is the right
 # thing; config/js/Makefile.in sets JS_MOZ_INSTALL in that case.
 NSDISTMODE	= copy
 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
@@ -95,20 +98,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
 
 ifeq (86,$(findstring 86,$(OS_TEST)))
 ifeq (64,$(findstring 64,$(OS_TEST)))
 else
 DEFINES += -DAVMPLUS_IA32
 NANOJIT_ARCH = i386
 ENABLE_JIT = 1
 endif
@@ -610,30 +615,32 @@ js-config: js-config.in Makefile $(DEPTH
 SCRIPTS = js-config
 
 install:: $(INSTALLED_HEADERS)
 	$(INSTALL) $(IFLAGS1) $^ $(includedir)/$(MODULE)
 
 install:: $(SCRIPTS) $(PROGRAM)
 	$(INSTALL) $(IFLAGS2) $^ $(bindir)
 
+install:: $(LIBRARY)
+ifneq (,$(LIBRARY))
+	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(libdir)
+endif
+ifneq (,$(IMPORT_LIBRARY))
+	$(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(libdir)
+endif
+
 # The Mozilla top-level makefiles use install-runtime-libs directly to
 # place an additional copy of the libraries in the 'dist/bin'
 # directory.
 install:: install-runtime-libs
 install-runtime-libs:: $(LIBRARY) $(SHARED_LIBRARY) $(IMPORT_LIBRARY)
-ifneq (,$(LIBRARY))
-	$(INSTALL) $(IFLAGS1) $(LIBRARY) $(libdir)
-endif
 ifneq (,$(SHARED_LIBRARY))
 	$(INSTALL) $(IFLAGS2) $(SHARED_LIBRARY) $(libdir)
 endif
-ifneq (,$(IMPORT_LIBRARY))
-	$(INSTALL) $(IFLAGS2) $(IMPORT_LIBRARY) $(libdir)
-endif
 
 # Extra dependancies and rules for auto-generated headers
 host_jskwgen.$(OBJ_SUFFIX): jsversion.h jskeyword.tbl
 
 # Use CURDIR to avoid finding a jsautokw.h in the source tree (from a
 # previous build?) via VPATH when we're building in a separate tree.
 $(CURDIR)/jsautokw.h: host_jskwgen$(HOST_BIN_SUFFIX)
 	./host_jskwgen$(HOST_BIN_SUFFIX) $@
--- 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
@@ -3803,17 +3803,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)
 
@@ -4741,33 +4740,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))
 
@@ -5142,21 +5151,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