2007年 02月 13日

fcsh らっぱ 自動高速コンパイル

#!/usr/bin/ruby
#

require "expect"
require "drb/drb"
require "nkf"


IO.popen("fcsh 2>&1", "r+") do |io|
	ids = {}
	front = Proc.new do |file|
		if ids[file]
			cmd = "compile #{ids[file]}"
		else
			cmd = "mxmlc #{file}"
		end

		puts cmd
		io.puts cmd
		read, = io.expect(/^¥(fcsh¥) $/)
		if read =~ /fcsh: Assigned (¥d) as the compile target id/
			ids[file] = Regexp.last_match[1]
		end
		read = NKF.nkf("-w8 -S", read)
		puts
		print read
		read
	end
	DRb.start_service("druby://:8787", front)
	puts DRb.uri
	print io.expect(/^¥(fcsh¥) $/)
	sleep
end
" flex
augroup Fcsh
	au!
	autocmd BufWritePost *.{as,mxml} call FcshCall()
augroup END

function! FcshCall()
	let ret = system('ruby -rdrb/drb -e "puts DRbObject.new_with_uri(''druby://localhost:8787'').call(ARGV[0])"  "'.expand("%:p").'"')
	if matchstr(ret, 'Error') != ""
		echo ret
	endif
endfunction

とか、どうですか(なぞ
編集中のファイルとコンパイルターゲットが違うとまずい。なんかないかな