forked from platformio/platformio-core
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-??-??)
|
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
|
* Fixed project generator for CLion IDE
|
||||||
|
|
||||||
3.5.0 (2017-12-28)
|
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(),
|
PROJECTSRC_DIR=util.get_projectsrc_dir(),
|
||||||
PROJECTTEST_DIR=util.get_projecttest_dir(),
|
PROJECTTEST_DIR=util.get_projecttest_dir(),
|
||||||
PROJECTDATA_DIR=util.get_projectdata_dir(),
|
PROJECTDATA_DIR=util.get_projectdata_dir(),
|
||||||
PROJECTPIOENVS_DIR=util.get_projectpioenvs_dir(),
|
PROJECTBUILD_DIR=util.get_projectbuild_dir(),
|
||||||
BUILD_DIR=join("$PROJECTPIOENVS_DIR", "$PIOENV"),
|
BUILD_DIR=join("$PROJECTBUILD_DIR", "$PIOENV"),
|
||||||
BUILDSRC_DIR=join("$BUILD_DIR", "src"),
|
BUILDSRC_DIR=join("$BUILD_DIR", "src"),
|
||||||
BUILDTEST_DIR=join("$BUILD_DIR", "test"),
|
BUILDTEST_DIR=join("$BUILD_DIR", "test"),
|
||||||
LIBSOURCE_DIRS=[
|
LIBSOURCE_DIRS=[
|
||||||
@ -150,7 +150,7 @@ env['LIBSOURCE_DIRS'] = [
|
|||||||
env.LoadPioPlatform(commonvars)
|
env.LoadPioPlatform(commonvars)
|
||||||
|
|
||||||
env.SConscriptChdir(0)
|
env.SConscriptChdir(0)
|
||||||
env.SConsignFile(join("$PROJECTPIOENVS_DIR", ".sconsign.dblite"))
|
env.SConsignFile(join("$PROJECTBUILD_DIR", ".sconsign.dblite"))
|
||||||
|
|
||||||
for item in env.GetPreExtraScripts():
|
for item in env.GetPreExtraScripts():
|
||||||
env.SConscript(item, exports="env")
|
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)
|
raise exception.NotPlatformIOProject(project_dir)
|
||||||
|
|
||||||
with util.cd(project_dir):
|
with util.cd(project_dir):
|
||||||
# clean obsolete .pioenvs dir
|
# clean obsolete build dir
|
||||||
if not disable_auto_clean:
|
if not disable_auto_clean:
|
||||||
try:
|
try:
|
||||||
_clean_pioenvs_dir(util.get_projectpioenvs_dir())
|
_clean_build_dir(util.get_projectbuild_dir())
|
||||||
except: # pylint: disable=bare-except
|
except: # pylint: disable=bare-except
|
||||||
click.secho(
|
click.secho(
|
||||||
"Can not remove temporary directory `%s`. Please remove "
|
"Can not remove temporary directory `%s`. Please remove "
|
||||||
"`.pioenvs` directory from the project manually to avoid "
|
"it manually to avoid build issues" %
|
||||||
"build issues" % util.get_projectpioenvs_dir(force=True),
|
util.get_projectbuild_dir(force=True),
|
||||||
fg="yellow")
|
fg="yellow")
|
||||||
|
|
||||||
config = util.load_project_config()
|
config = util.load_project_config()
|
||||||
@ -318,25 +318,25 @@ def _is_builtin_lib(lib_name):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def _clean_pioenvs_dir(pioenvs_dir):
|
def _clean_build_dir(build_dir):
|
||||||
structhash_file = join(pioenvs_dir, "structure.hash")
|
structhash_file = join(build_dir, "structure.hash")
|
||||||
proj_hash = calculate_project_hash()
|
proj_hash = calculate_project_hash()
|
||||||
|
|
||||||
# if project's config is modified
|
# if project's config is modified
|
||||||
if (isdir(pioenvs_dir)
|
if (isdir(build_dir)
|
||||||
and getmtime(join(util.get_project_dir(),
|
and getmtime(join(util.get_project_dir(),
|
||||||
"platformio.ini")) > getmtime(pioenvs_dir)):
|
"platformio.ini")) > getmtime(build_dir)):
|
||||||
util.rmtree_(pioenvs_dir)
|
util.rmtree_(build_dir)
|
||||||
|
|
||||||
# check project structure
|
# 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:
|
with open(structhash_file) as f:
|
||||||
if f.read() == proj_hash:
|
if f.read() == proj_hash:
|
||||||
return
|
return
|
||||||
util.rmtree_(pioenvs_dir)
|
util.rmtree_(build_dir)
|
||||||
|
|
||||||
if not isdir(pioenvs_dir):
|
if not isdir(build_dir):
|
||||||
makedirs(pioenvs_dir)
|
makedirs(build_dir)
|
||||||
|
|
||||||
with open(structhash_file, "w") as f:
|
with open(structhash_file, "w") as f:
|
||||||
f.write(proj_hash)
|
f.write(proj_hash)
|
||||||
@ -384,13 +384,13 @@ def check_project_defopts(config):
|
|||||||
if not config.has_section("platformio"):
|
if not config.has_section("platformio"):
|
||||||
return True
|
return True
|
||||||
known = ("env_default", "home_dir", "lib_dir", "libdeps_dir", "src_dir",
|
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")
|
"lib_extra_dirs")
|
||||||
unknown = set([k for k, _ in config.items("platformio")]) - set(known)
|
unknown = set([k for k, _ in config.items("platformio")]) - set(known)
|
||||||
if not unknown:
|
if not unknown:
|
||||||
return True
|
return True
|
||||||
click.secho(
|
click.secho(
|
||||||
"Warning! Ignore unknown `%s` option from `[platformio]` section" %
|
"Warning! Ignore unknown `%s` option in `[platformio]` section" %
|
||||||
", ".join(unknown),
|
", ".join(unknown),
|
||||||
fg="yellow")
|
fg="yellow")
|
||||||
return False
|
return False
|
||||||
|
@ -311,8 +311,8 @@ def get_projectboards_dir():
|
|||||||
join(get_project_dir(), "boards"))
|
join(get_project_dir(), "boards"))
|
||||||
|
|
||||||
|
|
||||||
def get_projectpioenvs_dir(force=False):
|
def get_projectbuild_dir(force=False):
|
||||||
path = get_project_optional_dir("envs_dir",
|
path = get_project_optional_dir("build_dir",
|
||||||
join(get_project_dir(), ".pioenvs"))
|
join(get_project_dir(), ".pioenvs"))
|
||||||
try:
|
try:
|
||||||
if not isdir(path):
|
if not isdir(path):
|
||||||
@ -322,7 +322,7 @@ def get_projectpioenvs_dir(force=False):
|
|||||||
with open(dontmod_path, "w") as fp:
|
with open(dontmod_path, "w") as fp:
|
||||||
fp.write("""
|
fp.write("""
|
||||||
[InternetShortcut]
|
[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
|
except Exception as e: # pylint: disable=broad-except
|
||||||
if not force:
|
if not force:
|
||||||
@ -330,6 +330,10 @@ URL=http://docs.platformio.org/page/projectconf.html#envs-dir
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
# compatibility with PIO Core+
|
||||||
|
get_projectpioenvs_dir = get_projectbuild_dir
|
||||||
|
|
||||||
|
|
||||||
def get_projectdata_dir():
|
def get_projectdata_dir():
|
||||||
return get_project_optional_dir("data_dir", join(get_project_dir(),
|
return get_project_optional_dir("data_dir", join(get_project_dir(),
|
||||||
"data"))
|
"data"))
|
||||||
|
@ -36,26 +36,27 @@ def pytest_generate_tests(metafunc):
|
|||||||
|
|
||||||
@pytest.mark.examples
|
@pytest.mark.examples
|
||||||
def test_run(pioproject_dir):
|
def test_run(pioproject_dir):
|
||||||
if isdir(join(pioproject_dir, ".pioenvs")):
|
with util.cd(pioproject_dir):
|
||||||
util.rmtree_(join(pioproject_dir, ".pioenvs"))
|
build_dir = util.get_projectbuild_dir()
|
||||||
|
if isdir(build_dir):
|
||||||
|
util.rmtree_(build_dir)
|
||||||
|
|
||||||
result = util.exec_command(
|
result = util.exec_command(["platformio", "--force", "run"])
|
||||||
["platformio", "--force", "run", "--project-dir", pioproject_dir]
|
if result['returncode'] != 0:
|
||||||
)
|
pytest.fail(result)
|
||||||
if result['returncode'] != 0:
|
|
||||||
pytest.fail(result)
|
|
||||||
|
|
||||||
# check .elf file
|
assert isdir(build_dir)
|
||||||
pioenvs_dir = join(pioproject_dir, ".pioenvs")
|
|
||||||
for item in listdir(pioenvs_dir):
|
# check .elf file
|
||||||
if not isdir(item):
|
for item in listdir(build_dir):
|
||||||
continue
|
if not isdir(item):
|
||||||
assert isfile(join(pioenvs_dir, item, "firmware.elf"))
|
continue
|
||||||
# check .hex or .bin files
|
assert isfile(join(build_dir, item, "firmware.elf"))
|
||||||
firmwares = []
|
# check .hex or .bin files
|
||||||
for ext in ("bin", "hex"):
|
firmwares = []
|
||||||
firmwares += glob(join(pioenvs_dir, item, "firmware*.%s" % ext))
|
for ext in ("bin", "hex"):
|
||||||
if not firmwares:
|
firmwares += glob(join(build_dir, item, "firmware*.%s" % ext))
|
||||||
pytest.fail("Missed firmware file")
|
if not firmwares:
|
||||||
for firmware in firmwares:
|
pytest.fail("Missed firmware file")
|
||||||
assert getsize(firmware) > 0
|
for firmware in firmwares:
|
||||||
|
assert getsize(firmware) > 0
|
||||||
|
Reference in New Issue
Block a user