go: Bunch of fixes when using excludedPackages and other bits
Few things going on in this commit:
Do not print "Building subPakage $pkg" message if actually going to skip the
package. This was confusing to me when I was trying to figure out how to set
excludedPackages and seeing the "Building subpackage $pkg" messages for
packages I wanted to skip. Turns out this messages was being printed before
checking if we actually wanted to build the package and not necessarily that my
excludedPackages was wrong.
This commit also does some setup outside the buildGoDir function so that we
avoid checking `excludedPackages` for every package and cut down the number
of grep calls by half since we always want at least one grep for the default
excludedPackages, might as well just add to the patterns being checked.
Finally, adds documentation for usage of excludedPackages and subPackages. I
had to read the implementation to figure out how to correctly use these
function arguments since there was no documentation and different uses in the
code base. So this commit documents usage of the arguments.
This is a port of 8b5a7940b0
This commit is contained in:
parent
359449a284
commit
31102e0753
1 changed files with 10 additions and 2 deletions
|
@ -261,13 +261,20 @@ let
|
|||
buildPhase = attrs.buildPhase or ''
|
||||
runHook preBuild
|
||||
|
||||
exclude='\(/_\|examples\|Godeps\|testdata'
|
||||
if [[ -n "$excludedPackages" ]]; then
|
||||
IFS=' ' read -r -a excludedArr <<<$excludedPackages
|
||||
printf -v excludedAlternates '%s\\|' "''${excludedArr[@]}"
|
||||
excludedAlternates=''${excludedAlternates%\\|} # drop final \| added by printf
|
||||
exclude+='\\|'"$excludedAlternates"
|
||||
fi
|
||||
exclude+='\)'
|
||||
|
||||
buildGoDir() {
|
||||
local d; local cmd;
|
||||
cmd="$1"
|
||||
d="$2"
|
||||
. $TMPDIR/buildFlagsArray
|
||||
echo "$d" | grep -q "\(/_\|examples\|Godeps\|testdata\)" && return 0
|
||||
[ -n "$excludedPackages" ] && echo "$d" | grep -q "$excludedPackages" && return 0
|
||||
local OUT
|
||||
if ! OUT="$(go $cmd $buildFlags "''${buildFlagsArray[@]}" ''${tags:+-tags=${lib.concatStringsSep "," tags}} ''${ldflags:+-ldflags="$ldflags"} -v -p $NIX_BUILD_CORES $d 2>&1)"; then
|
||||
if echo "$OUT" | grep -qE 'imports .*?: no Go files in'; then
|
||||
|
@ -308,6 +315,7 @@ let
|
|||
export NIX_BUILD_CORES=1
|
||||
fi
|
||||
for pkg in $(getGoDirs ""); do
|
||||
grep -q "$exclude" <<<$pkg && continue
|
||||
echo "Building subPackage $pkg"
|
||||
buildGoDir install "$pkg"
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue