The WAF build system Sebastian Jeltsch Electronic Vision(s) - - PowerPoint PPT Presentation

the waf build system
SMART_READER_LITE
LIVE PREVIEW

The WAF build system Sebastian Jeltsch Electronic Vision(s) - - PowerPoint PPT Presentation

The WAF build system The WAF build system Sebastian Jeltsch Electronic Vision(s) Kirchhoff Institute for Physics Ruprecht-Karls-Universitt Heidelberg 31. August 2010 Sebastian Jeltsch The WAF build system 31. August 2010 1 / 19 The WAF


slide-1
SLIDE 1

The WAF build system

The WAF build system

Sebastian Jeltsch

Electronic Vision(s) Kirchhoff Institute for Physics Ruprecht-Karls-Universität Heidelberg

  • 31. August 2010

Sebastian Jeltsch The WAF build system

  • 31. August 2010

1 / 19

slide-2
SLIDE 2

The WAF build system Introduction

WorkBuildflow

Sebastian Jeltsch The WAF build system

  • 31. August 2010

2 / 19

slide-3
SLIDE 3

The WAF build system Introduction

WorkBuildflow

For us: low-level code many many layers

Sebastian Jeltsch The WAF build system

  • 31. August 2010

3 / 19

slide-4
SLIDE 4

The WAF build system Introduction

WorkBuildflow

For us: low-level code many many layers

make = major pain

Sebastian Jeltsch The WAF build system

  • 31. August 2010

3 / 19

slide-5
SLIDE 5

The WAF build system Introduction

WorkBuildflow

For us: low-level code many many layers

make = major pain

What we expect from our build system: flexibility

integration of existing workflows access to well established libraries extensibility

power usability

Sebastian Jeltsch The WAF build system

  • 31. August 2010

3 / 19

slide-6
SLIDE 6

The WAF build system Introduction Autotools (GNU Build System)

GNU Build System

+ few dependencies on user side (shell scripts) + generates standard make files + widely used – platform dependent (bash scripts) – autoconf-configure is slow Often: tconfigure >> tmake. – another scripting language

developer user autoscan configure.ac autoconf aclocal autoheader configure aclocal.m4 config.h.in Makefile.am automake Makefile.in ed Makefile make

Sebastian Jeltsch The WAF build system

  • 31. August 2010

4 / 19

slide-7
SLIDE 7

The WAF build system Introduction CMake

CMake

+ generates standard make files + platform independent + cross compilation + parallel build – CMake scripting language – file content change detection via fs time stamp Projects using CMake: Boost, Blender, LLVM, KDE, MySQL, . . .

Sebastian Jeltsch The WAF build system

  • 31. August 2010

5 / 19

slide-8
SLIDE 8

The WAF build system WAF

WAF

Sebastian Jeltsch The WAF build system

  • 31. August 2010

6 / 19

slide-9
SLIDE 9

The WAF build system WAF why WAF?

Why WAF?

project configuration, building, installation, uninstallation

Sebastian Jeltsch The WAF build system

  • 31. August 2010

7 / 19

slide-10
SLIDE 10

The WAF build system WAF why WAF?

Why WAF?

project configuration, building, installation, uninstallation packaging & package checks for redistribution

Sebastian Jeltsch The WAF build system

  • 31. August 2010

7 / 19

slide-11
SLIDE 11

The WAF build system WAF why WAF?

Why WAF?

project configuration, building, installation, uninstallation packaging & package checks for redistribution ease of python (WAF comes with batteries) - no need for another language

Sebastian Jeltsch The WAF build system

  • 31. August 2010

7 / 19

slide-12
SLIDE 12

The WAF build system WAF why WAF?

Why WAF?

project configuration, building, installation, uninstallation packaging & package checks for redistribution ease of python (WAF comes with batteries) - no need for another language Waf is a 90kb script to execute (no installation required)

Sebastian Jeltsch The WAF build system

  • 31. August 2010

7 / 19

slide-13
SLIDE 13

The WAF build system WAF why WAF?

Why WAF?

project configuration, building, installation, uninstallation packaging & package checks for redistribution ease of python (WAF comes with batteries) - no need for another language Waf is a 90kb script to execute (no installation required) integrates unit testing into the build flow

