SlideShare a Scribd company logo
Multi-language Programming
with GPRbuild
Vasiliy Fofanov
October 1, 2015
What is GNAT Project technology?
(representation)
• Project definition language
– What programming languages are used by project ?
– Where are the sources ?
– How are they called ?
– How to build them ?
• Toolchain definition database
– How to find and use toolchains and runtimes ?
– User-extensible
What is GNAT Project technology?
(operational)
• Project-aware tools
– GPR* family
• gprbuild
• gprclean
• gprinstall …
– Standard GNAT Pro tools
• gnatcheck
• gnatcoverage …
– IDEs (GPS and GNATbench)
• Project handling API
– To develop user tools…
GNAT Project File
• A text file describing the various properties of a project
• Declarative language (no actions)
– Intuitive Ada-inspired syntax
– Compact description even for a complex multi-language project
• Project files can be used to describe most industrial software
projects
– Multiple build scenarios and configurations
– Complex system architectures
• Shared, standalone libraries
– Multi-language (including user-defined)
A Simple Example
with "gtkada";
project My_Project is
for Source_Dirs use ("src1", "src2");
for Object_Dir use "obj";
for Main use ("file.adb");
type Mode is ("production", "debug");
M : Mode := external ("MODE", "debug");
package Compiler is
case M is
when "production" =>
for Default_Switches ("Ada") use ("-O2");
when "debug" =>
for Default_Switches ("Ada") use ("-O0", "-g", "-gnata");
end case;
end Compiler;
end My_Project;
Used everywhere!
• Common way to describe user software project across all AdaCore
toolchains
– Edit sources
– Analyze sources
– Build / cleanup …
• Common interface
$> gps –P my_project.gpr
$> gprbuild –P my_project.gpr -Xmode=debug
$> gnatmetric –P my_project.gpr
Project Hierarchies
• Modularity of software projects can be achieved through a
hierarchy of GNAT projects
• Highly recommended for medium and big projects
• The "with" keyword identifies project dependencies
with "gtkada";
with "../core";
project Prj is
end Prj;
Multi-Language Projects
• GNAT Projects are multi-language multi-compiler aware
– Supports a number of languages by default, including C and C++
• A project file is assumed to be Ada by default, but can declare your
own set via Languages attribute
• All languages are first class citizens
• Extensible
– Define your own languages/toolchains if needed
(binding generators, scripts, resource compilers, etc…)
for Languages use ("Ada", "C"); -- My sources are Ada and C
Multi-language Project Example
with "trig";
project My_App is
for Languages use ("C");
for Main use ("my_app.c");
end My_App;
#include <stdio.h>
float my_sin (float angle);
main ()
{ printf ("%fn", my_sin (3.1415/2.0)); }
package Trig is
function My_Sin (Angle : Float)
return Float;
pragma Export (C, My_Sin, "my_sin");
end Trig;
with Ada.Numerics.Generic_Elementary_Functions;
package body Trig is
package GEF is new
Ada.Numerics.Generic_Elementary_Functions (Float);
function My_Sin (Angle : Float) return Float is
begin
return GEF.Sin (Angle);
end My_Sin;
end Trig;
library project Trig is
for Library_Dir use "lib";
for Library_Kind use "dynamic";
for Library_Interface use ("trig");
for Library_Name use "trig”;
end Trig;
for Library_Standalone use "encapsulated";
$> gprbuild my_app.gpr
...
$> ./my_app
1.000000
That’s it!
Defining Targets and Runtimes
• Non-native target and specific runtimes can be specified
– In a project:
– On a command line:
for Target use "powerpc-elf";
for Runtime("Ada") use "ravenscar-cert";
$> gprbuild –P prj.gpr –-target=powerpc-elf --RTS=ravenscar-cert
GPRbuild
• Our multi-language builder
• Understands different languages, compilers and targets
• Takes care of all building steps and complex cases
– compiling, binding, linking
– shared libraries, encapsulated libraries …
• Can be extended to understand new toolchains
• Can distribute compilation over several computers ?
Distributed builder
• Parallel builds have been supported for a long time
gcc –c …gcc –c …gcc –c …gcc –c …
gprbuild prj.gpr –j0
• …but not good enough!
– At best a dozen cores or so
– But we can drive hundreds of
build decisions at once
– Solution: distributed build farm
Distributed builder (2)
• Communication and file sync by lightweight sockets-based protocols
Master machine
Slave machines
gprslave
gprslave
gprslave
gprslave
• sources
• compile commands
• objects
• availability state
$ gprbuild prj --distributed=
file://comp1.xyz.com,
164.10.127.4, ...
Where to find it all?
• Bundled with all GNAT compiler toolchains
• Also as a separate package
– If you want to keep the current compiler and only update the builder
• Soon on GitHub (~early 2016)
Use It!
• GNAT Project Facility is a mature technology
– Good match for AdaCore product line and our vision of
development process
– Should be powerful enough to replace most if not all custom
build procedures, while remaining accessible
• Are you using it? If not, why?
• Don’t hesitate to ask us for help!
Resources
• Online GPR documentation
http://docs.adacore.com/gprbuild-docs/html/gprbuild_ug.html

