Alire से Ada project शुरू करना ── project बनाना, dependencies जोड़ना, build profiles और GNATprove तक

· · Ada, Alire, GNAT, SPARK, GNATprove, Package Manager, Build

X पर पोस्ट करें
संशोधन इतिहास (केवल पहला संस्करण, 1 Nov 2026 को प्रकाशित)
पहला प्रकाशन

जब आप Ada में program लिखना शुरू करते हैं, तो अक्सर यहीं अटक जाते हैं कि GNAT compiler कहाँ से install करें और libraries कैसे लाएँ। Alire, Ada और SPARK का package manager है जो ये दोनों काम संभालता है। इसकी command alr project बनाने, जिन libraries पर आप depend करते हैं उन्हें लाने, GNAT और GPRbuild लाने, और build व run करने का काम करती है।

यह article alr init से project बनाने से लेकर dependency जोड़ने, build profile बदलने और GNATprove से proof करने तक step by step चलता है। साथ ही असली output से यह भी confirm करता है कि default build preconditions को check नहीं करता।

Commands और output 1 November 2026 को Ubuntu (x86-64) पर alr 2.1.0 और लिखते समय के latest alr 2.1.1 के साथ चलाए गए। दोनों versions में एक जैसे results आए। लंबे output का कुछ हिस्सा हटा दिया गया है। Windows installer और MSYS2 वाले steps इस environment में try नहीं किए गए, इसलिए उनके बारे में सिर्फ़ वही लिखा है जो Alire के docs में है।

Ada के बारे में “The Appeal of the Ada Language” (English) में, और SPARK व GNATprove के बारे में “Introduction to Formal Verification with SPARK” (English) में लिखा है।

Alire किन चीज़ों को संभालता है

Alire में distribution और dependency की unit को crate कहते हैं। Crate के root पर alire.toml नाम का manifest होता है, जिसमें name, version, depend किए गए crates वगैरह TOML format में लिखे जाते हैं1। Publish हुए crates की जानकारी community index (GitHub पर alire-index repository) में इकट्ठा होती है, और alr dependency के candidates वहीं ढूँढता है2।

Build के लिए GPRbuild इस्तेमाल होता है। GPRbuild एक tool है जो project files (.gpr) पढ़कर कई languages में लिखे systems को build करता है3। alr build पहले GPR_PROJECT_PATH जैसे environment variables set करता है और फिर GPRbuild को call करता है4।

Alire के हिस्सेदिखाता है कि alr command manifest पढ़ती है, index से dependency crates और Alire द्वारा distribute किए गए GNAT और GPRbuild लाती है, और GPRbuild से build करती है।Developeralr commandalire.toml (manifest)Community indexDependency cratesGNAT और GPRbuildGPRbuild से build

चित्र 1: alr manifest पढ़ता है, dependency crates और toolchain लाता है, और GPRbuild से build करता है।

Diagram में solid line हमेशा लागू रहने वाला relation दिखाती है और dashed line conditional relation दिखाती है (शर्तें detail page पर हर relation के explanation में दी गई हैं)। Relations की पूरी list (कुल 11, evidence और certainty सहित) तथा मुख्य concepts की definitions knowledge map की detail page पर संकलित हैं (जापानी में)। Data: JSON-LD / Turtle

alr install करना

Windows

Windows के लिए GitHub के releases page पर installer है (2.1.1 के लिए alr-2.1.1-installer-x86_64-windows.exe)। Installer एक shortcut बनाता है जो alr को PATH में रखकर PowerShell खोलता है4।

पहली बार alr चलाने पर यह पूछता है कि MSYS2 install करना है या नहीं। MSYS2, native Windows software build और run करने के लिए tools और libraries का collection है, और package management के लिए Pacman इस्तेमाल करता है5। Alire ज़रूरी tools, जैसे git और make, और कुछ crates में इस्तेमाल होने वाली external libraries MSYS2 से install करता है। इसी वजह से docs MSYS2 install करने की सलाह देते हैं4। अगर pacman पहले से PATH में है, तो Alire उसी MSYS2 को इस्तेमाल करता है और नया install नहीं करता4।

Linux और macOS

