Skip to content

Commit

Permalink
Merge remote-tracking branch 'alire/master' into feat/enable-shared
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Oct 4, 2023
2 parents 2953a65 + aab567a commit c8e143c
Show file tree
Hide file tree
Showing 149 changed files with 1,464 additions and 351 deletions.
24 changes: 24 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@
],
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "(gdb) Launch alr at /tmp/a/xxx",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/alr",
"args": ["-d", "-vv", "with", "libfoo"],
"stopAtEntry": true,
"cwd": "/tmp/a/xxx",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
2 changes: 1 addition & 1 deletion alire.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ windows = { ALIRE_OS = "windows" }
[[pins]]
aaa = { url = "https://github.com/mosteo/aaa", commit = "ecc38772bd4a6b469b54c62363766ea1c0e9f912" }
ada_toml = { url = "https://github.com/mosteo/ada-toml", commit = "da4e59c382ceb0de6733d571ecbab7ea4919b33d" }
clic = { url = "https://github.com/alire-project/clic", commit = "6879b90876a1c918b4e112f59c6db0e25b713f52" }
clic = { url = "https://github.com/alire-project/clic", commit = "b40b170b1561adfa99910c69e3897cc2ca441730" }
dirty_booleans = { url = "https://github.com/mosteo/dirty_booleans", branch = "main" }
diskflags = { url = "https://github.com/mosteo/diskflags", branch = "main" }
gnatcoll = { url = "https://github.com/alire-project/gnatcoll-core.git", commit = "4e663b87a028252e7e074f054f8f453661397166" }
Expand Down
10 changes: 8 additions & 2 deletions alire_common.gpr
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,18 @@ abstract project Alire_Common is
end Compiler;

package Builder is
for Switches ("Ada") use ("-s", "-j0", "-g");
for Switches ("Ada") use
("-s", -- Recompile if switches changed
"-j0" -- Full parallelism
);
end Builder;

package Binder is
for Switches ("Ada") use
( "-Es", "-g", "-static");
("-Es", -- Symbolic tracebacks
"-g", -- Keep binder generated files (for debugging?)
"-static" -- Static linking
);
end Binder;

package Ide is
Expand Down
2 changes: 1 addition & 1 deletion deps/clic
12 changes: 12 additions & 0 deletions doc/user-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ following inputs for a given release:
- Vaue of `LIBRARY_TYPE` and `<CRATE>_LIBRARY_TYPE` variables.
- Hash of dependencies

### Automatic index updates

