Macros Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See

Slides:



Advertisements
Similar presentations
Configuration management
Advertisements

Input and Output Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Lecture 3 Getting Started with ITK!. Goals for this lecture Learn how to use Cmake Build ITK Example programs that use ITK.
S UMMER I NTERNSHIP Douglas Drobny Idaho National Laboratory High Performance Computing.
Internal Documentation Conventions. Kinds of comments javadoc (“doc”) comments describe the user interface: –What the classes, interfaces, fields and.
Software Delivery. Software Delivery Management  Managing Requirements and Changes  Managing Resources  Managing Configuration  Managing Defects 
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
CODING Research Data Management. Research Data Management Coding When writing software or analytical code it is important that others and your future.
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
CASE Tools And Their Effect On Software Quality Peter Geddis – pxg07u.
Introduction to The Linaro Toolchain Embedded Processors Training Multicore Software Applications Literature Number: SPRPXXX 1.
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
Introduction to ant Guy Rixon AstroGrid Consortium Meeting
Mechanics Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Project Source Code Structure and Build Process ● Remember consistency matters as source code structure, build process, and release processes are all intertwined.
Research Code Andrew Rosenberg with RA Manual: Notes on Writing Code by Matthew Gentzkow and Jesse Shapiro Chicago Booth and
Functions Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Fixtures Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Makefiles CISC/QCSE 810. BeamApp and Tests in C++ 5 source code files After any modification, changed source needs to be recompiled all object files need.
Makefiles. makefiles Problem: You are working on one part of a large programming project (e. g., MS Word).  It consists of hundreds of individual.cpp.
Introduction Use of makefiles to manage the build process Declarative, imperative and relational rules Environment variables, phony targets, automatic.
Nanotech Example Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Chapter Ten g++ and make1 System Programming Software Development: g++ and make.
Browsing Directories Copyright © Software Carpentry and The University of Edinburgh This work is licensed under the Creative Commons Attribution.
Unit Testing Maintaining Quality. How do you test? Testing to date…
Computer Science 313 – Advanced Programming Topics.
Files and Directories Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Interface and Implementation Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Access The L Line The Express Line to Learning 2007 L Line L © Wiley Publishing All Rights Reserved.
Intermediate 2 Computing Unit 2 - Software Development Topic 2 - Software Development Languages and Environments.
1 Day 18 Bash and the.files. 2 The.files ls shows you the files in your directory –Or at least most of them. –Some files are hidden. Try: ls –a –This.
Rollback Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Finding Things Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Lecture 8  make. Using make for compilation  With medium to large software projects containing many files, it’s difficult to: Type commands to compile.
(1) Introduction to Continuous Integration Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of.
Makefiles Problem: You are working on one part of a large programming project (e. g., MS Word).  It consists of hundreds of individual.c files all linked.
Make Make is a system utility that automatically compiles your programs for you Make looks for a file named Makefile (or makefile) in the current directory.
Exceptions Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Basics Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Build Tools 1. Building a program for a large project is usually managed by a build tool that controls the various steps involved. These steps may include:
CS 177 Recitation Week 1 – Intro to Java. Questions?
Makefile Script file to automate program compilation and linking (making) 1. Write the "makefile" 2. Write your programs 3. Run "make" or "make -f makefile"
Patterns Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Get your software working before putting it on the robot!
Glencoe Introduction to Web Design Chapter 4 XHTML Basics 1 Review Do you remember the vocabulary terms from this chapter? Use the following slides to.
CMake: Experience in ALICE P. Hristov 19/06/12. History I Recursive makefiles (F.Carminati): – Problems in dependencies – Slow "Recursive Makefiles.
CMake - Cross-Platform Make R. Douglas Barbieri Made to Order Software Corporation.
Python Aliasing Copyright © Software Carpentry 2010
Build and Test system for FairRoot
Program Design Invasion Percolation: Aliasing
Compilation and Debugging
Compilation and Debugging
Program Design Invasion Percolation: Resolving Ties
Lab: ssh, scp, gdb, valgrind
Advanced TAU Commander
Lab: ssh, scp, gdb, valgrind
Makefiles and the make utility
Cmake Primer.
has many aspects that work together to give people almost instant communication from any computer on the internet to any other computer There.
Version Control Basic Operation Copyright © Software Carpentry 2010
Version Control Introduction Copyright © Software Carpentry 2010
Kyle Fitzpatrick Konstantin Zak 11/29/2004
How to write good code Part 2
Version Control Conflict Copyright © Software Carpentry 2010
Program Design Invasion Percolation: The Grid
Makefiles and the make utility
Presentation transcript:

