Bug 97954: Record configuration details in an installable header. r=bsmedberg

Have js/src/configure create a header file, js-config.h, that records
configure-controlled options that affect the SpiderMonkey API, like
'--enable-threadsafe'.  js-config.h is namespace-clean, so it can be
installed with jsapi.h.

This means that clients can configure SpiderMonkey however they like,
and then simply #include "jsapi.h" and have everything work; they
don't have to remember to match their own compiler -D flags with those
SpiderMonkey's configure script chose.  For example, mozilla-config.h
needn't concern itself with JS_THREADSAFE.

It seems to me this could also be done by having js-config --cflags
print -D options.  The approach taken here seems a bit more robust: if
you can find jsapi.h at all, then you know you're getting the right
settings.
This commit is contained in:
Jim Blandy 2008-10-29 08:29:37 -07:00
Родитель 3ba206cdb7
Коммит b04f90894c
5 изменённых файлов: 58 добавлений и 2 удалений

Просмотреть файл

@ -8048,8 +8048,6 @@ elif test "$OS_ARCH" != "WINNT" -a "$OS_ARCH" != "OS2" -a "$OS_ARCH" != "WINCE";
fi
AC_SUBST(MOZ_MOVEMAIL)
AC_DEFINE(JS_THREADSAFE)
if test "$MOZ_DEBUG"; then
AC_DEFINE(MOZ_REFLOW_PERF)
AC_DEFINE(MOZ_REFLOW_PERF_DSP)

Просмотреть файл

@ -170,6 +170,7 @@ CSRCS += \
endif
INSTALLED_HEADERS = \
js-config.h \
jsautocfg.h \
jsautokw.h \
js.msg \

Просмотреть файл

@ -63,6 +63,7 @@ dnl ========================================================
AC_PREREQ(2.13)
AC_INIT(jsapi.h)
AC_CONFIG_AUX_DIR(${srcdir}/build/autoconf)
AC_CONFIG_HEADER(js-config.h)
AC_CANONICAL_SYSTEM
TARGET_CPU="${target_cpu}"
TARGET_VENDOR="${target_vendor}"

55
js/src/js-config.h.in Normal file
Просмотреть файл

@ -0,0 +1,55 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sw=4 et tw=78:
*
* ***** 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 Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* 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 ***** */
#ifndef js_config_h___
#define js_config_h___
/* Definitions set at build time that affect SpiderMonkey's public API.
This header file is generated by the SpiderMonkey configure script,
and installed along with jsapi.h. */
/* Define to 1 if SpiderMonkey should support multi-threaded clients. */
#undef JS_THREADSAFE
/* Define to 1 if SpiderMonkey should support the ability to perform
entirely too much GC. */
#undef JS_GC_ZEAL
#endif /* js_config_h___ */

Просмотреть файл

@ -45,6 +45,7 @@
*/
#include <stddef.h>
#include <stdio.h>
#include "js-config.h"
#include "jspubtd.h"
#include "jsutil.h"