Slide: 1 GPR Project Files Vincent Celier FOSDEM 8-9 February 2009 Senior software engineer, AdaCore.

Slides:



Advertisements
Similar presentations
Automating Software Module Testing for FAA Certification Usha Santhanam The Boeing Company.
Advertisements

OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Slide: 1 Copyright © AdaCore Packages Presented by Quentin Ochem university.adacore.com.
The Web Warrior Guide to Web Design Technologies
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 3 Object Oriented Programming in Java Language Basics Classes,
A Guide to Oracle9i1 Advanced SQL And PL/SQL Topics Chapter 9.
Guide To UNIX Using Linux Third Edition
C++ for Engineers and Scientists Third Edition
Views Dwight Deugo Nesa Matic
Using Ant to build J2EE Applications Kumar
Reusable Code For Your Appx Processes Presented By: Gary Rogers.
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
Chapter 6: User-Defined Functions
Introduction to Eclipse CSC 216 Lecture 3 Ed Gehringer Using (with permission) slides developed by— Dwight Deugo Nesa Matic
Introduction to Exception Handling and Defensive Programming.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Chapter 12 Support for Object oriented Programming.
Overview Intro to functions What are functions? Why use functions? Defining functions Calling functions Documenting functions Top-down design Variable.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Topics AliasesSubprograms Generics & Configurations.
OCR GCSE Computing © Hodder Education 2013 Slide 1 OCR GCSE Computing Python programming 1: Introduction.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
1 Introduction Purpose  This course gives an overview of assembler settings of the High-performance Embedded Workshop (HEW), used for developing software.
Classes, Interfaces and Packages
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Visual Programming Borland Delphi. Developing Applications Borland Delphi is an object-oriented, visual programming environment to develop 32-bit applications.
Java IDE Dwight Deugo Nesa Matic
An Introduction to Ant. What is Ant? How do you use it? Why would you want to?
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
GPS The GNAT Programming Studio GPS The GNAT Programming Studio Presentation cover page EU Vincent Celier FOSDEM 8-9 February 2009 Senior.
Slide: 1 GNATbench, an Ada Eclipse plugin Vincent Celier FOSDEM 8-9 February 2009 Senior software engineer, AdaCore.
Linux Filesystem Management
Design issues for Object-Oriented Languages
Chapter 13: Overloading and Templates
Working in the Forms Developer Environment
APPENDIX a WRITING SUBROUTINES IN C
Object-Oriented Programming: Inheritance
Java Programming: Guided Learning with Early Objects
Introduction to Triggers
About the Presentations
JavaScript: Functions
Deploying and Configuring SSIS Packages
Programming Language Concepts (CIS 635)
Java Programming: Guided Learning with Early Objects
Chapter 12 Outline Overview of Object Database Concepts
Objectives Insert a script element Write JavaScript comments
Designing and Debugging Batch and Interactive COBOL Programs
Exception Handling Chapter 9.
Chapter 3 Introduction to Classes, Objects Methods and Strings
Topics Introduction to File Input and Output
Java Programming Language
Lecture 22 Inheritance Richard Gesick.
Andy Wang Object Oriented Programming in C++ COP 3330
Packages and Interfaces
Digital Image Processing
CPE 528: Lecture #3 Department of Electrical and Computer Engineering University of Alabama in Huntsville.
Quattor Advanced Tutorial, LAL
Object-Oriented Programming: Inheritance and Polymorphism
Chapter 11: Inheritance and Composition
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Andy Wang Object Oriented Programming in C++ COP 3330
Final and Abstract Classes
Topics Introduction to File Input and Output
Interfaces,Packages and Threads
C++ Object Oriented 1.
SPL – PS1 Introduction to C++.
Introduction to Classes and Objects
Presentation transcript:

Slide: 1 GPR Project Files Vincent Celier FOSDEM 8-9 February 2009 Senior software engineer, AdaCore

Slide: 2 The GPR Project Facility Overview GPR Project Files Property Values Setting Project Properties External and Conditional References Importing Projects Extending (“Modifying”) Projects Source File Naming Schemes

Slide: 3 The GPR Project Facility Provides configurable properties for source files –Represented by “projects” Supports incremental, modular project definition –Projects can import other projects containing needed files –Child projects can extend parent projects, inheriting source files and optionally overriding any of them Facilitates the structuring of large development efforts into hierarchical subsystemsFacilitates the structuring of large development efforts into hierarchical subsystems –With build decisions deferred to the subsystem level