Linux और macOS पर archive extract करके bin folder को PATH में जोड़ें4। इस article में Linux (x86-64) वाला zip इस्तेमाल किया गया।

unzip alr-2.1.1-bin-x86_64-linux.zip -d ~/alire
export PATH="$HOME/alire/bin:$PATH"
alr --version
alr 2.1.1

macOS पर ऐसी warning आ सकती है कि developer verify नहीं हो सका, और alr start नहीं होता। Docs xattr -d com.apple.quarantine bin/alr से quarantine attribute हटाने का तरीका बताते हैं4।

OS के हिसाब से alr install करनादिखाता है कि Windows पर installer इस्तेमाल होता है और पहली बार चलाने पर MSYS2 install करने का फ़ैसला होता है, जबकि Linux और macOS पर archive extract करके PATH में जोड़ा जाता है।alr install करनाWindowsLinux, macOSInstaller चलाएँपहली बार alr चलाने पर MSYS2 के बारे में पूछा जाता हैpacman PATH में हो तो मौजूदा MSYS2 इस्तेमाल होता हैArchive extract करेंbin को PATH में जोड़ें

चित्र 2: Windows पर installer और MSYS2, Linux और macOS पर archive extract करके install करते हैं।

alr init से project बनाना

Executable बनाने वाला project alr init --bin <name> से बनता है। Library के लिए --lib इस्तेमाल करें।

alr init --bin hello_alire

चलाने पर सबसे पहले crate का description पूछा जाता है। पहली बार इस्तेमाल करने पर उसके बाद name, GitHub login और email address भी पूछे जाते हैं। ये skip किए जा सकते हैं और बाद में alr settings से बदले जा सकते हैं। फिर license, tags और website पूछी जाती है। GitHub login, community index में publish करते समय maintainer दिखाने के लिए इस्तेमाल होता है4।

बनी हुई files ये हैं।

hello_alire/.gitignore
hello_alire/alire.toml
hello_alire/alire/alire.lock
hello_alire/alire/build_hash_inputs
hello_alire/alire/settings.toml
hello_alire/config/hello_alire_config.ads
hello_alire/config/hello_alire_config.gpr
hello_alire/config/hello_alire_config.h
hello_alire/hello_alire.gpr
hello_alire/src/hello_alire.adb

.gitignore में ये 4 lines थीं। alire और config folders को Alire फिर से बना लेता है, इसलिए इन्हें version control में नहीं रखते। Repository में alire.toml, .gpr files और src के नीचे का source रखा जाता है।

/obj/
/bin/
/alire/
/config/
alr init से बनने वाली filesalr init से बनी files को दो हिस्सों में दिखाता है: जो repository में रखी जाती हैं, और जिन्हें Alire फिर से बनाता है इसलिए exclude किया जाता है।alr init से बनी filesRepository में रखेंExclude करें (.gitignore)alire.toml और .gprsrc के नीचे का sourcealire और configobj और binAlire फिर से बनाता है

चित्र 3: alire.toml, .gpr और source repository में रखें, और Alire के बनाए folders exclude करें।

Manifest alire.toml नीचे दिया है। इसे -n (non-interactive) से बनाया गया था, इसलिए name वगैरह में default values हैं।

name = "hello_alire"
description = ""
version = "0.1.0-dev"

authors = ["Your Name"]
maintainers = ["Your Name <example@example.com>"]
licenses = "MIT OR Apache-2.0 WITH LLVM-exception"
website = ""
tags = []

executables = ["hello_alire"]

Project file hello_alire.gpr, config/hello_alire_config.gpr को with से पढ़ती है और compiler switches वहीं से लेती है। आगे बताए जाने वाले build profile settings भी इसी generated file के ज़रिए compiler तक पहुँचते हैं।

with "config/hello_alire_config.gpr";
project Hello_Alire is

   for Source_Dirs use ("src/", "config/");
   for Object_Dir use "obj/" & Hello_Alire_Config.Build_Profile;
   for Create_Missing_Dirs use "True";
   for Exec_Dir use "bin";
   for Main use ("hello_alire.adb");

   package Compiler is
      for Default_Switches ("Ada") use Hello_Alire_Config.Ada_Compiler_Switches;
   end Compiler;

   package Binder is
      for Switches ("Ada") use ("-Es"); --  Symbolic traceback
   end Binder;

   package Install is
      for Artifacts (".") use ("share");
   end Install;

