Skip to content

Commit 5e533d5

Browse files
committed
Template registration
1 parent fc19c09 commit 5e533d5

10 files changed

+208
-5
lines changed

alire.gpr

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ library project Alire is
2525

2626
for Library_Name use "alire";
2727

28-
-- Set OS-dependent source files
28+
-- OS-independent source files
2929

30-
Src_Dirs := ("src/alire");
30+
Src_Dirs := ("src/alire",
31+
"src/templates");
3132

33+
-- OS-dependent source files
3234
case Alire_Common.Host_Os is
3335
when "freebsd" => Src_Dirs := Src_Dirs & ("src/alire/os_freebsd");
3436
when "openbsd" => Src_Dirs := Src_Dirs & ("src/alire/os_openbsd");

src/alire/alire-templates.adb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
with r;
2+
3+
package body Alire.Templates is
4+
5+
procedure Register (File : Relative_Path;
6+
Bytes : Data;
7+
Stamp : Ada.Calendar.Time) is null;
8+
9+
begin
10+
r.Init;
11+
end Alire.Templates;

src/alire/alire-templates.ads

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
with Ada.Calendar;
2+
with Ada.Streams;
3+
4+
package Alire.Templates with Elaborate_Body is
5+
6+
type Data is access constant Ada.Streams.Stream_Element_Array;
7+
8+
procedure Register (File : Relative_Path;
9+
Bytes : Data;
10+
Stamp : Ada.Calendar.Time);
11+
-- Register an embedded template to make it available for use
12+
13+
end Alire.Templates;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
-- AWSRes v1.3 - Generated on March 09 2025 at 11:20:21
3+
4+
pragma Style_Checks (Off);
5+
6+
with Ada.Streams;
7+
8+
package r.templates_crate_bin_alire_toml is
9+
10+
use Ada.Streams;
11+
12+
Content : aliased constant Stream_Element_Array :=
13+
(31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 117, 80, 203, 106,
14+
3, 49, 12, 188, 235, 43, 140, 239, 107, 182, 61, 55, 165, 185,
15+
53, 144, 165, 16, 66, 122, 8, 75, 209, 122, 135, 196, 197, 143,
16+
96, 107, 211, 124, 126, 247, 209, 80, 122, 232, 65, 7, 205, 104,
17+
70, 26, 69, 14, 80, 43, 165, 109, 102, 193, 71, 231, 162, 166,
18+
30, 197, 102, 119, 17, 151, 226, 196, 104, 186, 34, 151, 159, 166,
19+
54, 15, 166, 174, 122, 92, 53, 17, 15, 114, 78, 185, 140, 240,
20+
81, 175, 61, 62, 57, 246, 57, 169, 157, 81, 77, 42, 130, 164,
21+
91, 10, 236, 162, 140, 133, 255, 167, 212, 19, 223, 193, 151, 48,
22+
35, 198, 166, 240, 252, 87, 92, 249, 116, 114, 113, 241, 8, 119,
23+
115, 239, 44, 98, 193, 132, 234, 102, 179, 87, 111, 59, 181, 190,
24+
176, 61, 163, 122, 52, 181, 122, 223, 236, 95, 213, 118, 123, 104,
25+
42, 220, 44, 230, 48, 154, 190, 208, 21, 39, 88, 82, 9, 159,
26+
102, 199, 150, 8, 55, 216, 65, 184, 243, 88, 118, 252, 62, 99,
27+
36, 143, 130, 34, 45, 229, 33, 142, 167, 76, 82, 246, 46, 67,
28+
211, 55, 56, 52, 5, 204, 58, 1, 0, 0);
29+
30+
end r.templates_crate_bin_alire_toml;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
-- AWSRes v1.3 - Generated on March 09 2025 at 11:20:21
3+
4+
pragma Style_Checks (Off);
5+
6+
with Ada.Streams;
7+
8+
package r.templates_crate_bin_crate_bin_gpr is
9+
10+
use Ada.Streams;
11+
12+
Content : aliased constant Stream_Element_Array :=
13+
(31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 109, 145, 193, 110,
14+
131, 48, 16, 68, 239, 124, 197, 202, 135, 42, 145, 74, 242, 1,
15+
156, 18, 146, 67, 15, 81, 43, 209, 187, 101, 204, 66, 54, 33,
16+
24, 173, 141, 210, 254, 125, 109, 8, 70, 105, 203, 145, 157, 153,
17+
55, 35, 223, 201, 157, 65, 104, 211, 213, 212, 108, 53, 43, 135,
18+
178, 164, 78, 78, 63, 54, 77, 207, 34, 75, 122, 54, 23, 212,
19+
14, 242, 241, 188, 167, 14, 200, 38, 9, 0, 212, 134, 161, 48,
20+
3, 107, 148, 7, 98, 11, 131, 69, 88, 9, 203, 122, 43, 94,
21+
99, 168, 88, 103, 179, 246, 189, 12, 57, 65, 59, 74, 133, 41,
22+
47, 91, 1, 47, 75, 176, 204, 39, 238, 126, 160, 182, 146, 31,
23+
108, 106, 106, 49, 218, 115, 198, 160, 59, 145, 181, 212, 53, 11,
24+
82, 124, 242, 128, 34, 202, 142, 95, 168, 23, 134, 95, 179, 156,
25+
78, 202, 151, 159, 90, 198, 173, 27, 85, 149, 161, 99, 208, 244,
26+
74, 95, 85, 131, 144, 155, 91, 239, 201, 28, 134, 194, 248, 5,
27+
247, 1, 107, 53, 180, 78, 22, 119, 114, 250, 140, 214, 167, 236,
28+
42, 37, 214, 99, 226, 159, 13, 254, 36, 231, 156, 104, 25, 155,
29+
96, 87, 69, 194, 51, 215, 219, 171, 223, 212, 127, 105, 43, 145,
30+
30, 173, 111, 13, 105, 10, 80, 124, 223, 74, 211, 146, 6, 199,
31+
74, 99, 233, 179, 102, 202, 148, 247, 204, 120, 235, 172, 83, 109,
32+
251, 12, 217, 177, 163, 90, 105, 23, 40, 155, 200, 176, 103, 197,
33+
248, 120, 191, 16, 247, 176, 250, 188, 113, 194, 188, 56, 75, 126,
34+
0, 16, 76, 180, 88, 70, 2, 0, 0);
35+
36+
end r.templates_crate_bin_crate_bin_gpr;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
-- AWSRes v1.3 - Generated on March 09 2025 at 11:20:21
3+
4+
pragma Style_Checks (Off);
5+
6+
with Ada.Streams;
7+
8+
package r.templates_crate_bin_gitignore is
9+
10+
use Ada.Streams;
11+
12+
Content : aliased constant Stream_Element_Array :=
13+
(31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 211, 207, 79, 202,
14+
210, 231, 210, 79, 202, 204, 3, 146, 137, 57, 153, 69, 169, 64,
15+
58, 57, 63, 47, 45, 51, 93, 159, 11, 0, 187, 164, 100, 83,
16+
29, 0, 0, 0);
17+
18+
end r.templates_crate_bin_gitignore;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
-- AWSRes v1.3 - Generated on March 09 2025 at 11:20:21
3+
4+
pragma Style_Checks (Off);
5+
6+
with Ada.Streams;
7+
8+
package r.templates_crate_bin_src_crate_bin_adb is
9+
10+
use Ada.Streams;
11+
12+
Content : aliased constant Stream_Element_Array :=
13+
(31, 139, 8, 0, 0, 0, 0, 0, 0, 3, 43, 40, 202, 79,
14+
78, 77, 41, 45, 74, 85, 112, 46, 74, 44, 73, 141, 119, 202,
15+
204, 83, 200, 44, 230, 74, 74, 77, 207, 204, 227, 82, 80, 80,
16+
200, 43, 205, 201, 177, 230, 74, 205, 75, 65, 200, 91, 115, 1,
17+
0, 81, 226, 84, 168, 53, 0, 0, 0);
18+
19+
end r.templates_crate_bin_src_crate_bin_adb;

