New `alr with --versions` for version-related info of dependencies (#464)
* New `alr with --versions` for version-related info
This new version focuses on showing: which constraints were found for each
dependency, which version was used to fulfill them, and what's the latest
existing version for a crate (hence pointing to possible wanted updates).
Move ASCII graph to `--graph` switch, and add a `--tree` alternative & fallback (#465)
* New `alr with --tree`, `alr show --tree` switch
Prints dependency graph in tree form, as an alternative to the ascii-art plots
that 1) not always will be available, depending in libgraph-easy-perl and 2)
quickly become big and broken.
* Move ASCII graph to dedicated --graph switch
Previously, it was always attempted to be shown with `--solve`, which could be
an unnecessary pollution for an otherwise useful command.
Set up environment before post-fetch actions (#456)
* Alire.Environment: take release paths from a Root
The path lookup has three levels:
1. For the root release, the own root folder
2. For a regular release, the dependencies folder "/" release unique folder
3. For a pinned softlink, the absolute path of the softlink
The root contains the solution which in turn contains the softlinks, so the
query for the path can be directly made to the root.
* Set up build env before deploying dependencies
* Tests for softlink nested path and env export
* Review fixes
* Alire.Environment.Load: Remove unused parameter
This flies by CE but is detected by FSF (?)
* Alire.Roots: move expression functions to body
There's some bug manifesting when a lot of code is in the spec in which the
linker complaints about missing references.
* Spelling fixes
* Updated new tests index versions
* Rename dir_separator/path_separator to match GNAT...
... in the Python testsuite
* Remove trailing '/' separator in extra prj paths
This is to match the output of full path normalization by Ada.Directories.
Rework Solutions.Diffs internals to use States (#457)
* Rework Solutions.Diffs internals to use States
Now that the Solution type stores all relevant information via
Dependencies.States, making the diffs directly from the solution is both
simpler, more maintainable and more accurate.
implementation of an automatic gpr file with (#458)
* First prototype implementation of an automatic gpr file with
* Add user query and config option for Auto-gpr-with
* Introduce Boolean properties
* Alire.Properties.Labeled: check TOML_Kind for labels
* auto-gpr-with: add crate entry to disable auto-gpr-with feature
* testsuite: allow custom indexes to reference fixtures/crates/
This removes duplication of several sources and archives.
* Bump index version to 0.3 for auto-gpr-with feature
* auto-gpr-with: do not add default project file for extern crates
* Bump alire-index in CI scripts
* tests/workflows/auto-gpr-with: rename test crate to avoid conflicts with scripts
* Review fixes
* tests/get/external-tool-dependency: make the test more robust
On Windows when using msys2, the make seen by alr can be different than
the one seen from the testsuite scripts. The means that the current way
to identify make's version will fail in some cases.
This patch introduces a different way to workaround the different
version numbers of make.
Testsuite: canonicalize line endings in "alr" outputs (#460)
A recent e3-core update changed the behavior of e3.os.process.Run's
behavior regarding line endings, which are now left unchanged. This
creates discrepancies in process outputs depending on the platform.
Show linked paths and per-release dependencies (#453)
In the graph section of the solution printout, the concrete dependency for each
release that brings in another release is now shown. This may help in
understanding why a release is chosen, particularly when there are different
restrictions on a same crate introduced by different releases.
For the new linked folders with alire metadata, the source folder is shown in
the releases section. Otherwise, such source folders are listed in the
externals section without a concrete release (as we cannot determine a version
for them).
A new test shows this feature and also shows that the solver is able to
downgrade a dependency whenever this is needed to obtain a complete solution.
Detect and use Alire metadata found in pinned directory (#450)
* Detect crate at linked dir and use its deps/paths
If a path given to with/pin --use contains a loadable alire workspace (i.e.,
for a crate manually initialized, or retrieved with `get`), the release found
there will be used to retrieve additional dependencies, and its project paths
will also be used.
* `with` directory with autodetection of crate
When adding a dependency as a pinned dir, and the target dir is a regular Alire
crate, we can autodetect the crate we are adding as dependency. In that case
the command becomes `alr with --use <path>`. This can also be useful in the
future for remote URLs that will also provide the crate being retrieved.
While this has no implications for the crate being pinned, any regularly solved
crates will be missing afterwards unless the index is loaded pre-pinning.
Allow incomplete solutions in relevant commands (#451)
* Allow get with missing deps (with confirmation)
Up to now, trying to retrieve a release with non-solvable dependencies resulted
in an opaque "can't get a solution", leaving the only resort of doing an `alr
get --only`. With this patch, the best partial solution found is used and
displayed. The user can accept a partial deployment, understanding that the
build will fail unless missing dependencies are manually provided.
It would be relatively easy to allow the user to reject the proposal and
continue seeing other incomplete solutions (as, e.g., `aptitude` does) until
one of them is selected.
* Allow pinning to unavailable versions
The user may want for some reason to specify versions that are not in the
index, for work-in-progress releases or when switching between several indexes.
Instead of blocking him entirely, the incomplete solution is displayed and he
can accept it regardless. Forcing is required when not interactive.
* Allow update to complete with incomplete solution
When the solution is already incomplete we emit a warning to remind the user
about this, but we need not to err, since there are no changes to the solution,
or we might find a less incomplete one.
Also added a test for the behavior when trying to update a pinned version
* Allow withing dependencies with incomplete solution
This is the last of the commands that previously erred out with "Cannot solve
dependencies". Now, it can be forced into accepting any dependency as long as
the user is OK with having an incomplete solution.
* Remove deprecated Alire.Solutions.Valid
Instead, .Is_Complete or .Composition should be used for better granularity.
Is_Complete is more stringent than before (hints make the solution incomplete),
but the new flexibility to work with incomplete solutions makes the difference
secondary; the user is less restricted than before.
* Minor fixes to tests for Is_Complete change
By making solutions with any external (including hints) incomplete, it is
necessary to force a few commands in the tests that before succeeded normally.
Some tests that checked for exact text were now failing due to the extra
information/interaction caused by incomplete solutions.
The stderr warning on incomplete solutions in setenv also requires fixing its
output.
This bug would manifest when a regular release other than the root one in the
solution depends on a linked dependency. With the proposed change we should be
covered for any future dependency kind that is not fulfilled by a regular release.
Ability to use a local folder to fulfill a dependency (#439)
* New Alire.Externals.Softlink to support WIP crates
* Implement alr with --url to add/pin in one step
A dependency can now be added simultaneously with a target directory that
fulfils it. Minimal check of the folder existing is performed; the buildability
of the whole is now the responsibility of the user.
* Implement softlinks in Alr.Dependencies.States
The placeholder `linked` fulfilment is now properly implemented to
hold/load/save the information about a directory to be used to fulfill a
dependency.
* Implement softlinks in Alire.Solutions.Solution
Add a Alire.Solutions.Linking subprogram that includes a linked dependency into
a solution.
* Modify solver to use soflinks for dependencies
When a softlink for the dependency being solved exists in the starting
solution, that dependency can be considered fulfilled without further ado.
* Implement `alr pin --url` to pin existing dep
This is the delayed counterpart to `alr with --url`; i.e., users can add the
dependency normally with `alr with` and later decide to pin it to a folder with
`alr pin`, without needing to remove it completely first with `alr with --del`.
We present pinning to versions and to folders to users under the same idea of
pinning. Internally, alr distinguishes between pinning (to versions) and
linking (to URLs). Currently only local paths can be used for links, but in the
future we may add remote files to fetch or repositories to clone.
* New Alire.URI to centralize URL knowledge
* Include pinned dirs' paths in project paths
The logic of collecting all necessary paths has been moved from Alr.Build_Env
to Alire.Roots.Project_Paths. A Root was already necessary to collect the
paths, and furthermore the root has all the necessary information: the root
release and the complete solution, which includes releases and linked dirs.
To make Roots self-contained, the platform properties are copied during startup
to Alire.Root. This is a temporary measure until these properties are
refactored from Alr into Alire.
* New tests for within/pinning to folders
* Testsuite fixes for minor changes in output
Information shown for external (lacking a release) dependencies is more
comprehensive now, showing transitivity, pin information, hinting status.
The subprograms in Alr.Checkout, which disappears, are refactored into
Alire.Workspace. This will enable better logic for retrieval/updates, without
the need to internally reroute to Alr.Commands.Update, which causes some
unrelated side-effects (like re-resolving even when unnecessary).
Minor change: now all crates leave a trace in the form of their dependency
folder within the cache, even if this folder is empty for dependencies whose
deployment does not require such a folder. This is more homogeneous and might
be useful in the future to store status about dependency deployment
completeness right there.
A couple tests are fixed to account for minor output changes and a change in
behavior between Python 2 and 3 (not sure why it not arose initially).
Fabien Chouteau [Mon, 15 Jun 2020 10:27:43 +0000 (12:27 +0200)]
Alire.Config: add support of built-in options (#446)
* Alire.Config: add support of built-in options
Built-in options have a type that is checked when setting or loading a configuration file.
They also have a short help text to explain their meaning and usage.
Remove some unnecessary code after Solution changes (#431)
The solution stores platform-dependent releases, hence the Environment
parameter is not needed at the moment of writing the corresponding lockfile.
A stray exception handler in Alr.Commands.Withing was unneeded and masking as a
regular error some Constraint_Errors that should escalate to the main handler
to be reported as unexpected internal errors.
Dead code in Alire.Utils that is not going to be useful again has been removed.
Safeguards for changes in lockfile/crate format (#436)
If the lockfile is not loadable we presume it is in an old format. In this case
we recreate it from scratch, which entails the loss of any stored pins. If the
alire/crate.toml file is not loadable we advice the user to recreate the
workspace from scratch.
Note that both crate.toml and crate.lock use the index format to store
releases. Hence, any change in index format may impact these files. While the
lockfile is not that problematic, for the crate.toml file we have no easy
workaround since we cannot know to which crate the workspace belongs.
There are possible mitigations but as long as we don't have stable releases the
complexity/benefit ratio is unclear. If we eventually make the crate.toml file
only manually editable that could also impact how to deal with this issue, so
not doing anything about it yet.
Internal enhancements to Solution and Dependency states (#429)
* Remove obsolete Alire.Dependencies.Unavailable
This fake dependency was used in the old Ada index to store an unavailable
dependency. There is no longer any use for this constant.
* Image functions for newly tagged Alire.Milestones
Make the type tagged to gain dot notation, and add [TTY_]Image subprograms for
simpler printing elsewhere.
* New Alire.Dependencies.States type
This type is used to store the actual way in which a dependency was solved. All
possibilities are stored, which allows to properly cache a solution, and detect
changes in solutions across operations that modify the solution: pinning,
withing, updating...
* New Alire.Dependencies.States.Maps
A crate name -> dep state mapping which is at the core of the cached Solution,
with a couple of functional-style modifiers for use in expression functions.
* Remove pinning info from Releases
This information is now stored in the dependency State where it better belongs.
This way it doesn't matter if the solution contains a release for the pinned
dependency; the pinning information is always preserved.
* Reworked Solution internals to use States
(Doesn't build.) Changes to Alire.Solutions to use the new dependency states.
With these changes there is no loss of information when going from a valid to
an invalid solution (information about partial solutions is stored the same as
for complete solutions), which enables down the road better feedback to users
and simpler implementation of other improvements, like pinning of crates to
local folders.
* Solver improvements based on new dependency states
(Only alire-solver.adb builds.) With these changes, the solver needs not to
check the complete validity of a solution once all dependencies are processed
(which is an expensive test), because validity is guaranteed for any partial
solution (that is, no incompatible release can make into the solution). Also,
while the solver was previously complete in regard to valid solutions (with
releases or hints), now it is also complete for invalid solutions (those
missing releases and hints for some dependency). This means that the solver
will return the "best" incomplete solution when a complete one cannot be found.
* Tweaks to achieve build with new Solution
A few minor changes due to changes in the Solution public methods are needed
here and there, without functional implications.
* Tweaks for testsuite compliance
A few changes are needed to ensure the same output as before is produced, or to
adapt a few tests to minimal output changes caused by the homogenization of
dependency images.
* Make Alire.Crate_Name a proper private type
Our Dynamic_Predicate in the publicly defined Crate_Name as new String is
rejected by GNAT 9, and I couldn't find a workaround short of making all of
Alire.* non-preelaborable. Defining privately Crate_Name as new String in turn
caused numerous errors in child packages due to some mixing between the public
and private views. In the end, making it a record was the simplest change
without introducing the risk of missing checks (as if we had made it simply a
subtype of String).
So, given the change, I bit the bullet to make it tagged and provide a couple
of convenience functions.
This global modifier is available in Alire.Force. Other candidate locations,
like Alire.Config, Alire.Errors, Alire.Utils.User_Input cannot be used because
they bring in non-preelaborable units and it snowballs from there.
The recommended usage is through Alire.Recoverable_Error, which will warn or
raise appropriately depending on the flag. The boolean Alire.Force is also
available for less straightforward situations (interaction defaults for
example).
Exit code fix for `get --build` with build failure (#428)
We were not erroring if the build failed, which is counterintuitive. We now
require successful retrieval and build to exit with code 0. A test to verify
this situation has been added.
Remove unnecessary forced exit from `Alr.Main` (#425)
Historically, something was causing an extra empty line in the output of every
command. At some point this has been fixed inadvertently, so we can remove the
forced exit call, which in turn will allow finalization to complete normally,
if it were ever needed.
The images for CentOS (unsupported Linux) and debian+community have been
upgraded to use GNAT CE 2020. A few minor errors newly detected have been
fixed, related to anonymous access types and explicit aliased arguments.
Show changes to dependencies/solutions in relevant commands (#397)
* Show dependency changes in applicable commands
By relying on the lockfile we can easily summarize changes to the user. There
are no functional changes, except for some no-op updates that can now be omitted
altogether instead of simply blindly redeploying the same exact dependencies.
Fix: use local dependencies in `alr show --solve` (#400)
When the command was run for the local workspace (without explicit crate name),
the dependencies were being taken from the index instead of the local release.
This also manifested as not solvable dependencies for local releases without a
counterpart in the index.
This message is generally not wanted in the final output, since it's used only
to signal alr is not dead/stuck, but busy. Also, it must be entirely removed
from some commands like `alr setenv` or the output is no longer parseable.
* Detect output redirection to adjust logging
* Switch --no-tty to disable control chars in output
Windows CI: Force the installation for tar in msys2
The tar executable provided by Git install in GitHub Action Windows VM
doesn't seem to work. This patch forces the installation of tar in msys2
which is going to be used first by alr.
Alire.Origins.Deployers.System.Pacman: fix version detection
The dash in pacman version is does not correspond to sementic versioning definition.
It is the release number that comes from fixes in the build recipe.