Macros Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See for more information. Automated Builds

Macros Manage tasks and dependencies

Automated BuildsMacros figure-1.svg summary-1.dat Manage tasks and dependencies figure-2.svg data-1-1.datdata-1-3.datdata-1-2.dat paper.pdf paper.wdp

Automated BuildsMacros "must conform to university style"

Automated BuildsMacros "must conform to university style" figure-1.svgfigure-2.svg paper.pdf euphoric.wpspaper.wdp

Automated BuildsMacros "must conform to university style" figure-1.svgfigure-2.svg paper.pdf euphoric.wpspaper.wdp C:\papers home

Automated BuildsMacros "must conform to university style" figure-1.svgfigure-2.svg paper.pdf euphoric.wpspaper.wdp C:\papers/lib/styles/ homelab

Automated BuildsMacros "must conform to university style" figure-1.svgfigure-2.svg paper.pdf euphoric.wpspaper.wdp data-1-1.datdata-1-2.dateuphoric.fig

Automated BuildsMacros "must conform to university style" figure-1.svgfigure-2.svg paper.pdf euphoric.wpspaper.wdp C:\papers home data-1-1.datdata-1-2.dateuphoric.fig

Automated BuildsMacros "must conform to university style" figure-1.svgfigure-2.svg paper.pdf euphoric.wpspaper.wdp C:\papers /lib/styles/ home lab data-1-1.datdata-1-2.dateuphoric.fig

Automated BuildsMacros # false-dependencies.mk paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf $< figure-%.svg : summary-%.dat sgr -N -r $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Makefile so far

Automated BuildsMacros # with-directories-at-home.mk paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf --style c:/papers/euphoric.wps $< figure-%.svg : summary-%.dat sgr -N -r -s c:/papers/euphoric.fig $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Add directories for working at home

Automated BuildsMacros # with-directories-at-home.mk paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf --style c:/papers/euphoric.wps $< figure-%.svg : summary-%.dat sgr -N -r -s c:/papers/euphoric.fig $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Add directories for working at home

Automated BuildsMacros # with-directories-at-home.mk paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf --style c:/papers/euphoric.wps $< figure-%.svg : summary-%.dat sgr -N -r -s c:/papers/euphoric.fig $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Usually don't list "system" files explicitly Add directories for working at home

Automated BuildsMacros # with-directories-at-home.mk paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf --style c:/papers/euphoric.wps $< figure-%.svg : summary-%.dat sgr -N -r -s c:/papers/euphoric.fig $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Usually don't list "system" files explicitly But what about the lab? Add directories for working at home

Automated BuildsMacros 1. Write two Makefiles

Automated BuildsMacros 1. Write two Makefiles Write and maintain

Automated BuildsMacros 1.Write two Makefiles 2. Comment and uncomment lines Write and maintain

Automated BuildsMacros 1.Write two Makefiles 2. Comment and uncomment lines Write and maintain Consistently every time

Automated BuildsMacros 1.Write two Makefiles 2. Comment and uncomment lines Write and maintain Consistently every time Will create lots of noise in version control

Automated BuildsMacros 1.Write two Makefiles 2.Comment and uncomment lines 3.Refactor Write and maintain Consistently every time Will create lots of noise in version control

Automated BuildsMacros Use a macro