src/templates/r.adb

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
pragma Warnings (Off);
2+
3+
-- AWSRes v1.3 - Generated on March 09 2025 at 11:20:21
4+
5+
pragma Style_Checks (Off);
6+
7+
with r.templates_crate_bin_crate_bin_gpr;
8+
with r.templates_crate_bin_src_crate_bin_adb;
9+
with r.templates_crate_bin_gitignore;
10+
with r.templates_crate_bin_alire_toml;
11+
12+
with Alire.Templates;
13+
with GNAT.Calendar;
14+
15+
package body r is
16+
17+
Initialized : Boolean := False;
18+
19+
procedure Init is
20+
use Alire.Templates;
21+
begin
22+
if not Initialized then
23+
Initialized := True;
24+
Register
25+
("templates/crate_bin/crate_bin.gpr.gz",
26+
r.templates_crate_bin_crate_bin_gpr.Content'Access,
27+
GNAT.Calendar.Time_Of (2025, 03, 09, 09, 27, 18, 0.0));
28+
Register
29+
("templates/crate_bin/src/crate_bin.adb.gz",
30+
r.templates_crate_bin_src_crate_bin_adb.Content'Access,
31+
GNAT.Calendar.Time_Of (2025, 03, 09, 09, 27, 18, 0.0));
32+
Register
33+
("templates/crate_bin/.gitignore.gz",
34+
r.templates_crate_bin_gitignore.Content'Access,
35+
GNAT.Calendar.Time_Of (2025, 03, 09, 09, 27, 18, 0.0));
36+
Register
37+
("templates/crate_bin/alire.toml.gz",
38+
r.templates_crate_bin_alire_toml.Content'Access,
39+
GNAT.Calendar.Time_Of (2025, 03, 09, 09, 27, 18, 0.0));
40+
end if;
41+
end Init;
42+
43+
begin
44+
Init;
45+
end r;

