aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2023-06-11 01:34:08 +0300
committerEvgeny Zinoviev <me@ch1p.io>2023-06-11 01:34:08 +0300
commitee0341e137f6a8dcf90d5a744e334f66b9d6d60a (patch)
tree72afde11d78754f3bd3387c869236e5a450feb20
parent6055011d82fe001a8cb88359b322c8a8581cc987 (diff)
fix platformio.ini generation
-rwxr-xr-xbin/pio_ini.py26
-rw-r--r--include/py/homekit/config/__init__.py3
-rw-r--r--include/py/homekit/pio/products.py4
3 files changed, 21 insertions, 12 deletions
diff --git a/bin/pio_ini.py b/bin/pio_ini.py
index 34ad395..2926234 100755
--- a/bin/pio_ini.py
+++ b/bin/pio_ini.py
@@ -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,
diff --git a/include/py/homekit/config/__init__.py b/include/py/homekit/config/__init__.py
index 2fa5214..8fedfa6 100644
--- a/include/py/homekit/config/__init__.py
+++ b/include/py/homekit/config/__init__.py
@@ -5,7 +5,8 @@ from .config import (
Translation,
config,
is_development_mode,
- setup_logging
+ setup_logging,
+ CONFIG_DIRECTORIES
)
from ._configs import (
LinuxBoardsConfig,
diff --git a/include/py/homekit/pio/products.py b/include/py/homekit/pio/products.py
index 388da03..c4fcd73 100644
--- a/include/py/homekit/pio/products.py
+++ b/include/py/homekit/pio/products.py
@@ -8,8 +8,8 @@ from collections import OrderedDict
_logger = logging.getLogger(__name__)
_products_dir = os.path.join(
os.path.dirname(__file__),
- '..', '..', '..',
- 'platformio'
+ '..', '..', '..', '..',
+ 'pio'
)