CSnake C++ build automation based on CMake and Python Maarten Nieber, 2009.

Slides:



Advertisements
Similar presentations
Configuration management
Advertisements

Introduction to Maven 2.0 An open source build tool for Enterprise Java projects Mahen Goonewardene.
Software & Services Group, Developer Products Division Copyright© 2010, Intel Corporation. All rights reserved. *Other brands and names are the property.
Lecture 3 Getting Started with ITK!. Goals for this lecture Learn how to use Cmake Build ITK Example programs that use ITK.
CPSC Compiler Tutorial 9 Review of Compiler.
NetBeans IDE Tal Maoz Na’ama Zahavi.
The Basic Tools Presented by: Robert E., & Jonathan Chase.
Slide 1 of 9 Presenting 24x7 Scheduler The art of computer automation Press PageDown key or click to advance.
NetBeans IDE Vishnuvardhan.M Dept. of Computer Science - SSBN.
Software Installation The full set of lecture notes of this Geant4 Course is available at
Building with MPC Charles Calkins Principal Software Engineer Object Computing, Inc.
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
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
Windows.Net Programming Series Preview. Course Schedule CourseDate Microsoft.Net Fundamentals 01/13/2014 Microsoft Windows/Web Fundamentals 01/20/2014.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
Input/Output Controller (IOC) Overview Andrew Johnson Computer Scientist, AES Controls Group.
The NetBeans IDE CSIS 3701: Advanced Object Oriented Programming.
Computing IV Visual C Introduction with OpenCV Example Xinwen Fu.
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.
Configuration Management (CM)
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Developing C/C++ applications with the Eclipse CDT David Gallardo.
FairRoot Build and Test System
Ch 1. A Python Q&A Session Spring Why do people use Python? Software quality Developer productivity Program portability Support libraries Component.
FLUKA GUI Status FLUKA Meeting CERN, 10/7/2006.
NA-MIC National Alliance for Medical Image Computing Slicer Building and Deployment Steve Pieper, PhD.
System Programming - LAB 1 Programming Environments.
Guide to Programming with Python Chapter One Getting Started: The Game Over Program.
AliRoot Implementation of native CMake build system A. Grigoras, P. Hristov 19/11/20141Alice - CMake.
CMake refactoring P. Hristov 19/03/2014. History I  Recursive makefiles (F.Carminati):  Problems in dependencies  Slow  "Recursive Makefiles.
Developing software and hardware in parallel Vladimir Rubanov ISP RAS.
C++ and Ubuntu Linux Review and Practice CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and.
What am I?. Translators Translators – Module Knowledge Areas Types of translators and their use Lexical analysis Syntax analysis Code generation and.
Presentation Name / 1 Visual C++ Builds and External Dependencies NAME.
Test Specifications A Specification System for Multi-Platform Test Suite Configuration, Build, and Execution Greg Cooksey.
Programming for GCSE 1.0 Beginning with Python T eaching L ondon C omputing Margaret Derrington KCL Easter 2014.
CPS120: Introduction to Computer Science Compiling a C++ Program From The Command Line.
Chapter Eleven Windows XP Professional Application Support.
Open project in Microsoft Visual Studio → build program in “Release” mode.
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
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:
Institute for the Protection and Security of the Citizen HAZAS – Hazard Assessment ECCAIRS Technical Course Provided by the Joint Research Centre - Ispra.
ICS312 Introduction to Compilers Set 23. What is a Compiler? A compiler is software (a program) that translates a high-level programming language to machine.
Ganga/Dirac Data Management meeting October 2003 Gennady Kuznetsov Production Manager Tools and Ganga (New Architecture)
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Sung-Dong Kim Dept. of Computer Engineering, Hansung University Chapter 3 Programming Tools.
Visual Linker ADD presentation. slide 2  Project Overview And Vision  Project System View  The System Life Cycle  Data Model and.
C Copyright © 2009, Oracle. All rights reserved. Using SQL Developer.
Software development tools
CMake - Cross-Platform Make R. Douglas Barbieri Made to Order Software Corporation.
Introduction to CMake, v. 2
SQL Database Management
Makefiles CSSE 332 Operating Systems
Basic 1960s It was designed to emphasize ease of use. Became widespread on microcomputers It is relatively simple. Will make it easier for people with.
Pipeline Execution Environment
Microprocessor and Assembly Language
AVR-GCC Programming Using C Development Tools to program your Arduino Microcontrollers. Presented by: Charles Norona November 17th, 2011 C. Norona,
Introduction to .NET Framework Ch2 – Deitel’s Book
A451 Theory – 7 Programming 7A, B - Algorithms.
Deploying and Configuring SSIS Packages
Quick Start Guide for Visual Studio 2010
TRANSLATORS AND IDEs Key Revision Points.
Using Visual Studio and VS Code for Embedded C/C++ Development
Software Installation
Download and Installation of code::blocks
SSDT and Database Project Basics
Software Installation, release 4.0
Presentation transcript:

CSnake C++ build automation based on CMake and Python Maarten Nieber, 2009

A preliminary remark CSnake was developed at the Universitat Pompeu Fabra. It is not yet publicly available, and not yet open source

Outline  C++ build automation using CMake  Goals of CSnake  CSnake architecture  CSnake features  Future work

What is build automation? (Adapted from Wikipedia) Build automation is the act of scripting or automating the task of compiling computer source code into binary code

