<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Erlang非业余研究 &#187; typer</title>
	<atom:link href="http://blog.yufeng.info/archives/tag/typer/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.yufeng.info</link>
	<description>Erlang系统深度探索和应用</description>
	<lastBuildDate>Tue, 17 Jan 2012 06:05:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>erl命令行工具链的设计思路</title>
		<link>http://blog.yufeng.info/archives/151</link>
		<comments>http://blog.yufeng.info/archives/151#comments</comments>
		<pubDate>Tue, 24 Nov 2009 19:51:35 +0000</pubDate>
		<dc:creator>Yu Feng</dc:creator>
				<category><![CDATA[Erlang探索]]></category>
		<category><![CDATA[dialyzer]]></category>
		<category><![CDATA[erl]]></category>
		<category><![CDATA[typer]]></category>

		<guid isPermaLink="false">http://blog.yufeng.info/?p=151</guid>
		<description><![CDATA[原创文章，转载请注明： 转载自Erlang非业余研究 本文链接地址: erl命令行工具链的设计思路 erlang otp标准发布包里面的命令行工具都在bin目录下 dialyzer erlc escript typer erlang的这些命令行工具基本上都是erl模块的c的wrapper, 最后都是调用erl来运行相应的模块完成任务。 实验如下： 首先crack erts/etc/common/escript.c:33 static int debug = 1; 让之显示调用参数 我们可以清楚的看到是如何调用相应的模块的。 那我们再看下 erl 这个erl程序其实是个shell script, 简单的设置下环境变量 然后调用erlexec来调用相应的VM。 但是为什么其他的都是binary程序， 唯独erl是script呢。 我能想出的唯一理由是： OTP team的人为了我们方便修改erl的行为 特地用脚本来写， 这样用户就可以很方便的定制erl. 如果我的猜测没错的话，那么erlang真的很细心。 Post Footer automatically generated by wp-posturl plugin for wordpress.]]></description>
			<content:encoded><![CDATA[<div style="margin-top: 15px; font-style: italic">
<p><strong>原创文章，转载请注明：</strong> 转载自<a href="http://blog.yufeng.info/">Erlang非业余研究</a></p>
<p><strong>本文链接地址:</strong> <a href="http://blog.yufeng.info/archives/151">erl命令行工具链的设计思路</a></p>
</div>
<p>erlang otp标准发布包里面的命令行工具都在bin目录下<br />
dialyzer<br />
erlc<br />
escript<br />
typer</p>
<p>erlang的这些命令行工具基本上都是erl模块的c的wrapper, 最后都是调用erl来运行相应的模块完成任务。</p>
<p>实验如下：</p>
<pre class="brush: bash; title: ; notranslate">
root@nd-desktop:~# touch test.erl

root@nd-desktop:~# erlc -d test.erl
 erl -noinput -mode minimal -boot start_clean -s erl_compile compile_cmdline @cwd /root @files test.erl
</pre>
<p>首先crack erts/etc/common/escript.c:33  static int debug = 1; 让之显示调用参数</p>
<pre class="brush: bash; title: ; notranslate">
root@nd-desktop:~# escript test.erl
 erl +B -boot start_clean -noshell -run escript start -extra test.erl
</pre>
<p>我们可以清楚的看到是如何调用相应的模块的。</p>
<p>那我们再看下 erl</p>
<pre class="brush: bash; title: ; notranslate">
root@nd-desktop:/usr/src/otp_src_R13B03# cat bin/erl
#!/bin/sh
#
# %CopyrightBegin%
#
# Copyright Ericsson AB 1996-2009. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the &quot;License&quot;); you may not use this file except in
# compliance with the License. You should have received a copy of the
# Erlang Public License along with this software. If not, it can be
# retrieved online at http://www.erlang.org/.
#
# Software distributed under the License is distributed on an &quot;AS IS&quot;
# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
# the License for the specific language governing rights and limitations
# under the License.
#
# %CopyrightEnd%
#
ROOTDIR=/usr/src/otp_src_R13B03
BINDIR=$ROOTDIR/bin/i686-pc-linux-gnu
EMU=beam
PROGNAME=`echo $0 | sed 's/.*\///'`
export EMU
export ROOTDIR
export BINDIR
export PROGNAME
exec $BINDIR/erlexec ${1+&quot;$@&quot;}
</pre>
<p>这个erl程序其实是个shell script, 简单的设置下环境变量 然后调用erlexec来调用相应的VM。</p>
<p>但是为什么其他的都是binary程序， 唯独erl是script呢。 我能想出的唯一理由是： OTP team的人为了我们方便修改erl的行为 特地用脚本来写， 这样用户就可以很方便的定制erl.</p>
<p>如果我的猜测没错的话，那么erlang真的很细心。</p>
<div style="margin-top: 0; margin-bottom: 15px; color: #888888; font-size: 80%; font-style: italic">
<p>Post Footer automatically generated by <a href="http://easwy.com/blog/wordpress/wp-posturl/" style="color: #8888FF; text-decoration: underline;">wp-posturl plugin</a> for wordpress.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.yufeng.info/archives/151/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