Slide: 4 Configurable Properties Source directories and specific files’ names Output directory for object modules and.ali files Target directory for executable programs Switch settings for project-enabled tools Source files for main subprogram(s) to be built Source programming languages –Ada / C / C++ / Fortran /... Source file naming conventions

Slide: 5 Sample Uses Common set of sources generating object files in different directories, via different switches –“Debug” version –“Release” version Multiple versions of the body for a package spec Note this is not a configuration management facility –“Projects” should be under CM too!

Slide: 6 GPR Project Files Text files with Ada-like syntax Integrated into command-line tools –Specified via the –Pproject-file-name switch Integrated into GPS –A fundamental part of the IDE –Automatically generated –There is even a Project Wizard

Slide: 7 Property Values Introduction Strings Lists of strings Associative arrays –Like functions that map an input string to either a single string or a list of strings for Switches (“Ada”) use (“-v”, “-gnatv”); ("-v", "-gnatv")‏

Slide: 8 Common Files with Different Switches Example Directories Example usage for debug case –gnatmake –P/common/debug.gpr /common/main.adb /common /common/debug/common/release pack.ads debug.gpr pack.adb release.gpr main.adb pack.o main.o pack.o main.o

Slide: 9 Common Files with Different Switches Projects project Debug is for Object_Dir use "debug"; package Builder is for Default_Switches ("Ada") use ("-g"); end Builder; package Compiler is for Default_Switches ("Ada") use ("-fstack-check", "-gnata", "-gnato"); end Compiler; end Debug; project Release is for Object_Dir use "release"; package Compiler is for Default_Switches ("Ada") use ("-O2"); end Compiler; end Release;

Slide: 10 Conventions for Naming GPR Project Files File name should match project name –Not case sensitive Extension should be “.gpr” Warnings issued if not followed

Slide: 11 Setting Project Properties Packages Variables Types Switches Source Directories Source Files Object Directory Executable Directory

Slide: 12 Packages In GPR Project Files Package names correspond to tools –Builder –Compiler –Linker –Binder –etc. Allowable names and content defined by facility –Not by users

Slide: 13 Typed Versus Untyped Variables Typed variables have only listed values possible –Case sensitive, unlike Ada Typed variables are declared once per scope –Once at project level –Once within any package –Essentially read-only constants –Especially nice for external inputs Untyped variables may be “declared” many times –No previous declaration required

Slide: 14 Switches In GPR Project Files May be specified to apply by default May be specified on a per-unit basis –Associative array “Switches” indexed by unit name package Compiler is for Default_Switches ("Ada") use ("-gnaty", "-v"); end Compiler; package Builder is for Switches ("main1.adb") use ("-O2"); for Switches ("main2.adb") use ("-g"); end Builder;

Slide: 15 Source Directories In GPR Project Files One or more in any project file Default is same directory as project file Can specify additional individual directories Can specify additional directory trees Can specify that none are present for Source_Dirs use ("foo/**", "./**"); for Source_Dirs use ("mains", "drivers"); for Source_Dirs use ();

Slide: 16 Source Files In GPR Project Files Must contain at least one “immediate” source file –In one of the source directories of the project file –Unless explicitly specifies none present Can specify source files by name Can specify an external file containing source names for Source_Files use ("main.adb","pack1.ads","pack2.adb"); for Source_Files use (); for Source_List_File use “files.list”;

Slide: 17 Object Directory In GPR Project Files Specifies the location for compiler's output –Such as “ali” files and object files –For the project's immediate sources Only one per project –When extending a parent project the child’s object directory is used for any inherited sources not already compiled in the parent project Release is for Object_Dir use "release";... end Release;

Slide: 18 Executable Directory In GPR Project Files Specifies the location for executable image Default is same directory as object files Only one per project project Release is for Exec_Dir use “executables";... end Release;

Slide: 19 External and Conditional References Allow project file content to depend on value of environment variables & command-line arguments Reference to external values is by function –external( name [, default] ) returns value of name as supplied on the command line or as environment variable –If name is undefined, return default (if supplied) or “” Set via command line switch (for example) ‏ –gnatmake –P… -Xname=value … gnatmake –P/common/build.gpr -Xtarget=test /common/main.adb

