mfks17's blog(Life is Good !!)

趣味や思った事を書いていくと思います

macにjslをソースから入れようとして諦めた話

先日、javascriptlintをubuntuに導入したのですが、macにも入れようとしたときの過程です。

環境


  • macbookair 2010 Late
  • OSX 10.8.3
  • Xcode 4.6.1
  • python2.7.3

    インストール


    ubuntuのときと同じように進めていきます。
    $ python setup.py build
    running build
    cat: ../../dist/Darwin_OPT.OBJ/nspr/Version: No such file or directory
    cd editline; make -f Makefile.ref all
    make[1]: Nothing to be done for `all'.
    make -f Makefile.ref Darwin_OPT.OBJ/libjs.a Darwin_OPT.OBJ/libjs.dylib Darwin_OPT.OBJ/js Darwin_OPT.OBJ/jsautocfg.h Darwin_OPT.OBJ/jscpucfg Darwin_OPT.OBJ/jscpucfg.o
    cat: ../../dist/Darwin_OPT.OBJ/nspr/Version: No such file or directory
    make[1]: Circular jscpucfg.h <- Darwin_OPT.OBJ/jsautocfg.h dependency dropped.
    make[1]: Circular Darwin_OPT.OBJ/jsautocfg.h <- Darwin_OPT.OBJ/jsautocfg.h dependency dropped.
    cc -o Darwin_OPT.OBJ/jsprf.o -c -Wall -Wno-format -O -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DDARWIN -DX86_LINUX -UDEBUG -DNDEBUG -UDEBUG_typosterr -DEDITLINE -IDarwin_OPT.OBJ jsprf.c
    jsprf.c:644:9: error: array type 'va_list' (aka '__builtin_va_list') is not assignable
    VARARGS_ASSIGN(nas[cn].ap, ap);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    jsprf.c:64:47: note: expanded from macro 'VARARGS_ASSIGN'
    #define VARARGS_ASSIGN(foo, bar) (foo) = (bar)
    ~~~~~ ^
    1 error generated.
    make[1]: *** [Darwin_OPT.OBJ/jsprf.o] Error 1
    make: *** [all] Error 2
    Traceback (most recent call last):
    File "setup.py", line 115, in
    setup(**args)
    File "/Users/typosterr/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
    File "/Users/typosterr/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
    File "/Users/typosterr/.pythonbrew/pythons/Python-2.7.3/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
    File "setup.py", line 50, in run
    _runmakefiles(self.build_platlib)
    File "setup.py", line 38, in _runmakefiles
    raise _BuildError, 'Error running make.'
    __main__._BuildError: Error running make.

    と、いきなりコケました。
    この時点で、時間がかかりそうなので、ソースからの取得は諦めました。
    情弱乙orz

    解決策


    Homebrewにあるよ
    (゚ロ゚;)エェッ!?

    ということで、
    $ brew install jsl
    したのでした。

    新たな問題


    とりあえずjslが入ったということで、vimで走らせて確認しようとしたんですが、うまく動作しない。
    Error: unrecognized parameter: sample.js

    JavaScript Lint 0.3.0 (JavaScript-C 1.5 2004-09-24)
    Developed by Matthias Miller (http://www.JavaScriptLint.com)

    Usage: jsl [-help:conf]
    [-conf filename] [-process filename] [+recurse|-recurse] [-stdin]
    [-nologo] [-nofilelisting] [-nocontext] [-nosummary] [-output-format ______]

    Error levels:
    0 - Success
    1 - JavaScript warnings
    2 - Usage or configuration error
    3 - JavaScript error
    4 - File error

    Press ENTER or type command to continue


    こんな感じにです。
    よくよくみると、ubuntuにソースでコンパイルしたものと、APIが異なっていることがわかります。
    ubuntuの方は
    $ jsl -h
    Usage: jsl [options] [files]

    Options:
    -h, --help show this help message and exit
    --conf=CONF set the conf file
    --profile turn on hotshot profiling
    --recurse recursively search directories on the command line
    --enable-wildcards resolve wildcards in the command line
    --dump dump this script
    --unittest run the python unittests
    --quiet minimal output
    --verbose verbose output
    --nologo suppress version information
    --nofilelisting suppress file names
    --nosummary suppress lint summary
    --help:conf display the default configuration file

    macの方は、"-process"っていうオプションで実行するファイル名を指定しなしといけないみたいです。

    そして、解決策


    暫定処理として、OSによって処理を振り分けることにしました。
    そもそも、ソースを読んでコンパイルを通せばOKなのですが、
    とりあえず、先に進みたかったので(う〜ん、エンジニアとしてどうなのか?)
    以下のような記述を.vim/compiler/jsl.vimにしました。

    一部抜粋



    let OSTYPE = system('uname')
    if OSTYPE == "Darwin\n"
    CompilerSet makeprg=jsl\ --nologo\ --nofilelisting\ --nosummary\ -process\ %
    CompilerSet errorformat=%f(%l):\ %m
    elseif OSTYPE == "Linux\n"
    CompilerSet makeprg=jsl\ --nologo\ --nofilelisting\ --nosummary\ %
    CompilerSet errorformat=%f(%l):\ %m
    endif

    いけてなさ過ぎる。


    まとめ


    vimrcのOSの振り分け方法を学びました

    最後までお読みいただきありがとうございまいた。

    参考サイト様


  • zshとVimでOS判定