summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/util')
-rw-r--r--src/util/all_tests.go92
-rw-r--r--src/util/all_tests.json58
-rw-r--r--src/util/doc.go76
-rw-r--r--src/util/generate_build_files.py224
-rw-r--r--src/util/make_errors.go98
5 files changed, 181 insertions, 367 deletions
diff --git a/src/util/all_tests.go b/src/util/all_tests.go
index 566c3f7..49954df 100644
--- a/src/util/all_tests.go
+++ b/src/util/all_tests.go
@@ -41,6 +41,63 @@ var (
type test []string
+var tests = []test{
+ {"crypto/base64/base64_test"},
+ {"crypto/bio/bio_test"},
+ {"crypto/bn/bn_test"},
+ {"crypto/bytestring/bytestring_test"},
+ {"crypto/cipher/aead_test", "aes-128-gcm", "crypto/cipher/test/aes_128_gcm_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-128-key-wrap", "crypto/cipher/test/aes_128_key_wrap_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-256-gcm", "crypto/cipher/test/aes_256_gcm_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-256-key-wrap", "crypto/cipher/test/aes_256_key_wrap_tests.txt"},
+ {"crypto/cipher/aead_test", "chacha20-poly1305", "crypto/cipher/test/chacha20_poly1305_tests.txt"},
+ {"crypto/cipher/aead_test", "rc4-md5-tls", "crypto/cipher/test/rc4_md5_tls_tests.txt"},
+ {"crypto/cipher/aead_test", "rc4-sha1-tls", "crypto/cipher/test/rc4_sha1_tls_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-128-cbc-sha1-tls", "crypto/cipher/test/aes_128_cbc_sha1_tls_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-128-cbc-sha1-tls-implicit-iv", "crypto/cipher/test/aes_128_cbc_sha1_tls_implicit_iv_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-128-cbc-sha256-tls", "crypto/cipher/test/aes_128_cbc_sha256_tls_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-256-cbc-sha1-tls", "crypto/cipher/test/aes_256_cbc_sha1_tls_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-256-cbc-sha1-tls-implicit-iv", "crypto/cipher/test/aes_256_cbc_sha1_tls_implicit_iv_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-256-cbc-sha256-tls", "crypto/cipher/test/aes_256_cbc_sha256_tls_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-256-cbc-sha384-tls", "crypto/cipher/test/aes_256_cbc_sha384_tls_tests.txt"},
+ {"crypto/cipher/aead_test", "des-ede3-cbc-sha1-tls", "crypto/cipher/test/des_ede3_cbc_sha1_tls_tests.txt"},
+ {"crypto/cipher/aead_test", "des-ede3-cbc-sha1-tls-implicit-iv", "crypto/cipher/test/des_ede3_cbc_sha1_tls_implicit_iv_tests.txt"},
+ {"crypto/cipher/aead_test", "rc4-md5-ssl3", "crypto/cipher/test/rc4_md5_ssl3_tests.txt"},
+ {"crypto/cipher/aead_test", "rc4-sha1-ssl3", "crypto/cipher/test/rc4_sha1_ssl3_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-128-cbc-sha1-ssl3", "crypto/cipher/test/aes_128_cbc_sha1_ssl3_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-256-cbc-sha1-ssl3", "crypto/cipher/test/aes_256_cbc_sha1_ssl3_tests.txt"},
+ {"crypto/cipher/aead_test", "des-ede3-cbc-sha1-ssl3", "crypto/cipher/test/des_ede3_cbc_sha1_ssl3_tests.txt"},
+ {"crypto/cipher/aead_test", "aes-128-ctr-hmac-sha256", "crypto/cipher/test/aes_128_ctr_hmac_sha256.txt"},
+ {"crypto/cipher/aead_test", "aes-256-ctr-hmac-sha256", "crypto/cipher/test/aes_256_ctr_hmac_sha256.txt"},
+ {"crypto/cipher/cipher_test", "crypto/cipher/test/cipher_test.txt"},
+ {"crypto/cmac/cmac_test"},
+ {"crypto/constant_time_test"},
+ {"crypto/dh/dh_test"},
+ {"crypto/digest/digest_test"},
+ {"crypto/dsa/dsa_test"},
+ {"crypto/ec/ec_test"},
+ {"crypto/ec/example_mul"},
+ {"crypto/ecdsa/ecdsa_test"},
+ {"crypto/err/err_test"},
+ {"crypto/evp/evp_extra_test"},
+ {"crypto/evp/evp_test", "crypto/evp/evp_tests.txt"},
+ {"crypto/evp/evp_test", "crypto/hmac/hmac_tests.txt"},
+ {"crypto/evp/pbkdf_test"},
+ {"crypto/hkdf/hkdf_test"},
+ {"crypto/hmac/hmac_test", "crypto/hmac/hmac_tests.txt"},
+ {"crypto/lhash/lhash_test"},
+ {"crypto/modes/gcm_test"},
+ {"crypto/pkcs8/pkcs12_test"},
+ {"crypto/refcount_test"},
+ {"crypto/rsa/rsa_test"},
+ {"crypto/thread_test"},
+ {"crypto/x509/pkcs7_test"},
+ {"crypto/x509v3/tab_test"},
+ {"crypto/x509v3/v3name_test"},
+ {"ssl/pqueue/pqueue_test"},
+ {"ssl/ssl_test"},
+}
+
// testOutput is a representation of Chromium's JSON test result format. See
// https://www.chromium.org/developers/the-json-test-results-format
type testOutput struct {
@@ -197,43 +254,8 @@ func shortTestName(test test) string {
return strings.Join(args, " ")
}
-// setWorkingDirectory walks up directories as needed until the current working
-// directory is the top of a BoringSSL checkout.
-func setWorkingDirectory() {
- for i := 0; i < 64; i++ {
- if _, err := os.Stat("BUILDING.md"); err == nil {
- return
- }
- os.Chdir("..")
- }
-
- panic("Couldn't find BUILDING.md in a parent directory!")
-}
-
-func parseTestConfig(filename string) ([]test, error) {
- in, err := os.Open(filename)
- if err != nil {
- return nil, err
- }
- defer in.Close()
-
- decoder := json.NewDecoder(in)
- var result []test
- if err := decoder.Decode(&result); err != nil {
- return nil, err
- }
- return result, nil
-}
-
func main() {
flag.Parse()
- setWorkingDirectory()
-
- tests, err := parseTestConfig("util/all_tests.json")
- if err != nil {
- fmt.Printf("Failed to parse input: %s\n", err)
- os.Exit(1)
- }
testOutput := newTestOutput()
var failed []test
diff --git a/src/util/all_tests.json b/src/util/all_tests.json
deleted file mode 100644
index a6daa2f..0000000
--- a/src/util/all_tests.json
+++ /dev/null
@@ -1,58 +0,0 @@
-[
- ["crypto/aes/aes_test"],
- ["crypto/base64/base64_test"],
- ["crypto/bio/bio_test"],
- ["crypto/bn/bn_test"],
- ["crypto/bytestring/bytestring_test"],
- ["crypto/cipher/aead_test", "aes-128-gcm", "crypto/cipher/test/aes_128_gcm_tests.txt"],
- ["crypto/cipher/aead_test", "aes-128-key-wrap", "crypto/cipher/test/aes_128_key_wrap_tests.txt"],
- ["crypto/cipher/aead_test", "aes-256-gcm", "crypto/cipher/test/aes_256_gcm_tests.txt"],
- ["crypto/cipher/aead_test", "aes-256-key-wrap", "crypto/cipher/test/aes_256_key_wrap_tests.txt"],
- ["crypto/cipher/aead_test", "chacha20-poly1305", "crypto/cipher/test/chacha20_poly1305_tests.txt"],
- ["crypto/cipher/aead_test", "rc4-md5-tls", "crypto/cipher/test/rc4_md5_tls_tests.txt"],
- ["crypto/cipher/aead_test", "rc4-sha1-tls", "crypto/cipher/test/rc4_sha1_tls_tests.txt"],
- ["crypto/cipher/aead_test", "aes-128-cbc-sha1-tls", "crypto/cipher/test/aes_128_cbc_sha1_tls_tests.txt"],
- ["crypto/cipher/aead_test", "aes-128-cbc-sha1-tls-implicit-iv", "crypto/cipher/test/aes_128_cbc_sha1_tls_implicit_iv_tests.txt"],
- ["crypto/cipher/aead_test", "aes-128-cbc-sha256-tls", "crypto/cipher/test/aes_128_cbc_sha256_tls_tests.txt"],
- ["crypto/cipher/aead_test", "aes-256-cbc-sha1-tls", "crypto/cipher/test/aes_256_cbc_sha1_tls_tests.txt"],
- ["crypto/cipher/aead_test", "aes-256-cbc-sha1-tls-implicit-iv", "crypto/cipher/test/aes_256_cbc_sha1_tls_implicit_iv_tests.txt"],
- ["crypto/cipher/aead_test", "aes-256-cbc-sha256-tls", "crypto/cipher/test/aes_256_cbc_sha256_tls_tests.txt"],
- ["crypto/cipher/aead_test", "aes-256-cbc-sha384-tls", "crypto/cipher/test/aes_256_cbc_sha384_tls_tests.txt"],
- ["crypto/cipher/aead_test", "des-ede3-cbc-sha1-tls", "crypto/cipher/test/des_ede3_cbc_sha1_tls_tests.txt"],
- ["crypto/cipher/aead_test", "des-ede3-cbc-sha1-tls-implicit-iv", "crypto/cipher/test/des_ede3_cbc_sha1_tls_implicit_iv_tests.txt"],
- ["crypto/cipher/aead_test", "rc4-md5-ssl3", "crypto/cipher/test/rc4_md5_ssl3_tests.txt"],
- ["crypto/cipher/aead_test", "rc4-sha1-ssl3", "crypto/cipher/test/rc4_sha1_ssl3_tests.txt"],
- ["crypto/cipher/aead_test", "aes-128-cbc-sha1-ssl3", "crypto/cipher/test/aes_128_cbc_sha1_ssl3_tests.txt"],
- ["crypto/cipher/aead_test", "aes-256-cbc-sha1-ssl3", "crypto/cipher/test/aes_256_cbc_sha1_ssl3_tests.txt"],
- ["crypto/cipher/aead_test", "des-ede3-cbc-sha1-ssl3", "crypto/cipher/test/des_ede3_cbc_sha1_ssl3_tests.txt"],
- ["crypto/cipher/aead_test", "aes-128-ctr-hmac-sha256", "crypto/cipher/test/aes_128_ctr_hmac_sha256.txt"],
- ["crypto/cipher/aead_test", "aes-256-ctr-hmac-sha256", "crypto/cipher/test/aes_256_ctr_hmac_sha256.txt"],
- ["crypto/cipher/cipher_test", "crypto/cipher/test/cipher_test.txt"],
- ["crypto/cmac/cmac_test"],
- ["crypto/constant_time_test"],
- ["crypto/dh/dh_test"],
- ["crypto/digest/digest_test"],
- ["crypto/dsa/dsa_test"],
- ["crypto/ec/ec_test"],
- ["crypto/ec/example_mul"],
- ["crypto/ecdsa/ecdsa_test"],
- ["crypto/err/err_test"],
- ["crypto/evp/evp_extra_test"],
- ["crypto/evp/evp_test", "crypto/evp/evp_tests.txt"],
- ["crypto/evp/pbkdf_test"],
- ["crypto/hkdf/hkdf_test"],
- ["crypto/hmac/hmac_test", "crypto/hmac/hmac_tests.txt"],
- ["crypto/lhash/lhash_test"],
- ["crypto/modes/gcm_test"],
- ["crypto/pkcs8/pkcs8_test"],
- ["crypto/pkcs8/pkcs12_test"],
- ["crypto/poly1305/poly1305_test", "crypto/poly1305/poly1305_test.txt"],
- ["crypto/refcount_test"],
- ["crypto/rsa/rsa_test"],
- ["crypto/thread_test"],
- ["crypto/x509/pkcs7_test"],
- ["crypto/x509v3/tab_test"],
- ["crypto/x509v3/v3name_test"],
- ["ssl/pqueue/pqueue_test"],
- ["ssl/ssl_test"]
-]
diff --git a/src/util/doc.go b/src/util/doc.go
index 23cd5f4..540d6ca 100644
--- a/src/util/doc.go
+++ b/src/util/doc.go
@@ -48,8 +48,9 @@ type HeaderSection struct {
// Preamble contains a comment for a group of functions.
Preamble []string
Decls []HeaderDecl
- // Anchor, if non-empty, is the URL fragment to use in anchor tags.
- Anchor string
+ // Num is just the index of the section. It's included in order to help
+ // text/template generate anchors.
+ Num int
// IsPrivate is true if the section contains private functions (as
// indicated by its name).
IsPrivate bool
@@ -64,8 +65,10 @@ type HeaderDecl struct {
Name string
// Decl contains the preformatted C declaration itself.
Decl string
- // Anchor, if non-empty, is the URL fragment to use in anchor tags.
- Anchor string
+ // Num is an index for the declaration, but the value is unique for all
+ // declarations in a HeaderFile. It's included in order to help
+ // text/template generate anchors.
+ Num int
}
const (
@@ -189,6 +192,14 @@ func extractDecl(lines []string, lineNo int) (decl string, rest []string, restLi
return
}
+func skipPast(s, skip string) string {
+ i := strings.Index(s, skip)
+ if i > 0 {
+ return s[i:]
+ }
+ return s
+}
+
func skipLine(s string) string {
i := strings.Index(s, "\n")
if i > 0 {
@@ -216,9 +227,8 @@ func getNameFromDecl(decl string) (string, bool) {
}
return decl[:i], true
}
- decl = strings.TrimPrefix(decl, "OPENSSL_EXPORT ")
- decl = strings.TrimPrefix(decl, "STACK_OF(")
- decl = strings.TrimPrefix(decl, "LHASH_OF(")
+ decl = skipPast(decl, "STACK_OF(")
+ decl = skipPast(decl, "LHASH_OF(")
i := strings.Index(decl, "(")
if i < 0 {
return "", false
@@ -233,10 +243,6 @@ func getNameFromDecl(decl string) (string, bool) {
return decl[j+1 : i], true
}
-func sanitizeAnchor(name string) string {
- return strings.Replace(name, " ", "-", -1)
-}
-
func (config *Config) parseHeader(path string) (*HeaderFile, error) {
headerPath := filepath.Join(config.BaseDirectory, path)
@@ -308,7 +314,7 @@ func (config *Config) parseHeader(path string) (*HeaderFile, error) {
}
}
- allAnchors := make(map[string]struct{})
+ var sectionNumber, declNumber int
for {
// Start of a section.
@@ -324,7 +330,10 @@ func (config *Config) parseHeader(path string) (*HeaderFile, error) {
return nil, fmt.Errorf("blank line at start of section on line %d", lineNo)
}
- var section HeaderSection
+ section := HeaderSection{
+ Num: sectionNumber,
+ }
+ sectionNumber++
if strings.HasPrefix(line, commentStart) {
comment, rest, restLineNo, err := extractComment(lines, lineNo)
@@ -332,17 +341,8 @@ func (config *Config) parseHeader(path string) (*HeaderFile, error) {
return nil, err
}
if len(rest) > 0 && len(rest[0]) == 0 {
- anchor := sanitizeAnchor(firstSentence(comment))
- if len(anchor) > 0 {
- if _, ok := allAnchors[anchor]; ok {
- return nil, fmt.Errorf("duplicate anchor: %s", anchor)
- }
- allAnchors[anchor] = struct{}{}
- }
-
section.Preamble = comment
section.IsPrivate = len(comment) > 0 && strings.HasPrefix(comment[0], "Private functions")
- section.Anchor = anchor
lines = rest[1:]
lineNo = restLineNo + 1
}
@@ -381,18 +381,13 @@ func (config *Config) parseHeader(path string) (*HeaderFile, error) {
if last := len(section.Decls) - 1; len(name) == 0 && len(comment) == 0 && last >= 0 {
section.Decls[last].Decl += "\n" + decl
} else {
- anchor := sanitizeAnchor(name)
- // TODO(davidben): Enforce uniqueness. This is
- // skipped because #ifdefs currently result in
- // duplicate table-of-contents entries.
- allAnchors[anchor] = struct{}{}
-
section.Decls = append(section.Decls, HeaderDecl{
Comment: comment,
Name: name,
Decl: decl,
- Anchor: anchor,
+ Num: declNumber,
})
+ declNumber++
}
if len(lines) > 0 && len(lines[0]) == 0 {
@@ -456,7 +451,7 @@ again:
if end > 0 {
end += start
w := strings.ToLower(string(s[start:end]))
- if w == "a" || w == "an" {
+ if w == "a" || w == "an" || w == "deprecated:" {
start = end + 1
goto again
}
@@ -500,9 +495,9 @@ func generate(outPath string, config *Config) (map[string]string, error) {
<ol>
{{range .Sections}}
{{if not .IsPrivate}}
- {{if .Anchor}}<li class="header"><a href="#{{.Anchor}}">{{.Preamble | firstSentence | html | markupPipeWords}}</a></li>{{end}}
+ {{if .Preamble}}<li class="header"><a href="#section-{{.Num}}">{{.Preamble | firstSentence | html | markupPipeWords}}</a></li>{{end}}
{{range .Decls}}
- {{if .Anchor}}<li><a href="#{{.Anchor}}"><tt>{{.Name}}</tt></a></li>{{end}}
+ {{if .Name}}<li><a href="#decl-{{.Num}}"><tt>{{.Name}}</tt></a></li>{{end}}
{{end}}
{{end}}
{{end}}
@@ -513,7 +508,7 @@ func generate(outPath string, config *Config) (map[string]string, error) {
<div class="section">
{{if .Preamble}}
<div class="sectionpreamble">
- <a{{if .Anchor}} name="{{.Anchor}}"{{end}}>
+ <a name="section-{{.Num}}">
{{range .Preamble}}<p>{{. | html | markupPipeWords}}</p>{{end}}
</a>
</div>
@@ -521,7 +516,7 @@ func generate(outPath string, config *Config) (map[string]string, error) {
{{range .Decls}}
<div class="decl">
- <a{{if .Anchor}} name="{{.Anchor}}"{{end}}>
+ <a name="decl-{{.Num}}">
{{range .Comment}}
<p>{{. | html | markupPipeWords | newlinesToBR | markupFirstWord}}</p>
{{end}}
@@ -610,14 +605,6 @@ func generateIndex(outPath string, config *Config, headerDescriptions map[string
return nil
}
-func copyFile(outPath string, inFilePath string) error {
- bytes, err := ioutil.ReadFile(inFilePath)
- if err != nil {
- return err
- }
- return ioutil.WriteFile(filepath.Join(outPath, filepath.Base(inFilePath)), bytes, 0666)
-}
-
func main() {
var (
configFlag *string = flag.String("config", "doc.config", "Location of config file")
@@ -658,9 +645,4 @@ func main() {
fmt.Printf("Failed to generate index: %s\n", err)
os.Exit(1)
}
-
- if err := copyFile(*outputDir, "doc.css"); err != nil {
- fmt.Printf("Failed to copy static file: %s\n", err)
- os.Exit(1)
- }
}
diff --git a/src/util/generate_build_files.py b/src/util/generate_build_files.py
index 2eae98a..e534a56 100644
--- a/src/util/generate_build_files.py
+++ b/src/util/generate_build_files.py
@@ -19,7 +19,6 @@
import os
import subprocess
import sys
-import json
# OS_ARCH_COMBOS maps from OS and platform to the OpenSSL assembly "style" for
@@ -69,9 +68,7 @@ class Chromium(object):
gypi.write(self.header + '{\n \'variables\': {\n')
self.PrintVariableSection(
- gypi, 'boringssl_ssl_sources', files['ssl'])
- self.PrintVariableSection(
- gypi, 'boringssl_crypto_sources', files['crypto'])
+ gypi, 'boringssl_lib_sources', files['crypto'] + files['ssl'])
for ((osname, arch), asm_files) in asm_outputs:
self.PrintVariableSection(gypi, 'boringssl_%s_%s_sources' %
@@ -136,9 +133,6 @@ class Android(object):
"""
- def ExtraFiles(self):
- return ['android_compat_hacks.c', 'android_compat_keywrap.c']
-
def PrintVariableSection(self, out, name, files):
out.write('%s := \\\n' % name)
for f in sorted(files):
@@ -149,7 +143,8 @@ class Android(object):
with open('sources.mk', 'w+') as makefile:
makefile.write(self.header)
- files['crypto'].extend(self.ExtraFiles())
+ files['crypto'].append('android_compat_hacks.c')
+ files['crypto'].append('android_compat_keywrap.c')
self.PrintVariableSection(makefile, 'crypto_sources', files['crypto'])
self.PrintVariableSection(makefile, 'ssl_sources', files['ssl'])
self.PrintVariableSection(makefile, 'tool_sources', files['tool'])
@@ -159,127 +154,6 @@ class Android(object):
makefile, '%s_%s_sources' % (osname, arch), asm_files)
-class AndroidStandalone(Android):
- """AndroidStandalone is for Android builds outside of the Android-system, i.e.
-
- for applications that wish wish to ship BoringSSL.
- """
-
- def ExtraFiles(self):
- return []
-
-
-class Bazel(object):
- """Bazel outputs files suitable for including in Bazel files."""
-
- def __init__(self):
- self.firstSection = True
- self.header = \
-"""# This file is created by generate_build_files.py. Do not edit manually.
-
-"""
-
- def PrintVariableSection(self, out, name, files):
- if not self.firstSection:
- out.write('\n')
- self.firstSection = False
-
- out.write('%s = [\n' % name)
- for f in sorted(files):
- out.write(' "%s",\n' % f)
- out.write(']\n')
-
- def WriteFiles(self, files, asm_outputs):
- with open('BUILD.generated', 'w+') as out:
- out.write(self.header)
-
- self.PrintVariableSection(out, 'ssl_headers', files['ssl_headers'])
- self.PrintVariableSection(
- out, 'ssl_internal_headers', files['ssl_internal_headers'])
- self.PrintVariableSection(out, 'ssl_sources', files['ssl'])
- self.PrintVariableSection(out, 'crypto_headers', files['crypto_headers'])
- self.PrintVariableSection(
- out, 'crypto_internal_headers', files['crypto_internal_headers'])
- self.PrintVariableSection(out, 'crypto_sources', files['crypto'])
- self.PrintVariableSection(out, 'tool_sources', files['tool'])
-
- for ((osname, arch), asm_files) in asm_outputs:
- if osname is not 'linux':
- continue
- self.PrintVariableSection(
- out, 'crypto_sources_%s' % arch, asm_files)
-
- with open('BUILD.generated_tests', 'w+') as out:
- out.write(self.header)
-
- out.write('test_support_sources = [\n')
- for filename in files['test_support']:
- if os.path.basename(filename) == 'malloc.cc':
- continue
- out.write(' "%s",\n' % filename)
- out.write('] + glob(["src/crypto/test/*.h"])\n\n')
-
- name_counts = {}
- for test in files['tests']:
- name = os.path.basename(test[0])
- name_counts[name] = name_counts.get(name, 0) + 1
-
- first = True
- for test in files['tests']:
- name = os.path.basename(test[0])
- if name_counts[name] > 1:
- if '/' in test[1]:
- name += '_' + os.path.splitext(os.path.basename(test[1]))[0]
- else:
- name += '_' + test[1].replace('-', '_')
-
- if not first:
- out.write('\n')
- first = False
-
- src_prefix = 'src/' + test[0]
- for src in files['test']:
- if src.startswith(src_prefix):
- src = src
- break
- else:
- raise ValueError("Can't find source for %s" % test[0])
-
- out.write('cc_test(\n')
- out.write(' name = "%s",\n' % name)
- out.write(' size = "small",\n')
- out.write(' srcs = ["%s"] + test_support_sources,\n' % src)
-
- data_files = []
- if len(test) > 1:
-
- out.write(' args = [\n')
- for arg in test[1:]:
- if '/' in arg:
- out.write(' "$(location src/%s)",\n' % arg)
- data_files.append('src/%s' % arg)
- else:
- out.write(' "%s",\n' % arg)
- out.write(' ],\n')
-
- out.write(' copts = boringssl_copts,\n')
-
- if len(data_files) > 0:
- out.write(' data = [\n')
- for filename in data_files:
- out.write(' "%s",\n' % filename)
- out.write(' ],\n')
-
- if 'ssl/' in test[0]:
- out.write(' deps = [\n')
- out.write(' ":crypto",\n')
- out.write(' ":ssl",\n')
- out.write(' ],\n')
- else:
- out.write(' deps = [":crypto"],\n')
- out.write(')\n')
-
-
def FindCMakeFiles(directory):
"""Returns list of all CMakeLists.txt files recursively in directory."""
cmakefiles = []
@@ -314,10 +188,6 @@ def AllFiles(dent, is_dir):
return True
-def SSLHeaderFiles(dent, is_dir):
- return dent in ['ssl.h', 'tls1.h', 'ssl23.h', 'ssl3.h', 'dtls1.h']
-
-
def FindCFiles(directory, filter_func):
"""Recurses through directory and returns a list of paths to all the C source
files that pass filter_func."""
@@ -338,21 +208,6 @@ def FindCFiles(directory, filter_func):
return cfiles
-def FindHeaderFiles(directory, filter_func):
- """Recurses through directory and returns a list of paths to all the header files that pass filter_func."""
- hfiles = []
-
- for (path, dirnames, filenames) in os.walk(directory):
- for filename in filenames:
- if not filename.endswith('.h'):
- continue
- if not filter_func(filename, False):
- continue
- hfiles.append(os.path.join(path, filename))
-
- return hfiles
-
-
def ExtractPerlAsmFromCMakeFile(cmakefile):
"""Parses the contents of the CMakeLists.txt file passed as an argument and
returns a list of all the perlasm() directives found in the file."""
@@ -434,9 +289,6 @@ def WriteAsmFiles(perlasms):
if not output.startswith('src'):
raise ValueError('output missing src: %s' % output)
output = os.path.join(outDir, output[4:])
- if output.endswith('-armx.${ASM_EXT}'):
- output = output.replace('-armx',
- '-armx64' if arch == 'aarch64' else '-armx32')
output = output.replace('${ASM_EXT}', asm_ext)
if arch in ArchForAsmFilename(filename):
@@ -450,7 +302,7 @@ def WriteAsmFiles(perlasms):
return asmfiles
-def main(platforms):
+def main(platform):
crypto_c_files = FindCFiles(os.path.join('src', 'crypto'), NoTests)
ssl_c_files = FindCFiles(os.path.join('src', 'ssl'), NoTests)
tool_cc_files = FindCFiles(os.path.join('src', 'tool'), NoTests)
@@ -468,80 +320,36 @@ def main(platforms):
test_c_files = FindCFiles(os.path.join('src', 'crypto'), OnlyTests)
test_c_files += FindCFiles(os.path.join('src', 'ssl'), OnlyTests)
- ssl_h_files = (
- FindHeaderFiles(
- os.path.join('src', 'include', 'openssl'),
- SSLHeaderFiles))
-
- def NotSSLHeaderFiles(filename, is_dir):
- return not SSLHeaderFiles(filename, is_dir)
- crypto_h_files = (
- FindHeaderFiles(
- os.path.join('src', 'include', 'openssl'),
- NotSSLHeaderFiles))
-
- ssl_internal_h_files = FindHeaderFiles(os.path.join('src', 'ssl'), NoTests)
- crypto_internal_h_files = FindHeaderFiles(
- os.path.join('src', 'crypto'), NoTests)
-
- with open('src/util/all_tests.json', 'r') as f:
- tests = json.load(f)
- test_binaries = set([test[0] for test in tests])
- test_sources = set([
- test.replace('.cc', '').replace('.c', '').replace(
- 'src/',
- '')
- for test in test_c_files])
- if test_binaries != test_sources:
- print 'Test sources and configured tests do not match'
- a = test_binaries.difference(test_sources)
- if len(a) > 0:
- print 'These tests are configured without sources: ' + str(a)
- b = test_sources.difference(test_binaries)
- if len(b) > 0:
- print 'These test sources are not configured: ' + str(b)
-
files = {
'crypto': crypto_c_files,
- 'crypto_headers': crypto_h_files,
- 'crypto_internal_headers': crypto_internal_h_files,
'ssl': ssl_c_files,
- 'ssl_headers': ssl_h_files,
- 'ssl_internal_headers': ssl_internal_h_files,
'tool': tool_cc_files,
'test': test_c_files,
'test_support': test_support_cc_files,
- 'tests': tests,
}
asm_outputs = sorted(WriteAsmFiles(ReadPerlAsmOperations()).iteritems())
- for platform in platforms:
- platform.WriteFiles(files, asm_outputs)
+ platform.WriteFiles(files, asm_outputs)
return 0
def Usage():
- print 'Usage: python %s [chromium|android|android-standalone|bazel]' % sys.argv[0]
+ print 'Usage: python %s [chromium|android]' % sys.argv[0]
sys.exit(1)
if __name__ == '__main__':
- if len(sys.argv) < 2:
+ if len(sys.argv) != 2:
+ Usage()
+
+ platform = None
+ if sys.argv[1] == 'chromium':
+ platform = Chromium()
+ elif sys.argv[1] == 'android':
+ platform = Android()
+ else:
Usage()
- platforms = []
- for s in sys.argv[1:]:
- if s == 'chromium' or s == 'gyp':
- platforms.append(Chromium())
- elif s == 'android':
- platforms.append(Android())
- elif s == 'android-standalone':
- platforms.append(AndroidStandalone())
- elif s == 'bazel':
- platforms.append(Bazel())
- else:
- Usage()
-
- sys.exit(main(platforms))
+ sys.exit(main(platform))
diff --git a/src/util/make_errors.go b/src/util/make_errors.go
index cc35409..dc8039a 100644
--- a/src/util/make_errors.go
+++ b/src/util/make_errors.go
@@ -25,6 +25,7 @@ import (
"sort"
"strconv"
"strings"
+ "unicode"
)
// ssl.h reserves values 1000 and above for error codes corresponding to
@@ -60,11 +61,12 @@ func makeErrors(reset bool) error {
}
prefix := strings.ToUpper(lib)
- reasons, err := parseHeader(prefix, headerFile)
+ functions, reasons, err := parseHeader(prefix, headerFile)
headerFile.Close()
if reset {
err = nil
+ functions = make(map[string]int)
// Retain any reason codes above reservedReasonCode.
newReasons := make(map[string]int)
for key, value := range reasons {
@@ -95,11 +97,12 @@ func makeErrors(reset bool) error {
continue
}
- if err := addReasons(reasons, name, prefix); err != nil {
+ if err := addFunctionsAndReasons(functions, reasons, name, prefix); err != nil {
return err
}
}
+ assignNewValues(functions, -1)
assignNewValues(reasons, reservedReasonCode)
headerFile, err = os.Open(headerPath)
@@ -114,7 +117,7 @@ func makeErrors(reset bool) error {
}
defer newHeaderFile.Close()
- if err := writeHeaderFile(newHeaderFile, headerFile, prefix, reasons); err != nil {
+ if err := writeHeaderFile(newHeaderFile, headerFile, prefix, functions, reasons); err != nil {
return err
}
os.Rename(headerPath+".tmp", headerPath)
@@ -124,7 +127,8 @@ func makeErrors(reset bool) error {
return err
}
- outputStrings(dataFile, lib, reasons)
+ outputStrings(dataFile, lib, typeFunctions, functions)
+ outputStrings(dataFile, lib, typeReasons, reasons)
dataFile.Close()
return nil
@@ -132,16 +136,16 @@ func makeErrors(reset bool) error {
func findToplevel() (path string, err error) {
path = ".."
- buildingPath := filepath.Join(path, "BUILDING.md")
+ buildingPath := filepath.Join(path, "BUILDING")
_, err = os.Stat(buildingPath)
if err != nil && os.IsNotExist(err) {
path = filepath.Join("..", path)
- buildingPath = filepath.Join(path, "BUILDING.md")
+ buildingPath = filepath.Join(path, "BUILDING")
_, err = os.Stat(buildingPath)
}
if err != nil {
- return "", errors.New("Cannot find BUILDING.md file at the top-level")
+ return "", errors.New("Cannot find BUILDING file at the top-level")
}
return path, nil
}
@@ -179,7 +183,7 @@ func outputAssignments(w io.Writer, assignments map[string]int) {
}
}
-func parseDefineLine(line, lib string) (key string, value int, ok bool) {
+func parseDefineLine(line, lib string) (typ int, key string, value int, ok bool) {
if !strings.HasPrefix(line, "#define ") {
return
}
@@ -189,8 +193,16 @@ func parseDefineLine(line, lib string) (key string, value int, ok bool) {
return
}
+ funcPrefix := lib + "_F_"
+ reasonPrefix := lib + "_R_"
+
key = fields[1]
- if !strings.HasPrefix(key, lib+"_R_") {
+ switch {
+ case strings.HasPrefix(key, funcPrefix):
+ typ = typeFunctions
+ case strings.HasPrefix(key, reasonPrefix):
+ typ = typeReasons
+ default:
return
}
@@ -203,7 +215,7 @@ func parseDefineLine(line, lib string) (key string, value int, ok bool) {
return
}
-func writeHeaderFile(w io.Writer, headerFile io.Reader, lib string, reasons map[string]int) error {
+func writeHeaderFile(w io.Writer, headerFile io.Reader, lib string, functions, reasons map[string]int) error {
var last []byte
var haveLast, sawDefine bool
newLine := []byte("\n")
@@ -211,7 +223,7 @@ func writeHeaderFile(w io.Writer, headerFile io.Reader, lib string, reasons map[
scanner := bufio.NewScanner(headerFile)
for scanner.Scan() {
line := scanner.Text()
- _, _, ok := parseDefineLine(line, lib)
+ _, _, _, ok := parseDefineLine(line, lib)
if ok {
sawDefine = true
continue
@@ -235,6 +247,7 @@ func writeHeaderFile(w io.Writer, headerFile io.Reader, lib string, reasons map[
return err
}
+ outputAssignments(w, functions)
outputAssignments(w, reasons)
w.Write(newLine)
@@ -246,9 +259,14 @@ func writeHeaderFile(w io.Writer, headerFile io.Reader, lib string, reasons map[
return nil
}
-func outputStrings(w io.Writer, lib string, assignments map[string]int) {
+const (
+ typeFunctions = iota
+ typeReasons
+)
+
+func outputStrings(w io.Writer, lib string, ty int, assignments map[string]int) {
lib = strings.ToUpper(lib)
- prefixLen := len(lib + "_R_")
+ prefixLen := len(lib + "_F_")
keys := make([]string, 0, len(assignments))
for key := range assignments {
@@ -257,7 +275,11 @@ func outputStrings(w io.Writer, lib string, assignments map[string]int) {
sort.Strings(keys)
for _, key := range keys {
- fmt.Fprintf(w, "%s,%d,%s\n", lib, assignments[key], key[prefixLen:])
+ typeString := "function"
+ if ty == typeReasons {
+ typeString = "reason"
+ }
+ fmt.Fprintf(w, "%s,%s,%d,%s\n", lib, typeString, assignments[key], key[prefixLen:])
}
}
@@ -317,7 +339,7 @@ func handleDeclareMacro(line, join, macroName string, m map[string]int) {
}
}
-func addReasons(reasons map[string]int, filename, prefix string) error {
+func addFunctionsAndReasons(functions, reasons map[string]int, filename, prefix string) error {
file, err := os.Open(filename)
if err != nil {
return err
@@ -325,15 +347,45 @@ func addReasons(reasons map[string]int, filename, prefix string) error {
defer file.Close()
reasonPrefix := prefix + "_R_"
+ var currentFunction string
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
+ if len(line) > 0 && unicode.IsLetter(rune(line[0])) {
+ /* Function start */
+ fields := strings.Fields(line)
+ for _, field := range fields {
+ if i := strings.Index(field, "("); i != -1 {
+ f := field[:i]
+ // The return type of some functions is
+ // a macro that contains a "(".
+ if f == "STACK_OF" {
+ continue
+ }
+ currentFunction = f
+ for len(currentFunction) > 0 && currentFunction[0] == '*' {
+ currentFunction = currentFunction[1:]
+ }
+ break
+ }
+ }
+ }
+
+ // Do not include cross-module error lines.
+ if strings.Contains(line, "OPENSSL_PUT_ERROR(" + prefix + ",") {
+ functionToken := prefix + "_F_" + currentFunction
+ if _, ok := functions[functionToken]; !ok {
+ functions[functionToken] = -1
+ }
+ }
+
handleDeclareMacro(line, "_R_", "OPENSSL_DECLARE_ERROR_REASON(", reasons)
+ handleDeclareMacro(line, "_F_", "OPENSSL_DECLARE_ERROR_FUNCTION(", functions)
for len(line) > 0 {
- i := strings.Index(line, prefix+"_")
+ i := strings.Index(line, prefix + "_")
if i == -1 {
break
}
@@ -361,17 +413,25 @@ func addReasons(reasons map[string]int, filename, prefix string) error {
return scanner.Err()
}
-func parseHeader(lib string, file io.Reader) (reasons map[string]int, err error) {
+func parseHeader(lib string, file io.Reader) (functions, reasons map[string]int, err error) {
+ functions = make(map[string]int)
reasons = make(map[string]int)
scanner := bufio.NewScanner(file)
for scanner.Scan() {
- key, value, ok := parseDefineLine(scanner.Text(), lib)
+ typ, key, value, ok := parseDefineLine(scanner.Text(), lib)
if !ok {
continue
}
- reasons[key] = value
+ switch typ {
+ case typeFunctions:
+ functions[key] = value
+ case typeReasons:
+ reasons[key] = value
+ default:
+ panic("internal error")
+ }
}
err = scanner.Err()