Slide: 20 project Build is type Targets is ("release", "test"); Target : Targets := external("target", "test"); case Target is -- project attributes when "release" => for Object_Dir use "release"; for Exec_Dir use "."; when "test" => for Object_Dir use "debug"; end case; package Compiler is case Target is when "release" => for Default_Switches ("Ada") use ("-O2"); when "test" => for Default_Switches ("Ada") use ("-g", "-s", "-gnata", "-gnato", "-gnatE"); end case; end Compiler; end Build; External/Conditional Reference Example

Slide: 21 Importing Projects Compilation units in source files of one project may depend on compilation units in source files of others –“Depend” in the Ada sense (contains with-clauses) ‏ We want to localize properties of other projects –Switches etc. –Defined in one place and not repeated elsewhere Thus dependent projects “import” other projects to place other projects’ source files on search path

Slide: 22 Project Import Notation Similar to Ada’s “with” clauses –But uses strings String literals are path names of project files –Relative –Absolute with literal_string {, literal_string } ;

Slide: 23 Importing Projects Example with GUI, Math; package body Pack is... with “/gui/gui.gpr", “/math/math"; project MyApp is... end MyApp; /myapp myapp.gpr pack.ads pack.adb main.adb myapp.gpr pack.ads pack.adb main.adb /gui gui.gpr gui.ads gui.adb … gui.gpr gui.ads gui.adb … /math math.gpr math.ads math.adb … math.gpr math.ads math.adb …

Slide: 24 Project Path Locates GPR project files referenced by other projects Combined content of: – Directory containing GPR project file – GPR _PROJECT_PATH environment variable (if defined) ‏ Note “with” clauses are transitive –Indirectly imported projects are automatically included –Unlike Ada “with” clauses –A project is responsible for making its own imports work regardless of whether or not it is imported elsewhere

Slide: 25 Project Path Examples If /gui,/math are on GPR _PROJECT_PATH If /gui,/math are not on GPR _PROJECT_PATH with "gui.gpr", "math"; project MyApp is... with "gui.gpr", "math"; project MyApp is... with "/gui/gui.gpr", "/math/math"; project MyApp is... with "/gui/gui.gpr", "/math/math"; project MyApp is...

Slide: 26 Extending (“Modifying”) Projects Allows using modified versions of source files without changing the original sources Based on “inheritance” of parent project’s properties –Source files –Switch settings Supports localized build decisions and properties –Inherited properties may be overridden with new versions Hierarchies permitted

Slide: 27 Multiple Versions of Unit Bodies Example Assume this directory structure & files Usage (assume baseline is current directory) ‏ gnatmake –Pthreaded/threaded.gpr main …\baseline threaded p.ads base.gpr p.adb p.ads base.gpr p.adb p.adb threaded.gpr main.adb p.adb threaded.gpr main.adb Different versions of package body

Slide: 28 Multiple Versions of Unit Bodies File project Baseline is end Baseline; project Baseline is end Baseline; project Threaded extends "/source/ada/dev/baseline" is end Threaded; project Threaded extends "/source/ada/dev/baseline" is end Threaded;

Slide: 29 Source File Naming Schemes Allow arbitrary naming conventions –Other than default convention May be applied to all source files in a project –Specified in a package named “Naming” May be applied to specific files in a project –Individual attribute specifications

Slide: 30 Foreign Default File Naming Example project APEX is for Source_Files use (); package Naming is for Casing use "lowercase"; for Dot_Replacement use "."; for Specification_Suffix ("Ada") use ".1.ada"; for Implementation_Suffix ("Ada") use ".2.ada"; end Naming; end APEX;

Slide: 31 GNAT Default File Naming Example project GNAT is for Source_Files use (); package Naming is for Casing use "lowercase"; for Dot_Replacement use "-"; for Specification_Suffix ("Ada") use ".ads"; for Implementation_Suffix ("Ada") use ".adb"; end Naming; end GNAT;

Slide: 32 Individual (Arbitrary) File Naming Uses associative arrays to specify file names –Index is a string containing the unit name –Value is a string –Case sensitivity depends on host file system Has distinct attributes for specifications and bodies for Specification ("MyPack.MyChild") use "mypack.mychild.spec"; for Implementation ("MyPack.MyChild") use "mypack.mychild.body";

Slide: 33 GPS Directly Supports Projects The fundamental conceptual basis for GPS Graphically displays a project hierarchy Provides a wizard to help you create projects Displays and navigates project sources Compiles sources defined by a project Creates executables for project main programs Debugs a project’s executables et cetera

Slide: 34 GPR Project Manager Summary Supports hierarchical, localized build decisions Supports arbitrary file naming conventions GPS provides direct support See the GNAT User’s Guide for further details!