SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr 2007 - 1 Ralf Palsa CVS, GNU Build Tools & Coding Standards.

Slides:



Advertisements
Similar presentations
DFS/SDD C. Izzo VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Carlo Izzo Using External Libraries.
Advertisements

1. What is Subversion? Why do we need CM? Basic concepts Repositories Options Setup Clients Options Setup Operation Troubleshooting Slide 2.
Coding Standard: General Rules 1.Always be consistent with existing code. 2.Adopt naming conventions consistent with selected framework. 3.Use the same.
Introduction to C Programming
Documentation 1 Comprehending the present – Investing in the future.
2/6/2008Prof. Hilfinger CS164 Lecture 71 Version Control Lecture 7.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Chapter 6. 2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single Value Pass by Reference Variable Scope.
Low level CASE: Source Code Management. Source Code Management  Also known as Configuration Management  Source Code Managers are tools that: –Archive.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction 13.2The #include Preprocessor Directive 13.3The.
Introduction to C Programming
SubVersioN – the new Central Service at DESY by Marian Gawron.
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.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 19 - The Preprocessor Outline 19.1 Introduction 19.2 The #include Preprocessor Directive 19.3.
Version Control with Subversion. What is Version Control Good For? Maintaining project/file history - so you don’t have to worry about it Managing collaboration.
Windows Programming Lecture 05. Preprocessor Preprocessor Directives Preprocessor directives are instructions for compiler.
Chapter 3 Getting Started with C++
CCA Port, Component & Application Build Skeleton Templates “A new script toolkit for generating CCA build skeletons” Torsten Wilde and James Kohl Oak Ridge.
A First Book of C++: From Here To There, Third Edition2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single.
JavaDoc1 JavaDoc DEPARTMENT OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING CONCORDIA UNIVERSITY July 24, 2006 by Emil Vassev & Joey Paquet revision 1.2 –
The Structure of a C++ Program. Outline 1. Separate Compilation 2. The # Preprocessor 3. Declarations and Definitions 4. Organizing Decls & Defs into.
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Introduction to C Programming CE Lecture 7 Compiler options and makefiles.
Progress with migration to SVN Part3: How to work with g4svn and geant4tags tools. Geant4.
Sharda University P. K. Mishra (Asst.Prof) Department of Computer Science & Technology Subject Name: Programming Using C Sub Code: CSE-106 Programming.
CSE 219 Computer Science III CVS
SDD/DFS Y. Jung VLT 2 nd Generation Instrumentation Pipelines, 19 Apr General Introduction Yves Jung.
M4 Macro-processing Language Geoffrey Sewell. What will be shown? What’s a macro processor? History of M4 Uses Autotools Syntax Hopefully, you all learn.
Fundamentals of C and C++ Programming. EEL 3801 – Lotzi Bölöni Sub-Topics  Basic Program Structure  Variables - Types and Declarations  Basic Program.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Engineering Computing I Chapter 4 Functions and Program Structure.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessing Lecture 12 April 7, 2005.
National Center for Supercomputing ApplicationsNational Computational Science Grid Packaging Technology Technical Talk University of Wisconsin Condor/GPT.
Makefiles. Multiple Source Files (1) u Obviously, large programs are not going to be contained within single files. u C provides several techniques to.
SDD/DFS A. Modigliani VLT 2 nd Generation Instrumentation Pipelines, 19 Apr ACCEPTANCE TESTS Andrea Modigliani.
C Programming Day 3. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Storage Class Specifiers Every variable in a C.
Coding Conventions  Coding conventions are a set of guidelines for a specific software project that recommend programming style, practices and methods.
A FIRST BOOK OF C++ CHAPTER 6 MODULARITY USING FUNCTIONS.
Modular Programming. Introduction As programs grow larger and larger, it is more desirable to split them into sections or modules. C allows programs to.
Milan, 15 June 2001WP1 Meeting - F. Donno1 GRID Packaging and Code Management for WP1 F. Donno INFN - Pisa.
THE PREPROCESSOR
The Preprocessor Directives Introduction Preprocessing – Occurs before program compiled Inclusion of external files Definition of symbolic constants.
INTRODUCTION TO AUTOCONF AND AUTOMAKE. GNU BUILD SYSTEM 1)GNU AUTOCONF 2)GNU AUTOMAKE 3)GNU LIBTOOL 4)GNU GETTEXT.
WinCVS Training è Basic Concepts è Download & Setup è Importing a new module into CVS Repository è Getting new module from CVS è Getting Latest version.
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:
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
2. C FUNDAMENTALS. Example: Printing a Message /* Illustrates comments, strings, and the printf function */ #include int main(void) { printf("To C, or.
Wed Mar Michael Imamura / The GNU Autotools Your very own./configure.
CLHEP Infrastructure Improvements CHEP 2004 Lynn Garren, FNAL and Andreas Pfeiffer, CERN.
Fixing autotools-related build issues
Developing Portable Applications ● Introduction GNU autotools – GNU toolchain ● Goals - cross-platform ● Supported platforms (POSIX compliant) ● GNU autotools.
Autoconf, Automake, and Libtool Tom Tromey. Copyright ● Copyright 2006 Tom Tromey ● Parts Copyright 2006 Alexandre Duret-Lutz ●
Advanced Programing practices
Software Package development and management
SVN intro (review).
Upgrade SFX V3 to V4 Lieve Rottiers.
Chapter 13 - The Preprocessor
Introduction to C Programming Language
Variables in C Topics Naming Variables Declaring Variables
Introduction to Classes and Objects
Variables in C Topics Naming Variables Declaring Variables
Compiler vs linker The compiler translates one .c file into a .o file
Variables in C Topics Naming Variables Declaring Variables
Variables in C Topics Naming Variables Declaring Variables
SPL – PS1 Introduction to C++.
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Ralf Palsa CVS, GNU Build Tools & Coding Standards

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr CVS – Keep Track of your Work Each Instrument Pipeline has/gets a CVS repository on the ESO server (after FDR at the latest): This allows you and us to keep track of the project. The code is checked every night with our in house verification tools Problems can be caught early and we can advise you properly. If needed we can assist in the repository administration.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr CVS – Keep Track of your Work CVS best practices: Run cvs commands on individual files only. Write useful log messages (don't leave them empty). It should contain the function or variable which is affected and what has changed: my_function(): variable 'a' replaced by 'A' function_a(), function_b(): argument 'setup' added All changes committed to the repository must (at least) compile. Commit often. Use tags when preparing a release ( cvs tag iiinstrument-1_3 )

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr CVS – Keep Track of your Work CVS best practices (cont): Tag your project frequently (before major changes, iiinstrument ). Don't prepare releases from your working copy, make use of cvs export. Consider branches to separate patch releases from the main development line.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools The tools: autoconf (2.59, 2.60) automake (automake 1.9.6) libtool (1.5.22) Installation: Use the same installation prefix ( configure –prefix option) for all 3 tools. The tools must be installed in the order autoconf, automake and libtool. Adjust the PATH after the installation of autoconf.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools What is needed to start: A source tree (with standard layout as in iiinstrumentp ). configure.ac: The template of the configure script. Makefile.am: The Makefile template (per directory). (acinclude.m4): Local m4 macro definitions used by configure.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools How does it work: Checkout of the project from CVS. To create the configure script and the input Makefiles ( Makefile.in ) run aclocal, autoheader, libtoolize, automake and autoconf in the right order. ➜ bootstrap and/or autogen.sh (or autoreconf ) Run configure with the appropriate options. ► In particular use --enable-maintainer-mode to allow an automatic update of the build system

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools How does it work (cont): Run make targets as needed: ► make ► make install/uninstall ► make clean ► make dist ► make maintainer-clean ► make html/clean-html To compile an individual file, hello.c (using libtool) use: ► make hello.lo To build a single recipe/library (using libtool): ► make hello.la

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools What needs to be maintained: configure.ac: ► Package and library version ► Additional feature tests ► Adding or removing files/directories to configure (cf. Carlo's talk) Makefile.am: ► Adding/removing source files to/from libraries, programs ► Adding/removing subdirectories (cf. Carlo's talk) ► Adapting compiler/linker flags and options (acinclude.m4)

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools configure.ac: AC_INIT([IIINSTRUMENT Instrument Pipeline], [0.0.1], [iiinstrument]) AC_PREREQ([2.59])... # Immediately before every release do: # # if (the interface is totally unchanged from previous release) # REVISION++; # else { # /* interfaces have been added, removed or changed */ # REVISION = 0; # CURRENT++; # if (any interfaces have been _added_ since last release) # AGE++; # if (any interfaces have been _removed_ or incompatibly changed) # AGE = 0; # } # Order of arguments: VERSION, CURRENT, REVISION, AGE IIINSTRUMENT_SET_VERSION_INFO([$VERSION], [0], [0], [0])

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools Makefile.am: Adding/Removing sources: lib_LTLIBRARIES = libiiinstrument.la pkginclude_HEADERS = file1.h file2.h libiiiinstrument_la_SOURCES = file1.c file2.c Adding a plugin library (recipe): plugin_LTLIBRARIES = recipe1.la recipe1_la_SOURCES = recipe1.c recipe1_la_LIBADD = $(LIBIIINSTRUMENT) recipe1_la_LDFLAGS = -module -avoid-version recipe1_la_DEPENDENCIES = $(LIBIIINSTRUMENT) recipe2_la_SOURCES = recipe2.c recipe2_la_LIBADD = $(LIBIIINSTRUMENT) recipe2_la_LDFLAGS = -module -avoid-version recipe2_la_DEPENDENCIES = $(LIBIIINSTRUMENT) file3.c recipe2.la file3.h

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools Makefile.am (cont): Use AM_CFLAGS instead of CFLAGS in the Makefile.am : ► CFLAGS is a user variable, intended to override flags set in the Makefile ► Compiler calls are constructed so that overriding the Makefile is possible, don't ignore that.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards The Coding Standard for instrument pipelines is the one adopted for CPL. It is based on “Recommended C Style and Coding Standards”, L.W. Cannon, et al., 15 th March 2000, (modified version of the Indian Hill C Style and Coding Standards).

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards Readability: Maximum characters per line is 78. No tabulators may be used for indentation. The indentation width is 4 spaces. Only one statement per line. Use blanks around all binary operators, except “ -> ” and “. ”. Use a blank after comma, colon, semicolon, control flow keywords. Don't use blanks between an identifier and “ ( “, “ ) ”, “ [ “ and “ ] ” or before a semicolon.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards Naming Conventions: General: ► Function and variable names shall be all lower case letters, with words separated by an underscore. ► Use clear and informative names for functions and variables. Functions: ► Function names must be prefixed with the instrument acronym followed by an underscore. ► Function names must identify the action performed, or the information provided. Variables: ► Variable names should be short, but meaningful. ► Variables should be named with their content.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards Naming Conventions (cont): File Names: ► Header file names have the extension.h ► Source file names have the extension.c ► Header and source file names are prefixed with the instrument acronym followed by an underscore. Other Names: ► Preprocessor symbols and enumeration constants should be all upper case letters, with words separated by “ _ ”.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards Types, Variables, Operators and Expressions: Use the same name for the structure tag and the typedef name, i.e.: typedef struct my_type my_type; Avoid global variables. Variables should be declared in the smallest possible scope. All variables have to be initialized when they are defined (as far as possible). Don't write code that depends on the byte order, or word alignment boundaries of an architecture.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards Types, Variables, Operators and Expressions (cont): Avoid using macros. Whenever possible use enumeration constants rather than preprocessor symbols. Avoid writing code that requires excessive stack sizes: function(int n) { double a[n];...

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards Functions: ANSI C function prototypes must be used. The function return type should appear on a separate line All functions should return an error code (as far as possible). If no return value is required, a function has to be declared void. The return statement is still required. Statements and Control Flow: Always provide a default case for switch statements and break each case of the switch statement. Always use braces to delimit blocks of if, for, while and do... while statements (even if it is just one line). Don't use goto unless absolutely necessary (i.e. never).

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards Code Comments: All files, in particular source and header files must begin with the standard header (cf. GPL). Public functions, data type, enumeration constants, modules must be commented so that a reference manual can be build using doxygen. Block comments should be preceded by 2 and followed by 1 empty line, have the same indentation as the code it describes and look like: /* *... */ Do not break in-line comments into multiple lines. /* */

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards Header files: Header files should be used as interface specification for a software module. Use code guards to prevent multiple inclusion. It should be possible to use the header files with a C++ compiler.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards Header files (cont): #ifndef MY_HEADER_H #define MY_HEADER_H #ifdef _cplusplus extern “C” { #endif... #ifdef _cplusplus } #endif #endif /* MY_HEADER_H */

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr Coding Standards Source Files: All comments in source files must be up to date at any time. Code comments must be in English. Comments should give a synopsis of a section of code, outline the steps of an algorithm, or clarify a piece of code when it is not immediately obvious what or why something was done. Don't comment what is already clearly expressed by the code itself, for example: /* return from the function */ return 0;

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr El Fin

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr CVS – The Basics CVS working cycle: Initial checkout or working copy update: $ cvs -d co -P or $ cvs update -dP Modify, add and remove files: $ cvs add [-kb] $ cvs rm [-f]

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr CVS – The Basics CVS working cycle (cont): Checking file status, reading log messages, comparing file versions: $ cvs status [-v] $ cvs log $ cvs diff -r Committing changes: $ cvs ci -m “log message”

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools The Concept: Reduce Makefile maintenance to the minimum. Offer the possibility of adapting a source package to a variety of POSIX like systems. Release packages are independent of the build tools.

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools Basics The Automake Naming Scheme: Prefix Primary = libiiinstrument.laLTLIBRARIESlib_ PROGRAMS LIBRARIES LTLIBRARIES HEADERS SCRIPTS DATA... bin_ lib_ include_ data_... bindir libdir... dist_ nodist_ noinst_ check_

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tools Basics Typical Cases: Adding a new library (using libtool): INCLUDES = $(CPLCORE_INCLUDES) lib_LTLIBRARIES = libmylib.la include_HEADERS = mylib.h noinst_HEADERS = file2.h file3.h libmylib_la_SOURCES = file1.c file2.c file3.c libmylib_la_LDFLAGS = $(CPL_LDFLAGS) libmylib_la_LIBADD = $(LIBCPLCORE) Adding a program: bin_PROGRAMS = hello hello_SOURCES = hello.c

SDD/DFS R. Palsa VLT 2 nd Generation Instrumentation Pipelines, 19 Apr GNU Build Tool Basics Typical Cases (cont): Adding a subdirectory extra : ► Create the directory. ► Put the Makefile.am into extra. ► Update configure.ac: AC_CONFIG_FILES(Makefile doxygen/Doxyfile iiinstrument/Makefile recipes/Makefile extra/Makefile tests/Makefile) ► Update the Makefile.am in the top level directory: SUBDIRS = iiinstrument extra recipes ► Re-run bootstrap, configure and make iiinstrument admin doxygen iiinstrument m4macros recipes tests extra