Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code style check #93

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions scripts/psa_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ def copy_of_mbedtls_headers(mbedtls_root_path, psa_crypto_root_path):
if os.path.isfile(os.path.join(source_path, "lms.h")):
shutil.copy2(os.path.join(source_path, "lms.h"), include_tf_psa_crypto_path)

def copy_from_root(mbedtls_root_path, psa_crypto_root_path):
source_path = mbedtls_root_path
destination_path = psa_crypto_root_path

root_files_to_copy = [".uncrustify.cfg"]

for file_ in root_files_to_copy:
shutil.copy2(os.path.join(source_path, file_), destination_path)


def copy_from_library(mbedtls_root_path, psa_crypto_root_path):
builtin_path = os.path.join(psa_crypto_root_path, "drivers", "builtin")
library_files = filter(lambda file_: not re.match(
Expand Down Expand Up @@ -96,6 +106,7 @@ def copy_from_scripts(mbedtls_root_path, psa_crypto_root_path):
shutil.copy2(os.path.join(source_path, "min_requirements.py"), destination_path)
shutil.copy2(os.path.join(source_path, "lcov.sh"), destination_path)
shutil.copy2(os.path.join(source_path, "assemble_changelog.py"), destination_path)
shutil.copy2(os.path.join(source_path, "code_style.py"), destination_path)

for path in pathlib.Path(source_path).glob("*.requirements.txt"):
shutil.copy2(str(path), destination_path)
Expand Down Expand Up @@ -154,6 +165,7 @@ def copy_from_tests(mbedtls_root_path, psa_crypto_root_path):
"generate_test_code.py|"\
"scripts_path.py|"\
"test_generate_test_code.py|"\
"check_generated_files.sh|"\
"test_psa_compliance.py",
file_), os.listdir(scripts_source_path))
for file_ in scripts_files:
Expand Down Expand Up @@ -295,6 +307,7 @@ def main():

copy_of_psa_headers(mbedtls_root_path, os.getcwd())
copy_of_mbedtls_headers(mbedtls_root_path, os.getcwd())
copy_from_root(mbedtls_root_path, os.getcwd())
copy_from_library(mbedtls_root_path, os.getcwd())
copy_from_scripts(mbedtls_root_path, os.getcwd())
copy_from_tests(mbedtls_root_path, os.getcwd())
Expand Down
12 changes: 12 additions & 0 deletions tests/all_sh_components.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,15 @@ component_test_cmake_shared () {
cd "$TF_PSA_CRYPTO_ROOT_DIR"
rm -rf "$OUT_OF_SOURCE_DIR"
}

component_check_code_style () {
msg "Check C code style"
./scripts/code_style.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to run it and it seems we miss check-generated-files.sh.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, ok not sure why. Will investigate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, I misunderstood the meaning of the initial comment. I have added check-generated-files.sh to be copied in psa_crypto.py.

}

support_check_code_style() {
case $(uncrustify --version) in
*0.75.1*) true;;
*) false;;
esac
}