]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.boringcrypto] go/build: satisfy the boringcrypto build tag
authorFilippo Valsorda <filippo@golang.org>
Tue, 25 Aug 2020 15:25:38 +0000 (11:25 -0400)
committerFilippo Valsorda <filippo@golang.org>
Tue, 29 Sep 2020 11:13:37 +0000 (11:13 +0000)
This will let applications target Go+BoringCrypto specific APIs cleanly.

Change-Id: I49cbe3a7f044be043f1b98c53112e5147914eaed
Reviewed-on: https://go-review.googlesource.com/c/go/+/250500
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
src/crypto/boring/boring.go
src/crypto/boring/notboring_test.go [new file with mode: 0644]
src/go/build/build.go

index 31831d64126c228878117cdcea1a0af5c5502745..19e2a0876f757d5035e43c4eb279221c2d0f7e7f 100644 (file)
@@ -6,6 +6,9 @@
 // Go+BoringCrypto. This package is available on all targets as long as the
 // Go+BoringCrypto toolchain is used. Use the Enabled function to determine
 // whether the BoringCrypto core is actually in use.
+//
+// Any time the Go+BoringCrypto toolchain is used, the "boringcrypto" build tag
+// is satisfied, so that applications can tag files that use this package.
 package boring
 
 import "crypto/internal/boring"
diff --git a/src/crypto/boring/notboring_test.go b/src/crypto/boring/notboring_test.go
new file mode 100644 (file)
index 0000000..385a384
--- /dev/null
@@ -0,0 +1,13 @@
+// Copyright 2020 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build !boringcrypto
+
+package boring_test
+
+import "testing"
+
+func TestNotBoring(t *testing.T) {
+       t.Error("a file tagged !boringcrypto should not build under Go+BoringCrypto")
+}
index 4a5da308a0c584ebe511ec7b5a1c1fc4661dcaee..0a606161ca39f896844fd53054da53882fb76d1b 100644 (file)
@@ -1697,6 +1697,7 @@ func splitQuoted(s string) (r []string, err error) {
 //     $GOARCH
 //     cgo (if cgo is enabled)
 //     !cgo (if cgo is disabled)
+//     boringcrypto
 //     ctxt.Compiler
 //     !ctxt.Compiler
 //     tag (if tag is listed in ctxt.BuildTags or ctxt.ReleaseTags)
@@ -1748,6 +1749,10 @@ func (ctxt *Context) match(name string, allTags map[string]bool) bool {
        if ctxt.GOOS == "illumos" && name == "solaris" {
                return true
        }
+       // Let applications know that the Go+BoringCrypto toolchain is in use.
+       if name == "boringcrypto" {
+               return true
+       }
 
        // other tags
        for _, tag := range ctxt.BuildTags {