slides.tex 12 KB

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