Skip to content

Commit 58e09ee

Browse files
committed
cue/load: respect build tags when determining package
We should respect build tags when deciding what possible packages to choose where none is specified in the command line. Fixes #3795 Signed-off-by: Roger Peppe <[email protected]> Change-Id: I5e604eb0ac83111c5fb824c319b88eb0eede6845 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1211243 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
1 parent 8f2c89c commit 58e09ee

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

cmd/cue/cmd/testdata/script/pkg_resolution_multiple_packages_build_attr.txtar

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ stderr '^found packages "x" \(x.cue\) and "y" \(y.cue\) in ".*x"$'
1111
# build attributes.
1212

1313
cd x
14-
! exec cue eval
15-
cmp stderr $WORK/eval-x.golden
14+
exec cue eval
15+
cmp stdout $WORK/eval-x.golden
1616

1717
-- eval-all.golden --
1818
x: 5
1919
// ---
2020
x: 5
2121
-- eval-x.golden --
22-
found packages "x" (x.cue) and "y" (y.cue) in "x"
22+
x: 5
2323
-- cue.mod/module.cue --
2424
module: "mod.com"
2525
language: version: "v0.9.0"

cue/load/search.go

+4
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,10 @@ func appendExpandedUnqualifiedPackagePath(pkgPaths []resolvedPackageArg, origp s
436436
if err != nil {
437437
return nil, err
438438
}
439+
if err := shouldBuildFile(f.Syntax, tg.tagIsSet); err != nil {
440+
// Later build logic should pick up and report the same error.
441+
continue
442+
}
439443
pkgName := f.Syntax.PackageName()
440444
// 2. if pkgQual is "_", it looks for a package file with no package name.
441445
// 3. if there's a package named after ip.Qualifier it chooses that

0 commit comments

Comments
 (0)