Building Google Dart on Mac OS X Lion with XCode 4

I have spent about 30 mins trying to build Google Dart. The problem is in macosx sdk version. Google Dart needs 10.5 for building, but there is no 10.5 sdk in XCode 4 in Lion.

Error message:

=== BUILD NATIVE TARGET v8_base OF PROJECT v8 WITH CONFIGURATION Debug_x64 ===
** BUILD FAILED **

Full instruction how to build Google Dart and fix this issue:

0. Install depot_tools
First of all, we need depot_tools from google:
http://dev.chromium.org/developers/how-tos/install-depot-tools

svn co http://src.chromium.org/svn/trunk/tools/depot_tools
export PATH="$PATH":`pwd`/depot_tools

1. Getting the source
How to get the source: http://code.google.com/p/dart/wiki/GettingTheSource

gclient config http://dart.googlecode.com/svn/trunk/deps/all.deps
gclient sync

2. Change Mac OS X SDK to 10.6
Open tools/build.py and add the following lines after line 108:

'-sdk',
'macosx10.6',

Now build.py 108-119 lines should look like:

args = ['xcodebuild',
                '-sdk',
                'macosx10.6',
                '-project',
                project_file,
                '-target',
                target,
                '-parallelizeTargets',
                '-configuration',
                build_config,
                'SYMROOT=%s' % os.path.abspath('xcodebuild')
         ]

Diff:

Index: tools/build.py
===================================================================
--- tools/build.py	(revision 296)
+++ tools/build.py	(working copy)
@@ -106,6 +106,8 @@
         if os.path.exists('dart-%s.gyp' % CurrentDirectoryBaseName()):
           project_file = 'dart-%s.xcodeproj' % CurrentDirectoryBaseName()
         args = ['xcodebuild',
+                '-sdk',
+                'macosx10.6',
                 '-project',
                 project_file,
                 '-target',

3. Building everything
Next step is described in Google guide:
http://code.google.com/p/dart/wiki/Building#Building_everything

Just run

./tools/build.py --arch=ia32

or

./tools/build.py --arch=x64

That’s all.

Working with java subprocess from vim

First of all, we need Conque vim plugin: http://code.google.com/p/conque/ (If you are using git, github and Pathogen: https://github.com/rygwdn/vim-conque).

This plugin allows us to create subprocesses and communicate with them.

Let’s write simple Java program:


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class VIMIOTest {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while (true) {

            String command = br.readLine();
            if (command.equalsIgnoreCase("exit")) {
                break;
            }else if (command.equalsIgnoreCase("test")) {
                System.out.println("test answer");
            }
        }
    }
}

And vim script for working with it:

let g:jp = conque_term#subprocess('java VIMIOTest')

function! SendTest()
    call g:jp.writeln('test')
    let output = g:jp.read()
    echo 'output:'.output
endfunction

function! CloseTest()
    call g:jp.writeln('close')
    call g:jp.close()
endfunction

Thats all!
More docs about conque: http://code.google.com/p/conque/wiki/Usage

Refresh html page from vim on mac

For doing this just add these lines to project .vimrc or global .vimrc:

function! s:OpenHTML(path)
    exec('silent !open -a Safari '.a:path)
    exec("silent !osascript -e 'tell application "iTerm" to activate'")
    exec('redraw!')
endfunction                                                                      

command! OpenHTML call s:OpenHTML(expand('%'))
nmap <silent> <F5> :OpenHTML<CR>

You can replace expand(‘%’) to custom path for refreshing project html file.
For example:

command! OpenHTML call s:OpenHTML(s:projectPath.'/html-tests/chartView.html')

Also you need to replace iTerm to terminal you are using.

Key binding for refresh – F5.

Google Closure Linter: vim integration


0. Install google closure linter (http://code.google.com/closure/utilities/
1. Install google-closure-linter-for-vim vim plugin:
https://github.com/batsuev/google-closure-linter-for-vim
Using pathogen:

git clone git@github.com:batsuev/google-closure-linter-for-vim.git ~/.vim/bundle/google-closure-linter

Or manual:

cd ~/.vim/ftplugin
wget https://raw.github.com/batsuev/google-closure-linter-for-vim/master/ftplugin/javascript.vim

2. Now you can call :make in normal mode and use general error navigation (e.g. :cprev :cnext :clist)