Skip to content
Browse files

TOOLS-181: Fix javascriptlint build

  • Loading branch information...
1 parent 2f01f97 commit da9133ae70be7e0a48bec0c66dfcbeca33e8ebf4 @trentm trentm committed Aug 28, 2012
View
33 tools/javascriptlint/Makefile
@@ -16,21 +16,20 @@ CPPFLAGS += -DNDEBUG -D_REENTRANT \
-Ispidermonkey/src -Ispidermonkey/src/build \
-I/usr/include \
+
+PY_PYTHON=$(shell python -c "import sys; print(sys.executable)")
+PY_PREFIX=$(shell $(PY_PYTHON) -c "import sys; print(sys.prefix)")
+PY_VERSION=$(shell $(PY_PYTHON) -c "import sys; print('.'.join(map(str, sys.version_info[:2])))")
ifeq ($(BUILDOS),Darwin)
- PY_PREFIX=$(shell python2.6 -c "import sys; sys.stdout.write(sys.prefix)")
- PY_FRAMEWORK_PREFIX=$(shell python2.6 -c "import sys,os; sys.stdout.write(os.path.normpath(sys.prefix+'/../../..'))")
- SYSTEM_ARCH=$(shell uname -m)
- CPPFLAGS += -I$(PY_PREFIX)/include/python2.6
- SOLDFLAGS += -F$(PY_FRAMEWORK_PREFIX) -framework Python
- LD=gcc -arch $(SYSTEM_ARCH)
- CC=gcc -arch $(SYSTEM_ARCH)
+ PY_ARCH=$(shell $(PY_PYTHON) -c 'import sys; print (sys.maxint > 2**32 and "x86_64" or "i386")')
+ SOLDFLAGS += $(PY_PREFIX)/Python
+ CC=gcc -arch $(PY_ARCH)
else
- CPPFLAGS += \
- -I/opt/local/include/db4 \
- -I/opt/local/include/python2.6 \
- -I/opt/local/include/ncurses
+ PY_BIT=$(shell $(PY_PYTHON) -c 'import sys; print (sys.maxint > 2**32 and "64" or "32")')
+ CFLAGS += -m$(PY_BIT)
endif
+CPPFLAGS += -I$(PY_PREFIX)/include/python$(PY_VERSION)
SOFILE = $(BUILDDIR)/pyspidermonkey.so
all: $(SOFILE)
@@ -41,13 +40,13 @@ $(BUILDDIR) $(INSTALLDIRS):
$(OBJECTS): spidermonkey/src/build/libjs.a spidermonkey/src/build/js_operating_system.h
$(SOFILE): $(OBJECTS)
- $(LD) $(SOLDFLAGS) $(LDFLAGS) $(OBJECTS) -Lspidermonkey/src/build -ljs -o $@
+ $(CC) $(CFLAGS) $(SOLDFLAGS) $(LDFLAGS) $(OBJECTS) -Lspidermonkey/src/build -ljs -o $@
$(BUILDDIR)/%.o: javascriptlint/pyspidermonkey/%.c | $(BUILDDIR)
$(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $<
spidermonkey/src/build/libjs.a:
- (cd spidermonkey/src && CC="$(CC)" $(MAKE))
+ (cd spidermonkey/src && CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKE))
spidermonkey/src/build/js_operating_system.h:
echo "#define XP_UNIX" > $@
@@ -57,7 +56,13 @@ clean:
-(cd spidermonkey/src && $(MAKE) clean)
install: $(SOFILE) javascriptlint/jsl javascriptlint/jsl | $(INSTALLDIRS)
- cp javascriptlint/jsl $(SOFILE) build/install
+ cp $(SOFILE) build/install
cp javascriptlint/*.py build/install/javascriptlint
+ sed -e "1s:#\!/usr/bin/env python:#\!$(PY_PYTHON):" javascriptlint/jsl >build/install/jsl
+ chmod +x build/install/jsl
+ sed -e "1s:#\!/usr/bin/env python:#\!$(PY_PYTHON):" javascriptlint/jsl.py >build/install/javascriptlint/jsl.py
+ chmod +x build/install/javascriptlint/jsl.py
+ sed -e "1s:#\!/usr/bin/env python:#\!$(PY_PYTHON):" javascriptlint/jsparse.py >build/install/javascriptlint/jsparse.py
+ sed -e "1s:#\!/usr/bin/env python:#\!$(PY_PYTHON):" javascriptlint/lint.py >build/install/javascriptlint/lint.py
.PHONY: install
View
15 tools/javascriptlint/README.md
@@ -19,7 +19,7 @@ tools:
for cases where potentially dangerous behavior is being deliberately used
carefully.
-If you want style, see http://github.com/davepacheco/jsstyle.
+If you want a style checker, see http://github.com/davepacheco/jsstyle.
Synopsis
@@ -55,9 +55,11 @@ Supported Platforms
This branch of JSL has been tested on:
-- SmartOS (Illumos-based) with Python 2.4
-- Mac OSX 10.6.8 with Python 2.6
+- SmartOS (illumos-based), both 32-bit and 64-bit.
+- Mac OS X Snow Leopard, Lion, and Mountain Lion.
+- Debian Squeeze (6.0.5).
+All of these use Python 2.6 or later.
History
-------
@@ -66,8 +68,7 @@ This version forked from the Subversion repo at revision 302 (2011-04-06).
I'll happily look at incorporating new patches from upstream, though the
project has been pretty quiet for the last many months.
-The main purpose of this fork is to fix building on Illumos-based systems.
-Rather than fix the complex spidermonkey build system to work on Illumos, I
+The main purpose of this fork is to fix building on illumos-based systems.
+Rather than fix the complex spidermonkey build system to work on illumos, I
stripped out a bunch of unnecessary pieces and Makefiles and wrote a new set of
-Makefiles. The result now builds on Mac OSX as well, and should build on Linux
-with minimal changes to the Makefile.
+Makefiles. The result now builds on Mac OS X and Linux as well.
View
2 tools/javascriptlint/javascriptlint/jsl.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# vim: ts=4 sw=4 expandtab
import codecs
import fnmatch
View
2 tools/javascriptlint/javascriptlint/jsparse.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# vim: ts=4 sw=4 expandtab
""" Parses a script into nodes. """
import bisect
View
17 tools/javascriptlint/javascriptlint/lint.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# vim: ts=4 sw=4 expandtab
import os.path
import re
@@ -18,15 +18,15 @@
'eof', 'comma', 'dot', 'semi', 'colon', 'lc', 'rc', 'lp', 'rb', 'assign',
'relop', 'hook', 'plus', 'minus', 'star', 'divop', 'eqop', 'shop', 'or',
'and', 'bitor', 'bitxor', 'bitand', 'else', 'try'
-)
+)
_globals = frozenset([
'Array', 'Boolean', 'Math', 'Number', 'String', 'RegExp', 'Script', 'Date',
'isNaN', 'isFinite', 'parseFloat', 'parseInt',
'eval', 'NaN', 'Infinity',
'escape', 'unescape', 'uneval',
'decodeURI', 'encodeURI', 'decodeURIComponent', 'encodeURIComponent',
- 'Function', 'Object',
+ 'Function', 'Object',
'Error', 'InternalError', 'EvalError', 'RangeError', 'ReferenceError',
'SyntaxError', 'TypeError', 'URIError',
'arguments', 'undefined'
@@ -47,10 +47,12 @@ def _find_functions(node):
def _parse_control_comment(comment):
""" Returns None or (keyword, parms) """
- if comment.atom.lower().startswith('jsl:'):
- control_comment = comment.atom[4:]
- elif comment.atom.startswith('@') and comment.atom.endswith('@'):
- control_comment = comment.atom[1:-1]
+ atom = comment.atom.strip()
+ atom_lower = atom.lower()
+ if atom_lower.startswith('jsl:'):
+ control_comment = atom[4:]
+ elif atom.startswith('@') and atom.endswith('@'):
+ control_comment = atom[1:-1]
else:
return None
@@ -709,4 +711,3 @@ def parsetag(starttag, default_version=None):
script = parsetag('<script type="" language="mocha">',
util.JSVersion('1.2', False))
self.assertEquals(script['jsversion'], util.JSVersion.default())
-
View
13 tools/javascriptlint/spidermonkey/src/Makefile
@@ -39,16 +39,9 @@ CSRCS = \
OBJECTS = $(CSRCS:%.c=$(BUILDDIR)/%.o)
CFLAGS += -Wall -Wno-format -O
-
-ifeq ($(shell uname -s),Darwin)
-CPPFLAGS += -DXP_UNIX -O -DXP_UNIX \
- -DHAVE_LOCALTIME_R -UDEBUG -DNDEBUG -DEDITLINE \
- -I$(BUILDDIR)
-else
CPPFLAGS += -DXP_UNIX -O -DXP_UNIX -DSVR4 -DSYSV -DSOLARIS \
-DHAVE_LOCALTIME_R -UDEBUG -DNDEBUG -UDEBUG_dap -DEDITLINE \
-I$(BUILDDIR)
-endif
all: $(BUILDDIR)/libjs.a
@@ -59,19 +52,19 @@ $(BUILDDIR)/libjs.a: $(BUILDDIR)/jsautocfg.h $(BUILDDIR)/jsautokw.h $(OBJECTS)
$(AR) rv $@ $(OBJECTS)
$(BUILDDIR)/%.o: %.c | $(BUILDDIR)
- $(CC) -o $@ -c $(CFLAGS) $(CPPFLAGS) $^
+ $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $^
clean:
-rm -rf $(BUILDDIR)
$(BUILDDIR)/jscpucfg: $(BUILDDIR)/jscpucfg.o
- $(CC) -o $@ $^
+ $(CC) $(CFLAGS) -o $@ $^
$(BUILDDIR)/jsautocfg.h: $(BUILDDIR)/jscpucfg
$(BUILDDIR)/jscpucfg > $@
$(BUILDDIR)/jskwgen: $(BUILDDIR)/jskwgen.o
- $(CC) -o $@ $^
+ $(CC) $(CFLAGS) -o $@ $^
$(BUILDDIR)/jsautokw.h: $(BUILDDIR)/jskwgen
$(BUILDDIR)/jskwgen > $@

0 comments on commit da9133a

Please sign in to comment.
Something went wrong with that request. Please try again.