servo / rust-mozjs

DEPRECATED - moved to servo/mozjs instead.
Mozilla Public License 2.0
293 stars 122 forks source link

How to use rust-mozjs on Windows? #178

Open ctaggart opened 8 years ago

ctaggart commented 8 years ago

I took a look at the examples/callback.rs and I would like to try using rust-mozjs, but I'm not sure how to. Any plans to create a crate?

I was under the impression that I need to build SpiderMonkey on my PC. On this PC, I'm running Windows 8.1 and I'm not that familiar with make or mozmake. Here is a recap of what I've done so far:

cd c:\rust
git clone https://github.com/mozilla/gecko-dev.git --depth 1

Downloaded MozillaBuild 2.0.0 and extracted to c:\rust\mozilla-build. I have Visual Studio 2015 installed, so I launched the build environment c:\rust\mozilla-build\start-shell-msvc2015-x64.bat. In it, I did:

cd /c/rust/gecko-dev
mkdir build_OPT.OBJ
cd build_OPT.OBJ
../configure --target=x86_64-pc-mingw32 --host=x86_64-pc-mingw32 --enable-nspr-build
mozmake

image

How do I get a list of mozmake targets? How do I get it to build?

Here is `../configure --help' output:

Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
  --cache-file=FILE       cache test results in FILE
  --help                  print this message
  --no-create             do not create output files
  --quiet, --silent       do not print `checking...' messages
  --version               print the version of autoconf that created configure
