MAINT: Fixup hardcoded build folder
This commit is contained in:
parent
0701835710
commit
3f9ffecf86
|
@ -510,7 +510,8 @@ _read_config_py = './read_config.py'
|
||||||
|
|
||||||
run_command(py3,
|
run_command(py3,
|
||||||
_read_config_py,
|
_read_config_py,
|
||||||
_config_h,
|
'--file1', _config_h,
|
||||||
|
'--build_dir', meson.current_build_dir(),
|
||||||
check: true)
|
check: true)
|
||||||
|
|
||||||
keyval = import('keyval')
|
keyval = import('keyval')
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
def read_config_file(file_path: str) -> dict:
|
|
||||||
|
def read_config_file(file_path: Path) -> dict:
|
||||||
config_data = {}
|
config_data = {}
|
||||||
with open(file_path, "r") as file:
|
with file_path.open("r") as file:
|
||||||
lines = file.readlines()
|
lines = file.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
|
@ -22,18 +24,26 @@ def read_config_file(file_path: str) -> dict:
|
||||||
config_data[key] = 1
|
config_data[key] = 1
|
||||||
return config_data
|
return config_data
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser(description="Read a config.h file.")
|
parser = argparse.ArgumentParser(
|
||||||
parser.add_argument("file1", help="Path to the config.h file.")
|
description="Read a config.h file and write to a specified build directory."
|
||||||
|
)
|
||||||
|
parser.add_argument("--file1", type=Path, help="Path to the config.h file.")
|
||||||
|
parser.add_argument("--build_dir", type=Path, help="Path to the build directory.")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
config_data = read_config_file(args.file1)
|
config_data = read_config_file(args.file1)
|
||||||
fdat = []
|
fdat = []
|
||||||
for key, value in config_data.items():
|
for key, value in config_data.items():
|
||||||
fdat.append(f'{key}={value}')
|
fdat.append(f"{key}={value}")
|
||||||
result = '\n'.join(fdat)
|
result = "\n".join(fdat)
|
||||||
|
|
||||||
f = open("./build/config.kconf", "a")
|
# Ensure the build directory exists
|
||||||
f.write(result)
|
args.build_dir.mkdir(parents=True, exist_ok=True)
|
||||||
f.close()
|
|
||||||
|
# Write to the specified file in the build directory
|
||||||
|
output_file_path = args.build_dir / "config.kconf"
|
||||||
|
with output_file_path.open("a") as f:
|
||||||
|
f.write(result)
|
||||||
|
|
Loading…
Reference in New Issue