39 lines
915 B
Python
39 lines
915 B
Python
"""
|
|
Configuration file handling
|
|
"""
|
|
import os
|
|
|
|
__all__ = [
|
|
'config_file_generate'
|
|
]
|
|
|
|
#---
|
|
# Public
|
|
#---
|
|
|
|
def config_file_generate(kernconf, confile_prefix):
|
|
""" Generate the kernel configuration file for CMake build system
|
|
|
|
@args
|
|
> kernconf (dict) - kernel configuration information
|
|
> confile_prefix (str) - build prefix
|
|
|
|
@return
|
|
> 0 on success, negative value otherwise
|
|
"""
|
|
if not os.path.exists(confile_prefix):
|
|
os.makedirs(confile_prefix)
|
|
|
|
content = "# file generated by the vxSDK\n\n"
|
|
for item in kernconf.items():
|
|
if not (data := item[1]):
|
|
continue
|
|
if isinstance(item[1], list):
|
|
data = ' '.join(item[1])
|
|
content += f"set({item[0]} {data})\n"
|
|
|
|
confile_path = f"{confile_prefix}/vxkernel_config.cmake"
|
|
with open(confile_path, 'w+', encoding='utf8') as file:
|
|
file.write(content)
|
|
return 0
|