Directory and file names:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [same as prefix]
  --bindir=DIR            user executables in DIR [EPREFIX/bin]
  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
  --datadir=DIR           read-only architecture-independent data in DIR
                          [PREFIX/share]
  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
                          [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
  --includedir=DIR        C header files in DIR [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
  --infodir=DIR           info documentation in DIR [PREFIX/info]
  --mandir=DIR            man documentation in DIR [PREFIX/man]
  --srcdir=DIR            find the sources in DIR [configure dir or ..]
  --program-prefix=PREFIX prepend PREFIX to installed program names
  --program-suffix=SUFFIX append SUFFIX to installed program names
  --program-transform-name=PROGRAM
                          run sed PROGRAM on installed program names
Host type:
  --build=BUILD           configure for building on BUILD [BUILD=HOST]
  --host=HOST             configure for HOST [guessed]
  --target=TARGET         configure for TARGET [TARGET=HOST]
Features and packages:
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --x-includes=DIR        X include files are in DIR
  --x-libraries=DIR       X library files are in DIR
--enable and --with options recognized:
  --enable-release        Build with more conservative, release engineering-oriented options.
                          This may slow down builds.
  --disable-compile-environment
                          Disable compiler/library checks.
  --with-l10n-base=DIR    path to l10n repositories
  --with-gonk=DIR
               location of gonk dir
  --with-gonk-toolchain-prefix=DIR
                          prefix to gonk toolchain commands
  --with-android-ndk=DIR
                          location where the Android NDK can be found
  --with-android-toolchain=DIR
                          location of the android toolchain
  --with-android-gnu-compiler-version=VER
                          gnu compiler version to use
  --enable-android-libstdcxx
                          use GNU libstdc++ instead of STLPort
  --with-android-version=VER
                          android platform version, default 9
  --with-ios-sdk=TYPE
                          Type of iOS SDK to use (iphonesimulator, iphoneos)
                          and optionally version (like iphoneos8.2)
  --enable-ios-target=VER (default=8.0)
                          Set the minimum iOS version needed at runtime
  --with-compiler-wrapper[=path/to/wrapper]
    Enable compiling with wrappers such as distcc and ccache
  --with-ccache[=path/to/ccache]
                          Enable compiling with ccache
  --enable-rust           Include rust language sources
  --enable-macos-target=VER (default=10.6)
                          Set the minimum MacOS version needed at runtime
  --with-windows-version=WINSDK_TARGETVER
                          Windows SDK version to target. Win8.1 (603) is
                          currently the minimum supported version.
  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)
  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)
  --with-macos-private-frameworks=dir    Location of private frameworks to use (Mac OS X only)
  --with-x                use the X Window System
  --with-arch=[[type|toolchain-default]]
                           Use specific CPU features (-march=type). Resets
                           thumb, fpu, float-abi, etc. defaults when set
  --with-thumb[[=yes|no|toolchain-default]]
                          Use Thumb instruction set (-mthumb)
  --with-thumb-interwork[[=yes|no|toolchain-default]]
                           Use Thumb/ARM instuctions interwork (-mthumb-interwork)
  --with-fpu=[[type|toolchain-default]]
                           Use specific FPU type (-mfpu=type)
  --with-float-abi=[[type|toolchain-default]]
                           Use specific arm float ABI (-mfloat-abi=type)
  --with-soft-float[[=yes|no|toolchain-default]]
                           Use soft float library (-msoft-float)
  --enable-address-sanitizer       Enable Address Sanitizer (default=no)
  --enable-memory-sanitizer       Enable Memory Sanitizer (default=no)
  --enable-thread-sanitizer       Enable Thread Sanitizer (default=no)
  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)
  --enable-warnings-as-errors
                          Enable treating warnings as errors
  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)
  --enable-systrace       Set compile flags necessary for using sampling profilers (e.g. shark, perf)
  --enable-valgrind       Enable Valgrind integration hooks (default=no)
  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.
  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.
  --enable-instruments    Enable instruments remote profiling. Implies --enable-profiling.
  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.
  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.
  --enable-debug[=DBG]    Enable building with developer debug info
                           (using compiler flags DBG)
  --with-debug-label=LABELS
                          Define DEBUG_<value> for each comma-separated
                          value given.
  --enable-debug-symbols[=DBG]
                          Enable debugging symbols (using compiler flags DBG)
  --enable-cpp-rtti       Enable C++ RTTI 
  --enable-gold           Enable GNU Gold Linker when it is not already the default
  --disable-icf          Disable Identical Code Folding
  --enable-pie           Enable Position Independent Executables
  --enable-dtrace         build with dtrace support if available (default=no)
  --with-linux-headers=DIR
                          location where the Linux kernel headers can be found
  --with-pthreads         Force use of system pthread library with NSPR 
  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>
  --with-nspr-cflags=FLAGS
                          Pass FLAGS to CC when building code that uses NSPR.
                          Use this when there's no accurate nspr-config
                          script available.  This is the case when building
                          SpiderMonkey as part of the Mozilla tree: the
                          top-level configure script computes NSPR flags
                          that accomodate the quirks of that environment.
  --with-nspr-libs=LIBS   Pass LIBS to LD when linking code that uses NSPR.
                          See --with-nspr-cflags for more details.
  --enable-nspr-build     Configure and build NSPR from source tree
  --with-system-nspr      Use an NSPR that is already built and installed.
                          Use the 'nspr-config' script in the current path,
                          or look for the script in the directories given with
                          --with-nspr-exec-prefix or --with-nspr-prefix.
                          (Those flags are only checked if you specify
                          --with-system-nspr.)
  --enable-posix-nspr-emulation
                          Enable emulation of NSPR for POSIX systems
  --with-nspr-prefix=PFX  Prefix where NSPR is installed
  --with-nspr-exec-prefix=PFX
                          Exec prefix where NSPR is installed
  --with-system-libevent[=PFX]
                          Use system libevent [installed at prefix PFX]
  --with-system-nss       Use system installed NSS
  --with-nss-prefix=PFX   Prefix where NSS is installed
  --with-nss-exec-prefix=PFX
                          Exec prefix where NSS is installed
  --with-system-jpeg[=PFX]
                          Use system libjpeg [installed at prefix PFX]
  --with-system-zlib[=PFX]
                          Use system libz [installed at prefix PFX]
  --with-system-bz2[=PFX]
                          Use system libbz2 [installed at prefix PFX]
  --with-system-png[=PFX]
                          Use system libpng [installed at prefix PFX]
  --enable-png-arm-neon-support=TYPE
             Options include:
                 no
                 check (default)
                 nocheck (faster but unsafe)
  --enable-system-hunspell
                          Use system hunspell (located with pkgconfig)
  --enable-system-ffi       Use system libffi (located with pkgconfig)
  --enable-shared-js
                          Create a shared JavaScript library.
  --with-java-bin-path=dir
                          Location of Java binaries (java, javac, jar)
  --with-external-source-dir=dir
                          External directory containing additional build files.
  --enable-application=APP
                          Options include:
                            browser (Firefox)
                            xulrunner
                            tools/update-packaging (AUS-related packaging tools)
  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name
  --enable-update-channel=CHANNEL
                          Select application update channel (default=default)
  --with-mozilla-api-keyfile=file   Use the secret key contained in the given keyfile for Mozilla API requests
  --with-google-api-keyfile=file   Use the secret key contained in the given keyfile for Google API requests
 --with-google-oauth-api-keyfile=file  Use the client id and secret key contained in the given keyfile for Google OAuth API requests
  --with-bing-api-keyfile=file   Use the client id and secret key contained in the given keyfile for Bing API requests
  --with-adjust-sdk-keyfile=file   Use the app token contained in the given keyfile for Adjust SDK requests
  --disable-android-include-fonts
                          Disable the inclusion of fonts into the final APK
  --enable-android-resource-constrained
                          Exclude hi-res images and similar from the final APK
  --enable-official-branding
                          Enable Official mozilla.org Branding
                          Do not distribute builds with
                          --enable-official-branding unless you have
                          permission to use trademarks per
                          http://www.mozilla.org/foundation/trademarks/ .