end Hello_Alire;

पहले alr build में GNAT install होता है

कोई setting न होने पर alr build चलाया तो Alire ने toolchain चुनी, download की, और फिर build किया।

Note: Alire has selected automatically this toolchain:
   gprbuild=26.0.1
   gnat_native=16.1.0
You can select a different toolchain at any time with `alr toolchain --select`
Download will start now:
Note: Deploying gprbuild=26.0.1...
Note: gprbuild=26.0.1 installed successfully.
Note: Deploying gnat_native=16.1.0...
Note: gnat_native=16.1.0 installed successfully.
Note: Building hello_alire=0.1.0-dev/hello_alire.gpr...
...
Success: Build finished successfully in 0.61 seconds.

gnat_native उस crate का नाम है जो उस platform के native compiler को दर्शाता है6। इस environment में apt से install किया GNAT 13.3.0 भी था, लेकिन Alire ने अपना distribute किया हुआ 16.1.0 चुना। कौन-सा version चुना जाएगा, यह उस समय के index पर निर्भर करता है।

इसके बाद src/hello_alire.adb बदलकर alr run चलाते हैं। alr run ज़रूरत हो तो पहले build करता है, फिर executable start करता है। Hello_Alire_Config, config folder में generate हुआ package है जो चुने गए build profile को constant के रूप में रखता है।

with Ada.Text_IO;
with Hello_Alire_Config;

procedure Hello_Alire is
begin
   Ada.Text_IO.Put_Line ("Hello from Alire");
   Ada.Text_IO.Put_Line
     ("Build profile: "
      & Hello_Alire_Config.Build_Profile_Kind'Image
          (Hello_Alire_Config.Build_Profile));
end Hello_Alire;
$ alr run
Note: Building hello_alire=0.1.0-dev/hello_alire.gpr...
...
Success: Build finished successfully in 0.59 seconds.
Hello from Alire
Build profile: DEVELOPMENT
पहले build का flowदिखाता है कि पहले alr build में toolchain चुनी न गई हो तो Alire उसे चुनकर download करता है, config files generate करता है, GPRbuild से build करता है, और alr run से program चलता है।नहींहाँalr buildToolchain चुनी गई है?Alire चुनकर download करता हैconfig में settings generateGPRbuild से buildbin में executablealr run से चलाएँ

चित्र 4: पहले build में toolchain आती है, settings generate होती हैं, फिर GPRbuild से build होता है।

alr with से dependency crate जोड़ना

Index में मौजूद crates alr search --crates <word> से ढूँढे जा सकते हैं।

$ alr search --crates log
elogs             Embedded logging, proven absent of runtime errors
gnatcoll_syslog   GNAT Components Collection - syslog binding
journada          Simple and nice configurable logging
loga              Simple library for simple logging. Like npm package "debug", but for Ada
pico_ada_c04_pwm  Chapter 4: Analog LED with PWM
prolog            Simple Prolog library
simple_logging    Simple logging to console
testlog           Log test activity to support unit testing of Ada packages
utilada           Utility Library with streams, processes, logs, serialization, encoders

यहाँ console पर log दिखाने वाला simple_logging जोड़ते हैं।

$ alr with simple_logging
Requested changes:

   + simple_logging ^3.0.0 (add)

Changes to dependency solution:

   + simple_logging 3.0.0 (new)

Do you want to proceed?
Note: Deploying simple_logging=3.0.0...

Manifest के आख़िर में dependency जुड़ जाती है।

[[depends-on]]
simple_logging = "^3.0.0"

^3.0.0 का मतलब है 3.0.0 या उससे नया, लेकिन वही major number। Alire में crate versions semantic versioning में लिखे जाते हैं; ^ उसी major number के अंदर नए versions accept करता है, और ~ उसी minor number के अंदर7। लेकिन 1.0 से पहले के versions के लिए ^ और ~ का कोई special behavior नहीं है। ^0.2 का मतलब भी 1.0 से नीचे के सारे versions है, इसलिए docs 1.0 से पहले के versions के लिए ~0.x form इस्तेमाल करने की सलाह देते हैं7।

