slides.tex (11921B)
1 % © Jérôme Carretero 2010 (Zougloub) 2 % See license at end of file 3 4 \documentclass[xetex]{beamer} 5 \RequirePackage{fontspec} 6 \RequirePackage{xunicode} %Unicode extras! 7 \RequirePackage{xltxtra} %Fixes 8 \RequirePackage{verbatim} 9 \RequirePackage{listings} 10 \RequirePackage{multicol} 11 \RequirePackage{moreverb} 12 13 \usetheme[hideothersubsections, width=.15\textwidth]{waf} 14 \usecolortheme{orchid} 15 \setbeamertemplate{navigation symbols}{} % hides navigation symbols 16 17 \usepackage{fancybox} 18 \usepackage{multimedia} 19 20 \usepackage{eso-pic} 21 22 \title[Build Tools]{ 23 Build Automation Tools 24 } 25 26 \subtitle{ 27 Comparison of make and waf for non-technical users 28 } 29 30 \author[]{Jérôme Carretero} 31 32 \institute[] {} 33 34 \date{2010-11-05} 35 36 \lstdefinelanguage{waf} 37 {morekeywords={def, ctx, bld, opt, configure, options, build, features, source, target, load, use}, 38 sensitive=true, 39 morecomment=[l]{\#}, 40 %morecomment=[s]{/*}{*/}, 41 morestring=[b]", 42 } 43 \begin{document} 44 45 \lstset{ 46 language=make, 47 basicstyle=\tiny,%\footnotesize, 48 %numbers=left,% -> where to put the line-numbers 49 %numberstyle=\footnotesize,% -> size of the fonts used for the line-numbers 50 %stepnumber=5,% -> the step between two line-numbers. 51 %numbersep=5pt,% -> how far the line-numbers are from the code 52 %backgroundcolor=\color{white},% -> sets background color (needs package) 53 showspaces=false,% -> show spaces adding particular underscores 54 showstringspaces=false,% -> underline spaces within strings 55 showtabs=false,% -> show tabs within strings through particular underscores 56 frame=single,% -> adds a frame around the code 57 tabsize=4,% -> sets default tab-size to 2 spaces 58 captionpos=b,% -> sets the caption-position to bottom 59 breaklines=true,% -> sets automatic line breaking 60 breakatwhitespace=false,% -> automatic breaks happen at whitespace 61 %morecomment=[l]{//}, 62 } 63 64 \setbeamertemplate{background}{ 65 \begin{picture}(320, 270) 66 \put(300, 250){\includegraphics[width=.05\textwidth]{gfx/waflogo.png}} 67 \end{picture} 68 } 69 70 71 \frame{ 72 \begin{picture}(0,0) 73 %\put(0,-5){\includegraphics[width=.2\textwidth]{RT09_Logo.jpg}} 74 \end{picture} 75 \vspace{1cm} 76 \titlepage 77 } 78 79 80 \frame{ 81 \frametitle{Outline} 82 \tableofcontents[subsectionstyle=hide/show/hide] 83 } 84 85 \section{Introduction} 86 87 \begin{frame}{Definition and Context} 88 \begin{itemize} 89 \item Build automation is the act of scripting or automating a wide variety of tasks that software developers do in their day-to-day activities \cite{wp_build_automation}. 90 \item I have seen a lot of code and used many build automation tools 91 \item For technical reasons, I consider waf to be the best tool out there 92 \end{itemize} 93 \end{frame} 94 95 \section{Make} 96 97 98 \frame{ 99 \frametitle{Make: outline} 100 \tableofcontents[sectionstyle=hide/hide,subsectionstyle=hide/show/hide] 101 } 102 103 \begin{frame}[fragile] 104 \scriptsize 105 \frametitle{Simplest Makefile} 106 \lstinputlisting{snippets/make-1/Makefile} 107 \lstinputlisting{snippets/make-1/output} 108 \end{frame} 109 110 \subsection{Structure of a Makefile} 111 112 \begin{frame}[fragile]{Makefile properties} 113 Makefiles are like basic kitchen recipes: 114 \begin{itemize} 115 \item basic syntax:\\ 116 \begin{lstlisting} 117 variable = value 118 119 target: dependencies 120 commands to run 121 \end{lstlisting} 122 \item plus include ability and a few commands 123 \end{itemize} 124 125 Features: 126 \begin{itemize} 127 \item the return codes of the commands are checked for errors 128 \item the variables are expanded into commands, dependencies, or command strings 129 \item pretty simple, but relatively efficient 130 \item nothing beats make for tiny jobs 131 \end{itemize} 132 \end{frame} 133 134 135 136 \subsection{Limitations} 137 138 \begin{frame}{It can become complicated} 139 The following is a little caricature of what becomes necessary with big projects.\\ 140 It only works with gcc-style compilers on UNIX: 141 \lstinputlisting{snippets/make-2/Makefile} 142 \lstinputlisting{snippets/make-2/output} 143 \end{frame} 144 145 \subsection{Conclusion} 146 147 \begin{frame}{So what} 148 \begin{itemize} 149 \item make was born in 1973\\ 150 It's mature, but not very high-tech 151 \item very efficient for small 80's projects 152 \item since then, other tools have appeared 153 \item domain-specific language 154 \item string-based, command-line based (based on the usage of shell scripts) 155 \end{itemize} 156 \end{frame} 157 158 \section{Waf Intro} 159 160 \frame{ 161 \frametitle{Waf: outline} 162 \tableofcontents[sectionstyle=hide/hide,subsectionstyle=hide/show/hide] 163 } 164 165 \subsection{Waf is to Make as C++ is to assembly} 166 167 168 \begin{frame}{Intro} 169 \begin{itemize} 170 \item waf is a newest-generation build tool\\ 171 History: sh $\to$ make $\to$ scons $\to$ waf 172 \item built on the Python language, not a custom, restricted special-purpose one\\ 173 $\neq$ CMake, ant, maven\\ 174 a waf script can do \textbf{anything} 175 \item task-based, not file-based\\ 176 can build abstract stuff 177 \item includes build configuration 178 \item custom commands can be added 179 \item tool abstraction, more portability, cross-compilation friendly 180 \end{itemize} 181 \end{frame} 182 183 184 \begin{frame}[fragile]{Simplest waf script} 185 \scriptsize 186 \lstinputlisting[language=waf]{snippets/waf-1/wscript} 187 \lstinputlisting{snippets/waf-1/output} 188 \end{frame} 189 190 \subsection{New Concepts} 191 192 \begin{frame}{New Concepts} 193 \begin{itemize} 194 \item \texttt{configure()} configures the build machine to enable proper compilation (library detection, config.h writing, etc.).\\ 195 Similar to autoconf.\\ 196 Useful to provide better portability of code. 197 198 \item \texttt{build()} is where you define your build tasks 199 200 \item \texttt{options()} allows to provide compilation options to the build\\ 201 Mostly unused in simple cases 202 \end{itemize} 203 \end{frame} 204 205 \begin{frame}[fragile]{Dependencies Graph} 206 If you wanted to export modules A and/or B: 207 \lstinputlisting[language=waf]{snippets/waf-2/wscript} 208 \end{frame} 209 210 211 \begin{frame}{Dependencies Specifications} 212 \begin{center} 213 \includegraphics[height=.3\textheight]{gfx/slides-executable_deps.png} 214 \end{center} 215 \begin{itemize} 216 \item You don't need to specify the whole dependency tree of your target\\ 217 just the closest nodes ! $\neq$ make 218 \item every \textit{task generator} defines what it does and what it uses 219 \item[+] less redundancy 220 \item[+] build scripts quickly become much smaller and powerful than equivalent makefiles 221 \end{itemize} 222 \end{frame} 223 224 225 \begin{frame}{Tools} 226 \begin{itemize} 227 \item You can use waf just like make (specify everything) but there are \textit{tools} 228 \item ex: compiler\_c, compiler\_cxx, java, cs, winres, d, bison, qt4, ... 229 \item[+] The tools avoid you to type and build scripts are more readable 230 \item[+] compiler\_c automatically detects MSVC, GCC, ICC, SUNCC, ... 231 \item[+] Less lines of code, less maintenance 232 \end{itemize} 233 \end{frame} 234 235 \begin{frame}{Waf “Recursivity”} 236 \begin{itemize} 237 \item Variables do not get shared with recursive make 238 \item They do with recursive waf scripts 239 \end{itemize} 240 241 You define a component in a module, and use it in another module “as is”. 242 \\ 243 Ex: NGPF build scripts, the targets are shared between folders 244 245 \end{frame} 246 247 248 \begin{frame}{Dependencies Scanning} 249 \begin{itemize} 250 \item waf tools automatically scan include dependencies (C, C++, LaTeX, Java, C\#), ... 251 \item waf keeps a cache of the task yields checksums 252 \item[$\to$] waf will only rebuild modified files 253 \item[$\to$] faster online compilation (a lot less \texttt{make clean} performed) 254 \end{itemize} 255 \end{frame} 256 257 258 \begin{frame}{More} 259 \begin{itemize} 260 \item built-in support for build folders\\ 261 \textbf{very important} 262 \item built-in support for unit testing 263 \item built-in support for build machines (auto-build) 264 \item built-in support for build variants and cross-compilation 265 \end{itemize} 266 \end{frame} 267 268 \subsection{Myth Busting} 269 270 \begin{frame}{“waf is a big pile of dark crap”} 271 Wrong: 272 \begin{itemize} 273 \item waf is very small!\\ 274 core files are <6500 lines of Python code including comments (25\%)\\ 275 GNU make: 32000 (C) 276 \item logical and extensible architecture 277 \begin{itemize} 278 \scriptsize 279 \item Core: Context, Build, Node, Configure, Task, TaskGen, Runner, misc %(Errors, Utils, ConfigSet) 280 \item Plugins: Tools/ 281 \end{itemize} 282 \item lots and lots of documentation and examples, great support 283 \item used by lots of high-tech people: 284 \begin{itemize} 285 \scriptsize 286 \item big enterprise projects (Cisco® IOS, ...) 287 \item big OpenSource projects (Samba \cite{samba_waf}, XMMS2, Ardour \cite{ardour_waf}, Jack, ...) 288 \item big research projects (NS-3, ...) 289 \end{itemize} 290 \end{itemize} 291 \end{frame} 292 293 294 \begin{frame}{“waf is too complex for me”} 295 waf scripts are easy to read and write. 296 A wscript is typically composed of: 297 \begin{itemize} 298 \item \texttt{configure()} 299 \begin{itemize} 300 \scriptsize 301 \item external libraries definitions for multiple build platforms (eg. Linux 32+64, QNX, Win32 cross, Win32 native) 302 \item targets configuration 303 \item environment checks 304 \item config.h writing 305 \end{itemize} 306 \item \texttt{build()}: build rules (the most touched and simplest part) 307 \item misc (optional): multi-variant build functions, command-line options parsing, etc. 308 \end{itemize} 309 310 It's easy to create a simple wscript (lots of examples, very simple syntax). 311 \\ 312 ~\\ 313 Contributing to a big wscript is easier than contributing to a big Makefile. 314 \\ 315 The only important part when contributing is the definition of the build task generators. 316 \end{frame} 317 318 319 \begin{frame}{Summary} 320 \begin{itemize} 321 \item a recent tool (2005)\\ 322 still, a lot of examples, and support for complex usages are available 323 \item a little more complex than make for tiny projects\\ 324 but it's worth it for everyday development 325 \item more performant 326 \item a lot more powerful and flexible 327 \item me likes it 328 \end{itemize} 329 \end{frame} 330 331 \section{Conclusion} 332 333 \begin{frame}{Conclusion} 334 \begin{itemize} 335 \item I am convinced that waf brings long-term advantages\\ 336 I definitely recommend it for complex builds 337 \item very appropriate for modular project integration 338 \item I would not maintain huge unreadable makefiles 339 \end{itemize} 340 \end{frame} 341 342 \begin{frame}{Links} 343 344 \begin{thebibliography}{9} 345 346 \bibitem{samba_waf} Samba team waf page\\ 347 \url{http://wiki.samba.org/index.php/Waf} 348 349 \bibitem{wp_build_automation} Wikipedia article on Build Automation\\ 350 \url{http://en.wikipedia.org/wiki/Build_automation} 351 352 \bibitem{ardour_waf} Ardour build page\\ 353 \url{http://www.ardour.org/building_ardour3} 354 355 \bibitem{xmms2_waf} XMMS2 installation instructions\\ 356 \url{http://xmms2.org/wiki/Install_instructions} 357 358 \end{thebibliography} 359 360 \end{frame} 361 362 \end{document} 363 364 License: 365 366 Redistribution and use in source and binary forms, with or without 367 modification, are permitted provided that the following conditions 368 are met: 369 370 1. Redistributions of source code must retain the above copyright 371 notice, this list of conditions and the following disclaimer. 372 373 2. Redistributions in binary form must reproduce the above copyright 374 notice, this list of conditions and the following disclaimer in the 375 documentation and/or other materials provided with the distribution. 376 377 3. The name of the author may not be used to endorse or promote products 378 derived from this software without specific prior written permission. 379 380 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 381 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 382 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 383 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 384 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 385 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 386 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 387 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 388 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 389 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 390 POSSIBILITY OF SUCH DAMAGE. 391 392