mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Rename envs_dir
option to build_dir
in platformio.ini
This commit is contained in:
@ -7,6 +7,8 @@ PlatformIO 3.0
|
||||
3.5.1 (2018-??-??)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
* Renamed ``envs_dir`` option to ``build_dir``
|
||||
in `Project Configuration File "platformio.ini" <http://docs.platformio.org/page/projectconf/section_platformio.html#build-dir>`__
|
||||
* Fixed project generator for CLion IDE
|
||||
|
||||
3.5.0 (2017-12-28)
|
||||
|
2
docs
2
docs
Submodule docs updated: 9ba6ef3fad...3c76b2d289
2
examples
2
examples
Submodule examples updated: 2d716306f3...817a51b719
@ -91,8 +91,8 @@ DEFAULT_ENV_OPTIONS = dict(
|
||||
PROJECTSRC_DIR=util.get_projectsrc_dir(),
|
||||
PROJECTTEST_DIR=util.get_projecttest_dir(),
|
||||
PROJECTDATA_DIR=util.get_projectdata_dir(),
|
||||
PROJECTPIOENVS_DIR=util.get_projectpioenvs_dir(),
|
||||
BUILD_DIR=join("$PROJECTPIOENVS_DIR", "$PIOENV"),
|
||||
PROJECTBUILD_DIR=util.get_projectbuild_dir(),
|
||||
BUILD_DIR=join("$PROJECTBUILD_DIR", "$PIOENV"),
|
||||
BUILDSRC_DIR=join("$BUILD_DIR", "src"),
|
||||
BUILDTEST_DIR=join("$BUILD_DIR", "test"),
|
||||
LIBSOURCE_DIRS=[
|
||||
@ -150,7 +150,7 @@ env['LIBSOURCE_DIRS'] = [
|
||||
env.LoadPioPlatform(commonvars)
|
||||
|
||||
env.SConscriptChdir(0)
|
||||
env.SConsignFile(join("$PROJECTPIOENVS_DIR", ".sconsign.dblite"))
|
||||
env.SConsignFile(join("$PROJECTBUILD_DIR", ".sconsign.dblite"))
|
||||
|
||||
for item in env.GetPreExtraScripts():
|
||||
env.SConscript(item, exports="env")
|
||||
|
@ -60,15 +60,15 @@ def cli(ctx, environment, target, upload_port, project_dir, silent, verbose,
|
||||
raise exception.NotPlatformIOProject(project_dir)
|
||||
|
||||
with util.cd(project_dir):
|
||||
# clean obsolete .pioenvs dir
|
||||
# clean obsolete build dir
|
||||
if not disable_auto_clean:
|
||||
try:
|
||||
_clean_pioenvs_dir(util.get_projectpioenvs_dir())
|
||||
_clean_build_dir(util.get_projectbuild_dir())
|
||||
except: # pylint: disable=bare-except
|
||||
click.secho(
|
||||
"Can not remove temporary directory `%s`. Please remove "
|
||||
"`.pioenvs` directory from the project manually to avoid "
|
||||
"build issues" % util.get_projectpioenvs_dir(force=True),
|
||||
"it manually to avoid build issues" %
|
||||
util.get_projectbuild_dir(force=True),
|
||||
fg="yellow")
|
||||
|
||||
config = util.load_project_config()
|
||||
@ -318,25 +318,25 @@ def _is_builtin_lib(lib_name):
|
||||
return False
|
||||
|
||||
|
||||
def _clean_pioenvs_dir(pioenvs_dir):
|
||||
structhash_file = join(pioenvs_dir, "structure.hash")
|
||||
def _clean_build_dir(build_dir):
|
||||
structhash_file = join(build_dir, "structure.hash")
|
||||
proj_hash = calculate_project_hash()
|
||||
|
||||
# if project's config is modified
|
||||
if (isdir(pioenvs_dir)
|
||||
if (isdir(build_dir)
|
||||
and getmtime(join(util.get_project_dir(),
|
||||
"platformio.ini")) > getmtime(pioenvs_dir)):
|
||||
util.rmtree_(pioenvs_dir)
|
||||
"platformio.ini")) > getmtime(build_dir)):
|
||||
util.rmtree_(build_dir)
|
||||
|
||||
# check project structure
|
||||
if isdir(pioenvs_dir) and isfile(structhash_file):
|
||||
if isdir(build_dir) and isfile(structhash_file):
|
||||
with open(structhash_file) as f:
|
||||
if f.read() == proj_hash:
|
||||
return
|
||||
util.rmtree_(pioenvs_dir)
|
||||
util.rmtree_(build_dir)
|
||||
|
||||
if not isdir(pioenvs_dir):
|
||||
makedirs(pioenvs_dir)
|
||||
if not isdir(build_dir):
|
||||
makedirs(build_dir)
|
||||
|
||||
with open(structhash_file, "w") as f:
|
||||
f.write(proj_hash)
|
||||
@ -384,13 +384,13 @@ def check_project_defopts(config):
|
||||
if not config.has_section("platformio"):
|
||||
return True
|
||||
known = ("env_default", "home_dir", "lib_dir", "libdeps_dir", "src_dir",
|
||||
"envs_dir", "data_dir", "test_dir", "boards_dir",
|
||||
"build_dir", "data_dir", "test_dir", "boards_dir",
|
||||
"lib_extra_dirs")
|
||||
unknown = set([k for k, _ in config.items("platformio")]) - set(known)
|
||||
if not unknown:
|
||||
return True
|
||||
click.secho(
|
||||
"Warning! Ignore unknown `%s` option from `[platformio]` section" %
|
||||
"Warning! Ignore unknown `%s` option in `[platformio]` section" %
|
||||
", ".join(unknown),
|
||||
fg="yellow")
|
||||
return False
|
||||
|
@ -311,8 +311,8 @@ def get_projectboards_dir():
|
||||
join(get_project_dir(), "boards"))
|
||||
|
||||
|
||||
def get_projectpioenvs_dir(force=False):
|
||||
path = get_project_optional_dir("envs_dir",
|
||||
def get_projectbuild_dir(force=False):
|
||||
path = get_project_optional_dir("build_dir",
|
||||
join(get_project_dir(), ".pioenvs"))
|
||||
try:
|
||||
if not isdir(path):
|
||||
@ -322,7 +322,7 @@ def get_projectpioenvs_dir(force=False):
|
||||
with open(dontmod_path, "w") as fp:
|
||||
fp.write("""
|
||||
[InternetShortcut]
|
||||
URL=http://docs.platformio.org/page/projectconf.html#envs-dir
|
||||
URL=http://docs.platformio.org/page/projectconf.html#build-dir
|
||||
""")
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
if not force:
|
||||
@ -330,6 +330,10 @@ URL=http://docs.platformio.org/page/projectconf.html#envs-dir
|
||||
return path
|
||||
|
||||
|
||||
# compatibility with PIO Core+
|
||||
get_projectpioenvs_dir = get_projectbuild_dir
|
||||
|
||||
|
||||
def get_projectdata_dir():
|
||||
return get_project_optional_dir("data_dir", join(get_project_dir(),
|
||||
"data"))
|
||||
|
@ -36,26 +36,27 @@ def pytest_generate_tests(metafunc):
|
||||
|
||||
@pytest.mark.examples
|
||||
def test_run(pioproject_dir):
|
||||
if isdir(join(pioproject_dir, ".pioenvs")):
|
||||
util.rmtree_(join(pioproject_dir, ".pioenvs"))
|
||||
with util.cd(pioproject_dir):
|
||||
build_dir = util.get_projectbuild_dir()
|
||||
if isdir(build_dir):
|
||||
util.rmtree_(build_dir)
|
||||
|
||||
result = util.exec_command(
|
||||
["platformio", "--force", "run", "--project-dir", pioproject_dir]
|
||||
)
|
||||
if result['returncode'] != 0:
|
||||
pytest.fail(result)
|
||||
result = util.exec_command(["platformio", "--force", "run"])
|
||||
if result['returncode'] != 0:
|
||||
pytest.fail(result)
|
||||
|
||||
# check .elf file
|
||||
pioenvs_dir = join(pioproject_dir, ".pioenvs")
|
||||
for item in listdir(pioenvs_dir):
|
||||
if not isdir(item):
|
||||
continue
|
||||
assert isfile(join(pioenvs_dir, item, "firmware.elf"))
|
||||
# check .hex or .bin files
|
||||
firmwares = []
|
||||
for ext in ("bin", "hex"):
|
||||
firmwares += glob(join(pioenvs_dir, item, "firmware*.%s" % ext))
|
||||
if not firmwares:
|
||||
pytest.fail("Missed firmware file")
|
||||
for firmware in firmwares:
|
||||
assert getsize(firmware) > 0
|
||||
assert isdir(build_dir)
|
||||
|
||||
# check .elf file
|
||||
for item in listdir(build_dir):
|
||||
if not isdir(item):
|
||||
continue
|
||||
assert isfile(join(build_dir, item, "firmware.elf"))
|
||||
# check .hex or .bin files
|
||||
firmwares = []
|
||||
for ext in ("bin", "hex"):
|
||||
firmwares += glob(join(build_dir, item, "firmware*.%s" % ext))
|
||||
if not firmwares:
|
||||
pytest.fail("Missed firmware file")
|
||||
for firmware in firmwares:
|
||||
assert getsize(firmware) > 0
|
||||
|
Reference in New Issue
Block a user