changeset 35:3e66613d1d4d

Added information about getting my SpiderMonkey mirror, and also added an option for linking statically to SpiderMonkey's runtime instead of dynamically.
author Atul Varma <varmaa@toolness.com>
date Thu, 02 Jul 2009 15:20:02 -0700
parents 5d3d3b25f23f
children 04a6e9a67ae5
files README manage.py
diffstat 2 files changed, 41 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/README	Tue Jun 30 22:47:31 2009 -0700
+++ b/README	Thu Jul 02 15:20:02 2009 -0700
@@ -47,29 +47,23 @@
 Building and Testing
 --------------------
 
-Right now building is annoying and difficult because Pymonkey wraps
-SpiderMonkey 1.8.1, which doesn't yet exist as standalone code--it's
-only available in the mozilla-central HG repository.  As such,
-Pymonkey currently requires a full build of the Mozilla platform. You
-can find out how to do this here:
+You can either build SpiderMonkey off the mozilla-central HG
+repository, or off a mirror I made of its SpiderMonkey directory. The
+latter can be obtained here:
 
-  https://developer.mozilla.org/en/Build_Documentation
+  http://hg.toolness.com/spidermonkey/
 
-Once you've built Mozilla, you can build the extension and run the
-tests like this:
+Just HG clone that repository and read the instructions in the README
+to build SpiderMonkey.
 
-  python manage.py build --objdir=PATH_TO_OBJDIR
+Then come back to the root of your pymonkey repository and run:
 
-Where PATH_TO_OBJDIR is the path to your Mozilla build's objdir (if
-you don't know what that is, read the build documentation).
+  python manage.py build --static --objdir=PATH_TO_OBJDIR
 
-Note that at the moment, the build script is only tested on OS X, and
-even then some things need to be done to the environment in order for
-pymonkey to be loaded properly; look at manage.py if you need more
-specifics on that. Right now this isn't a huge deal because we're only
-really concerned with the test suite, which is run automatically after
-building--but obviously it's something that needs to be fixed in the
-future.
+Where PATH_TO_OBJDIR is the path to your Mozilla/SpiderMonkey build's
+objdir.
+
+Note that at the moment, the build script is only tested on OS X.
 
 Example Code
 ------------
--- a/manage.py	Tue Jun 30 22:47:31 2009 -0700
+++ b/manage.py	Thu Jul 02 15:20:02 2009 -0700
@@ -31,7 +31,8 @@
 from paver.easy import *
 
 @task
-@cmdopts([("objdir=", "o", "The root of your Mozilla objdir")])
+@cmdopts([("objdir=", "o", "The root of your Mozilla objdir"),
+          ("static", "s", "Build against static libraries")])
 def build(options):
     """Build the pymonkey Python C extension."""
 
@@ -46,22 +47,26 @@
 
     print "Building extension."
 
-    result = subprocess.call(
-        ["g++",
-         "-framework", "Python",
-         "-I%s" % incdir,
-         "-L%s" % libdir,
-         "-Wall",
-         "-lmozjs",
-         "-o", "pymonkey.so",
-         "-dynamiclib",
-         "pymonkey.c",
-         "utils.c",
-         "object.c",
-         "undefined.c",
-         "context.c",
-         "runtime.c"]
-        )
+    args = ["g++",
+            "-framework", "Python",
+            "-I%s" % incdir,
+            "-L%s" % libdir,
+            "-Wall",
+            "-o", "pymonkey.so",
+            "-dynamiclib",
+            "pymonkey.c",
+            "utils.c",
+            "object.c",
+            "undefined.c",
+            "context.c",
+            "runtime.c"]
+
+    if options.get("static"):
+        args.append(os.path.join(objdir, "libjs_static.a"))
+    else:
+        args.append("-lmozjs")
+
+    result = subprocess.call(args)
 
     if result:
         sys.exit(result)
@@ -70,7 +75,13 @@
 
     new_env = {}
     new_env.update(os.environ)
-    new_env['DYLD_LIBRARY_PATH'] = libdir
+    if not options.get("static"):
+        print("NOTE: Because you're linking dynamically to the "
+              "SpiderMonkey shared library, you'll need to make sure "
+              "that it's on your library load path. You may need to "
+              "add %s to your library load path to do this." %
+              libdir)
+        new_env['DYLD_LIBRARY_PATH'] = libdir
 
     result = subprocess.call(
         [sys.executable,