What is C++ build automation? C++ files: hola.cpp, hi.cpp Binary code: hello (library)‏ Compiler: gcc Linker: ld Writing a Makefile for building 'hello' is an example of build automation

C++ build automation using CMake Instead of writing a Makefile, write a platform independent CMakeLists C++ source files, CMakeLists → [CMake] → Makefile/.sln/.kdevelop → [gcc/msdev/kdevelop] → binary

Example CMake file project (HELLO)‏ add_subdirectory (Hello)‏ add_subdirectory (Demo)‏ add_library (Hello hello.cxx)‏ include_directories (${HELLO_SOURCE_DIR}/Hello)‏ link_directories (${HELLO_BINARY_DIR}/Hello)‏ add_executable (helloDemo demo.cxx demo_b.cxx)‏ target_link_libraries (helloDemo Hello)‏

Problems with CMake CMake syntax is primitive and not OO Has some convenience functions Messy code when projects get large Not very modular A CMake script may call the CMake scripts for dependency projects, but usually only the top-level script works stand-alone No debugger Overhead in creating Use-file and Config-file Link dependencies are not recursive Install step may take long

CSnake: a CMake code generator Do build automation using Python scripts while being able to integrate existing CMakeLists CSnake file → [CSnake] → CMakeLists → [CMake] → Makefile → [make] → binary

Improvements offered by CSnake Build automation scripts are written in Python Basic usage must suit non-expert programmers Scripts use OO and are modular A CSnake script creates Project objects Any Project is usable as top-level target in a configuration Handles project inter-dependencies Generates CMake Use file and Config file Build folder is usable as install folder

CSnake script import csnProject from csnExamples import * greetMe = csnProject.Executable("GreetMe")‏ greetMe.AddSources(['src/*.cpp'])‏ greetMe.AddIncludeFolders(['tests', 'src'])‏ greetMe.AddTests(['tests/*.h', 'tests/*.cpp'], cxxTest)‏ greetMe.AddProjects([hello])‏

Script versus Context A script describes a target - which source files? - which include folders? - which dependencies on other projects? The context describes which target to build and how: - which csnake script? (csnGreetMe.py)‏ - which instance? (greetMe)‏ - which compiler? (kdevelop)‏ - debug build or release build? (release)‏ - where to store build results? (~/build)‏

Smallest code to build a target context = csnContext.Load(“GreetMe.csnakecontext”)‏ csnProject.globalContext = context module = csnUtility.LoadModule(context.csnakeFile)‏ exec “module.%s.Generate()” % context.instance # module.greetMe.Generate()‏

The global context # in CSnake script file csnGreetMe.py greetMe = csnProject.CreateExecutable("GreetMe")‏ This is syntactic sugar for csnProject.globalContext.CreateProject("GreetMe", “executable”)‏ Note that instantiating the Context is de-coupled from instantiating the Project.

CSnake architecture: Project class The Project class has functions that delegate to manager objects (pseudo code)‏ class Project: self.dependenciesManager# dependency projects self.compileManager# source files, include folders,... self.installManager# files and folders to install self.testsManager# associated test projects self.pathsManager# rootFolder, buildSubfolder self.cmakeWriter# writes cmake files - each manager has a back-link to its containing Project, and can use the other managers (but usually this does not happen)‏

CSnake architecture: Project class # example of delegating work to a manager object folders = [“src”, “include”] project.AddIncludeFolders(folders, win32=True)‏ # is handled as project.compileManager.AddIncludeFolders(folders, win32=True)‏

CSnake architecture: flags Instead of using: if project.context.IsForPlatform(win32): project.AddIncludeFolders(folders)‏ I often get cleaner code writing project.AddIncludeFolders(folders, win32=True)‏ which is handled inside the Compiler manager class as follows: def AddIncludeFolders(folders, win32, notWin32): if not self.project.context.IsForPlatform(win32, notWin32): return # do work

CSnake architecture: flags An improvement would be to generalize by replacing boolean args with a Flags class def AddIncludeFolders(folders, flags): if not self.project.context.IsForPlatform(flags): That way, you could write # include from 'folders' on Windows machines when in debug mode project.AddIncludeFolders(folders, [win32, debugMode]);

Summary of main features Write configuration files in Python CSnake configuration files are very clean compared to pure CMake files Modular (any dependency project can be a target)‏ Recursive handling of dependencies OO access to all configuration information Projects can depend on pure CMake projects Applications run directly in the build folder Extra necessary files must be installed once to the build folder Generates use file and config file (but...!)‏

Other features Support for installing files (to the build folder)‏ Can schedule folders for installation Skips source control files Can automatically re-install new files Support for Visual Studio: project.SetPrecompiledHeader Defines ProjectName_EXPORT macro for you Support for KDevelop: Patches kdevelop file to show full source tree Integrates with CxxTest project.AddTests Writes project structure to an XML file

GUI Features Can import an existing source project Generates a CSnake file‏ Allows to fine-tune the selection of projects in the configuration Fine-tune which test projects to include Select which plugin-modules to build along with the target

Future work Better integration with CMake Generate standard CMake packages! Use the FIND_PACAKAGE macro for installed pure CMake projects Test replacing CSnake-generated CMakeLists with a custom one Work around CMake inheritance “feature” Make files generated by CMake depend on configuration order! Improve customization with Context classes In addition to csnKDevelop.py, csnVisualStudio2003, etc. Option to write output as Scons files Release as open source Review with a second developer

Further reading → articles