Automated BuildsMacros # with-macro.mk STYLE_DIR=c:/papers/ paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf --style ${STYLE_DIR}/euphoric.wps $< figure-%.svg : summary-%.dat sgr -N -r -s ${STYLE_DIR}/euphoric.fig $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Use a macro

Automated BuildsMacros # with-macro.mk STYLE_DIR=c:/papers/ paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf --style ${STYLE_DIR}/euphoric.wps $< figure-%.svg : summary-%.dat sgr -N -r -s ${STYLE_DIR}/euphoric.fig $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Use a macro

Automated BuildsMacros # with-macro.mk STYLE_DIR=c:/papers/ paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf --style ${STYLE_DIR}/euphoric.wps $< figure-%.svg : summary-%.dat sgr -N -r -s ${STYLE_DIR}/euphoric.fig $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Use a macro

Automated BuildsMacros Only have one thing to change

Automated BuildsMacros Only have one thing to change ✓ Consistency

Automated BuildsMacros Only have one thing to change ✓ Consistency ✗ But still have noise

Automated BuildsMacros Only have one thing to change Must use ${MACRO} or $(MACRO), not $MACRO ✓ Consistency ✗ But still have noise

Automated BuildsMacros Only have one thing to change Must use ${MACRO} or $(MACRO), not $MACRO Make reads $MACRO is ($M)ACRO ✓ Consistency ✗ But still have noise

Automated BuildsMacros Only have one thing to change Must use ${MACRO} or $(MACRO), not $MACRO Make reads $MACRO is ($M)ACRO Which is probably just "ACRO" ✓ Consistency ✗ But still have noise

Automated BuildsMacros Only have one thing to change Must use ${MACRO} or $(MACRO), not $MACRO Make reads $MACRO is ($M)ACRO Which is probably just "ACRO" Which is probably not what you want ✓ Consistency ✗ But still have noise

Automated BuildsMacros Only have one thing to change Must use ${MACRO} or $(MACRO), not $MACRO Make reads $MACRO is ($M)ACRO Which is probably just "ACRO" Which is probably not what you want yet another legacy wart ✓ Consistency ✗ But still have noise

Automated BuildsMacros Commonly define macros for control flags

Automated BuildsMacros # with-lots-of-macros.mk STYLE_DIR=c:/papers/ WDP2PDF_FLAGS=--style ${STYLE_DIR}/euphoric.wps SGR_FLAGS=-N -r -s ${STYLE_DIR}/euphoric.fig paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf ${WDP2PDF_FLAGS} $< figure-%.svg : summary-%.dat sgr ${SGR_FLAGS} $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Commonly define macros for control flags

Automated BuildsMacros # with-lots-of-macros.mk STYLE_DIR=c:/papers/ WDP2PDF_FLAGS=--style ${STYLE_DIR}/euphoric.wps SGR_FLAGS=-N -r -s ${STYLE_DIR}/euphoric.fig paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf ${WDP2PDF_FLAGS} $< figure-%.svg : summary-%.dat sgr ${SGR_FLAGS} $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Commonly define macros for control flags

Automated BuildsMacros # with-lots-of-macros.mk STYLE_DIR=c:/papers/ WDP2PDF_FLAGS=--style ${STYLE_DIR}/euphoric.wps SGR_FLAGS=-N -r -s ${STYLE_DIR}/euphoric.fig paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf ${WDP2PDF_FLAGS} $< figure-%.svg : summary-%.dat sgr ${SGR_FLAGS} $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch Commonly define macros for control flags

Automated BuildsMacros # config.mk STYLE_DIR=c:/papers/ Now put the first macro in a separate file

Automated BuildsMacros # with-include.mk include config.mk WDP2PDF_FLAGS=--style ${STYLE_DIR}/euphoric.wps SGR_FLAGS=-N -r -s ${STYLE_DIR}/euphoric.fig paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf ${WDP2PDF_FLAGS} $< figure-%.svg : summary-%.dat sgr ${SGR_FLAGS} $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch And include it from the main file

