Introduce guess_mbedtls_root
Signed-off-by: Thomas Daubney <thomas.daubney@arm.com>
This commit is contained in:
parent
56bee0344e
commit
d1f2934e78
2 changed files with 15 additions and 4 deletions
|
@ -367,7 +367,7 @@ def generate_ssl_debug_helpers(output_directory, mbedtls_root):
|
||||||
Generate functions of debug helps
|
Generate functions of debug helps
|
||||||
"""
|
"""
|
||||||
mbedtls_root = os.path.abspath(
|
mbedtls_root = os.path.abspath(
|
||||||
mbedtls_root or build_tree.guess_project_root())
|
mbedtls_root or build_tree.guess_mbedtls_root())
|
||||||
with open(os.path.join(mbedtls_root, 'include/mbedtls/ssl.h')) as f:
|
with open(os.path.join(mbedtls_root, 'include/mbedtls/ssl.h')) as f:
|
||||||
source_code = remove_c_comments(f.read())
|
source_code = remove_c_comments(f.read())
|
||||||
|
|
||||||
|
|
|
@ -48,8 +48,7 @@ def crypto_library_filename(root: Optional[str] = None) -> str:
|
||||||
raise Exception('Neither Mbed TLS nor TF-PSA-Crypto source tree found')
|
raise Exception('Neither Mbed TLS nor TF-PSA-Crypto source tree found')
|
||||||
|
|
||||||
def check_repo_path():
|
def check_repo_path():
|
||||||
"""
|
"""Check that the current working directory is the project root, and throw
|
||||||
Check that the current working directory is the project root, and throw
|
|
||||||
an exception if not.
|
an exception if not.
|
||||||
"""
|
"""
|
||||||
if not all(os.path.isdir(d) for d in ["include", "library", "tests"]):
|
if not all(os.path.isdir(d) for d in ["include", "library", "tests"]):
|
||||||
|
@ -69,7 +68,6 @@ def chdir_to_root() -> None:
|
||||||
return
|
return
|
||||||
raise Exception('Mbed TLS source tree not found')
|
raise Exception('Mbed TLS source tree not found')
|
||||||
|
|
||||||
|
|
||||||
def guess_project_root():
|
def guess_project_root():
|
||||||
"""Guess project source code directory.
|
"""Guess project source code directory.
|
||||||
|
|
||||||
|
@ -87,3 +85,16 @@ def guess_project_root():
|
||||||
if looks_like_root(d):
|
if looks_like_root(d):
|
||||||
return d
|
return d
|
||||||
raise Exception('Neither Mbed TLS nor TF-PSA-Crypto source tree found')
|
raise Exception('Neither Mbed TLS nor TF-PSA-Crypto source tree found')
|
||||||
|
|
||||||
|
def guess_mbedtls_root(root: Optional[str] = None) -> str:
|
||||||
|
"""Guess Mbed TLS source code directory.
|
||||||
|
|
||||||
|
Return the first possible Mbed TLS root directory.
|
||||||
|
Raise an exception if we are not in Mbed TLS.
|
||||||
|
"""
|
||||||
|
if root is None:
|
||||||
|
root = guess_project_root()
|
||||||
|
if looks_like_mbedtls_root(root):
|
||||||
|
return root
|
||||||
|
else:
|
||||||
|
raise Exception('Mbed TLS source tree not found')
|
||||||
|
|
Loading…
Reference in a new issue