--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME
--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME
  --with-android-sdk=DIR
                          location where the Android SDK can be found (base directory, e.g. .../android/platforms/android-6)
  --with-android-min-sdk=[VER]     Impose a minimum Firefox for Android SDK version
  --with-android-max-sdk=[VER]     Impose a maximum Firefox for Android SDK version
  --enable-default-toolkit=TK
                          Select default toolkit
                          Platform specific defaults:
                            Mac OS X - cairo-cocoa
                            Win32 - cairo-windows
                            * - cairo-gtk2
                            * - cairo-gtk3
                            * - cairo-qt
  --without-x              Build without X11
  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)
  --enable-startup-notification
                          Enable startup-notification support (default: disabled) 
  --disable-printing      Disable printing support
  --with-qtdir=$dir       Specify Qt directory 
  --enable-ui-locale=ab-CD
                          Select the user interface locale (default: en-US)
  --with-branding=dir     Use branding from the specified directory.
  --with-distribution-id=ID
                          Set distribution-specific id (default=org.mozilla)
  --disable-gio           Disable GIO support
  --disable-gconf      Disable Gconf support 
  --enable-libproxy         Enable libproxy support 
  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support 
  --disable-dbus          Disable dbus support 
  --enable-android-apz      Switch to C++ pan/zoom code
  --disable-websms-backend
                           Disable WebSMS backend
  --enable-ipdl-tests     Enable expensive IPDL tests
  --disable-dbm           Disable building dbm
  --disable-accessibility Disable accessibility support
  --disable-webrtc        Disable support for WebRTC
  --enable-hardware-aec-ns   Enable support for hardware AEC and noise suppression
  --disable-webspeech        Disable support for HTML Speech API
  --disable-webspeechtestbackend        Disable support for HTML Speech API Test Backend
  --enable-raw           Enable support for RAW media
  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)
  --disable-directshow  Disable support for DirectShow
  --disable-wmf  Disable support for Windows Media Foundation
  --disable-ffmpeg         Disable FFmpeg for fragmented H264/AAC decoding
  --disable-fmp4  Disable support for in built Fragmented MP4 parsing
  --enable-eme[=adobe]  Enable support for Encrypted Media Extensions  
  --enable-android-omx  Enable support for Android OMX media backend
  --enable-media-navigator  Enable support for getUserMedia
  --enable-omx-plugin      Enable building OMX plugin (B2G)
  --with-system-libvpx    Use system libvpx (located with pkgconfig)
  --disable-wave          Disable Wave decoder support
  --enable-alsa          Enable Alsa support (default on Linux)
  --disable-pulseaudio          Disable PulseAudio support
  --enable-gstreamer[=0.10]           Enable GStreamer support
  --disable-permissions   Disable permissions (popup and cookie blocking)
  --disable-negotiateauth Disable GSS-API negotiation 
  --disable-pref-extensions
                          Disable pref extensions such as autoconfig
  --disable-system-extension-dirs
                          Disable searching system- and account-global
                          directories for extensions of any kind; use
                          only profile-specific extension directories
  --disable-universalchardet
                          Disable universal encoding detection
  --enable-require-all-d3dc-versions Require all versions of the D3D compiler needed for supported Windows systems.
  --disable-gamepad   Disable gamepad support
  --disable-crashreporter Disable breakpad crash reporting
  --with-crashreporter-enable-percent=NN
                          Enable sending crash reports by default on NN% of users. (default=100)
 --disable-libjpeg-turbo  Disable optimized jpeg decoding routines
  --enable-extensions     Enable extensions
  --enable-tree-freetype  Enable Tree FreeType
  --disable-webapp-runtime  Disable Web App Runtime
  --enable-maintenance-service       Enable building of maintenanceservice
  --enable-bundled-fonts  Enable support for bundled fonts on desktop platforms
  --enable-verify-mar     Enable verifying MAR signatures
  --enable-signmar     Enable building the signmar program
  --disable-updater       Disable building of updater
  --enable-update-packaging
                          Enable tools/update-packaging
  --disable-tests         Do not build test libraries & programs
  --disable-parental-controls
                          Do not build parental controls
  --disable-sandbox        Disable sandboxing support
  --enable-content-sandbox Enable sandboxing support for content-processes
  --disable-content-sandbox Disable sandboxing support for content-processes
  --disable-feeds         Disable feed handling and processing components
  --enable-system-sqlite  Use system sqlite (located with pkgconfig)
  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation
  --enable-url-classifier Enable url classifier module
  --disable-zipwriter     Disable zipwriter component
  --with-gl-provider=ID
                          Set GL provider backend type
  --enable-faststripe     Use faststripe theme
  --enable-mobile-optimize
                          Enable mobile optimizations
  --disable-optimize      Disable compiler optimization
  --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]
  --disable-logging       Disable logging facilities
  --enable-logrefcnt      Enable logging of refcounts (default=debug) 
 --enable-approximate-location    Enable approximate location 
 --enable-gps-debug    Enable gps specific debug messages 
  --enable-dump-painting          Enable paint debugging.
  --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc
  --enable-jemalloc       Replace memory allocator with jemalloc
  --enable-replace-malloc   Enable ability to dynamically replace the malloc implementation
  --with-static-checking=path/to/gcc_dehydra.so
                          Enable static checking of code using GCC-dehydra
  --enable-clang-plugin   Enable building with the mozilla clang plugin 
  --enable-strip          Enable stripping of libs & executables 
  --enable-install-strip  Enable stripping of libs & executables when packaging 
  --disable-elf-hack      Disable elf hacks
  --enable-stdcxx-compat  Enable compatibility with older libstdc++
  --enable-tasktracer       Set compile flags necessary for using TaskTracer
  --enable-reflow-perf    Enable reflow performance tracing
  --disable-startupcache          Disable startup cache 
  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets 
  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G 
  --enable-nfc         Set compile flags necessary for compiling NFC API 
  --enable-synth-pico  Set compile flags necessary for compiling Pico Web Speech API 
  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G 
  --jitreport-granularity=N
                           Default granularity at which to report JIT code
                           to external tools
                             0 - no info
                             1 - code ranges for whole functions only
                             2 - per-line information
                             3 - per-op information
  --disable-mozril-geoloc         Disable Mozilla's RIL and geolocation
  --enable-xterm-updates  Update XTERM titles with current command.
  --enable-chrome-format=jar|flat|omni
                          Select FORMAT of chrome files during packaging
  --with-default-mozilla-five-home
                          Set the default value for MOZILLA_FIVE_HOME
  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)
  --with-doc-input-dirs=DIRS
                          Header/idl dirs to create docs from
  --with-doc-include-dirs=DIRS
                          Include dirs to preprocess doc headers
  --with-doc-output-dir=DIR
                          Dir to generate docs into
  --enable-skia   Enable use of Skia
  --disable-skia-gpu  Disable use of Skia-GPU
  --enable-system-cairo   Use system cairo (located with pkgconfig)
 --enable-system-pixman Use system pixman (located with pkgconfig)
  --disable-xul           Disable XUL
  --disable-profilelocking
                          Disable profile locking
  --enable-necko-protocols[={http,ftp,default,all,none}]
                          Enable/disable specific protocol handlers
  --disable-necko-wifi    Disable necko wifi scanner
  --disable-cookies       Disable cookie support
  --disable-ctypes        Disable js-ctypes
  --with-macbundlename-prefix=prefix
                          Prefix for MOZ_MACBUNDLE_NAME
  --with-system-icu
                          Use system ICU (located with pkgconfig)
  --with-intl-api, --with-intl-api=build, --without-intl-api
    Determine the status of the ECMAScript Internationalization API.  The first
    (or lack of any of these) builds and exposes the API.  The second builds it
    but doesn't use ICU or expose the API to script.  The third doesn't build
    ICU at all.

Here is mozmake --help output:

Usage: mozmake [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  --eval=STRING               Evaluate STRING as a makefile statement.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from recipes.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any recipe; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -O[TYPE], --output-sync[=TYPE]
                              Synchronize output of parallel jobs by TYPE.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no recipe; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo recipes.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  --trace                     Print tracing information.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.

This program built for Windows32
Report bugs to <bug-make@gnu.org>
jdm commented 8 years ago

rust-mozjs works specifically with https://github.com/servo/mozjs which should both be usable from any cargo-using project like so:

[dependencies.js]
git = "https://github.com/servo/rust-mozjs"
ctaggart commented 8 years ago

That looks much easier! I'll give that a shot.

pathikdevani commented 7 years ago

@ctaggart you got success using rust-mozjs in windows?