Automated BuildsMacros # with-include.mk include config.mk WDP2PDF_FLAGS=--style ${STYLE_DIR}/euphoric.wps SGR_FLAGS=-N -r -s ${STYLE_DIR}/euphoric.fig paper.pdf : paper.wdp figure-1.svg figure-2.svg wdp2pdf ${WDP2PDF_FLAGS} $< figure-%.svg : summary-%.dat sgr ${SGR_FLAGS} $^ summary-%.dat : data-%-*.dat stats.py $^ data-*-*.dat : stats.py touch And include it from the main file

Automated BuildsMacros Actually create two configuration files

Automated BuildsMacros # config-home.mk STYLE_DIR=c:/papers/ Actually create two configuration files

Automated BuildsMacros # config-home.mk STYLE_DIR=c:/papers/ Actually create two configuration files # config-lab.mk STYLE_DIR=/lib/styles

Automated BuildsMacros # config-home.mk STYLE_DIR=c:/papers/ Actually create two configuration files # config-lab.mk STYLE_DIR=/lib/styles These two files stay in version control

Automated BuildsMacros # config-home.mk STYLE_DIR=c:/papers/ Actually create two configuration files # config-lab.mk STYLE_DIR=/lib/styles These two files stay in version control Copy to create config.mk per machine

Automated BuildsMacros paper/ config-lab.mk config-home.mk Makefile Home

Automated BuildsMacros paper/ config.mk config-lab.mk config-home.mk Makefile Home

Automated BuildsMacros paper/ config.mk config-lab.mk config-home.mk Makefile Home paper/ config-lab.mk config-home.mk Makefile Lab

Automated BuildsMacros paper/ config.mk config-lab.mk config-home.mk Makefile Home paper/ config.mk config-lab.mk config-home.mk Makefile Lab

Automated BuildsMacros paper/ config.mk config-lab.mk config-home.mk Makefile Home paper/ config.mk config-lab.mk config-home.mk Makefile Lab

Automated BuildsMacros Can also define macro value on command line

Automated BuildsMacros $ make -DSTYLE_DIR=/lib/styles -f Makefile Can also define macro value on command line

Automated BuildsMacros $ make -DSTYLE_DIR=/lib/styles -f Makefile Can also define macro value on command line Generally a bad idea

Automated BuildsMacros $ make -DSTYLE_DIR=/lib/styles -f Makefile Can also define macro value on command line Generally a bad idea Have to remember to type definition each time

Automated BuildsMacros $ make -DSTYLE_DIR=/lib/styles -f Makefile Can also define macro value on command line Generally a bad idea Have to remember to type definition each time correctly

Automated BuildsMacros $ make -DSTYLE_DIR=/lib/styles -f Makefile Can also define macro value on command line Generally a bad idea Have to remember to type definition each time correctly And there's no record of the flag

Automated BuildsMacros Many other approaches

Automated BuildsMacros Many other approaches CMake and Autoconf/Automake: compile higher-level specification into a Makefile (or equivalent)

Automated BuildsMacros Many other approaches CMake and Autoconf/Automake: compile higher-level specification into a Makefile (or equivalent) ✓ Automatically discover/manage differences between machines

Automated BuildsMacros Many other approaches CMake and Autoconf/Automake: compile higher-level specification into a Makefile (or equivalent) ✓ Automatically discover/manage differences between machines ✗ But even harder to debug

Automated BuildsMacros Many other approaches CMake and Autoconf/Automake: compile higher-level specification into a Makefile (or equivalent) ✓ Automatically discover/manage differences between machines ✗ But even harder to debug A build file is a program

Automated BuildsMacros Many other approaches CMake and Autoconf/Automake: compile higher-level specification into a Makefile (or equivalent) ✓ Automatically discover/manage differences between machines ✗ But even harder to debug A build file is a program Requires the same degree of respect

August 2010 created by Greg Wilson Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See for more information.