Skip to content

Commit

Permalink
Allow to specify global build directory (esphome#6276)
Browse files Browse the repository at this point in the history
  • Loading branch information
werwolfby authored Feb 25, 2024
1 parent b5e633a commit a8ab745
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docker/docker_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ export PLATFORMIO_PLATFORMS_DIR="${pio_cache_base}/platforms"
export PLATFORMIO_PACKAGES_DIR="${pio_cache_base}/packages"
export PLATFORMIO_CACHE_DIR="${pio_cache_base}/cache"

# If /build is mounted, use that as the build path
# otherwise use path in /config (so that builds aren't lost on container restart)
if [[ -d /build ]]; then
export ESPHOME_BUILD_PATH=/build
fi

exec esphome "$@"
5 changes: 3 additions & 2 deletions esphome/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
__version__ as ESPHOME_VERSION,
)
from esphome.core import CORE, coroutine_with_priority
from esphome.helpers import copy_file_if_changed, walk_files
from esphome.helpers import copy_file_if_changed, get_str_env, walk_files

_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -190,7 +190,8 @@ def preload_core_config(config, result):
CORE.data[KEY_CORE] = {}

if CONF_BUILD_PATH not in conf:
conf[CONF_BUILD_PATH] = f"build/{CORE.name}"
build_path = get_str_env("ESPHOME_BUILD_PATH", "build")
conf[CONF_BUILD_PATH] = os.path.join(build_path, CORE.name)
CORE.build_path = CORE.relative_internal_path(conf[CONF_BUILD_PATH])

has_oldstyle = CONF_PLATFORM in conf
Expand Down

0 comments on commit a8ab745

Please sign in to comment.