Browse Source

scripts: zephyr_modules.py cleanup.

This commit has no functional changes but is simply a cleanup so that
flake8 will pass without warnings.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
pull/27899/head
Torsten Rasmussen 5 years ago committed by Carles Cufí
parent
commit
25c3f8e12f
  1. 31
      scripts/zephyr_module.py

31
scripts/zephyr_module.py

@ -129,17 +129,19 @@ def process_cmake(module, meta): @@ -129,17 +129,19 @@ def process_cmake(module, meta):
cmake_setting = section.get('cmake', None)
if not validate_setting(cmake_setting, module, 'CMakeLists.txt'):
sys.exit('ERROR: "cmake" key in {} has folder value "{}" which '
'does not contain a CMakeLists.txt file.'
.format(module_yml.as_posix(), cmake_setting))
'does not contain a CMakeLists.txt file.'
.format(module_yml.as_posix(), cmake_setting))
cmake_path = os.path.join(module, cmake_setting or 'zephyr')
cmake_file = os.path.join(cmake_path, 'CMakeLists.txt')
if os.path.isfile(cmake_file):
return('\"{}\":\"{}\"\n'
.format(module_path.name, Path(cmake_path).resolve().as_posix()))
.format(module_path.name,
Path(cmake_path).resolve().as_posix()))
else:
return ""
def process_settings(module, meta):
section = meta.get('build', dict())
build_settings = section.get('settings', None)
@ -154,6 +156,7 @@ def process_settings(module, meta): @@ -154,6 +156,7 @@ def process_settings(module, meta):
return out_text
def process_kconfig(module, meta):
section = meta.get('build', dict())
module_path = PurePath(module)
@ -162,16 +165,17 @@ def process_kconfig(module, meta): @@ -162,16 +165,17 @@ def process_kconfig(module, meta):
kconfig_setting = section.get('kconfig', None)
if not validate_setting(kconfig_setting, module):
sys.exit('ERROR: "kconfig" key in {} has value "{}" which does '
'not point to a valid Kconfig file.'
.format(module_yml, kconfig_setting))
'not point to a valid Kconfig file.'
.format(module_yml, kconfig_setting))
kconfig_file = os.path.join(module, kconfig_setting or 'zephyr/Kconfig')
if os.path.isfile(kconfig_file):
return 'osource "{}"\n\n'.format(Path(kconfig_file).resolve().as_posix())
return 'osource "{}"\n\n'.format(Path(kconfig_file)
.resolve().as_posix())
else:
return ""
def process_sanitycheck(module, meta):
out = ""
@ -182,12 +186,14 @@ def process_sanitycheck(module, meta): @@ -182,12 +186,14 @@ def process_sanitycheck(module, meta):
for pth in tests + samples:
if pth:
dir = os.path.join(module, pth)
out += '-T\n{}\n'.format(PurePath(os.path.abspath(dir)).as_posix())
out += '-T\n{}\n'.format(PurePath(os.path.abspath(dir))
.as_posix())
for pth in boards:
if pth:
dir = os.path.join(module, pth)
out += '--board-root\n{}\n'.format(PurePath(os.path.abspath(dir)).as_posix())
out += '--board-root\n{}\n'.format(PurePath(os.path.abspath(dir))
.as_posix())
return out
@ -201,7 +207,8 @@ def main(): @@ -201,7 +207,8 @@ def main():
help="""File to write with resulting KConfig import
statements.""")
parser.add_argument('--sanitycheck-out',
help="""File to write with resulting sanitycheck parameters.""")
help="""File to write with resulting sanitycheck
parameters.""")
parser.add_argument('--cmake-out',
help="""File to write with resulting <name>:<path>
values to use for including in CMake""")
@ -218,7 +225,8 @@ def main(): @@ -218,7 +225,8 @@ def main():
args = parser.parse_args()
if args.modules is None:
# West is imported here, as it is optional (and thus maybe not installed)
# West is imported here, as it is optional
# (and thus maybe not installed)
# if user is providing a specific modules list.
from west.manifest import Manifest
from west.util import WestNotFound
@ -312,5 +320,6 @@ def main(): @@ -312,5 +320,6 @@ def main():
with open(args.sanitycheck_out, 'w', encoding="utf-8") as fp:
fp.write(sanitycheck)
if __name__ == "__main__":
main()

Loading…
Cancel
Save