Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 41 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,60 @@
name: Build

on:
push:
branches: [ master ]
pull_request:
workflow_dispatch:
workflow_call:
inputs:
build:
description: 'Whether to run a plain `alr build`'
required: false
default: true
type: boolean
crate:
description: 'The crate to build'
required: true
type: string

env:
AAA_STYLE_CHECKS: enabled
AAA_RUNTIME_CHECKS: enabled
AAA_COMPILE_CHECKS: enabled
AAA_CONTRACTS: enabled

jobs:
build:
name: test (${{inputs.crate}}, GNAT ${{ matrix.combo.gnat }}, ${{ matrix.combo.os }})
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
gnat_version: [^10, ^11]
gprbuild_version: [^21]
runs-on: ${{ matrix.os }}
env:
AAA_STYLE_CHECKS: enabled
AAA_RUNTIME_CHECKS: enabled
AAA_COMPILE_CHECKS: enabled
AAA_CONTRACTS: enabled
combo: # Test an assorment of representative combinations
- os: macos-13
gnat: 13
- os: macos-latest
gnat: 14
- os: ubuntu-22.04
gnat: 10
- os: ubuntu-latest
gnat: 12
# Waiting for indexed compiler
# - os: ubuntu-24.04-arm
# gnat: 14
- os: windows-latest
gnat: 11

runs-on: ${{ matrix.combo.os }}

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Alire and toolchain
uses: alire-project/setup-alire@v1
uses: alire-project/setup-alire@v4
with:
toolchain: gprbuild${{ matrix.gprbuild_version }} gnat_native${{ matrix.gnat_version }} --disable-assistant
version: nightly # for [test]
toolchain: gnat_native^${{ matrix.combo.gnat }} gprbuild

- name: Build
run: alr -q build
if: ${{inputs.build}}
run: cd ${{inputs.crate}} && alr -q build

- name: Run tests
run: cd tests && alr -q run
run: cd ${{inputs.crate}} && alr test
13 changes: 13 additions & 0 deletions .github/workflows/build_aaa.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: aaa

on:
push:
branches: [ main, master ]
pull_request:
workflow_dispatch:

jobs:
check:
uses: ./.github/workflows/build.yml
with:
crate: aaa_base
14 changes: 14 additions & 0 deletions .github/workflows/build_aaa_texts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: aaa_texts

on:
push:
branches: [ main, master ]
pull_request:
workflow_dispatch:

jobs:
check:
uses: ./.github/workflows/build.yml
with:
crate: aaa_texts
build: false
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ alire.lock
bin
lib
obj
/obj/
/lib/
/alire/
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
[![Build](https://github.com/mosteo/aaa/workflows/Build/badge.svg)](https://github.com/mosteo/aaa/actions)
[![Alire](https://img.shields.io/endpoint?url=https://alire.ada.dev/badges/aaa.json)](https://alire.ada.dev/crates/aaa.html)

Alex's Ada Assortment of Utilities.

Alex's Ada Assortment of Utilities
## aaa

- Text formatting (paragraphs, tables).
- Indefinite containers.
- Enumeration validity/conversions of string images.
- On-demand stack backtraces.
- String containers and utilities.
- Simple subprocess spawning.
- Write-through minimal cache for objects stored in files

## aaa_texts

- Unicode ANSI text formatting (paragraphs, tables).
File renamed without changes.
File renamed without changes.
12 changes: 7 additions & 5 deletions alire.toml → aaa_base/alire.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "aaa"
version = "0.3.0-dev"
version = "0.3.0"
description = "Alex's Ada Assortment (of miscellaneous utilities)"

long-description = """
Expand All @@ -21,8 +21,10 @@ maintainers-logins = ["mosteo"]
tags = ["miscellanea", "utility"]
website = "https://github.com/mosteo/aaa"

[[depends-on]]
umwi = "~0.1.0"
[[actions]]
type = "test"
directory = "tests"
command = ["alr", "build"]

# [[pins]]
# umwi = { url="https://github.com/mosteo/umwi", branch="main" }
[test]
runner = "alire"
2 changes: 1 addition & 1 deletion config/aaa_config.ads → aaa_base/config/aaa_config.ads
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma Style_Checks (Off);
package Aaa_Config is
pragma Pure;

Crate_Version : constant String := "0.3.0-dev";
Crate_Version : constant String := "0.3.0";
Crate_Name : constant String := "aaa";

Alire_Host_OS : constant String := "linux";
Expand Down
3 changes: 1 addition & 2 deletions config/aaa_config.gpr → aaa_base/config/aaa_config.gpr
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-- Configuration for aaa generated by Alire
with "umwi.gpr";
abstract project Aaa_Config is
Crate_Version := "0.3.0-dev";
Crate_Version := "0.3.0";
Crate_Name := "aaa";

Alire_Host_OS := "linux";
Expand Down
2 changes: 1 addition & 1 deletion config/aaa_config.h → aaa_base/config/aaa_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#ifndef AAA_CONFIG_H
#define AAA_CONFIG_H

#define CRATE_VERSION "0.3.0-dev"
#define CRATE_VERSION "0.3.0"
#define CRATE_NAME "aaa"

#define ALIRE_HOST_OS "linux"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions aaa_base/src/aaa-containers-suite.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
with Ada.Containers.Indefinite_Ordered_Maps;
with Ada.Containers.Indefinite_Ordered_Sets;
with Ada.Containers.Indefinite_Vectors;

generic
type Keys (<>) is private;
type Stored (<>) is private;
with function "<" (L, R : Keys) return Boolean is <>;
with function "<" (L, R : Stored) return Boolean is <>;
package AAA.Containers.Suite with Preelaborate is

-- A collection of ready-to-use containers with conversions among them

package Maps is new Ada.Containers.Indefinite_Ordered_Maps (Keys, Stored);
package Sets is new Ada.Containers.Indefinite_Ordered_Sets (Stored);
package Vecs is new Ada.Containers.Indefinite_Vectors (Positive, Stored);

type Vector is new Vecs.Vector with null record;

-------------------
-- Conversions --
-------------------

end AAA.Containers.Suite;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions src/aaa-filesystem.adb → aaa_base/src/aaa-filesystem.adb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
with AAA.Debug;
with AAA.Processes;
with AAA.Strings;

with Ada.Numerics.Discrete_Random;
Expand Down Expand Up @@ -51,19 +52,18 @@ package body AAA.Filesystem is
procedure Ensure_Deletable (Path : String) is
use Ada.Directories;
use GNAT;
OK : Boolean := False;
Args : OS_Lib.Argument_List_Access;
Args : Strings.Vector;
Result : Processes.Result;
begin
if Exists (Path) and then
Kind (Path) = Directory and then
OS_Lib.Directory_Separator = '\'
then
Args := OS_Lib.Argument_String_To_List ("-R /D /S " & Path & "\*");
Args := Strings.Split ("-R /D /S", ' ').Append (Path & "\*");

OS_Lib.Spawn ("attrib", Args.all, OK);
OS_Lib.Free (Args);
Result := Processes.Run (Strings.To_Vector ("attrib").Append (Args));

if not OK then
if Result.Exit_Code /= 0 then
raise Program_Error with "failed to change attributes of " & Path;
end if;
end if;
Expand Down
File renamed without changes.
26 changes: 21 additions & 5 deletions src/aaa-processes.adb → aaa_base/src/aaa-processes.adb
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,27 @@ package body AAA.Processes is
-- & Command & " " & Arguments.Flatten
-- & " > " & Name.all);

Spawn (Program_Name => Command,
Args => Arg_List,
Output_File_Descriptor => File,
Return_Code => Exit_Code,
Err_To_Out => Err_To_Out);
declare
Full_Path_Ptr : GNAT.OS_Lib.String_Access
:= GNAT.OS_Lib.Locate_Exec_On_Path (Command);
Full_Path : constant String :=
(if Full_Path_Ptr /= null
then Full_Path_Ptr.all
else "");
begin
if Full_Path = "" then
raise Constraint_Error with
"Executable not found: " & Command;
else
GNAT.OS_Lib.Free (Full_Path_Ptr);
end if;

Spawn (Program_Name => Full_Path,
Args => Arg_List,
Output_File_Descriptor => File,
Return_Code => Exit_Code,
Err_To_Out => Err_To_Out);
end;

Close (File); -- Can't raise
Read_Output;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions aaa_base/tests/aaa_tests.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
with "config/aaa_tests_config.gpr";
with "config/aaa_tests_list_config.gpr";

project Aaa_Tests is
for Source_Dirs use ("src/", "common/", "config/");
for Object_Dir use "obj/" & Aaa_Tests_Config.Build_Profile;
for Create_Missing_Dirs use "True";
for Exec_Dir use "bin";
for Main use Aaa_Tests_List_Config.Test_Files;

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

package Binder is
for Switches ("Ada") use ("-Es"); -- Symbolic traceback
end Binder;
end Aaa_Tests;
12 changes: 12 additions & 0 deletions aaa_base/tests/alire.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name = 'aaa_tests'
description = ''
version = '0.0.0-test'

[[depends-on]]
aaa = '*'

[[pins]]
aaa = { path = '..' }

[build-profiles]
"*" = "validation"
3 changes: 3 additions & 0 deletions aaa_base/tests/common/aaa_tests-strings.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package Aaa_Tests.Strings is

end Aaa_Tests.Strings;
12 changes: 12 additions & 0 deletions aaa_base/tests/common/aaa_tests.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package body Aaa_Tests is

------------
-- Assert --
------------

procedure Assert (Cond : Boolean; Text : String) is
begin
pragma Assert (Cond, Text);
end Assert;

end Aaa_Tests;
5 changes: 5 additions & 0 deletions aaa_base/tests/common/aaa_tests.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package Aaa_Tests is

procedure Assert (Cond : Boolean; Text : String);

end Aaa_Tests;
20 changes: 20 additions & 0 deletions aaa_base/tests/config/aaa_tests_config.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Configuration for aaa_tests generated by Alire
pragma Restrictions (No_Elaboration_Code);
pragma Style_Checks (Off);

package Aaa_Tests_Config is
pragma Pure;

Crate_Version : constant String := "0.0.0-test";
Crate_Name : constant String := "aaa_tests";

Alire_Host_OS : constant String := "linux";

Alire_Host_Arch : constant String := "x86_64";

Alire_Host_Distro : constant String := "ubuntu";

type Build_Profile_Kind is (release, validation, development);
Build_Profile : constant Build_Profile_Kind := validation;

end Aaa_Tests_Config;
Loading