fix platformio.ini generation
This commit is contained in:
parent
6055011d82
commit
ee0341e137
@ -8,17 +8,19 @@ from pprint import pprint
|
||||
from argparse import ArgumentParser, ArgumentError
|
||||
from homekit.pio import get_products, platformio_ini
|
||||
from homekit.pio.exceptions import ProductConfigNotFoundError
|
||||
from homekit.config import CONFIG_DIRECTORIES
|
||||
|
||||
|
||||
def get_config(product: str) -> dict:
|
||||
config_path = os.path.join(
|
||||
os.getenv('HOME'), '.config',
|
||||
'homekit_pio', f'{product}.yaml'
|
||||
)
|
||||
if not os.path.exists(config_path):
|
||||
raise ProductConfigNotFoundError(f'{config_path}: product config not found')
|
||||
|
||||
with open(config_path, 'r') as f:
|
||||
path = None
|
||||
for directory in CONFIG_DIRECTORIES:
|
||||
config_path = os.path.join(directory, 'pio', f'{product}.yaml')
|
||||
if os.path.exists(config_path) and os.path.isfile(config_path):
|
||||
path = config_path
|
||||
break
|
||||
if not path:
|
||||
raise ProductConfigNotFoundError(f'pio/{product}.yaml not found')
|
||||
with open(path, 'r') as f:
|
||||
return yaml.safe_load(f)
|
||||
|
||||
|
||||
@ -83,7 +85,8 @@ def bsd_get(product_config: dict,
|
||||
defines[f'CONFIG_{define_name}'] = f'HOMEKIT_{attr_value.upper()}'
|
||||
return
|
||||
if kwargs['type'] == 'bool':
|
||||
defines[f'CONFIG_{define_name}'] = True
|
||||
if attr_value is True:
|
||||
defines[f'CONFIG_{define_name}'] = True
|
||||
return
|
||||
defines[f'CONFIG_{define_name}'] = str(attr_value)
|
||||
bsd_walk(product_config, f)
|
||||
@ -124,6 +127,11 @@ if __name__ == '__main__':
|
||||
raise ArgumentError(None, f'target {arg.target} not found for product {product}')
|
||||
|
||||
bsd, bsd_enums = bsd_get(product_config, arg)
|
||||
print('>>> bsd:')
|
||||
pprint(bsd)
|
||||
print('>>> bsd_enums:')
|
||||
pprint(bsd_enums)
|
||||
|
||||
ini = platformio_ini(product_config=product_config,
|
||||
target=arg.target,
|
||||
build_specific_defines=bsd,
|
||||
|
@ -5,7 +5,8 @@ from .config import (
|
||||
Translation,
|
||||
config,
|
||||
is_development_mode,
|
||||
setup_logging
|
||||
setup_logging,
|
||||
CONFIG_DIRECTORIES
|
||||
)
|
||||
from ._configs import (
|
||||
LinuxBoardsConfig,
|
||||
|
@ -8,8 +8,8 @@ from collections import OrderedDict
|
||||
_logger = logging.getLogger(__name__)
|
||||
_products_dir = os.path.join(
|
||||
os.path.dirname(__file__),
|
||||
'..', '..', '..',
|
||||
'platformio'
|
||||
'..', '..', '..', '..',
|
||||
'pio'
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user