This repository has been archived by the owner on Sep 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 369
/
automation03_make-test-drive.html
208 lines (181 loc) · 8.8 KB
/
automation03_make-test-drive.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="author" content="Shaun Jackman, Jenny Bryan" />
<title>Automation: Test drive make</title>
<script src="libs/jquery-1.11.0/jquery.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="libs/bootstrap-3.3.1/css/bootstrap.min.css" rel="stylesheet" />
<script src="libs/bootstrap-3.3.1/js/bootstrap.min.js"></script>
<script src="libs/bootstrap-3.3.1/shim/html5shiv.min.js"></script>
<script src="libs/bootstrap-3.3.1/shim/respond.min.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-68219208-1', 'auto');
ga('send', 'pageview');
</script>
<style type="text/css">code{white-space: pre;}</style>
<link rel="stylesheet"
href="libs/highlight/default.css"
type="text/css" />
<script src="libs/highlight/highlight.js"></script>
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
<script type="text/javascript">
if (window.hljs && document.readyState && document.readyState === "complete") {
window.setTimeout(function() {
hljs.initHighlighting();
}, 0);
}
</script>
<link rel="stylesheet" href="libs/local/main.css" type="text/css" />
<link rel="stylesheet" href="libs/local/nav.css" type="text/css" />
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" type="text/css" />
</head>
<body>
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
code {
color: inherit;
background-color: rgba(0, 0, 0, 0.04);
}
img {
max-width:100%;
height: auto;
}
</style>
<div class="container-fluid main-container">
<header>
<div class="nav">
<a class="nav-logo" href="index.html">
<img src="static/img/stat545-logo-s.png" width="70px" height="70px"/>
</a>
<ul>
<li class="home"><a href="index.html">Home</a></li>
<li class="faq"><a href="faq.html">FAQ</a></li>
<li class="syllabus"><a href="syllabus.html">Syllabus</a></li>
<li class="topics"><a href="topics.html">Topics</a></li>
<li class="people"><a href="people.html">People</a></li>
</ul>
</div>
</header>
<div id="header">
<h1 class="title">Automation: Test drive make</h1>
<h4 class="author"><em>Shaun Jackman, Jenny Bryan</em></h4>
</div>
<div id="TOC">
<ul>
<li><a href="#create-a-temporary-rstudio-project">Create a temporary RStudio Project</a></li>
<li><a href="#disable-insert-spaces-for-tab">Disable “insert spaces for tab”</a></li>
<li><a href="#write-a-toy-makefile">Write a toy <code>Makefile</code></a></li>
<li><a href="#configure-this-rstudio-project-to-use-make">Configure this Rstudio Project to use <code>make</code></a></li>
<li><a href="#run-make-via-rstudio">Run <code>make</code> via RStudio</a></li>
<li><a href="#run-make-from-the-shell">Run <code>make</code> from the <a href="git09_shell.html">shell</a></a></li>
</ul>
</div>
<p>Before we use <code>make</code> for real work, we want to prove beyond a shadow of a doubt that it’s installed and findable from RStudio and/or the <a href="git09_shell.html">shell</a>.</p>
<p>back to <a href="automation00_index.html">All the automation things</a></p>
<div id="create-a-temporary-rstudio-project" class="section level3">
<h3>Create a temporary RStudio Project</h3>
<p>You can delete this project after this test drive, so don’t sweat too much about what you name it or where you put it.</p>
<ul>
<li>Create an RStudio project: <em>File > New Project</em></li>
<li>Create a new text file: <em>File > New File > Text File</em></li>
<li>We are about to write our first <code>Makefile</code>!</li>
</ul>
<p>But first …</p>
</div>
<div id="disable-insert-spaces-for-tab" class="section level3">
<h3>Disable “insert spaces for tab”</h3>
<p>Tabs are very meaningful in <code>Makefiles</code>, so it’s important to make sure your text editor is not “helpfully” but silently converting tabs to spaces.</p>
<p>Here’s how to disable this in RStudio.</p>
<ul>
<li>Global setting: <em>Tools > Global Options… > Code editing</em>. Make sure “insert spaces for tab” is <strong>unchecked</strong>.</li>
<li>Project-specific setting: <em>Tools > Project Options… > Code editing</em>. Make sure “insert spaces for tab” is <strong>unchecked</strong>.</li>
</ul>
<p>RStudio can reveal information about the whitespace in a file: <em>RStudio > Preferences… > Code editing > Show whitespace characters</em>. When in doubt, make darn sure your <code>Makefile</code> is indented with tabs and not spaces!</p>
</div>
<div id="write-a-toy-makefile" class="section level3">
<h3>Write a toy <code>Makefile</code></h3>
<p>Type or paste this into your new text file. Make sure the indentation before <code>@echo</code> is always a tab! Save as <code>Makefile</code>:</p>
<pre class="makefile"><code>all:
@echo Build all
clean:
@echo Clean all</code></pre>
</div>
<div id="configure-this-rstudio-project-to-use-make" class="section level3">
<h3>Configure this Rstudio Project to use <code>make</code></h3>
<p>Select <em>Build > Configure Build Tools > Build Tools > Project build tools > Makefile</em>.</p>
<p>This will make a new tab and buttons and menus available in RStudio, usually in the upper right-hand pane, similar to the Git stuff.</p>
</div>
<div id="run-make-via-rstudio" class="section level3">
<h3>Run <code>make</code> via RStudio</h3>
<p>Select <em>Build > Build All</em> (the hammer icon).</p>
<p>The result and any error messages should appear under the <em>Build</em> tab.</p>
<p>Hopefully you will see this:</p>
<pre class="sh"><code>Build all</code></pre>
<p>If you see something like this:</p>
<pre class="sh"><code>Makefile:2: *** missing separator. Stop.</code></pre>
<p>you probably have spaces instead of tabs as indentation. Fix that and try again.</p>
<p>RStudio offers these buttons or menu items to run things from your <code>Makefile</code>:</p>
<ul>
<li><em>Build All</em> runs <code>make all</code>, as we just saw</li>
<li><em>Clean All</em> runs <code>make clean</code></li>
<li><em>Clean and Rebuild</em> runs <code>make clean all</code></li>
</ul>
<p>For these menu items to work, your <code>Makefile</code> needs to have targets named <code>all</code> and <code>clean</code>. These non-file targets are called phony targets.</p>
<p>You should be able to select <em>Build > More > Clean All</em> and get this:</p>
<pre class="sh"><code>Clean all</code></pre>
<p>You should be able to select <em>Build > More > Clean and Rebuild</em> and get this:</p>
<pre class="sh"><code>Clean all
Build all</code></pre>
<p>This proves that <code>make</code> is installed and working from RStudio.</p>
</div>
<div id="run-make-from-the-shell" class="section level3">
<h3>Run <code>make</code> from the <a href="git09_shell.html">shell</a></h3>
<p>RStudio only provides access to a very limited bit of <code>make</code> – it’s even more limited than the RStudio Git client. In the long run, it’s important to be able to run <code>make</code> from the <a href="git09_shell.html">shell</a>.</p>
<ul>
<li>Select <em>Tools > Shell</em></li>
<li><p>Run</p>
<pre class="sh"><code>make clean
make all
make clean all</code></pre></li>
</ul>
<p>You should be seeing similar output as you saw in the Build tab of RStudio.</p>
<p>If you are not, are you getting the error message that’s characteristic of a “spaces instead of tabs” problem? Or does it look more like <code>make</code> or other commands aren’t being found? If the latter, go back to the <a href="automation02_windows.html">Windows installation page</a> or reach out to the course staff.</p>
<p>back to <a href="automation00_index.html">All the automation things</a></p>
</div>
<div class="footer">
This work is licensed under the <a href="http://creativecommons.org/licenses/by-nc/3.0/">CC BY-NC 3.0 Creative Commons License</a>.
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
$(document).ready(function () {
$('tr.header').parent('thead').parent('table').addClass('table table-condensed');
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>