Dependency जोड़ने के बाद generate होने वाली config/hello_alire_config.gpr की शुरुआत में with "simple_logging.gpr"; आ गया। इसलिए अपनी .gpr बदले बिना source से Simple_Logging को with किया जा सकता है।

with Simple_Logging;
with Hello_Alire_Config;

procedure Hello_Alire is
   package Log renames Simple_Logging;
begin
   Log.Level := Log.Debug;
   Log.Info ("Hello from Alire");
   Log.Debug
     ("Build profile: "
      & Hello_Alire_Config.Build_Profile_Kind'Image
          (Hello_Alire_Config.Build_Profile));
end Hello_Alire;
$ alr run
...
Build Libraries
   [gprlib]       simple_logging.lexch
   [archive]      libsimple_logging.a
   [index]        libsimple_logging.a
...
Success: Build finished successfully in 4.58 seconds.
Hello from Alire
-->> Build profile: DEVELOPMENT

Log.Level को Debug पर set किया था, इसलिए Log.Debug का message भी दिखा। उस line की शुरुआत में -->> लगा है।

Dependency resolution का result alr with --solve या alr with --tree से देखा जा सकता है।

$ alr with --tree
hello_alire=0.1.0-dev
+-- simple_logging=3.0.0 (^3.0.0)
alr with से dependency जोड़ने का flowदिखाता है कि alr with manifest में dependency जोड़ता है, version resolve करके source लाता है, और generate होने वाली config file में with डालता है ताकि source से उसे इस्तेमाल किया जा सके।alr with simple_loggingalire.toml में depends-on जोड़ाVersion resolve (^3.0.0 → 3.0.0)Source लायाconfig की .gpr में with जोड़ाSource से with किया जा सकता है

चित्र 5: alr with dependency को manifest में लिखता है, version resolve करता है, और config file के ज़रिए उसे इस्तेमाल लायक बनाता है।

alire.lock और version pin करना

Resolve हुआ version alire/alire.lock में record होता है। लेकिन यह file alire folder के अंदर है और .gitignore से exclude है। Alire के docs भी कहते हैं कि alire.lock internal file है जो ज़रूरत पड़ने पर फिर से बनती है, इसलिए इसे version control में रखने की ज़रूरत नहीं8।

इसलिए repository में manifest में लिखी ^3.0.0 जैसी version range ही share होती है। किसी एक version पर fix करना हो तो alr pin इस्तेमाल करें। Pin manifest में लिखा जाता है।

$ alr pin simple_logging
...
   . simple_logging 3.0.0 (pin=3.0.0)
[[depends-on]]
simple_logging = "^3.0.0"

[[pins]]
simple_logging = { version='3.0.0' }

alr update, जो dependencies pin नहीं हैं उन्हें configured index से फिर से resolve करता है। --online लगाने पर पहले index update होता है। Pin को local folder या git repository पर भी point किया जा सकता है7। जैसे development में चल रही अपनी library को alr with <name> --use=<path> से इस्तेमाल करना।

Version range, pin और resolution resultदिखाता है कि manifest में लिखी version range और pins से alr version resolve करता है, result alire.lock में record होता है, और alire.lock version control में नहीं रखा जाता।सिर्फ़ pin न की गई dependenciesalire.toml का depends-on (version range)alr version resolve करता हैalire.toml के pins (fix)alire/alire.lock में recordVersion control में नहीं रखतेalr update

चित्र 6: Manifest की range और pins share होते हैं, alire.lock हर machine पर फिर से बनता है।

Build profile से क्या बदलता है

Alire में तीन build profiles हैं: Development, Release और Validation। Default रूप से आपका अपना crate Development में और dependency crates Release में build होते हैं7। अपने crate का profile alr build के switch से बदला जा सकता है।

$ alr build --release
...
$ alr run --skip-build
Hello from Alire
-->> Build profile: RELEASE

alr run पिछली बार alr build में इस्तेमाल हुए profile से build करता है8।

हर profile के compiler switches config/hello_alire_config.gpr में लिखे जाते हैं। alr 2.1 ने ये लिखे (style checks वाले -gnaty… हटा दिए हैं)।

