Commit 173741d0 authored by Philip Chimento's avatar Philip Chimento

Merge branch 'master.windows' into 'master'

Fix Windows builds on GIT master

Closes #228

See merge request GNOME/gjs!270
parents 64a88b75 169e21fc
......@@ -36,6 +36,7 @@ AC_LANG([C++])
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX_14
AC_CHECK_HEADERS([sys/syscall.h unistd.h])
LT_PREREQ([2.2.0])
# no stupid static libraries
......
......@@ -1592,7 +1592,7 @@ gjs_value_to_g_argument(JSContext *context,
GjsAutoBaseInfo interface_info =
g_type_info_get_interface(type_info);
g_assert(interface_info != NULL);
g_assert(interface_info);
GIInfoType interface_type = g_base_info_get_type(interface_info);
if (interface_type == GI_INFO_TYPE_ENUM ||
......
......@@ -882,6 +882,7 @@ BoxedPrototype::BoxedPrototype(GIStructInfo* info, GType gtype)
m_zero_args_constructor(-1),
m_default_constructor(-1),
m_default_constructor_name(JSID_VOID),
m_field_map(nullptr),
m_can_allocate_directly(struct_is_simple(info)) {
GJS_INC_COUNTER(boxed_prototype);
}
......
......@@ -55,7 +55,7 @@ class BoxedInstance;
class BoxedBase
: public GIWrapperBase<BoxedBase, BoxedPrototype, BoxedInstance> {
friend class GIWrapperBase;
friend class GIWrapperBase<BoxedBase, BoxedPrototype, BoxedInstance>;
protected:
explicit BoxedBase(BoxedPrototype* proto = nullptr)
......@@ -89,8 +89,9 @@ class BoxedBase
class BoxedPrototype : public GIWrapperPrototype<BoxedBase, BoxedPrototype,
BoxedInstance, GIStructInfo> {
friend class GIWrapperPrototype;
friend class GIWrapperBase;
friend class GIWrapperPrototype<BoxedBase, BoxedPrototype, BoxedInstance,
GIStructInfo>;
friend class GIWrapperBase<BoxedBase, BoxedPrototype, BoxedInstance>;
using FieldMap =
JS::GCHashMap<JS::Heap<JSString*>, GjsAutoFieldInfo,
......@@ -155,8 +156,8 @@ class BoxedPrototype : public GIWrapperPrototype<BoxedBase, BoxedPrototype,
class BoxedInstance
: public GIWrapperInstance<BoxedBase, BoxedPrototype, BoxedInstance> {
friend class GIWrapperInstance;
friend class GIWrapperBase;
friend class GIWrapperInstance<BoxedBase, BoxedPrototype, BoxedInstance>;
friend class GIWrapperBase<BoxedBase, BoxedPrototype, BoxedInstance>;
friend class BoxedBase; // for field_getter, etc.
bool m_allocated_directly : 1;
......
......@@ -248,7 +248,8 @@ FundamentalPrototype::FundamentalPrototype(GIObjectInfo* info, GType gtype)
m_ref_function(g_object_info_get_ref_function_pointer(info)),
m_unref_function(g_object_info_get_unref_function_pointer(info)),
m_get_value_function(g_object_info_get_get_value_function_pointer(info)),
m_set_value_function(g_object_info_get_set_value_function_pointer(info)) {
m_set_value_function(g_object_info_get_set_value_function_pointer(info)),
m_constructor_info(nullptr) {
g_assert(m_ref_function);
g_assert(m_unref_function);
g_assert(m_set_value_function);
......
......@@ -45,7 +45,8 @@ class FundamentalInstance;
class FundamentalBase
: public GIWrapperBase<FundamentalBase, FundamentalPrototype,
FundamentalInstance> {
friend class GIWrapperBase;
friend class GIWrapperBase<FundamentalBase, FundamentalPrototype,
FundamentalInstance>;
protected:
explicit FundamentalBase(FundamentalPrototype* proto = nullptr)
......@@ -66,8 +67,10 @@ class FundamentalBase
class FundamentalPrototype
: public GIWrapperPrototype<FundamentalBase, FundamentalPrototype,
FundamentalInstance> {
friend class GIWrapperPrototype;
friend class GIWrapperBase;
friend class GIWrapperPrototype<FundamentalBase, FundamentalPrototype,
FundamentalInstance>;
friend class GIWrapperBase<FundamentalBase, FundamentalPrototype,
FundamentalInstance>;
GIObjectInfoRefFunction m_ref_function;
GIObjectInfoUnrefFunction m_unref_function;
......@@ -122,8 +125,10 @@ class FundamentalPrototype
class FundamentalInstance
: public GIWrapperInstance<FundamentalBase, FundamentalPrototype,
FundamentalInstance> {
friend class GIWrapperInstance;
friend class GIWrapperBase;
friend class GIWrapperInstance<FundamentalBase, FundamentalPrototype,
FundamentalInstance>;
friend class GIWrapperBase<FundamentalBase, FundamentalPrototype,
FundamentalInstance>;
explicit FundamentalInstance(JSContext* cx, JS::HandleObject obj);
~FundamentalInstance(void);
......
......@@ -51,7 +51,7 @@ class ErrorInstance;
class ErrorBase
: public GIWrapperBase<ErrorBase, ErrorPrototype, ErrorInstance> {
friend class GIWrapperBase;
friend class GIWrapperBase<ErrorBase, ErrorPrototype, ErrorInstance>;
protected:
explicit ErrorBase(ErrorPrototype* proto = nullptr)
......@@ -93,8 +93,9 @@ class ErrorBase
class ErrorPrototype : public GIWrapperPrototype<ErrorBase, ErrorPrototype,
ErrorInstance, GIEnumInfo> {
friend class GIWrapperPrototype;
friend class GIWrapperBase;
friend class GIWrapperPrototype<ErrorBase, ErrorPrototype, ErrorInstance,
GIEnumInfo>;
friend class GIWrapperBase<ErrorBase, ErrorPrototype, ErrorInstance>;
GQuark m_domain;
......@@ -110,8 +111,9 @@ class ErrorPrototype : public GIWrapperPrototype<ErrorBase, ErrorPrototype,
class ErrorInstance : public GIWrapperInstance<ErrorBase, ErrorPrototype,
ErrorInstance, GError> {
friend class GIWrapperInstance;
friend class GIWrapperBase;
friend class GIWrapperInstance<ErrorBase, ErrorPrototype, ErrorInstance,
GError>;
friend class GIWrapperBase<ErrorBase, ErrorPrototype, ErrorInstance>;
explicit ErrorInstance(JSContext* cx, JS::HandleObject obj);
~ErrorInstance(void);
......
......@@ -50,7 +50,8 @@ class InterfaceInstance;
class InterfaceBase : public GIWrapperBase<InterfaceBase, InterfacePrototype,
InterfaceInstance> {
friend class GIWrapperBase;
friend class GIWrapperBase<InterfaceBase, InterfacePrototype,
InterfaceInstance>;
protected:
explicit InterfaceBase(InterfacePrototype* proto = nullptr)
......@@ -83,8 +84,10 @@ class InterfaceBase : public GIWrapperBase<InterfaceBase, InterfacePrototype,
class InterfacePrototype
: public GIWrapperPrototype<InterfaceBase, InterfacePrototype,
InterfaceInstance, GIInterfaceInfo> {
friend class GIWrapperPrototype;
friend class GIWrapperBase;
friend class GIWrapperPrototype<InterfaceBase, InterfacePrototype,
InterfaceInstance, GIInterfaceInfo>;
friend class GIWrapperBase<InterfaceBase, InterfacePrototype,
InterfaceInstance>;
friend class InterfaceBase; // for has_instance_impl
// the GTypeInterface vtable wrapped by this JS object
......@@ -108,8 +111,10 @@ class InterfacePrototype
class InterfaceInstance
: public GIWrapperInstance<InterfaceBase, InterfacePrototype,
InterfaceInstance> {
friend class GIWrapperInstance;
friend class GIWrapperBase;
friend class GIWrapperInstance<InterfaceBase, InterfacePrototype,
InterfaceInstance>;
friend class GIWrapperBase<InterfaceBase, InterfacePrototype,
InterfaceInstance>;
G_GNUC_NORETURN InterfaceInstance(JSContext* cx, JS::HandleObject obj)
: GIWrapperInstance(cx, obj) {
......
......@@ -658,7 +658,7 @@ bool ObjectPrototype::resolve_no_info(JSContext* cx, JS::HandleObject obj,
GjsAutoFunctionInfo method_info =
g_interface_info_find_method(iface_info, name);
if (method_info != NULL) {
if (method_info) {
if (g_function_info_get_flags (method_info) & GI_FUNCTION_IS_METHOD) {
if (!gjs_define_function(cx, obj, m_gtype, method_info)) {
g_free(interfaces);
......@@ -760,8 +760,7 @@ bool ObjectPrototype::resolve_impl(JSContext* context, JS::HandleObject obj,
bool defined_by_parent;
GjsAutoVFuncInfo vfunc = find_vfunc_on_parents(
m_info, name_without_vfunc_, &defined_by_parent);
if (vfunc != NULL) {
if (vfunc) {
/* In the event that the vfunc is unchanged, let regular
* prototypal inheritance take over. */
if (defined_by_parent && is_vfunc_unchanged(vfunc)) {
......@@ -2195,7 +2194,7 @@ bool ObjectPrototype::hook_up_vfunc_impl(JSContext* cx,
&field_info))
return false;
if (field_info != NULL) {
if (field_info) {
gint offset;
gpointer method_ptr;
GjsCallbackTrampoline *trampoline;
......
......@@ -79,7 +79,7 @@ class ObjectPrototype;
*/
class ObjectBase
: public GIWrapperBase<ObjectBase, ObjectPrototype, ObjectInstance> {
friend class GIWrapperBase;
friend class GIWrapperBase<ObjectBase, ObjectPrototype, ObjectInstance>;
protected:
/* a list of all GClosures installed on this object (from
......@@ -167,8 +167,9 @@ class ObjectBase
class ObjectPrototype
: public GIWrapperPrototype<ObjectBase, ObjectPrototype, ObjectInstance> {
friend class GIWrapperPrototype;
friend class GIWrapperBase;
friend class GIWrapperPrototype<ObjectBase, ObjectPrototype,
ObjectInstance>;
friend class GIWrapperBase<ObjectBase, ObjectPrototype, ObjectInstance>;
using PropertyCache =
JS::GCHashMap<JS::Heap<JSString*>, GjsAutoParam,
......@@ -250,8 +251,9 @@ class ObjectPrototype
class ObjectInstance : public GIWrapperInstance<ObjectBase, ObjectPrototype,
ObjectInstance, GObject> {
friend class GIWrapperInstance;
friend class GIWrapperBase;
friend class GIWrapperInstance<ObjectBase, ObjectPrototype, ObjectInstance,
GObject>;
friend class GIWrapperBase<ObjectBase, ObjectPrototype, ObjectInstance>;
friend class ObjectBase; // for add_property, prop_getter, etc.
// GIWrapperInstance::m_ptr may be null in ObjectInstance.
......
......@@ -37,7 +37,7 @@ class UnionInstance;
class UnionBase
: public GIWrapperBase<UnionBase, UnionPrototype, UnionInstance> {
friend class GIWrapperBase;
friend class GIWrapperBase<UnionBase, UnionPrototype, UnionInstance>;
protected:
explicit UnionBase(UnionPrototype* proto = nullptr)
......@@ -55,8 +55,9 @@ class UnionBase
class UnionPrototype : public GIWrapperPrototype<UnionBase, UnionPrototype,
UnionInstance, GIUnionInfo> {
friend class GIWrapperPrototype;
friend class GIWrapperBase;
friend class GIWrapperPrototype<UnionBase, UnionPrototype, UnionInstance,
GIUnionInfo>;
friend class GIWrapperBase<UnionBase, UnionPrototype, UnionInstance>;
explicit UnionPrototype(GIUnionInfo* info, GType gtype);
~UnionPrototype(void);
......@@ -71,8 +72,8 @@ class UnionPrototype : public GIWrapperPrototype<UnionBase, UnionPrototype,
class UnionInstance
: public GIWrapperInstance<UnionBase, UnionPrototype, UnionInstance> {
friend class GIWrapperInstance;
friend class GIWrapperBase;
friend class GIWrapperInstance<UnionBase, UnionPrototype, UnionInstance>;
friend class GIWrapperBase<UnionBase, UnionPrototype, UnionInstance>;
explicit UnionInstance(JSContext* cx, JS::HandleObject obj);
~UnionInstance(void);
......
......@@ -25,7 +25,6 @@
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
#include <array>
#include <codecvt>
......@@ -59,6 +58,10 @@
#include <windows.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <string.h>
static void gjs_context_dispose (GObject *object);
......@@ -126,6 +129,8 @@ static GList *all_contexts = NULL;
static GjsAutoChar dump_heap_output;
static unsigned dump_heap_idle_id = 0;
#ifdef G_OS_UNIX
/* Currently heap dumping is only supported on UNIX platforms! */
static void
gjs_context_dump_heaps(void)
{
......@@ -167,6 +172,7 @@ dump_heap_signal_handler(int signum)
dump_heap_idle_id = g_idle_add_full(G_PRIORITY_HIGH_IDLE,
dump_heap_idle, nullptr, nullptr);
}
#endif
static void
setup_dump_heap(void)
......@@ -178,6 +184,7 @@ setup_dump_heap(void)
/* install signal handler only if environment variable is set */
const char *heap_output = g_getenv("GJS_DEBUG_HEAP_OUTPUT");
if (heap_output) {
#ifdef G_OS_UNIX
struct sigaction sa;
dump_heap_output = g_strdup(heap_output);
......@@ -185,6 +192,10 @@ setup_dump_heap(void)
memset(&sa, 0, sizeof(sa));
sa.sa_handler = dump_heap_signal_handler;
sigaction(SIGUSR1, &sa, nullptr);
#else
g_message(
"heap dump is currently only supported on UNIX platforms");
#endif
}
}
}
......@@ -956,8 +967,14 @@ bool GjsContextPrivate::eval_with_scope(JS::HandleObject scope_object,
JS::CompileOptions options(m_cx);
options.setFileAndLine(filename, start_line_number).setSourceIsLazy(true);
#if defined(G_OS_WIN32) && (defined(_MSC_VER) && (_MSC_VER >= 1900))
std::wstring wscript = gjs_win32_vc140_utf8_to_utf16(script);
std::u16string utf16_string(reinterpret_cast<const char16_t*>(wscript.c_str()));
#else
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
std::u16string utf16_string = convert.from_bytes(script);
#endif
JS::SourceBufferHolder buf(utf16_string.c_str(), utf16_string.size(),
JS::SourceBufferHolder::NoOwnership);
......
......@@ -22,8 +22,6 @@
* Authored By: Philip Chimento <philip.chimento@gmail.com>
*/
#include <unistd.h>
#include <gio/gio.h>
#include "gjs/context-private.h"
......@@ -36,6 +34,15 @@
#include <stdio.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#elif defined(XP_WIN)
# include <io.h>
# ifndef STDIN_FILENO
# define STDIN_FILENO 0
# endif
#endif
GJS_JSAPI_RETURN_CONVENTION
static bool quit(JSContext* cx, unsigned argc, JS::Value* vp) {
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
......@@ -90,7 +97,7 @@ static bool do_readline(JSContext* cx, unsigned argc, JS::Value* vp) {
args.rval().setUndefined();
return true;
}
} while (line && line[0] == '\0');
} while (line && line.get()[0] == '\0');
/* Add line to history and convert it to a JSString so that we can pass it
* back as the return value */
......
......@@ -707,7 +707,7 @@ static bool importer_new_enumerate(JSContext* context, JS::HandleObject object,
GjsAutoChar filename = g_file_get_basename(file);
/* skip hidden files and directories (.svn, .git, ...) */
if (filename[0] == '.')
if (filename.get()[0] == '.')
continue;
/* skip module init file */
......
......@@ -399,8 +399,8 @@ GJS_JSAPI_RETURN_CONVENTION static bool gjs_parse_call_args(
}
GjsAutoStrv parts = g_strsplit(format, "|", 2);
fmt_required = parts[0];
fmt_optional = parts[1]; /* may be NULL */
fmt_required = parts.get()[0];
fmt_optional = parts.get()[1]; // may be NULL
retval = parse_call_args_helper(cx, function_name, args,
ignore_trailing_args, fmt_required,
......
......@@ -34,6 +34,11 @@
#include <js/GCAPI.h>
#include <js/Printf.h>
#ifdef XP_WIN
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
#include "gjs/context-private.h"
#include "gjs/jsapi-class.h"
#include "gjs/jsapi-util.h"
......@@ -660,3 +665,26 @@ gjs_strip_unix_shebang(const char *script,
return script;
}
#if defined(G_OS_WIN32) && (defined(_MSC_VER) && (_MSC_VER >= 1900))
/* Unfortunately Visual Studio's C++ .lib somehow did not contain the right
* codecvt stuff that we need to convert from utf8 to utf16 (char16_t), so we
* need to work around this Visual Studio bug. Use Windows API
* MultiByteToWideChar() and obtain the std::u16string on the std::wstring we
* obtain from MultiByteToWideChar(). See:
* https://social.msdn.microsoft.com/Forums/en-US/8f40dcd8-c67f-4eba-9134-a19b9178e481/vs-2015-rc-linker-stdcodecvt-error?forum=vcgeneral
*/
std::wstring gjs_win32_vc140_utf8_to_utf16(const char* str) {
int len = MultiByteToWideChar(CP_UTF8, 0, str, -1, nullptr, 0);
if (len == 0)
return nullptr;
std::wstring wstr(len, 0);
int result = MultiByteToWideChar(CP_UTF8, 0, str, -1, &wstr[0], len);
if (result == 0)
return nullptr;
wstr.resize(strlen(str));
return wstr;
}
#endif
......@@ -363,4 +363,8 @@ GJS_USE std::string gjs_debug_id(jsid id);
GJS_USE
char* gjs_hyphen_to_underscore(const char* str);
#if defined(G_OS_WIN32) && (defined(_MSC_VER) && (_MSC_VER >= 1900))
GJS_USE std::wstring gjs_win32_vc140_utf8_to_utf16(const char* str);
#endif
#endif /* __GJS_JSAPI_UTIL_H__ */
......@@ -32,6 +32,7 @@
# else
# define GJS_EXPORT __declspec(dllimport)
# endif
# define siginfo_t void
#else
# define GJS_EXPORT
#endif
......
......@@ -99,8 +99,15 @@ class GjsModule {
JS::CompileOptions options(cx);
options.setFileAndLine(filename, line_number);
#if defined(G_OS_WIN32) && (defined(_MSC_VER) && (_MSC_VER >= 1900))
std::wstring wscript = gjs_win32_vc140_utf8_to_utf16(script);
std::u16string utf16_string(
reinterpret_cast<const char16_t*>(wscript.c_str()));
#else
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
std::u16string utf16_string = convert.from_bytes(script);
#endif
JS::SourceBufferHolder buf(utf16_string.c_str(), utf16_string.size(),
JS::SourceBufferHolder::NoOwnership);
......
......@@ -27,11 +27,7 @@
#include <errno.h>
#include <memory>
#include <signal.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <unistd.h>
#include <glib-unix.h>
#include "jsapi-wrapper.h"
#include <js/ProfilingStack.h>
......@@ -39,8 +35,18 @@
#include "context.h"
#include "jsapi-util.h"
#include "profiler-private.h"
#ifdef ENABLE_PROFILER
# include <alloca.h>
# ifdef HAVE_SYS_SYSCALL_H
# include <sys/syscall.h>
# endif
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
# ifdef G_OS_UNIX
# include <glib-unix.h>
# endif
# include "util/sp-capture-writer.h"
#endif
......
......@@ -27,12 +27,15 @@
#include <string.h>
#include <gio/gio.h>
#include <glib-unix.h>
#include <glib.h>
#include <glib/gi18n.h>
#include "gjs-util.h"
#ifdef G_OS_UNIX
# include <glib-unix.h>
#endif
char *
gjs_format_int_alternative_output(int n)
{
......@@ -164,6 +167,7 @@ int gjs_open_bytes(GBytes* bytes, GError** error) {
g_return_val_if_fail(bytes, -1);
g_return_val_if_fail(error == NULL || *error == NULL, -1);
#ifdef G_OS_UNIX
if (!g_unix_open_pipe(pipefd, FD_CLOEXEC, error))
return -1;
......@@ -186,4 +190,7 @@ int gjs_open_bytes(GBytes* bytes, GError** error) {
}
return pipefd[0];
#else
g_error("%s is currently supported on UNIX only", __func__);
#endif
}
......@@ -251,14 +251,18 @@ elif [[ $1 == "CPPLINT" && "$log_message" != *'[skip cpplint]'* ]]; then
do_Print_Labels 'C/C++ Linter report '
cpplint --quiet $(find . -name \*.cpp -or -name \*.c -or -name \*.h | sort) 2>&1 | \
tee "$save_dir"/analysis/current-report.txt | sed -E -e 's/:[0-9]+:/:LINE:/' -e 's/ +/ /g' > /cwd/current-report.txt
tee "$save_dir"/analysis/current-report.txt | \
sed -E -e 's/:[0-9]+:/:LINE:/' -e 's/Total errors found: [0-9]+//' -e 's/ +/ /g' \
> /cwd/current-report.txt
cat "$save_dir"/analysis/current-report.txt
echo
# Get the code committed at upstream master
do_Get_Upstream_Master "cppLint"
cpplint --quiet $(find . -name \*.cpp -or -name \*.c -or -name \*.h | sort) 2>&1 | \
tee "$save_dir"/analysis/master-report.txt | sed -E -e 's/:[0-9]+:/:LINE:/' -e 's/ +/ /g' > /cwd/master-report.txt
tee "$save_dir"/analysis/master-report.txt | \
sed -E -e 's/:[0-9]+:/:LINE:/' -e 's/Total errors found: [0-9]+//' -e 's/ +/ /g' \
> /cwd/master-report.txt
echo
# Compare the report with master and fail if new warnings are found
......
......@@ -18,8 +18,8 @@
!if "$(VALID_CFGSET)" == "TRUE"
# We need Visual Studio 2013 or later
!if $(VSVER) < 12
# We need Visual Studio 2017 15.6 or later
!if $(VCVERSION) < 1913
VALID_MSC = FALSE
!else
VALID_MSC = TRUE
......@@ -53,7 +53,7 @@ tests: all
!else # "$(VALID_MSC)" == "TRUE"
all:
@echo You need Visual Studio 2013 or later.
@echo You need Visual Studio 2017 15.6 or later.
!endif # "$(VALID_MSC)" == "TRUE"
......
Instructions for building GJS on Visual Studio
==============================================
Building the GJS on Windows is now supported using Visual Studio
versions 2013 or later in both 32-bit and 64-bit (x64) flavors,
via NMake Makefiles. Due to C++-11 usage, Visual Studio 2012 or
earlier is not supported.
versions 2017 15.6.x or later in both 32-bit and 64-bit (x64) flavors,
via NMake Makefiles. Due to C++-14 usage, Visual Studio 2015 or
earlier is not supported, nor is Visual Studio 2017 15.5.x or earlier,
as the compiler flag /Zc:externConstexpr is needed.
You will need the following items to build GJS using Visual Studio:
-SpiderMonkey 60 (mozjs-60)
-SpiderMonkey 60 (mozjs-60). Please see the below section carefully on this...
-GObject-Introspection (G-I) 1.41.4 or later
-GLib 2.50.x or later, (which includes GIO, GObject, and the associated tools)
-GLib 2.54.x or later, (which includes GIO, GObject, and the associated tools)
-Cairo including Cairo-GObject support, unless NO_CAIRO=1 is specified.
-GTK+-3.20.x or later, unless NO_GTK=1 is specified.
-and anything that the above items depends on.
......@@ -17,15 +18,60 @@ Note that SpiderMonkey must be built with Visual Studio, and the rest
should preferably be built with Visual Studio as well. The Visual Studio
version used should preferably be the one that is used here to build GJS.
If you built SpiderMonkey 38 using the normal build instructions as described
on Mozilla's website, you may notice that the output library, DLLs and include
directory might not be what one may expect, which is likely due to bugs in its build
scripts. If this is the case, rename mozjs-.lib to mozjs-38.lib, and the
include directory from mozjs- to mozjs-38 (but please do *not* rename mozjs-.dll
and mozjs-.pdb, as they will be searched for when gjs-console.exe/gjs.exe runs,
along with any program that uses the GJS DLL). Otherwise, do (or redo) the
SpiderMonkey build process (including running configure) after applying the patch
from https://git.gnome.org/browse/jhbuild/tree/patches/mozjs38-release-number.patch
Be aware that it is often hard to find a suitable source release for
SpiderMonkey nowadays, so it may be helpful to look in
ftp://ftp.gnome.org/pub/gnome/teams/releng/tarballs-needing-help/mozjs/
for the suitable release series of SpiderMonkey that corresponds to the GJS
version that is being built, as GJS depends on ESR (Extended Service Release,
a.k.a Long-term support) releases of SpiderMonkey.
Please do note that the build must be done carefully, in addition to the
official instructions that are posted on the Mozilla website:
https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Build_Documentation
For the configuration step, you will need to run the following:
(64-bit/x64 builds)
JS_STANDALONE=1 $(mozjs_srcroot)/js/src/configure --enable-nspr-build --host=x86_64-pc-mingw32 --target=x86_64-pc-mingw32 --prefix=--prefix=<some_prefix> --disable-jemalloc
(32-bit builds)
JS_STANDALONE=1 $(mozjs_srcroot)/js/src/configure --enable-nspr-build --prefix=<some_prefix> --disable-jemalloc
Notice that "JS_STANDALONE=1" and "--disable-jemalloc" are absolutely required,
otherwise GJS will not build/run correctly. Please do not try to update the
NMake Makefiles to link to mozglue.lib! Note in particular that a mozglue.dll
should *not* be in $(builddir)/dist/bin, although there will be a mozglue.lib
somewhere in the build tree (which, you can safely delete after building
SpiderMonkey). The --host=... and --target=... are absolutely required for x64
builds, as per the Mozilla's SpiderMonkey build instructions.
You may want to pass in --disable-js-shell to not build the JS shell that comes
with SpiderMonkey to save time, and perhaps use --with-system-nspr (instead of
the --enable-nspr-build as above), --with-system-zlib and --with-system-icu if
you know what you are doing and that their pkg-config files (or headers/LIB's)
can be found directly or using configuration options, to further save time.
After the configuration finishes successfully, you may run 'mozmake' and
'mozmake install' as you would for a standard SpiderMonkey build. If
'mozmake install' does not work for you for some reason, the DLLs you need
and js.exe (if you did not pass in --disable-js-shell) can be found in
$(buildroot)/dist/bin (you need *all* the DLLs, make sure that there is no
mozglue.dll, otherwise you will need to redo your build as noted above),
and the required headers are found in $(buildroot)/dist/include. Note that
for PDB files and .lib files, you will need to search for them in $(buildroot),
where the PDB file names match the filenames for the DLLs/EXEs in
$(buildroot)/dist/bin, and you will need to look for the following .lib files:
-mozjs-60.lib
-js_static.lib (optional)
-nspr4.lib (optional, recommended for future use, if --enable-nspr-build is used)
-plc4.lib (optional, recommended for future use, if --enable-nspr-build is used)
-plds4.lib (optional, recommended for future use, if --enable-nspr-build is used)
You may want to put the .lib's and DLLs/EXEs into $(PREFIX)\lib and $(PREFIX)\bin
respectively, and put the headers into $(PREFIX)\include\mozjs-60 for convenience.
The following are instructions for performing such a build, as there is a
number of build configurations supported for the build. Note that the default
......@@ -49,8 +95,7 @@ PREFIX: Optional. Base directory of where the third-party headers, libraries
specified, $(PREFIX) is set as $(srcroot)\..\vs$(X)\$(platform), where
$(platform) is win32 for 32-bit builds or x64 for 64-bit builds, and
$(X) is the short version of the Visual Studio used, as follows:
2013: 12
2015: 14
2017: 15
Explanation of options, set by <option>=1:
------------------------------------------
......@@ -68,6 +113,7 @@ INTROSPECTION: Enable build of introspection files, for making
required.
PYTHON: Full path to the Python interpreter to be used, if it is not in %PATH%.
This is necessary for building the introspection files (INTROSPECTION=1).
LIBTOOL_DLL_NAME: Enable libtool-style DLL names. Note this does not make this
GJS build usable by other compilers, due to C++ usage.
......@@ -13,63 +13,63 @@
# $(CC)|$(CXX) $(cflags) /Fo$(destdir) /c @<<
# $<
# <<
{..\modules\}.cpp{$(CFG)\$(PLAT)\module-console\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\module-console\ /c @<<
{..\modules\}.cpp{vs$(VSVER)\$(CFG)\$(PLAT)\module-console\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\module-console\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\module-console\ /c @<<
$<
<<
{..\modules\}.cpp{$(CFG)\$(PLAT)\module-system\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\module-system\ /c @<<
{..\modules\}.cpp{vs$(VSVER)\$(CFG)\$(PLAT)\module-system\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\module-system\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\module-system\ /c @<<
$<
<<
{..\modules\}.cpp{$(CFG)\$(PLAT)\module-cairo\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\module-cairo\ /c @<<
{..\modules\}.cpp{vs$(VSVER)\$(CFG)\$(PLAT)\module-cairo\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\module-cairo\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\module-cairo\ /c @<<
$<
<<
{..\gi\}.cpp{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
{..\gi\}.cpp{vs$(VSVER)\$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\gjs\}.cpp{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
{..\gjs\}.cpp{vs$(VSVER)\$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\libgjs-private\}.cpp{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
{..\libgjs-private\}.cpp{vs$(VSVER)\$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\libgjs-private\}.c{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CC) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
{..\libgjs-private\}.c{vs$(VSVER)\$(CFG)\$(PLAT)\libgjs\}.obj::
$(CC) $(CFLAGS) $(LIBGJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\modules\}.cpp{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
{..\modules\}.cpp{vs$(VSVER)\$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\util\}.cpp{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
{..\util\}.cpp{vs$(VSVER)\$(CFG)\$(PLAT)\libgjs\}.obj::
$(CXX) $(CFLAGS) $(LIBGJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{$(CFG)\$(PLAT)\module-resources\}.c{$(CFG)\$(PLAT)\libgjs\}.obj::
$(CC) $(CFLAGS) $(LIBGJS_CFLAGS) /Fo$(CFG)\$(PLAT)\libgjs\ /c @<<
{vs$(VSVER)\$(CFG)\$(PLAT)\module-resources\}.c{vs$(VSVER)\$(CFG)\$(PLAT)\libgjs\}.obj::
$(CC) $(CFLAGS) $(LIBGJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libgjs\ /c @<<
$<
<<
{..\gjs\}.cpp{$(CFG)\$(PLAT)\gjs-console\}.obj::
$(CXX) $(CFLAGS) $(GJS_CFLAGS) /Fo$(CFG)\$(PLAT)\gjs-console\ /c @<<
{..\gjs\}.cpp{vs$(VSVER)\$(CFG)\$(PLAT)\gjs-console\}.obj::
$(CXX) $(CFLAGS) $(GJS_CFLAGS) /Fovs$(VSVER)\$(CFG)\$(PLAT)\gjs-console\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\gjs-console\ /c @<<
$<
<<
</