src/templates/r.ads

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
-- AWSRes v1.3 - Generated on March 09 2025 at 11:20:21
3+
4+
package r is
5+
6+
procedure Init;
7+
-- Register all resources files
8+
9+
end r;

support/embedder/embedder.sh

+23-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ trap 'echo "Interrupted" >&2 ; exit 1' INT
99
set -o errexit
1010
set -o nounset
1111

12+
# Location of generated files
13+
generated=../../src/templates
14+
1215
function cleanup {
1316
# Delete softlink if it is indeed a softlink
1417
[ -L templates ] && rm -f templates
@@ -38,8 +41,8 @@ export PATH+=":$PWD"
3841

3942
# Clean up old resources
4043
[ -L templates ] && rm -f templates
41-
rm -rf ../../src/templates
42-
mkdir -p ../../src/templates
44+
rm -rf $generated
45+
mkdir -p $generated
4346

4447
# Create a softlink to avoid .. paths that confuse awsres
4548
ln -s ../../templates templates
@@ -60,11 +63,28 @@ ln -s ../../templates templates
6063

6164
awsres \
6265
-a \
63-
-o ../../src/templates \
66+
-o $generated \
6467
-R \
6568
-r r \
6669
-q \
6770
-z \
6871
templates
6972

73+
# We use actual file names rather than hashes so changes in version control, and
74+
# detecting missing resources, is easier.
75+
76+
# Fix bad package names (two __ in a row)
77+
find $generated -type f -exec sed -i 's/__/_/g' {} \;
78+
# Likewise, but for file names
79+
find $generated -type f -name '*__*' -exec \
80+
bash -c 'mv "$1" "${1//__/_}"' _ {} \;
81+
82+
# Since we don't want to depend on superheavy AWS, we replace calls to it with
83+
# our own registering procedure.
84+
find $generated -type f -exec \
85+
sed -i 's/AWS\.Resources\.Embedded/Alire.Templates/g' {} \;
86+
87+
# Silence warnings in generated registering code
88+
sed -i '1s/^/pragma Warnings (Off);\n/' $generated/r.adb
89+
7090
echo "Resources created successfully"

0 commit comments

Comments
 (0)