aboutsummaryrefslogtreecommitdiff
path: root/docs/contributor_guide
diff options
context:
space:
mode:
authorGunes Bayir <gunes.bayir@arm.com>2023-07-01 22:55:42 +0100
committerGunes Bayir <gunes.bayir@arm.com>2023-08-08 14:23:35 +0000
commit66b4a6a8ca1ee55e5b7f05bae2543cf99fe22d6d (patch)
treea11e009e6fc742df0fd4551fd7c545325210a07d /docs/contributor_guide
parentf77b969d3375f412ff236586d2b6eb2297c6b96d (diff)
downloadComputeLibrary-66b4a6a8ca1ee55e5b7f05bae2543cf99fe22d6d.tar.gz
Setup pre-commit and include code formatting scripts
This patch - includes our code formatting scripts used in our precommit pipeline - sets up pre-commit framework to help contributors validate their patches This has several benefits: - our repository becomes more inclusive to external contributions - we can use several hooks available online efficiently, w/o implementing our own - it speeds up our development flow and, it is completely optional. The pre-commit configuration includes running the following: - our code formatting scripts - CMake and Bazel build file generation scripts - hooks that check trailing whitespace, end of files, committed large files etc. The number of checks can easily be extended using pre-commit framework. Change-Id: I06bf1259715579d321f89820726a8301504c36d9 Signed-off-by: Gunes Bayir <gunes.bayir@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/10064 Reviewed-by: Jakub Sujak <jakub.sujak@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Benchmark: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'docs/contributor_guide')
-rw-r--r--docs/contributor_guide/contribution_guidelines.dox20
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/contributor_guide/contribution_guidelines.dox b/docs/contributor_guide/contribution_guidelines.dox
index 30ee41af0f..cbaa502635 100644
--- a/docs/contributor_guide/contribution_guidelines.dox
+++ b/docs/contributor_guide/contribution_guidelines.dox
@@ -335,6 +335,26 @@ void foo(const Goo &g); // OK
astyle (http://astyle.sourceforge.net/) and clang-format (https://clang.llvm.org/docs/ClangFormat.html) can check and help you apply some of these rules.
+We have also provided the python scripts we use in our precommit pipeline inside scripts directory.
+ - format_code.py: checks Android.bp, bad style, end of file, formats doxygen, runs astyle and clang-format (assuming necessary binaries are in the path). Example invocations:
+@code{.sh}
+ python format_code.py
+ python format_code.py --error-on-diff
+ python format_code.py --files=git-diff (Default behavior in pre-commit configuration, where it checks the staged files)
+@endcode
+ - generate_build_files.py: generates build files required for CMake and Bazel builds. Example invocations:
+@code{.sh}
+ python generate_build_files.py --cmake
+ python generate_build_files.py --bazel
+@endcode
+
+Another way of running the checks is using `pre-commit` (https://pre-commit.com/) framework, which has also nice features like checking trailing spaces, and large committed files etc.
+`pre-commit` can be installed via `pip`. After installing, run the following command in the root directory of the repository:
+
+ pre-commit install
+
+This will create the hooks that perform the formatting checks mentioned above and will automatically run just before committing to flag issues.
+
@subsection S5_1_3_library_size_guidelines Library size: best practices and guidelines
@subsubsection S5_1_3_1_template_suggestions Template suggestions