PR [#1447](https://github.com/alire-project/alire/pull/1447)

A new configuration option, `index.auto_update`, allows setting the refresh
period of indexes. It defaults to 24 hours and the user will be asked the first
time to allow automatic updates. Setting this option to 0 will also disable
automatic updates.

When enabled, updates may happen before executing commands that rely on
indexes: `get`, `search`, `with`, etc.

### Deprecation of `dependencies.dir` in favor of `dependencies.shared`

PR [#1419](https://github.com/alire-project/alire/pull/1419)
Expand Down
34 changes: 33 additions & 1 deletion src/alire/alire-builds-hashes.adb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,27 @@ package body Alire.Builds.Hashes is
Root.Configuration.Build_Profile (Rel.Name)'Image);
end Add_Profile;

------------------
-- Add_Switches --
------------------

procedure Add_Switches is
-- List the exact switches used for compilation due to Alire, as
-- any changes in those will require regen of configuration files.
-- We add a single entry, alphabetically sorted.
Switches : AAA.Strings.Set;
Config : Crate_Configuration.Global_Config :=
Root.Configuration.all;
begin
for Switch of Config.Build_Switches (Root, Rel.Name)
loop
Switches.Include (Switch);
end loop;
Add ("switches",
Rel.Name.As_String,
Switches.To_Vector.Flatten (","));
end Add_Switches;

-------------------
-- Add_Externals --
-------------------
Expand Down Expand Up @@ -214,6 +235,7 @@ package body Alire.Builds.Hashes is

-- Add individual contributors to the hash input
Add_Profile; -- Build profile
Add_Switches; -- Exact list of build switches
Add_Configuration; -- Crate configuration variables

-- These are only relevant for shared dependencies, as they don't
Expand All @@ -222,7 +244,17 @@ package body Alire.Builds.Hashes is
if not Builds.Sandboxed_Dependencies then
Add_Externals; -- GPR externals
Add_Environment; -- Environment variables
Add_Compiler; -- Compiler version

-- In the root crate we can skip compiler detection, as it has no
-- bearing on the hash or config regeneration. This allows most
-- operations in a crate without dependencies to succeed even in
-- absence of a configured compiler. Note that for linked crates,
-- even if they don't have a proper build dir, the hash is
-- important for dependents.
if not Root.Is_Root_Release (Rel.Name) then
Add_Compiler; -- Compiler version
end if;

Add_Dependencies; -- Hash of dependencies
end if;

Expand Down
26 changes: 20 additions & 6 deletions src/alire/alire-builds.adb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ package body Alire.Builds is
is
Src : constant Absolute_Path := Paths.Vault.Path
/ Release.Deployment_Folder;
Dst : constant Absolute_Path := Builds.Path (Root, Release);
Dst : constant Absolute_Path := Builds.Path (Root,
Release,
Subdir => False);
-- In case of monorepo, the first time the repo is deployed, it will be
-- synced in its entirety.
Synced : Flags.Flag := Flags.Complete_Copy (Dst);
begin
Was_There := False;
Expand Down Expand Up @@ -87,11 +91,21 @@ package body Alire.Builds is
----------

function Path (Root : in out Roots.Root;
Release : Releases.Release)
Release : Releases.Release;
Subdir : Boolean)
return Absolute_Path
is (Builds.Path
/ (Release.Deployment_Folder
& "_"
& Root.Build_Hash (Release.Name)));
is
Base : constant Absolute_Path :=
Builds.Path
/ (Release.Deployment_Folder
& "_"
& Root.Build_Hash (Release.Name));
begin
if Subdir and then Release.Origin.Is_Monorepo then
return Base / Release.Origin.Subdir;
else
return Base;
end if;
end Path;

end Alire.Builds;
7 changes: 5 additions & 2 deletions src/alire/alire-builds.ads
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ package Alire.Builds is
-- Location of shared builds

function Path (Root : in out Roots.Root;
Release : Releases.Release)
Release : Releases.Release;
Subdir : Boolean)
return Absolute_Path;
-- Computes the complete path in which the release is going to be built
-- Computes the complete path in which the release is going to be built.
-- If Subdir and Release is in monorepo, include the extra path inside the
-- monorepo. Has no effect for ordinary releases.

end Alire.Builds;
29 changes: 29 additions & 0 deletions src/alire/alire-config-builtins.ads
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ package Alire.Config.Builtins is
-- Builtins --
--------------

-- DEPENDENCIES

Dependencies_Git_Keep_Repository : constant Builtin := New_Builtin
(Key => "dependencies.git.keep_repository",
Def => False,
Help =>
"When true, git origins are a proper git repository after deployment. "
& "Otherwise they are deployed as a plain directory.");

Dependencies_Shared : constant Builtin := New_Builtin
(Key => "dependencies.shared",
Def => True,
Expand Down Expand Up @@ -42,6 +51,26 @@ package Alire.Config.Builtins is
"When unset or true, the community index will be added " &
"automatically when required if no other index is configured.");

Index_Auto_Update : constant Builtin := New_Builtin
(Key => "index.auto_update",
Kind => Cfg_Int,
Def => "24", -- hours
Help =>
"Hours between automatic index refresh. Set to 0 to disable.");

Index_Auto_Update_Asked : constant Builtin := New_Builtin
(Key => "index.auto_update_asked",
Def => False,
Public => False,
Help => "First time we must autoupdate, we ask the user to approve");