Sebastian Jeltsch The WAF build system

  • 31. August 2010

7 / 19

slide-14
SLIDE 14

The WAF build system WAF why WAF?

Why WAF?

project configuration, building, installation, uninstallation packaging & package checks for redistribution ease of python (WAF comes with batteries) - no need for another language Waf is a 90kb script to execute (no installation required) integrates unit testing into the build flow supports build variants

Sebastian Jeltsch The WAF build system

  • 31. August 2010

7 / 19

slide-15
SLIDE 15

The WAF build system WAF why WAF?

Why WAF?

project configuration, building, installation, uninstallation packaging & package checks for redistribution ease of python (WAF comes with batteries) - no need for another language Waf is a 90kb script to execute (no installation required) integrates unit testing into the build flow supports build variants Good documentation & active development

Sebastian Jeltsch The WAF build system

  • 31. August 2010

7 / 19

slide-16
SLIDE 16

The WAF build system WAF why WAF?

Why WAF?

project configuration, building, installation, uninstallation packaging & package checks for redistribution ease of python (WAF comes with batteries) - no need for another language Waf is a 90kb script to execute (no installation required) integrates unit testing into the build flow supports build variants Good documentation & active development Fast and small memory footprint

as fast as make and 15x faster than SCons 10x less function calls than SCons

Sebastian Jeltsch The WAF build system

  • 31. August 2010

7 / 19

slide-17
SLIDE 17

The WAF build system WAF why WAF?

Samba 4

Build time 5min ⇒ 35s

Sebastian Jeltsch The WAF build system

  • 31. August 2010

8 / 19

slide-18
SLIDE 18

The WAF build system WAF why WAF?

Samba 4

Build time 5min ⇒ 35s Build size reduction

check object file duplication extensive shared-object and rpath use

Sebastian Jeltsch The WAF build system

  • 31. August 2010

8 / 19

slide-19
SLIDE 19

The WAF build system WAF why WAF?

Samba 4

Build time 5min ⇒ 35s Build size reduction

check object file duplication extensive shared-object and rpath use

full dependency checks

Sebastian Jeltsch The WAF build system

  • 31. August 2010

8 / 19

slide-20
SLIDE 20

The WAF build system WAF why WAF?

Samba 4

Build time 5min ⇒ 35s Build size reduction

check object file duplication extensive shared-object and rpath use

full dependency checks cleaner build rules

Sebastian Jeltsch The WAF build system

  • 31. August 2010

8 / 19

slide-21
SLIDE 21

The WAF build system WAF wscript for this presentation

wscript for this presentation

#!/usr/bin/env python # encoding: utf -8 APPNAME=" CodeJam4_WAF_pres " top=’.’ def configure(context ): context.check_tool("tex") def build(context ):

  • context. new_task_gen (

features = "tex", source = "main.tex", )

Sebastian Jeltsch The WAF build system

  • 31. August 2010

9 / 19

slide-22
SLIDE 22

The WAF build system WAF basic structure

basic structure

#!/usr/bin/env python APPNAME=’basic_structure ’ VERSION=’0.1’ top=’.’ def configure(context ): pass def build(context ): pass

Sebastian Jeltsch The WAF build system

  • 31. August 2010

10 / 19

slide-23
SLIDE 23

The WAF build system WAF Installing WAF

Installation

no installation needed Interpreter: installed version will not run on Python 3 yet OS: platform independence Admin: installation is cumbersome, and requires admin privileges Versions: avoid version conflicts (too old, too new, bugs) Size: the WAF file is small enough to be redistributed (about 90kB)

Sebastian Jeltsch The WAF build system

  • 31. August 2010

11 / 19

slide-24
SLIDE 24

The WAF build system WAF Configuration Phase

Configuration Phase (example1)

