summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReiko Asakura2021-03-13 11:02:55 -0500
committerReiko Asakura2021-03-13 11:02:55 -0500
commitdb45e31fd92dd834c2426a780266d0fb03652e9b (patch)
treec327c6666a2dfeb0382b6c2b4a123011744b4941
parentAdd sce_process_preload_disabled flags (diff)
downloadvds-libraries-db45e31fd92dd834c2426a780266d0fb03652e9b.tar.gz
Add lint script for header files
-rw-r--r--.github/workflows/lint.yml4
-rw-r--r--include/kernel/kernel/iofilemgr_dirent.h5
-rw-r--r--include/kernel/scejpegenc.h5
-rw-r--r--scripts/check-header-files.py43
4 files changed, 57 insertions, 0 deletions
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 5cb1c46..2cd117b 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -33,3 +33,7 @@ jobs:
- name: Check NIDs digest
run: |
python3 scripts/nids-check-digest.py
+
+ - name: Check header files
+ run: |
+ python3 scripts/check-header-files.py
diff --git a/include/kernel/kernel/iofilemgr_dirent.h b/include/kernel/kernel/iofilemgr_dirent.h
index ff33f7e..660b4a3 100644
--- a/include/kernel/kernel/iofilemgr_dirent.h
+++ b/include/kernel/kernel/iofilemgr_dirent.h
@@ -2,4 +2,9 @@
Vita Development Suite Libraries
*/
+#ifndef _VDSUITE_KERNEL_KERNEL_IOFILEMGR_DIRENT_H
+#define _VDSUITE_KERNEL_KERNEL_IOFILEMGR_DIRENT_H
+
#include_next <kernel/iofilemgr_dirent.h>
+
+#endif /* _VDSUITE_KERNEL_KERNEL_IOFILEMGR_DIRENT_H */
diff --git a/include/kernel/scejpegenc.h b/include/kernel/scejpegenc.h
index 2087613..2d860f5 100644
--- a/include/kernel/scejpegenc.h
+++ b/include/kernel/scejpegenc.h
@@ -2,4 +2,9 @@
Vita Development Suite Libraries
*/
+#ifndef _VDSUITE_KERNEL_SCEJPEGENC_H
+#define _VDSUITE_KERNEL_SCEJPEGENC_H
+
#include_next <scejpegenc.h>
+
+#endif /* _VDSUITE_KERNEL_SCEJPEGENC_H */
diff --git a/scripts/check-header-files.py b/scripts/check-header-files.py
new file mode 100644
index 0000000..c6ee32e
--- /dev/null
+++ b/scripts/check-header-files.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python3
+
+#
+# Copyright (C) 2021 Reiko Asakura. All Rights Reserved.
+#
+# Vita Development Suite Libraries
+#
+
+import sys
+from pathlib import Path
+
+import nids
+
+def check_file(base, f):
+ mode = f.stat().st_mode
+
+ if mode != 0o100644:
+ sys.exit(f'{f} has incorrect permission mode {mode:o}')
+
+ if f.suffix != '.h' or f.stem != Path(f.stem).stem:
+ sys.exit(f'{f} has incorrect file name format')
+
+ text = f.read_bytes().decode()
+
+ if '\r' in text:
+ sys.exit(f'{f} has carriage return')
+
+ if not text.startswith('/*\n\tVita Development Suite Libraries\n*/'):
+ sys.exit(f'{f} has incorrect boilerplate')
+
+ if not text.endswith('\n'):
+ sys.exit(f'{f} does not have trailing line feed')
+
+ include_guard = ('#define _VDSUITE_' + f'{f.relative_to(base)}'
+ .replace('/', '_')
+ .replace('\\', '_')
+ .replace('.', '_')
+ .upper())
+
+ if include_guard not in text:
+ sys.exit(f'{f} has incorrect include guard\n{include_guard}')
+
+nids.iterdir(Path('include'), lambda f: check_file(Path('include'), f))