Index_Last_Update : constant Builtin := New_Builtin
(Key => "index.last_update",
Public => False,
Kind => Cfg_Int,
Def => "0", -- seconds since epoch
Help => "Timestamp of last index auto-refresh (seconds)");

Index_Host : constant Builtin := New_Builtin
(Key => "index.host",
Kind => Cfg_String,
Expand Down
20 changes: 20 additions & 0 deletions src/alire/alire-config.adb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ package body Alire.Config is
function Get (This : Builtin_Option) return Boolean
is (DB.Get (+This.Key, Boolean'Value (+This.Def)));

---------
-- Get --
---------

function Get (This : Builtin_Option) return Config_Int
is (Config_Int'Value
(DB.Get_As_String (+This.Key, +This.Def)));

-----------------
-- Set_Locally --
-----------------
Expand Down Expand Up @@ -58,6 +66,18 @@ package body Alire.Config is
Edit.Set_Boolean (Level, +This.Key, Value);
end Set;

---------
-- Set --
---------

procedure Set (This : Builtin_Option;
Level : Config.Level;
Value : Config_Int)
is
begin
Edit.Set (Level, +This.Key, Value'Image, This.Check);
end Set;

-----------
-- Unset --
-----------
Expand Down
7 changes: 7 additions & 0 deletions src/alire/alire-config.ads
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ package Alire.Config is
-- Ordering is important, as Globals are loaded first and overridden by any
-- Local definition loaded later.

subtype Config_Int is Long_Long_Integer;

---------------
-- Built-ins --
---------------
Expand All @@ -41,6 +43,7 @@ package Alire.Config is

function Get (This : Builtin_Option) return String;
function Get (This : Builtin_Option) return Boolean;
function Get (This : Builtin_Option) return Config_Int;

procedure Set_Locally (This : Builtin_Option; Value : String);

Expand All @@ -54,6 +57,10 @@ package Alire.Config is
Level : Config.Level;
Value : Boolean);

procedure Set (This : Builtin_Option;
Level : Config.Level;
Value : Config_Int);

procedure Unset (This : Builtin_Option;
Level : Config.Level);

Expand Down
22 changes: 22 additions & 0 deletions src/alire/alire-crate_configuration.adb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ package body Alire.Crate_Configuration is

subtype Crate_Name_Set is Containers.Crate_Name_Sets.Set;

procedure Make_Switches_Map (This : in out Global_Config;
Root : in out Alire.Roots.Root;
Rel_Vect : Crate_Name_Set);
-- Prepare the list of switches that apply to a release

-- The Host info types below could be Enums instead of Strings. This would
-- have the advantage of providing users the entire list of potential
-- values. However, using enums in Ada would have a very high risk of
Expand Down Expand Up @@ -89,6 +94,23 @@ package body Alire.Crate_Configuration is
return Utils.Switches.Profile_Kind
is (This.Profile_Map (Crate));

--------------------
-- Build_Switches --
--------------------

function Build_Switches (This : in out Global_Config;
Root : in out Roots.Root;
Crate : Crate_Name)
return Utils.Switches.Switch_List
is
begin
-- Ensure they're up to date
Make_Switches_Map (This, Root,
Containers.Crate_Name_Sets.To_Set (Crate));

return This.Switches_Map (Crate);
end Build_Switches;

-----------------------
-- Build_Profile_Key --
-----------------------
Expand Down
8 changes: 8 additions & 0 deletions src/alire/alire-crate_configuration.ads
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ package Alire.Crate_Configuration is
return Utils.Switches.Profile_Kind
with Pre => This.Is_Valid;

function Build_Switches (This : in out Global_Config;
Root : in out Roots.Root;
Crate : Crate_Name)
return Utils.Switches.Switch_List
with Pre => This.Is_Valid;
-- The exact switches that apply to a crate (the ones that will be written
-- to their config .gpr files)

function Is_Default_Profile (This : Global_Config;
Crate : Crate_Name)
return Boolean;
Expand Down
Loading

0 comments on commit c8e143c

Please sign in to comment.