def configure(context ): from Configure import ConfigurationError try:

  • context. find_program ([’touch ’, ’ls’], \

mandatory=True)

  • context. find_program (’echo ’, var=’ECHO ’, \

mandatory=True) except ConfigurationError :

  • context. check_message_2 ("programs

not found") print context.env[’ECHO ’] # execute custom tool context.check_tool(’my_tool ’, tooldir=’.’)

Sebastian Jeltsch The WAF build system

  • 31. August 2010

12 / 19

slide-25
SLIDE 25

The WAF build system WAF Configuration Options

Option Parser

def set_options(context ): context.add_option(’--foo’, action=’store ’, \ default=False , help=’Silly test ’) # c++ compiler path

  • pt.tool_options(’compiler_cxx ’)

# python interpreter path

  • pt.tool_options(’python ’)

def configure(context ): import Options print(’the value of foo is %r’ % Options.options.foo)

easy to add options values are stored in the context variable

Sebastian Jeltsch The WAF build system

  • 31. August 2010

13 / 19

slide-26
SLIDE 26

The WAF build system WAF Build Phase

Task System

def build(context ):

commands: build, clean, install and uninstall call build() ⇒ isolate targets from actual code Execution control: targets are evaluated lazily Parallel: task scheduling FS abstraction: e.g. distributed build Language abstraction: flexibility and extensibility Shell abstraction: platform independence

Sebastian Jeltsch The WAF build system

  • 31. August 2010

14 / 19

slide-27
SLIDE 27

The WAF build system WAF Build Phase

Task Abstraction Layer

abstraction layer between code execution (task) and declaration (task generators): Task:

abstract transformation unit sequential constraints require scheduler for parallel execution

Task generator:

factory tasks creation Handle global constraints (across tasks)

configuration set access data sharing OS abstraction

Sebastian Jeltsch The WAF build system

  • 31. August 2010

15 / 19

slide-28
SLIDE 28

The WAF build system WAF Build Phase

#!/usr/bin/env python APPNAME=’example2a ’ # Task Generator VERSION=’0.1337 ’ build_rule=’gcc ${SRC} -o ${TGT}’ import TaskGen

  • TaskGen. declare_chain (

rule = build_rule , ext_in = ’.c’, ext_out = ’’, reentrant = False) def configure(context ): pass def build(context ): context(source=’t0.c’, target=’t0’, rule=build_rule)

  • context. new_task_gen (source=’t1.c’,

target=’t1’,rule=build_rule) context(source=’t2.c’)

Sebastian Jeltsch The WAF build system

  • 31. August 2010

16 / 19

slide-29
SLIDE 29

The WAF build system WAF Build Phase

c/c++ support routines

#!/usr/bin/env python APPNAME=’example2b ’ # Task Generator VERSION=’0.1337 ’ def set_options(context ):

  • context. tool_options (’compiler_cc ’)

def configure(context ): context.check_tool(’compiler_cc ’) def build(context ): context(target=’t’, source=’t.c’, features=’cc cprogram ’)

Sebastian Jeltsch The WAF build system

  • 31. August 2010

17 / 19

slide-30
SLIDE 30

The WAF build system WAF task translation

example4: demo

#!/usr/bin/env python APPNAME=’example4 ’ # shell usage & task translation VERSION=’0.1337 ’ def configure(context ): pass def build(bld): bld(rule=’cp ${SRC} ${TGT}’, source=’wscript ’, target=’f1.txt’, shell=False) bld(rule=’cp ${SRC} ${TGT}’, source=’wscript ’, target=’f2.txt’, shell=True) # commands containing ’>’,’<’ or ’&’ can not be executed # => FALLBACK: shell usage bld(rule=’cat ${SRC} > ${TGT}’, source=’wscript ’, target=’f3.txt’, shell=False)

Sebastian Jeltsch The WAF build system

  • 31. August 2010

18 / 19

slide-31
SLIDE 31

The WAF build system WAF interacting with the Filesystem through WAF

FS interaction

def build(context ): context.root # root (/) node context.path # current (.) node etc = context.root.find_dir(’/etc’) fstab = context.root. find_resource (’/etc/fstab ’) context.root.ant_glob(’etc /**/g*’, dir=True , src=False , bld=False)

Ant Globs (http://ant.apache.org/manual/dirtasks.html)

Sebastian Jeltsch The WAF build system

  • 31. August 2010

19 / 19