Profile मुख्य switches
Development -Og -g -gnatwa -gnatVa
Release -O3 -gnatn
Validation -O3 -gnatn -g -gnato -gnatwa -gnatVa -gnatwe -gnata

-gnata सिर्फ़ Validation में है। GNAT के docs के अनुसार -gnata preconditions, postconditions, type invariants, predicates जैसे assertions enable करने वाला switch है, और इसे न देने पर ये assertions disabled रहते हैं9। मतलब default alr build से बने program में Pre में लिखी condition runtime पर check नहीं होती।

Precondition check होती है या नहीं, यह आज़माना

नीचे वाले program से check किया। Half सिर्फ़ even numbers लेने के लिए बना है, और precondition में यही लिखा है। Caller जानबूझकर odd number 7 pass करता है।

with Ada.Text_IO;

procedure Profile_Demo with SPARK_Mode is

   function Half (X : Integer) return Integer
     with Pre => X mod 2 = 0;

   function Half (X : Integer) return Integer is (X / 2);

begin
   Ada.Text_IO.Put_Line (Integer'Image (Half (7)));
end Profile_Demo;

Development में build करने पर precondition check नहीं हुई, program ने 3 print किया और exit code 0 के साथ खत्म हुआ।

$ alr build
$ ./bin/profile_demo
 3

Validation में build करने पर precondition violation पर Assertion_Error raise हुआ और exit code 1 आया।

$ alr build --validation
$ ./bin/profile_demo

raised ADA.ASSERTIONS.ASSERTION_ERROR : failed precondition from profile_demo.adb:6

Contracts वाले crate को test करते समय Validation में build करें, या manifest के [build-profiles] में profile set करें। नीचे जैसा लिखने पर बिना switch वाला alr build भी Validation में build हुआ।

[build-profiles]
profile_demo = "validation"

Dependency crates का profile भी इसी table में set किया जा सकता है। Command line से alr build --profiles='*=development' जैसे पूरे project के लिए भी set किया जा सकता है8।

Build profile और precondition checkदिखाता है कि Development, Release और Validation में से सिर्फ़ -gnata वाले Validation में precondition runtime पर check होती है, बाकी दो में नहीं।Build profileDevelopment (default)ReleaseValidation-gnata नहीं-gnata हैPre runtime पर check नहीं होतीPre violation पर Assertion_Error

चित्र 7: Precondition runtime पर सिर्फ़ -gnata वाले Validation में check होती है।

Toolchain चुनना

alr toolchain local toolchains और default रूप से इस्तेमाल होने वाली toolchain दिखाता है।

$ alr toolchain
CRATE         VERSION         STATUS    NOTES
gprbuild      18.0.0          Available Detected at /usr/bin/gprbuild
gprbuild      26.0.1          Default
gprbuild      2024.1.20231009 Available Provided by system package: gprbuild
gnat_native   16.1.0          Default
gnat_external 13.3.0          Available Detected at /usr/bin/gnat

alr toolchain --select बिना argument के interactive selection screen दिखाता है, और version देने पर उसे default बना देता है। --local लगाने पर पूरे configuration की जगह सिर्फ़ उस working folder में इस्तेमाल होने वाला version तय होता है6।

$ alr toolchain --select --local gnat_native=15.2.1
Note: Deploying gnat_native=15.2.1...
Note: gnat_native=15.2.1 installed successfully.
Note: gnat_native=15.2.1 set as default in local configuration.

--local का selection alire/settings.toml में लिखा गया। यह folder .gitignore से exclude है, इसलिए यह selection दूसरों के साथ share नहीं होता। अगर crate सिर्फ़ कुछ compiler versions पर चलता है, तो docs gnat = ">=13" जैसे gnat पर dependency लिखने का तरीका बताते हैं6।

Alire की चुनी toolchain alr exec से चलाई गई commands में इस्तेमाल होती है। एक ही terminal में भी, alr exec से चलाने या न चलाने पर अलग GNAT call हुआ।

$ gnat --version
GNAT 13.3.0
$ alr exec -- gnat --version
GNAT 15.2.0

gnat_native का 15.2.1 crate version है; compiler खुद 15.2.0 दिखाता है। alr exec पहले GPR_PROJECT_PATH और PATH set करता है, फिर command चलाता है। वही environment variables alr printenv से दिखाए जा सकते हैं, जो editor से GPRbuild चलाते समय काम आते हैं4।

Alire compiler किस order में चुनता हैदिखाता है कि अगर कोई dependency target-specific compiler माँगती है तो वही इस्तेमाल होता है, नहीं तो user का चुना compiler, और वह भी न हो तो user के environment में मौजूद compiler।हाँनहींहाँनहींक्या dependency target-specific compiler माँगती है?वही compiler इस्तेमालक्या user ने default चुना है?चुना हुआ compiler इस्तेमालUser के environment वाला इस्तेमाल

चित्र 8: Compiler इस order में चुना जाता है: dependency की माँग, user का चुनाव, environment में मौजूद।

यह order Alire के docs के अनुसार है। हर step में पहले से download किया compiler priority पाता है, और सिर्फ़ तब नया download होता है जब कोई matching न मिले6। इस article के environment में पहले build के दौरान Alire ने default अपने-आप चुना था, इसलिए दूसरा step लागू हुआ।

GNATprove को dependency के रूप में जोड़कर proof करना

SPARK code का proof करने वाला GNATprove भी crate के रूप में जोड़ा जा सकता है।

$ alr with gnatprove
...
   +b gnatprove 16.1.0 (new,binary)
...
Note: Deploying gnatprove=16.1.0...

alr gnatprove, alr में alr exec -P1 -- gnatprove के alias के रूप में built-in है (alr help के ALIASES में दिखता है)। -P1 का मतलब है पहले argument के रूप में crate की .gpr को -P से pass करना। ऊपर वाले Profile_Demo का proof चलाया तो odd number pass करने वाली call पकड़ी गई।

$ alr gnatprove
Phase 1 of 3: generation of data representation information ...
Phase 2 of 3: generation of Global contracts ...
Phase 3 of 3: flow analysis and proof ...
 medium: precondition might fail
--> profile_demo.adb:11:41
   11 |       Ada.Text_IO.Put_Line (Integer'Image (Half (7)));
      |                                            ^~~~~~~
      + provers gave up before completing the proof

Development build में बिना error के 3 print करने वाली call को यह बिना चलाए ही पकड़ लेता है। लेकिन उस समय alr gnatprove का exit code 0 था। GNATprove default रूप से unproved checks होने पर भी exit code 0 देता है, और सिर्फ़ --checks-as-errors=on देने पर non-zero देता है10।

$ alr gnatprove --checks-as-errors=on
...
gnatprove: unproved check messages considered as errors
ERROR: Command ["gnatprove", "-P", "profile_demo.gpr", "--checks-as-errors=on"] exited with code 1

Call को Half (8) करने पर सारे checks prove हो गए।

$ alr gnatprove --checks-as-errors=on --report=all
...
 info: precondition proved
--> profile_demo.adb:11:41

Success: all checks proved (4 checks).

Unproved check होने पर CI job fail कराने के लिए --checks-as-errors=on लगाएँ। GNATprove के proof levels और contracts लिखने का तरीका “Introduction to Formal Verification with SPARK” (English) में समझाया है।

alr gnatprove का result और exit codeदिखाता है कि alr gnatprove में unproved check होने पर default रूप से exit code 0 आता है, checks-as-errors लगाने पर 1 आता है, और सब prove हो जाए तो 0 आता है।नहींहैनहींहाँalr gnatproveUnproved check है?all checks proved, exit code 0--checks-as-errors=on है?Warnings दिखती हैं, exit code 0Warnings दिखती हैं, exit code 1

चित्र 9: Unproved checks होने पर भी default exit code 0 रहता है। CI में –checks-as-errors=on लगाएँ।

alr test क्या check करता है

alr test unit tests चलाने वाली command नहीं है। Working crate में बिना argument चलाने पर, अगर manifest में test action है तो उसे चलाता है, नहीं तो alr build --release चलाता है (alr help test)। Argument में crate name देने पर यह index के versions लाकर देखता है कि वे build होते हैं या नहीं।

Test action manifest में type = "test" से लिखा जाता है। Action होने पर crate पहले build नहीं होता, इसलिए build ज़रूरी हो तो वह command भी action में डालें7। नीचे के example में proof को test के रूप में चलाया गया है।

[[actions]]
type = "test"
command = ["alr", "gnatprove", "--checks-as-errors=on"]
$ alr test
Note: Synchronizing workspace...
Nothing to update.

Success: Test ended successfully.

Half (7) वापस करने पर alr test exit code 1 के साथ खत्म हुआ।

$ alr test
ERROR: Local test of profile_demo=0.1.0-dev failed:
ERROR:    Check alire/alr_test_local.log for details.

इस environment में alr test से call होने वाला alr, PATH से ढूँढा गया। शुरुआत में PATH में apt से install किया दूसरा version का alr पहले था, वही चला और fail हुआ। अगर कई versions install हैं, तो PATH का order check कर लें।

Unit tests लिखने के layout के रूप में docs main crate के नीचे एक test crate बनाने और उसमें main crate को relative path से pin करने का तरीका दिखाते हैं। इससे सिर्फ़ tests में लगने वाली AUnit जैसी dependencies main manifest में नहीं डालनी पड़तीं7।

# tests/alire.toml
[[depends-on]]
my_crate = "*"
aunit = "*"

[[pins]]
my_crate = { path = ".." }
alr test क्या चलाता हैदिखाता है कि बिना argument वाला alr test, manifest में type test action हो तो उसे चलाता है, नहीं तो alr build --release चलाता है।हैनहींalr test (बिना argument)type = test action है?Action चलाता है (build नहीं)alr build --releaseExit code से pass/fail

चित्र 10: alr test, test action या Release build चलाता है।

Crate publish करते समय

बनाया हुआ crate community index में publish करने के लिए alr publish इस्तेमाल होता है। इस article के environment में यह try नहीं किया गया, इसलिए सिर्फ़ docs में बताया गया flow दिया है2।

  1. Publish करने वाला version commit करें और GitHub जैसी trusted site पर git repository में push करें। Working tree में कोई uncommitted change न रहे।
  2. public_repo permission के साथ GitHub का Personal Access Token (classic) बनाएँ। उसे environment variable GH_TOKEN में रखें, या alr पूछे तब डालें।
  3. Repository के root में alr publish चलाएँ। alr content check करता है, alire-index को fork करता है, और pull request बनाता है।
alr publish से crate publish करने का flowदिखाता है कि publish होने वाला version commit और push करके, Personal Access Token तैयार करके alr publish चलाने पर alr, alire-index का fork और pull request बनाता है, और पहला registration एक व्यक्ति review करके approve करता है।Version commit और pushPersonal Access Token तैयार करेंalr publish चलाएँalire-index को forkPull request बनाएँपहला registration व्यक्ति review करके approve करता है

चित्र 11: alr publish, push हो चुके version से index में pull request बनाता है।

नए crate का पहला registration एक व्यक्ति review करने के बाद approve करता है। उसके बाद नए versions सिर्फ़ manifest के maintainers-logins में लिखे maintainers ही register कर सकते हैं2। Organization के अंदर ही इस्तेमाल होने वाले crates के लिए --for-private-index लगाने पर community index में submit किए बिना अपने index के लिए manifest बनता है8।

संबंधित लेख

संदर्भ लिंक

  1. Alire, Documentation. Manifest alire.toml, build environment और catalog format की जानकारी। ↩

  2. Alire, Publishing your projects in Alire. alr publish, Personal Access Token, और index में registration का review। ↩ ↩2 ↩3

  3. AdaCore, Building with GPRbuild. GPRbuild की भूमिका और project files। ↩

  4. Alire, Getting Started. हर OS पर install करना, MSYS2, alr init के सवाल, और alr printenv। ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8

  5. MSYS2, MSYS2. MSYS2 और Pacman। ↩

  6. Alire, Toolchain management. gnat_native, alr toolchain --select, compiler चुनने का order, और gnat पर dependency। ↩ ↩2 ↩3 ↩4

  7. Alire, Catalog format specification. depends-on में version लिखना, actions, pins, build profiles और switches, और test crates का layout। ↩ ↩2 ↩3 ↩4 ↩5 ↩6

  8. Alire, User-facing changes log. alire.lock की location और handling, alr build --profiles, और alr run का पिछला profile इस्तेमाल करना। ↩ ↩2 ↩3 ↩4

  9. GCC, Alphabetical List of All Switches (GNAT User’s Guide). -gnata से enable होने वाले assertions और इसे न देने पर default। ↩

  10. AdaCore, How to Run GNATprove (SPARK User’s Guide). Exit codes और --checks-as-errors=on। ↩

निकटवर्ती विषयों में गहराई से जाने के लिए समान टैग वाले नवीनतम लेख।

ये इस विषय से जुड़े topic पृष्ठ हैं। लेख से शुरू करके आप संबंधित सेवाओं और दूसरे लेखों तक जा सकते हैं।

यह लेख नीचे दिए गए सेवा पृष्ठों से जुड़ता है। जो प्रवेश-बिंदु आपके सबसे क़रीब हो, वहाँ से देखिए।

तकनीकी परामर्श और डिज़ाइन समीक्षा

अगर आपको तय करना है कि Ada का development environment Alire पर standardize करें या नहीं, या मौजूदा GPR projects को कैसे migrate करें, तो हम इसे technical consulting और design review के रूप में ले सकते हैं।

मौजूदा Windows सॉफ़्टवेयर में बदलाव और रखरखाव

अगर आप Ada में लिखा मौजूदा software maintain करते हैं और हर developer का compiler version अलग है या build environment reproduce नहीं हो पाता, तो यह modernization और maintenance work के लिए अच्छा case है।

अक्सर पूछे जाने वाले प्रश्न

इस लेख के विषय पर परामर्श में अक्सर पूछे जाने वाले प्रश्न।

Alire क्या है?
यह Ada और SPARK का package manager है। इसकी command alr है, और यह project (crate) बनाना, dependency crates लाना, GNAT और GPRbuild लाना और चुनना, और build व run करना, सब एक ही tool में संभालता है।
क्या Alire के लिए GNAT अलग से install करना पड़ता है?
x86-64 Linux, Windows और macOS पर Alire पहले build में GNAT और GPRbuild download करके इस्तेमाल करता है। इस article के Linux environment में हाथ से कुछ install किए बिना gnat_native 16.1.0 और gprbuild 26.0.1 चुने गए। System में install GNAT इस्तेमाल करने वाला configuration भी बन सकता है।
क्या alire.lock को version control में रखना चाहिए?
Alire के docs कहते हैं कि alire.lock एक internal file है जो ज़रूरत पड़ने पर फिर से बनती है, इसलिए इसे version control में रखने की ज़रूरत नहीं। alr init जो .gitignore बनाता है, वह भी इस file वाले alire folder को exclude करता है। Dependency का version fix करना हो तो alr pin इस्तेमाल करें; pin manifest alire.toml में लिखा जाता है।
क्या alr build से बने program में preconditions (Pre) check होती हैं?
Default Development profile में check नहीं हुईं, क्योंकि Development के switches में -gnata नहीं है। Validation profile (alr build --validation) में -gnata जुड़ता है, और precondition पूरी न करने वाली call पर Assertion_Error raise हुआ।
क्या alr test unit tests चलाने वाली command है?
इसका अपना कोई testing framework नहीं है। Manifest में type = "test" वाला action हो तो यह उसे चलाता है, नहीं तो alr build --release चलाकर देखता है कि crate build होता है या नहीं। Unit tests के लिए Alire के docs एक अलग test crate बनाने और उसमें main crate को relative path से pin करने वाला layout suggest करते हैं।

लेखक की प्रोफ़ाइल

लेख के लेखक का परिचय पृष्ठ।

Go Komura

KomuraSoft LLC के प्रतिनिधि

Windows सॉफ़्टवेयर विकास, तकनीकी परामर्श और बग जाँच पर केंद्रित; जिन परियोजनाओं में मौजूदा assets बचे हैं, उनमें और जिन खराबियों का कारण आसानी से नहीं दिखता, उनकी जाँच में हमारी विशेष ताकत है।

सार्वजनिक लिंक

ब्लॉग पर लौटें