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