Skip to content

Commit

Permalink
Update for Alire 1.2 and separate demo crate (#4)
Browse files Browse the repository at this point in the history
* Update for Alire 1.2 and separate demo crate

* Rename ANSI -> AnsiAda and bump major version

* Add release configuration for standalone use

Co-authored-by: Alejandro R. Mosteo <[email protected]>
  • Loading branch information
Fabien-Chouteau and mosteo authored Jun 6, 2022
1 parent c2b5b0c commit dc770a5
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 76 deletions.
6 changes: 0 additions & 6 deletions alire.lock

This file was deleted.

4 changes: 1 addition & 3 deletions alire.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
name = "ansiada"
description = "ANSI escape sequences"
version = "0.1.1"
version = "1.0.0"

licenses = "MIT"
authors = ["Alejandro R. Mosteo"]
maintainers = ["Alejandro R. Mosteo <[email protected]>"]
maintainers-logins = ["mosteo"]

tags = ["ansi", "terminal"]

project-files = ["ansi.gpr"]
54 changes: 0 additions & 54 deletions ansi.gpr

This file was deleted.

29 changes: 29 additions & 0 deletions ansiada.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
with "config/ansiada_config.gpr";
project Ansiada is

for Library_Name use "Ansiada";
for Library_Version use Project'Library_Name & ".so." & Ansiada_Config.Crate_Version;

for Source_Dirs use ("src/", "config/");
for Object_Dir use "obj/" & Ansiada_Config.Build_Profile;
for Create_Missing_Dirs use "True";
for Library_Dir use "lib";

type Library_Type_Type is ("relocatable", "static", "static-pic");
Library_Type : Library_Type_Type :=
external ("ANSIADA_LIBRARY_TYPE", external ("LIBRARY_TYPE", "static"));
for Library_Kind use Library_Type;

package Compiler is
for Default_Switches ("Ada") use Ansiada_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 Ansiada;
19 changes: 19 additions & 0 deletions config/ansiada_config.ads
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- Configuration for ansiada generated by Alire
pragma Restrictions (No_Elaboration_Code);

package Ansiada_Config is
pragma Pure;

Crate_Version : constant String := "1.0.0";
Crate_Name : constant String := "ansiada";

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 := release;

end Ansiada_Config;
22 changes: 22 additions & 0 deletions config/ansiada_config.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- Configuration for ansiada generated by Alire
abstract project Ansiada_Config is
Crate_Version := "1.0.0";
Crate_Name := "ansiada";

Alire_Host_OS := "linux";

Alire_Host_Arch := "x86_64";

Alire_Host_Distro := "ubuntu";
Ada_Compiler_Switches := External_As_List ("ADAFLAGS", " ") &
(
"-O3" -- Optimize for performance
,"-gnatn" -- Enable inlining
,"-ffunction-sections" -- Separate ELF section for each function
,"-fdata-sections" -- Separate ELF section for each variable
);

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

end Ansiada_Config;
20 changes: 20 additions & 0 deletions config/ansiada_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* Configuration for ansiada generated by Alire */
#ifndef ANSIADA_CONFIG_H
#define ANSIADA_CONFIG_H

#define CRATE_VERSION "1.0.0"
#define CRATE_NAME "ansiada"

#define ALIRE_HOST_OS "linux"

#define ALIRE_HOST_ARCH "x86_64"

#define ALIRE_HOST_DISTRO "ubuntu"

#define BUILD_PROFILE_RELEASE 1
#define BUILD_PROFILE_VALIDATION 2
#define BUILD_PROFILE_DEVELOPMENT 3

#define BUILD_PROFILE 1

#endif
4 changes: 4 additions & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/obj/
/bin/
/alire/
/config/
11 changes: 11 additions & 0 deletions demo/alire.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name = "demo"
description = "Ansiada demo"
version = "0.1.0-dev"

executables = ["demo"]

[[depends-on]]
ansiada = "*"

[[pins]]
ansiada = { path='..' }
22 changes: 22 additions & 0 deletions demo/demo.gpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
with "config/demo_config.gpr";
project Demo is

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

package Compiler is
for Default_Switches ("Ada") use Demo_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 Demo;
23 changes: 14 additions & 9 deletions src/ansi-demo.adb → demo/src/demo.adb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
with Ada.Text_IO; use Ada.Text_IO;

procedure ANSI.Demo is
with AnsiAda; use AnsiAda;

procedure Demo is
function Pad (S : String; Len : Positive) return String is
(S & (1 .. Len - S'Length => ' '));

Expand Down Expand Up @@ -28,17 +30,19 @@ begin

Title ("PALETTE COLOR TEST (subsample)");
declare
Palette : constant array (Positive range <>) of Palette_RGB := (0, 1, 3, 5);
Palette : constant array (Positive range <>) of Palette_RGB :=
(0, 1, 3, 5);
begin
for R of Palette loop
for G of Palette loop
for B of Palette loop
for BR of Palette loop
for BG of Palette loop
for BB of Palette loop
Put (Color_Wrap (Text => "X",
Foreground => Palette_Fg (R, G, B),
Background => Palette_Bg (BR, BG, BB)));
Put (Color_Wrap
(Text => "X",
Foreground => Palette_Fg (R, G, B),
Background => Palette_Bg (BR, BG, BB)));
end loop;
end loop;
end loop;
Expand Down Expand Up @@ -68,9 +72,10 @@ begin
for BR of Palette loop
for BG of Palette loop
for BB of Palette loop
Put (Color_Wrap (Text => "X",
Foreground => Foreground (R, G, B),
Background => Background (BR, BG, BB)));
Put (Color_Wrap
(Text => "X",
Foreground => Foreground (R, G, B),
Background => Background (BR, BG, BB)));
end loop;
end loop;
end loop;
Expand Down Expand Up @@ -123,4 +128,4 @@ begin
Put (Restore);
New_Line;
Put_Line ("Test ended, check the text at top-left");
end ANSI.Demo;
end Demo;
8 changes: 4 additions & 4 deletions src/ansi.ads → src/ansiada.ads
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package ANSI with Pure is
package AnsiAda with Pure is

Reset_All : constant String;
-- Resets the device to its original state. This may include (if
Expand Down Expand Up @@ -299,9 +299,9 @@ private

function Style_Wrap (Text : String;
Style : Styles) return String is
(ANSI.Style (Style, On)
(AnsiAda.Style (Style, On)
& Text
& ANSI.Style (Style, Off));
& AnsiAda.Style (Style, Off));

function Wrap (Text : String;
Style : Styles;
Expand Down Expand Up @@ -367,4 +367,4 @@ private
function Scroll_Down (Lines : Positive) return String is
(CSI & Img (Lines) & "T");

end ANSI;
end AnsiAda;

0 comments on commit dc770a5

Please sign in to comment.