More Related Content

PPTX
Tech Days 2015: SPARK 2014
ODP
2014 01-02-patching-workflow
PDF
TSC BoF: OSS Toolchain Discussion - SFO17-409
PPTX
EclipseOMRBuildingBlocks4Polyglot_TURBO18
PDF
Debugging Python with gdb
PPTX
Rancher master class globalized edge workloads with k3s
PPTX
Infrastrucutre as Code
PDF
Canary deployment with Traefik and K3S
Tech Days 2015: SPARK 2014
2014 01-02-patching-workflow
TSC BoF: OSS Toolchain Discussion - SFO17-409
EclipseOMRBuildingBlocks4Polyglot_TURBO18
Debugging Python with gdb
Rancher master class globalized edge workloads with k3s
Infrastrucutre as Code
Canary deployment with Traefik and K3S

What's hot (20)

PDF
Docker Introduction
PDF
Why Python In Entertainment Industry?
PPTX
Talk Python To Me: Stream Processing in your favourite Language with Beam on ...
PDF
NAB 2019 Latest Technical and Business Progress with AV1
PDF
GstTranscoder: A High Level API to Quickly Implement Transcoding Capabilities...
PPTX
MPL: modular pipeline library - Dynamic Talks Milwaukee 4/11/2019
PDF
gRPC with java
PDF
Swift should I switch?
PDF
How does Netflix Get Built and Triumphed?
PDF
Introduction to D programming language at Weka.IO
PPTX
A basic overview of Containers
PPTX
How to debug machine learning call stacks
PDF
Run Go applications on Pico using TinyGo
PPTX
(Very) Loose proposal to revamp MPI_INIT and MPI_FINALIZE
PDF
TDC2018FLN | Trilha Containers - Kubernetes para usuarios Docker.
PDF
Timed Text At Netflix
PPTX
DevOps from the Provider Perspective
PDF
Netflix Architecture and Open Source
PDF
IL2CPP: Debugging and Profiling
Docker Introduction
Why Python In Entertainment Industry?
Talk Python To Me: Stream Processing in your favourite Language with Beam on ...
NAB 2019 Latest Technical and Business Progress with AV1
GstTranscoder: A High Level API to Quickly Implement Transcoding Capabilities...
MPL: modular pipeline library - Dynamic Talks Milwaukee 4/11/2019
gRPC with java
Swift should I switch?
How does Netflix Get Built and Triumphed?
Introduction to D programming language at Weka.IO
A basic overview of Containers
How to debug machine learning call stacks
Run Go applications on Pico using TinyGo
(Very) Loose proposal to revamp MPI_INIT and MPI_FINALIZE
TDC2018FLN | Trilha Containers - Kubernetes para usuarios Docker.
Timed Text At Netflix
DevOps from the Provider Perspective
Netflix Architecture and Open Source
IL2CPP: Debugging and Profiling
Ad

Viewers also liked (10)

