Merge pull request #9902 from ronald-cron-arm/crypto-config-default-path-3.6
Simplify crypto config default path setting
diff --git a/framework b/framework
index fe852d3..57ee691 160000
--- a/framework
+++ b/framework
@@ -1 +1 @@
-Subproject commit fe852d3b9a3b08171c99176ffebfe8a8475d546d
+Subproject commit 57ee691a3e57f172a03c3f2f5c4da457e8fabf3c
diff --git a/scripts/min_requirements.py b/scripts/min_requirements.py
index b36f906..a67b761 100755
--- a/scripts/min_requirements.py
+++ b/scripts/min_requirements.py
@@ -5,125 +5,12 @@
# Copyright The Mbed TLS Contributors
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
-import argparse
import os
-import re
-import subprocess
-import sys
-import tempfile
-import typing
-
-from typing import List, Optional
-
import framework_scripts_path # pylint: disable=unused-import
-from mbedtls_framework import typing_util
+from mbedtls_framework import min_requirements
-def pylint_doesn_t_notice_that_certain_types_are_used_in_annotations(
- _list: List[typing.Any],
-) -> None:
- pass
-
-
-class Requirements:
- """Collect and massage Python requirements."""
-
- def __init__(self) -> None:
- self.requirements = [] #type: List[str]
-
- def adjust_requirement(self, req: str) -> str:
- """Adjust a requirement to the minimum specified version."""
- # allow inheritance #pylint: disable=no-self-use
- # If a requirement specifies a minimum version, impose that version.
- split_req = req.split(';', 1)
- split_req[0] = re.sub(r'>=|~=', r'==', split_req[0])
- return ';'.join(split_req)
-
- def add_file(self, filename: str) -> None:
- """Add requirements from the specified file.
-
- This method supports a subset of pip's requirement file syntax:
- * One requirement specifier per line, which is passed to
- `adjust_requirement`.
- * Comments (``#`` at the beginning of the line or after whitespace).
- * ``-r FILENAME`` to include another file.
- """
- for line in open(filename):
- line = line.strip()
- line = re.sub(r'(\A|\s+)#.*', r'', line)
- if not line:
- continue
- m = re.match(r'-r\s+', line)
- if m:
- nested_file = os.path.join(os.path.dirname(filename),
- line[m.end(0):])
- self.add_file(nested_file)
- continue
- self.requirements.append(self.adjust_requirement(line))
-
- def write(self, out: typing_util.Writable) -> None:
- """List the gathered requirements."""
- for req in self.requirements:
- out.write(req + '\n')
-
- def install(
- self,
- pip_general_options: Optional[List[str]] = None,
- pip_install_options: Optional[List[str]] = None,
- ) -> None:
- """Call pip to install the requirements."""
- if pip_general_options is None:
- pip_general_options = []
- if pip_install_options is None:
- pip_install_options = []
- with tempfile.TemporaryDirectory() as temp_dir:
- # This is more complicated than it needs to be for the sake
- # of Windows. Use a temporary file rather than the command line
- # to avoid quoting issues. Use a temporary directory rather
- # than NamedTemporaryFile because with a NamedTemporaryFile on
- # Windows, the subprocess can't open the file because this process
- # has an exclusive lock on it.
- req_file_name = os.path.join(temp_dir, 'requirements.txt')
- with open(req_file_name, 'w') as req_file:
- self.write(req_file)
- subprocess.check_call([sys.executable, '-m', 'pip'] +
- pip_general_options +
- ['install'] + pip_install_options +
- ['-r', req_file_name])
-
+# The default file is located in the same folder as this script.
DEFAULT_REQUIREMENTS_FILE = 'ci.requirements.txt'
-def main() -> None:
- """Command line entry point."""
- parser = argparse.ArgumentParser(description=__doc__)
- parser.add_argument('--no-act', '-n',
- action='store_true',
- help="Don't act, just print what will be done")
- parser.add_argument('--pip-install-option',
- action='append', dest='pip_install_options',
- help="Pass this option to pip install")
- parser.add_argument('--pip-option',
- action='append', dest='pip_general_options',
- help="Pass this general option to pip")
- parser.add_argument('--user',
- action='append_const', dest='pip_install_options',
- const='--user',
- help="Install to the Python user install directory"
- " (short for --pip-install-option --user)")
- parser.add_argument('files', nargs='*', metavar='FILE',
- help="Requirement files"
- " (default: {} in the script's directory)" \
- .format(DEFAULT_REQUIREMENTS_FILE))
- options = parser.parse_args()
- if not options.files:
- options.files = [os.path.join(os.path.dirname(__file__),
- DEFAULT_REQUIREMENTS_FILE)]
- reqs = Requirements()
- for filename in options.files:
- reqs.add_file(filename)
- reqs.write(sys.stdout)
- if not options.no_act:
- reqs.install(pip_general_options=options.pip_general_options,
- pip_install_options=options.pip_install_options)
-
-if __name__ == '__main__':
- main()
+min_requirements.main(os.path.join(os.path.dirname(__file__),
+ DEFAULT_REQUIREMENTS_FILE))
diff --git a/tests/scripts/components-build-system.sh b/tests/scripts/components-build-system.sh
index 0db7885..a6da8e6 100644
--- a/tests/scripts/components-build-system.sh
+++ b/tests/scripts/components-build-system.sh
@@ -115,7 +115,11 @@
make
./cmake_package
if [[ "$OSTYPE" == linux* ]]; then
- PKG_CONFIG_PATH="${build_variant_dir}/mbedtls/pkgconfig" ${root_dir}/tests/scripts/pkgconfig.sh
+ PKG_CONFIG_PATH="${build_variant_dir}/mbedtls/pkgconfig" \
+ ${root_dir}/framework/scripts/pkgconfig.sh \
+ mbedtls mbedx509 mbedcrypto
+ # These are the EXPECTED package names. Renaming these could break
+ # consumers of pkg-config, consider carefully.
fi
}
@@ -212,4 +216,3 @@
support_build_cmake_programs_no_testing () {
support_test_cmake_out_of_source
}
-
diff --git a/tests/scripts/pkgconfig.sh b/tests/scripts/pkgconfig.sh
deleted file mode 100755
index 2702bfa..0000000
--- a/tests/scripts/pkgconfig.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/sh
-#
-# Copyright The Mbed TLS Contributors
-# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
-#
-# Purpose
-#
-# Test pkgconfig files.
-#
-# For each of the build pkg-config files, .pc files, check that
-# they validate and do some basic sanity testing on the output,
-# i.e. that the strings are non-empty.
-#
-# NOTE: This requires the built pc files to be on the pkg-config
-# search path, this can be controlled with env variable
-# PKG_CONFIG_PATH. See man(1) pkg-config for details.
-#
-
-set -e -u
-
-# These are the EXPECTED package names. Renaming these could break
-# consumers of pkg-config, consider carefully.
-all_pcs="mbedtls mbedx509 mbedcrypto"
-
-for pc in $all_pcs; do
- printf "testing package config file: ${pc} ... "
- pkg-config --validate "${pc}"
- version="$(pkg-config --modversion "${pc}")"
- test -n "$version"
- cflags="$(pkg-config --cflags "${pc}")"
- test -n "$cflags"
- libs="$(pkg-config --libs "${pc}")"
- test -n "$libs"
- printf "passed\n"
-done
-
-exit 0