blob: ac6d5e4f984fb326e53baa842b7cf072121d3d9d [file] [log] [blame]
# Copyright 2022 The Pigweed Authors
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
"""pw_ide configuration."""
import os
from pathlib import Path
from typing import Any, Dict, List, Optional, Union
from pw_console.yaml_config_loader_mixin import YamlConfigLoaderMixin
PW_IDE_DIR_NAME = '.pw_ide'
os.path.expandvars('$PW_PROJECT_ROOT')) / PW_IDE_DIR_NAME
'setup': [],
'targets': [],
'working_dir': _PW_IDE_DEFAULT_DIR,
_DEFAULT_USER_FILE = Path('$HOME/.pw_ide.yaml')
class IdeSettings(YamlConfigLoaderMixin):
"""Pigweed IDE features settings storage class."""
def __init__(
project_file: Union[Path, bool] = _DEFAULT_PROJECT_FILE,
project_user_file: Union[Path, bool] = _DEFAULT_PROJECT_USER_FILE,
user_file: Union[Path, bool] = _DEFAULT_USER_FILE,
default_config: Optional[Dict[str, Any]] = None,
) -> None:
if default_config is None else default_config,
def working_dir(self) -> Path:
"""Path to the pw_ide working directory.
This should not be a directory that's regularly deleted or manipulated
by other processes (e.g. the GN `out` directory) nor should it be
committed to the code repo.
return Path(self._config.get('working_dir', ''))
def targets(self) -> List[str]:
"""The list of targets that should be made available for code analysis.
In this case, "target" is analogous to a GN target, i.e., a particular
build configuration. Targets defined here will be used when processing
a compilation database.
return self._config.get('targets', list())
def setup(self) -> List[str]:
"""`pw ide setup` should do everything necessary to get the project from
a fresh checkout to a working default IDE experience. This defines the
list of commands that makes that happen.
Commands need to be formatted as lists in the way that Python's expects, since that's exactly where they're going.
Note that this command must be idempotent, so that the user can run it
whenever they want without a care in the world.
return self._config.get('setup', list())