Commit graph

11 commits

Author SHA1 Message Date
Vincent Ambo
5649c75d01 fix(external): Fix "inverted" local dependencies
Usually in large packages the root depends on one or more
sub-packages (or there is no root), but some projects (e.g.
golang.org/x/oauth2) do it the other way around.

This fix adds compatibility for both ways.
2019-12-13 12:10:32 +00:00
Vincent Ambo
d8ef203f78 feat(external): Support foreign dependencies in external packages
Users can supply a list of foreign dependencies in calls to
buildGo.external. These are now appropriately inserted into packages
that *need them* and no further, resolving issues with complex
internal recursion in some repositories!
2019-12-13 00:39:53 +00:00
Vincent Ambo
218b81c709 fix(external): Skip folders with "no buildable Go files"
This error is returned by the build analysis logic if the target
package does not have any relevant Go files, which might be the case
if `+build` flags and such are used.
2019-12-13 00:39:53 +00:00
Vincent Ambo
39e73f42b2 style(external): Minor formatting fixes 2019-12-13 00:39:53 +00:00
Vincent Ambo
875628a097 feat(external): Switch between packages & programs automatically 2019-12-13 00:39:53 +00:00
Vincent Ambo
c5373a69fe feat(external): Implement builder function for externals
Implements a builder function that calls the analysis tool on the
provided source and builds up the required attribute set, including
local dependencies.
2019-12-13 00:39:53 +00:00
Vincent Ambo
bbf3a418a5 feat(external): Add fully qualified import path to analyser output
This is used by Nix to build the derivation names for individual
packages.
2019-12-13 00:39:53 +00:00
Vincent Ambo
1fd80fb201 fix(external): Correctly set names for root packages
Fixes the prefix trimming logic for package names and source files if
the source files appear in the package root (which is, unsurprisingly,
very common).
2019-12-13 00:39:53 +00:00
Vincent Ambo
b20e46d60b fix(external): Ensure findGoDirs "finds" top-level directory
Due to the lexical walk order of `filepath.Walk` the previous
directory identification logic failed under certain conditions if the
top-level directory contained Go files that showed up *after* the
first subdirectories.

To simplify the logic a set of directories is now gathered instead on
a file-level.
2019-12-13 00:39:53 +00:00
Vincent Ambo
a5473293e7 feat(external): Return references in more useable format for Nix
Sub-packages of external dependencies are traversed by Nix as a tree
of attribute sets which need to be accessed by "path". To make this
easier, the dependency analyser now returns "paths" as string lists.
2019-12-13 00:39:53 +00:00
Vincent Ambo
fb4dd76146 feat(external): Implement tool to analyse external dependencies
Adds a tool that can analyse dependencies that were not originally
meant to be built with buildGo.nix and return information that can be
used to construct appropriate Nix dependencies.

The tool will return information about package-local and foreign
dependencies separately to let Nix determine whether all required
dependencies are provided and to correctly link together sub-packages.

To avoid listing standard library imports in the dependencies, a list
of all packages in the standard library is generated statically to
allow for those to be filtered out during the analysis.

This tool is still work-in-progress.
2019-12-13 00:39:53 +00:00