<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>plusHa &#187; Rakefile</title>
	<atom:link href="http://plusha.com/tag/rakefile/feed/" rel="self" type="application/rss+xml" />
	<link>http://plusha.com</link>
	<description>in the light</description>
	<lastBuildDate>Sat, 19 May 2012 00:58:17 +0000</lastBuildDate>
	<language>ko</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='plusha.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>plusHa &#187; Rakefile</title>
		<link>http://plusha.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://plusha.com/osd.xml" title="plusHa" />
	<atom:link rel='hub' href='http://plusha.com/?pushpress=hub'/>
		<item>
		<title>Rakefile basic</title>
		<link>http://plusha.com/2008/05/20/rakefile-basic/</link>
		<comments>http://plusha.com/2008/05/20/rakefile-basic/#comments</comments>
		<pubDate>Tue, 20 May 2008 12:06:21 +0000</pubDate>
		<dc:creator>plusha</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Makefile]]></category>
		<category><![CDATA[Rakefile]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://plusha.wordpress.com/?p=13</guid>
		<description><![CDATA[Rakefile은 Makefile과 비슷한 역할을 하는, Ruby script입니다. 따라서 Ruby라는 언어의 강력한 기능들을 그대로 가져다 쓸 수 있다는 장점이 있습니다. 단, Ruby를 알아야 제대로 사용할 수 있겠죠. Makefile을 make라는 명령어로 실행하듯이, Rakefile은 rake라는 명령어로 실행합니다. Rakefile 작성법을 Makefile 작성법과 비교하며 살펴보도록 하겠습니다. Makefile의 기본적인 작성법은 Target: Dependency list [Tab] Command 였죠. Rakefile도 유사합니다. 단, Ruby syntax를 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=plusha.com&#038;blog=174108&#038;post=13&#038;subd=plusha&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Rakefile은 Makefile과 비슷한 역할을 하는, Ruby script입니다. 따라서 Ruby라는 언어의 강력한 기능들을 그대로 가져다 쓸 수 있다는 장점이 있습니다. 단, Ruby를 알아야 제대로 사용할 수 있겠죠. Makefile을 make라는 명령어로 실행하듯이, Rakefile은 rake라는 명령어로 실행합니다. Rakefile 작성법을 Makefile 작성법과 비교하며 살펴보도록 하겠습니다. Makefile의 기본적인 작성법은<br />
<code>Target: Dependency list<br />
[Tab] Command<br />
</code><br />
였죠. Rakefile도 유사합니다. 단, Ruby syntax를 사용하죠. 기본적인 작성법은 다음과 같습니다.<br />
<code>task :name = [:prereq1, :prereq2] do<br />
    Command<br />
end<br />
</code><br />
Makefile에서 Target에 해당하는 것이 Rakefile의 task입니다. 잘 살펴보면 task라는 함수명과 Hash, Block 두 개의 argument로 이루어진 구조라는 것을 알 수 있습니다. Hash의 key는 target이 되고 value는 prerequisites (dependency list)가 됩니다. Block은 실행해야 할 명령들로 이루어집니다. 특별히 compile하는 경우와 같이 파일을 작성하는 task의 경우에는<br />
<code>file "name" = ["prereq1", "prereq2"] do<br />
    Command<br />
end<br />
</code><br />
와 같이 file task를 사용합니다. Command 부분에서 &#8216;name&#8217; 또는 dependency list (prereq1, prereq2, &#8230; )를 사용하고 싶을 때는<br />
<code>file "name" = ["prereq1", "prereq2"] do |t|<br />
sh "f77 -o #{t.name} #{t.prerequisites.join(' ')}"<br />
end<br />
</code><br />
과 같이 사용하여 <code>f77 -o name prereq1 prereq2</code>와 같은 결과를 얻을 수도 있습니다.</p>
<p>그럼 <a href="http://plusha.com/2008/05/08/makefile-basic/">앞에서 만들었던 Makefile</a>과 같은 기능을 하는 Rakefile을 만들어 비교해 보겠습니다. 앞에서 만들었던 Makefile은 다음과 같고,</p>
<pre><tt><code><span style="color:#000000;">01:</span> <em><span style="color:#9a1900;"># target: dependency list</span></em>
<span style="color:#000000;">02:</span> <em><span style="color:#9a1900;"># [tab] command</span></em>
<span style="color:#000000;">03:</span> <span style="color:#009900;">F77=</span>gfortran
<span style="color:#000000;">04:</span>
<span style="color:#000000;">05:</span> <span style="color:#990000;">all:</span> main
<span style="color:#000000;">06:</span>
<span style="color:#000000;">07:</span> <span style="color:#990000;">main:</span> main.o sub1.o sub2.o
<span style="color:#000000;">08:</span>         <span style="color:#009900;">$(F77)</span> -O<span style="color:#993399;">2</span> -o main main.o sub1.o sub2.o
<span style="color:#000000;">09:</span> <span style="color:#990000;">main.o:</span> main.f
<span style="color:#000000;">10:</span>         <span style="color:#009900;">$(F77)</span> -O<span style="color:#993399;">2</span> -c main.f
<span style="color:#000000;">11:</span> <span style="color:#990000;">sub1.o:</span> sub1.f
<span style="color:#000000;">12:</span>         <span style="color:#009900;">$(F77)</span> -O<span style="color:#993399;">2</span> -c sub1.f
<span style="color:#000000;">13:</span> <span style="color:#990000;">sub2.o:</span> sub2.f
<span style="color:#000000;">14:</span>         <span style="color:#009900;">$(F77)</span> -O<span style="color:#993399;">2</span> -c sub2.f
<span style="color:#000000;">15:</span> <span style="color:#990000;">clean:</span>
<span style="color:#000000;">16:</span>         rm main main.o sub1.o sub2.o</code>
</tt></pre>
<p>이에 해당하는 Rakefile은 다음과 같습니다.</p>
<p><pre class="brush: ruby;">
f90='gfortran'

task :default =&gt; ['main.e']
file 'main.e' =&gt; ['main.o','sub1.o','sub2.o'] do |t|
    sh &quot;#{f90} -o #{t.name} main.o sub1.o sub2.o&quot;
end

file 'main.o' =&gt; ['main.f'] do
    sh &quot;#{f90} -c main.f&quot;
end
file 'sub1.o' =&gt; ['sub1.f'] do
    sh &quot;#{f90} -c sub1.f&quot;
end
file 'sub2.o' =&gt; ['sub2.f'] do
    sh &quot;#{f90} -c sub2.f&quot;
end

require 'rake/clean'
CLEAN.include('*.o')
CLOBBER.include('main.e')
</pre></p>
<p><code>task :default</code> 부분은 Makefile에서 all 이라는 target을 지정해서 사용했던 것과 같은 역할을 합니다. 단, Rakefile에서는 default task가 맨 처음에 나올 필요가 없습니다. 파일 내 아무데나 나와도 잘 인식합니다. 중간 부분은 Makefile과 매우 유사하므로 특별한 설명이 필요 없겠죠? 뒤에 있는 clean task는 rake에 이미 지정되어 있는 task입니다. 사용하기 위해서는 &#8216;rake/clean&#8217;을 불러옵니다. <code>rake clean</code>을 실행하면 CLEAN에 포함된 파일들을 지워주고 <code>rake clobber</code>를 실행하면 CLOBBER와 CLEAN에 지정된 파일들을 모두 지워줍니다. 위에서 볼 수 있는 것처럼, 최종 결과 파일만 CLOBBER에 포함시키고 중간에 생성되는 파일들은 CLEAN에 포함시키면 편리하게 사용할 수 있습니다.</p>
<p>Makefile에서는 확장자법칙을 이용해 편리하게 compile할 수 있었죠? Rakefile에도 같은 기능이 있습니다. 비교해볼까요?</p>
<pre><tt><code><span style="color:#000000;">01:</span> <em><span style="color:#9a1900;"># $^ : dependency list</span></em>
<span style="color:#000000;">02:</span> <em><span style="color:#9a1900;"># $@ : target</span></em>
<span style="color:#000000;">03:</span>
<span style="color:#000000;">04:</span> <span style="color:#009900;">F77=</span>ifort
<span style="color:#000000;">05:</span> <span style="color:#009900;">FFLAG=</span>-assume byterecl -O<span style="color:#993399;">2</span>
<span style="color:#000000;">06:</span> <span style="color:#009900;">TARGET=</span>main
<span style="color:#000000;">07:</span> <span style="color:#009900;">OBJECTS=</span>main.o sub1.o sub2.o
<span style="color:#000000;">08:</span>
<span style="color:#000000;">09:</span> <span style="color:#990000;">all:</span> <span style="color:#009900;">$(TARGET)</span>
<span style="color:#000000;">10:</span>
<span style="color:#000000;">11:</span> <span style="color:#009900;">$(TARGET)</span><span style="color:#990000;">:</span> <span style="color:#009900;">$(OBJECTS)</span>
<span style="color:#000000;">12:</span>         <span style="color:#009900;">$(F77)</span> -o <span style="color:#009900;">$@</span> <span style="color:#009900;">$^</span>
<span style="color:#000000;">13:</span>
<span style="color:#000000;">14:</span> <strong><span style="color:#000080;">.SUFFIXES:</span></strong> .o .f
<span style="color:#000000;">15:</span> <span style="color:#990000;">%</span>.o<span style="color:#990000;">:</span> <span style="color:#990000;">%</span>.f
<span style="color:#000000;">16:</span>         <span style="color:#009900;">$(F77)</span> <span style="color:#009900;">${FFLAG}</span> -c <span style="color:#009900;">$^</span>
<span style="color:#000000;">17:</span>
<span style="color:#000000;">18:</span> <span style="color:#990000;">clean:</span>
<span style="color:#000000;">19:</span>         rm <span style="color:#009900;">$(TARGET)</span> <span style="color:#009900;">$(OBJECTS)</span></code>
</tt></pre>
<p><pre class="brush: ruby;">
F90='ifort'
FFLAG='-assume byterecl -O2'
TARGET='main.e'
SRC=FileList['*.f']
OBJ=SRC.ext('o')

task :default =&gt; TARGET
file TARGET =&gt; OBJ do
    sh &quot;#{F90} -o #{TARGET} #{OBJ}&quot;
end
rule '.o' =&gt; '.f' do |t|
    sh &quot;#{F90} #{FFLAG} -c #{t.source}&quot;
end

require 'rake/clean'
CLEAN.include('*.o')
CLOBBER.include('main.e')
</pre></p>
<p>Rakefile에서는 rule이라는 함수가 Makefile의 확장자법칙과 같은 역할을 합니다. FileList 명령은 glob pattern (여기서는 &#8216;*.f&#8217;)을 받아들여서 해당하는 파일들의 목록을 만들어주고, FileList 객체의 ext method는 목록에 있는 파일들의 확장자를 원하는 확장자로 바꿔서 새로운 FileList를 만들어줍니다. 앞에서 dependency list를 불러올 때 <code>t.prerequisites.join(' ')</code>이라고 사용했었는데 여기서는 <code>t.source</code>라고 사용했습니다. 앞의 방법은 전체 dependency list를 문자열로 만들어주고(&#8216; &#8216;을 이용하여 각각을 합치죠), 뒤의 방법은 dependency list의 첫 번 째 항목만 문자열로 만들어줍니다. 위의 예에서는 dependency list에 &#8216;.o&#8217;에 해당하는 &#8216;.f&#8217; 파일 하나만 있으니까 <code>t.source</code>라고 사용해도 무관하겠죠?</p>
<p>Makefile에 없고 Rakefile에만 있는 기능 중 하나로, task에 설명을 달 수 있는 기능이 있습니다. task 또는 file task 바로 윗 줄에<br />
<code>desc "description"</code><br />
이라고 설명을 추가해주면 <code>rake -T</code>라고 실행했을 때 설명과 함께 task 목록을 보여줍니다. Rakefile을 직접 보지 않고도 안에 무슨 task가 있는지 확인할 수 있는 유용한 기능이죠^^</p>
<p>더 자세한 내용은 다음의 site들을 참고하세요.<br />
<a href="http://rake.rubyforge.org/">http://rake.rubyforge.org/</a><br />
<a href="http://docs.rubyrake.org/">http://docs.rubyrake.org/</a></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/plusha.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/plusha.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/plusha.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/plusha.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/plusha.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/plusha.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/plusha.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/plusha.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/plusha.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/plusha.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/plusha.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/plusha.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/plusha.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/plusha.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/plusha.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/plusha.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=plusha.com&#038;blog=174108&#038;post=13&#038;subd=plusha&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://plusha.com/2008/05/20/rakefile-basic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">plusha</media:title>
		</media:content>
	</item>
		<item>
		<title>Custom Rake Applications</title>
		<link>http://plusha.com/2006/06/03/custom-rake-applications/</link>
		<comments>http://plusha.com/2006/06/03/custom-rake-applications/#comments</comments>
		<pubDate>Sat, 03 Jun 2006 06:04:48 +0000</pubDate>
		<dc:creator>plusha</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[Rakefile]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://plusha.wordpress.com/?p=9</guid>
		<description><![CDATA[Reference Rake를 Rakefile을 이용하여 실행하지 않고 library로 사용하는 방법입니다.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=plusha.com&#038;blog=174108&#038;post=9&#038;subd=plusha&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.onestepback.org/index.cgi/Tech/Rake/CustomRakeApplications.blog.red">Reference</a></p>
<p>Rake를 Rakefile을 이용하여 실행하지 않고 library로 사용하는 방법입니다.</p>
<p><pre class="brush: ruby;">
#!/usr/bin/env ruby

#gem 'rake', '&gt;= 0.7.3'
require 'rake'

Rake.application.init('server')

### (write a Rakefile here)

Rake.application.top_level
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/plusha.wordpress.com/9/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/plusha.wordpress.com/9/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/plusha.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/plusha.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/plusha.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/plusha.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/plusha.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/plusha.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/plusha.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/plusha.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/plusha.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/plusha.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/plusha.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/plusha.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/plusha.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/plusha.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=plusha.com&#038;blog=174108&#038;post=9&#038;subd=plusha&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://plusha.com/2006/06/03/custom-rake-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">plusha</media:title>
		</media:content>
	</item>
	</channel>
</rss>
