संशोधन इतिहास (केवल पहला संस्करण, 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।
flowchart TB
accTitle: Alire के हिस्से
accDescr: दिखाता है कि alr command manifest पढ़ती है, index से dependency crates और Alire द्वारा distribute किए गए GNAT और GPRbuild लाती है, और GPRbuild से build करती है।
U["Developer"] --> A["alr command"]
A --> M["alire.toml (manifest)"]
A --> I["Community index"]
I --> D["Dependency crates"]
A --> T["GNAT और GPRbuild"]
A --> G["GPRbuild से build"]
D --> G
T --> G
चित्र 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।
flowchart TB
accTitle: OS के हिसाब से alr install करना
accDescr: दिखाता है कि Windows पर installer इस्तेमाल होता है और पहली बार चलाने पर MSYS2 install करने का फ़ैसला होता है, जबकि Linux और macOS पर archive extract करके PATH में जोड़ा जाता है।
S["alr install करना"] --> W["Windows"]
S --> L["Linux, macOS"]
W --> WI["Installer चलाएँ"]
WI --> WF["पहली बार alr चलाने पर MSYS2 के बारे में पूछा जाता है"]
WF --> WP["pacman PATH में हो तो मौजूदा MSYS2 इस्तेमाल होता है"]
L --> LZ["Archive extract करें"]
LZ --> LP["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/
flowchart TB
accTitle: alr init से बनने वाली files
accDescr: alr init से बनी files को दो हिस्सों में दिखाता है: जो repository में रखी जाती हैं, और जिन्हें Alire फिर से बनाता है इसलिए exclude किया जाता है।
R["alr init से बनी files"] --> K["Repository में रखें"]
R --> X["Exclude करें (.gitignore)"]
K --> K1["alire.toml और .gpr"]
K --> K2["src के नीचे का source"]
X --> X1["alire और config"]
X --> X2["obj और bin"]
X1 -.-> N["Alire फिर से बनाता है"]
चित्र 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
flowchart TB
accTitle: पहले build का flow
accDescr: दिखाता है कि पहले alr build में toolchain चुनी न गई हो तो Alire उसे चुनकर download करता है, config files generate करता है, GPRbuild से build करता है, और alr run से program चलता है।
B["alr build"] --> Q{"Toolchain चुनी गई है?"}
Q -->|"नहीं"| S["Alire चुनकर download करता है"]
Q -->|"हाँ"| C["config में settings generate"]
S --> C
C --> G["GPRbuild से build"]
G --> E["bin में executable"]
E --> R["alr 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)
flowchart TB
accTitle: alr with से dependency जोड़ने का flow
accDescr: दिखाता है कि alr with manifest में dependency जोड़ता है, version resolve करके source लाता है, और generate होने वाली config file में with डालता है ताकि source से उसे इस्तेमाल किया जा सके।
W["alr with simple_logging"] --> M["alire.toml में depends-on जोड़ा"]
M --> S["Version resolve (^3.0.0 → 3.0.0)"]
S --> D["Source लाया"]
D --> C["config की .gpr में with जोड़ा"]
C --> U["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> से इस्तेमाल करना।
flowchart TB
accTitle: Version range, pin और resolution result
accDescr: दिखाता है कि manifest में लिखी version range और pins से alr version resolve करता है, result alire.lock में record होता है, और alire.lock version control में नहीं रखा जाता।
M["alire.toml का depends-on (version range)"] --> S["alr version resolve करता है"]
P["alire.toml के pins (fix)"] --> S
S --> L["alire/alire.lock में record"]
L --> X["Version control में नहीं रखते"]
U["alr update"] -.->|"सिर्फ़ pin न की गई dependencies"| S
चित्र 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।
flowchart TB
accTitle: Build profile और precondition check
accDescr: दिखाता है कि Development, Release और Validation में से सिर्फ़ -gnata वाले Validation में precondition runtime पर check होती है, बाकी दो में नहीं।
P["Build profile"] --> D["Development (default)"]
P --> R["Release"]
P --> V["Validation"]
D --> N["-gnata नहीं"]
R --> N
V --> A["-gnata है"]
N --> N2["Pre runtime पर check नहीं होती"]
A --> A2["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।
flowchart TB
accTitle: Alire compiler किस order में चुनता है
accDescr: दिखाता है कि अगर कोई dependency target-specific compiler माँगती है तो वही इस्तेमाल होता है, नहीं तो user का चुना compiler, और वह भी न हो तो user के environment में मौजूद compiler।
Q1{"क्या dependency target-specific compiler माँगती है?"} -->|"हाँ"| C1["वही compiler इस्तेमाल"]
Q1 -->|"नहीं"| Q2{"क्या user ने default चुना है?"}
Q2 -->|"हाँ"| C2["चुना हुआ compiler इस्तेमाल"]
Q2 -->|"नहीं"| C3["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) में समझाया है।
flowchart TB
accTitle: alr gnatprove का result और exit code
accDescr: दिखाता है कि alr gnatprove में unproved check होने पर default रूप से exit code 0 आता है, checks-as-errors लगाने पर 1 आता है, और सब prove हो जाए तो 0 आता है।
G["alr gnatprove"] --> Q{"Unproved check है?"}
Q -->|"नहीं"| OK["all checks proved, exit code 0"]
Q -->|"है"| O{"--checks-as-errors=on है?"}
O -->|"नहीं"| Z["Warnings दिखती हैं, exit code 0"]
O -->|"हाँ"| F["Warnings दिखती हैं, 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 = ".." }
flowchart TB
accTitle: alr test क्या चलाता है
accDescr: दिखाता है कि बिना argument वाला alr test, manifest में type test action हो तो उसे चलाता है, नहीं तो alr build --release चलाता है।
T["alr test (बिना argument)"] --> Q{"type = test action है?"}
Q -->|"है"| A["Action चलाता है (build नहीं)"]
Q -->|"नहीं"| B["alr build --release"]
A --> R["Exit code से pass/fail"]
B --> R
चित्र 10: alr test, test action या Release build चलाता है।
Crate publish करते समय
बनाया हुआ crate community index में publish करने के लिए alr publish इस्तेमाल होता है। इस article के environment में यह try नहीं किया गया, इसलिए सिर्फ़ docs में बताया गया flow दिया है2।
- Publish करने वाला version commit करें और GitHub जैसी trusted site पर git repository में push करें। Working tree में कोई uncommitted change न रहे।
public_repopermission के साथ GitHub का Personal Access Token (classic) बनाएँ। उसे environment variableGH_TOKENमें रखें, याalrपूछे तब डालें।- Repository के root में
alr publishचलाएँ।alrcontent check करता है, alire-index को fork करता है, और pull request बनाता है।
flowchart TB
accTitle: alr publish से crate publish करने का flow
accDescr: दिखाता है कि publish होने वाला version commit और push करके, Personal Access Token तैयार करके alr publish चलाने पर alr, alire-index का fork और pull request बनाता है, और पहला registration एक व्यक्ति review करके approve करता है।
C["Version commit और push"] --> T["Personal Access Token तैयार करें"]
T --> P["alr publish चलाएँ"]
P --> F["alire-index को fork"]
F --> R["Pull request बनाएँ"]
R --> A["पहला 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।
संबंधित लेख
- The Appeal of the Ada Language — Expressing Design Through Types and Powering Software That Runs for Decades
- Introduction to Formal Verification with SPARK — From Ada Contracts to Mathematical Proof
- Proving AI-Written Code with SPARK
- Ada में memory management
संदर्भ लिंक
-
Alire, Documentation. Manifest
alire.toml, build environment और catalog format की जानकारी। ↩ -
Alire, Publishing your projects in Alire.
alr publish, Personal Access Token, और index में registration का review। ↩ ↩2 ↩3 -
AdaCore, Building with GPRbuild. GPRbuild की भूमिका और project files। ↩
-
Alire, Getting Started. हर OS पर install करना, MSYS2,
alr initके सवाल, औरalr printenv। ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 -
Alire, Toolchain management.
gnat_native,alr toolchain --select, compiler चुनने का order, औरgnatपर dependency। ↩ ↩2 ↩3 ↩4 -
Alire, Catalog format specification.
depends-onमें version लिखना, actions, pins, build profiles और switches, और test crates का layout। ↩ ↩2 ↩3 ↩4 ↩5 ↩6 -
Alire, User-facing changes log.
alire.lockकी location और handling,alr build --profiles, औरalr runका पिछला profile इस्तेमाल करना। ↩ ↩2 ↩3 ↩4 -
GCC, Alphabetical List of All Switches (GNAT User’s Guide).
-gnataसे enable होने वाले assertions और इसे न देने पर default। ↩ -
AdaCore, How to Run GNATprove (SPARK User’s Guide). Exit codes और
--checks-as-errors=on। ↩
संबंधित लेख
निकटवर्ती विषयों में गहराई से जाने के लिए समान टैग वाले नवीनतम लेख।
क्या आपके Ada और SPARK tests code में बदलाव पकड़ पाते हैं? ── AdaMutant का परिचय
AdaMutant, Ada और SPARK के लिए एक mutation testing tool है। यह source में छोटे बदलाव डालकर check करता है कि tests या GNATprove के proofs ...
Ada में generic programming — type पर contract लिखकर zero-cost reuse
Ada की generic programming को generic subprogram, generic package, formal subprogram, type category और practical design guidelines तक sys...
Ada में memory management ── access types, controlled types और storage pools का सही इस्तेमाल
Ada GC पर निर्भर नहीं रहता: values पहले stack पर रखी जाती हैं, और heap चाहिए तो access types lifetime के rules type में लिख देते हैं। Dea...
MIL-STD-882E software safety को कैसे handle करता है?
MIL-STD-882E software failure की probability estimate नहीं करता। Software कितना control रखता है और नुकसान कितना गंभीर हो सकता है, इससे an...
Ada में real-time systems programming — priority, period और execution time control
Ada के Annex D (Real-Time Systems) को 8 practical code examples से सीखें। Task priority, Ceiling_Locking, delay until से periodic executi...
संबंधित विषय
ये इस विषय से जुड़े topic पृष्ठ हैं। लेख से शुरू करके आप संबंधित सेवाओं और दूसरे लेखों तक जा सकते हैं।
Windows के तकनीकी विषय
Windows विकास, बग जाँच और मौजूदा संपत्तियों के उपयोग से जुड़े तकनीकी विषयों का प्रवेश-द्वार।
इस विषय से जुड़ी सेवाएँ
यह लेख नीचे दिए गए सेवा पृष्ठों से जुड़ता है। जो प्रवेश-बिंदु आपके सबसे क़रीब हो, वहाँ से देखिए।
तकनीकी परामर्श और डिज़ाइन समीक्षा
अगर आपको तय करना है कि 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 बचे हैं, उनमें और जिन खराबियों का कारण आसानी से नहीं दिखता, उनकी जाँच में हमारी विशेष ताकत है।