PDF
S emb t1-introduction
PDF
An3906 serial to eth freescale
PDF
Bolt mld1717 11100975
PPTX
Introduction to the new MediaTek LinkIt™ Development Platform for RTOS
PPTX
Andrew_Liu_ARDrone
PPTX
Tech Days 2015: Ada 2012 and Spark Crazyflie and Railway Demo
PDF
TDC2016SP - Trilha Linux Embarcado
PDF
S emb t13-freertos
PDF
Automatizando uma app Híbrida
PDF
How to Become a Thought Leader in Your Niche
S emb t1-introduction
An3906 serial to eth freescale
Bolt mld1717 11100975
Introduction to the new MediaTek LinkIt™ Development Platform for RTOS
Andrew_Liu_ARDrone
Tech Days 2015: Ada 2012 and Spark Crazyflie and Railway Demo
TDC2016SP - Trilha Linux Embarcado
S emb t13-freertos
Automatizando uma app Híbrida
How to Become a Thought Leader in Your Niche
Ad

Similar to Tech Days 2015: Multi-language Programming with GPRbuild (20)

PPTX
Programming a CI/CD pipeline with Go: hands-on Dagger SDK
PPTX
MozillaPH Rust Hack & Learn Session 1
PDF
DevEx | there’s no place like k3s
PDF
gtkgst video in your widgets!
PDF
Embedded Rust
PPTX
Tech Days 2015: AdaCore Roadmap
PDF
Kubernetes
PDF
Code, ci, infrastructure - the gophers way
PDF
LCU13: GPGPU on ARM Experience Report
PDF
"The Vision API Maze: Options and Trade-offs," a Presentation from the Khrono...
PDF
LAS16-108: JerryScript and other scripting languages for IoT
PPTX
Localization (l10n) - The Process
PDF
Plasmaquick Workshop - FISL 13
PDF
Build Low-Latency Applications in Rust on ScyllaDB
PDF
High-Performance Computing with C++
PDF
The Ring programming language version 1.7 book - Part 6 of 196
PDF
TRACK F: OpenCL for ALTERA FPGAs, Accelerating performance and design product...
PDF
Multimedia support in WebKitGTK and WPE, current status and plans (GStreamer ...
PPTX
Transpilers(Source-to-Source Compilers)
ODP
Some wonderful Linux softwares for daily use
Programming a CI/CD pipeline with Go: hands-on Dagger SDK
MozillaPH Rust Hack & Learn Session 1
DevEx | there’s no place like k3s
gtkgst video in your widgets!
Embedded Rust
Tech Days 2015: AdaCore Roadmap
Kubernetes
Code, ci, infrastructure - the gophers way
LCU13: GPGPU on ARM Experience Report
"The Vision API Maze: Options and Trade-offs," a Presentation from the Khrono...
LAS16-108: JerryScript and other scripting languages for IoT
Localization (l10n) - The Process
Plasmaquick Workshop - FISL 13
Build Low-Latency Applications in Rust on ScyllaDB
High-Performance Computing with C++
The Ring programming language version 1.7 book - Part 6 of 196
TRACK F: OpenCL for ALTERA FPGAs, Accelerating performance and design product...
Multimedia support in WebKitGTK and WPE, current status and plans (GStreamer ...
Transpilers(Source-to-Source Compilers)
Some wonderful Linux softwares for daily use

More from AdaCore (20)

PDF
RCA OCORA: Safe Computing Platform using open standards
PDF
Have we a Human Ecosystem?
PDF
Rust and the coming age of high integrity languages
PDF
SPARKNaCl: A verified, fast cryptographic library
PDF
Developing Future High Integrity Processing Solutions
PDF
Taming event-driven software via formal verification
PDF
Pushing the Boundary of Mostly Automatic Program Proof
PDF
RCA OCORA: Safe Computing Platform using open standards
PDF
Product Lines and Ecosystems: from customization to configuration
PDF
Securing the Future of Safety and Security of Embedded Software
PDF
Spark / Ada for Safe and Secure Firmware Development
PDF
Introducing the HICLASS Research Programme - Enabling Development of Complex ...
PDF
The Future of Aerospace – More Software Please!
PDF
Adaptive AUTOSAR - The New AUTOSAR Architecture
PDF
Using Tiers of Assurance Evidence to Reduce the Tears! Adopting the “Wheel of...
PDF
Software Engineering for Robotics - The RoboStar Technology
PDF
MISRA C in an ISO 26262 context
PPTX
Application of theorem proving for safety-critical vehicle software
PDF
The Application of Formal Methods to Railway Signalling Software
PDF
Bounded Model Checking for C Programs in an Enterprise Environment
RCA OCORA: Safe Computing Platform using open standards
Have we a Human Ecosystem?
Rust and the coming age of high integrity languages
SPARKNaCl: A verified, fast cryptographic library
Developing Future High Integrity Processing Solutions
Taming event-driven software via formal verification
Pushing the Boundary of Mostly Automatic Program Proof
RCA OCORA: Safe Computing Platform using open standards
Product Lines and Ecosystems: from customization to configuration
Securing the Future of Safety and Security of Embedded Software
Spark / Ada for Safe and Secure Firmware Development
Introducing the HICLASS Research Programme - Enabling Development of Complex ...
The Future of Aerospace – More Software Please!
Adaptive AUTOSAR - The New AUTOSAR Architecture
Using Tiers of Assurance Evidence to Reduce the Tears! Adopting the “Wheel of...
Software Engineering for Robotics - The RoboStar Technology
MISRA C in an ISO 26262 context
Application of theorem proving for safety-critical vehicle software
The Application of Formal Methods to Railway Signalling Software
Bounded Model Checking for C Programs in an Enterprise Environment

Recently uploaded (20)

PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
AI in Product Development-omnex systems
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
ai tools demonstartion for schools and inter college
PDF
Nekopoi APK 2025 free lastest update
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Essential Infomation Tech presentation.pptx
Design an Analysis of Algorithms I-SECS-1021-03
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
AI in Product Development-omnex systems
Odoo POS Development Services by CandidRoot Solutions
Wondershare Filmora 15 Crack With Activation Key [2025
2025 Textile ERP Trends: SAP, Odoo & Oracle
VVF-Customer-Presentation2025-Ver1.9.pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
ai tools demonstartion for schools and inter college
Nekopoi APK 2025 free lastest update
Odoo Companies in India – Driving Business Transformation.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
wealthsignaloriginal-com-DS-text-... (1).pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PTS Company Brochure 2025 (1).pdf.......
Essential Infomation Tech presentation.pptx

Tech Days 2015: Multi-language Programming with GPRbuild

  • 2. What is GNAT Project technology? (representation) • Project definition language – What programming languages are used by project ? – Where are the sources ? – How are they called ? – How to build them ? • Toolchain definition database – How to find and use toolchains and runtimes ? – User-extensible
  • 3. What is GNAT Project technology? (operational) • Project-aware tools – GPR* family • gprbuild • gprclean • gprinstall … – Standard GNAT Pro tools • gnatcheck • gnatcoverage … – IDEs (GPS and GNATbench) • Project handling API – To develop user tools…
  • 4. GNAT Project File • A text file describing the various properties of a project • Declarative language (no actions) – Intuitive Ada-inspired syntax – Compact description even for a complex multi-language project • Project files can be used to describe most industrial software projects – Multiple build scenarios and configurations – Complex system architectures • Shared, standalone libraries – Multi-language (including user-defined)
  • 5. A Simple Example with "gtkada"; project My_Project is for Source_Dirs use ("src1", "src2"); for Object_Dir use "obj"; for Main use ("file.adb"); type Mode is ("production", "debug"); M : Mode := external ("MODE", "debug"); package Compiler is case M is when "production" => for Default_Switches ("Ada") use ("-O2"); when "debug" => for Default_Switches ("Ada") use ("-O0", "-g", "-gnata"); end case; end Compiler; end My_Project;
  • 6. Used everywhere! • Common way to describe user software project across all AdaCore toolchains – Edit sources – Analyze sources – Build / cleanup … • Common interface $> gps –P my_project.gpr $> gprbuild –P my_project.gpr -Xmode=debug $> gnatmetric –P my_project.gpr
  • 7. Project Hierarchies • Modularity of software projects can be achieved through a hierarchy of GNAT projects • Highly recommended for medium and big projects • The "with" keyword identifies project dependencies with "gtkada"; with "../core"; project Prj is end Prj;
  • 8. Multi-Language Projects • GNAT Projects are multi-language multi-compiler aware – Supports a number of languages by default, including C and C++ • A project file is assumed to be Ada by default, but can declare your own set via Languages attribute • All languages are first class citizens • Extensible – Define your own languages/toolchains if needed (binding generators, scripts, resource compilers, etc…) for Languages use ("Ada", "C"); -- My sources are Ada and C
  • 9. Multi-language Project Example with "trig"; project My_App is for Languages use ("C"); for Main use ("my_app.c"); end My_App; #include <stdio.h> float my_sin (float angle); main () { printf ("%fn", my_sin (3.1415/2.0)); } package Trig is function My_Sin (Angle : Float) return Float; pragma Export (C, My_Sin, "my_sin"); end Trig; with Ada.Numerics.Generic_Elementary_Functions; package body Trig is package GEF is new Ada.Numerics.Generic_Elementary_Functions (Float); function My_Sin (Angle : Float) return Float is begin return GEF.Sin (Angle); end My_Sin; end Trig; library project Trig is for Library_Dir use "lib"; for Library_Kind use "dynamic"; for Library_Interface use ("trig"); for Library_Name use "trig”; end Trig; for Library_Standalone use "encapsulated"; $> gprbuild my_app.gpr ... $> ./my_app 1.000000 That’s it!
  • 10. Defining Targets and Runtimes • Non-native target and specific runtimes can be specified – In a project: – On a command line: for Target use "powerpc-elf"; for Runtime("Ada") use "ravenscar-cert"; $> gprbuild –P prj.gpr –-target=powerpc-elf --RTS=ravenscar-cert
  • 11. GPRbuild • Our multi-language builder • Understands different languages, compilers and targets • Takes care of all building steps and complex cases – compiling, binding, linking – shared libraries, encapsulated libraries … • Can be extended to understand new toolchains • Can distribute compilation over several computers ?
  • 12. Distributed builder • Parallel builds have been supported for a long time gcc –c …gcc –c …gcc –c …gcc –c … gprbuild prj.gpr –j0 • …but not good enough! – At best a dozen cores or so – But we can drive hundreds of build decisions at once – Solution: distributed build farm
  • 13. Distributed builder (2) • Communication and file sync by lightweight sockets-based protocols Master machine Slave machines gprslave gprslave gprslave gprslave • sources • compile commands • objects • availability state $ gprbuild prj --distributed= file://comp1.xyz.com, 164.10.127.4, ...
  • 14. Where to find it all? • Bundled with all GNAT compiler toolchains • Also as a separate package – If you want to keep the current compiler and only update the builder • Soon on GitHub (~early 2016)
  • 15. Use It! • GNAT Project Facility is a mature technology – Good match for AdaCore product line and our vision of development process – Should be powerful enough to replace most if not all custom build procedures, while remaining accessible • Are you using it? If not, why? • Don’t hesitate to ask us for help!
  • 16. Resources • Online GPR documentation http://docs.adacore.com/gprbuild-docs/html/gprbuild_ug.html

Editor's Notes

  • #2: This template can be used as a starter file for presenting training materials in a group setting. Sections Sections can help to organize your slides or facilitate collaboration between multiple authors. On the Home tab under Slides, click Section, and then click Add Section. Notes Use the Notes pane for delivery notes or to provide additional details for the audience. You can see these notes in Presenter View during your presentation. Keep in mind the font size (important for accessibility, visibility, videotaping, and online production) Coordinated colors Pay particular attention to the graphs, charts, and text boxes. Consider that attendees will print in black and white or grayscale. Run a test print to make sure your colors work when printed in pure black and white and grayscale. Graphics, tables, and graphs Keep it simple: If possible, use consistent, non-distracting styles and colors. Label all graphs and tables.
  • #3: Project definition language Describes where the sources of the software project are located, how are they called, how to build them Toolchain definition database Describes how to detect the presence of known toolchains and runtimes and how they should be invoked and used User-extensible Used by gprconfig tool to set up the execution environment Project-aware tools GPR* family gprbuild Gprclean gprinstall Standard GNAT Pro toolchain components AdaCore IDEs (GPS and GNATbench) Official project handling API GNATCOLL.Projects Allows developing user project-aware tools
  • #4: Project definition language Describes where the sources of the software project are located, how are they called, how to build them Toolchain definition database Describes how to detect the presence of known toolchains and runtimes and how they should be invoked and used User-extensible Used by gprconfig tool to set up the execution environment Project-aware tools GPR* family gprbuild Gprclean gprinstall Standard GNAT Pro toolchain components AdaCore IDEs (GPS and GNATbench) Official project handling API GNATCOLL.Projects Allows developing user project-aware tools
  • #17: Microsoft Confidential