forked from platformio/platformio-core
Allow to initialise PlatformIO project for the specified IDE // Resolve #151
This commit is contained in:
14
HISTORY.rst
14
HISTORY.rst
@ -4,15 +4,18 @@ Release History
|
||||
2.0.0 (2015-??-??)
|
||||
------------------
|
||||
|
||||
* PlatformIO as :ref:`ci` (CI) tool for embedded projects
|
||||
(`issue #108 <https://github.com/platformio/platformio/issues/108>`_)
|
||||
* Initialise PlatformIO project for the specified IDE
|
||||
(`issue #151 <https://github.com/platformio/platformio/issues/151>`_)
|
||||
* PlatformIO CLI 2.0: "platform" related commands have been
|
||||
moved to ``platformio platforms`` subcommand
|
||||
(`issue #158 <https://github.com/platformio/platformio/issues/158>`_)
|
||||
* PlatformIO as Continuous Integration (CI) tool for embedded projects
|
||||
(`issue #108 <https://github.com/platformio/platformio/issues/108>`_)
|
||||
* Created `PlatformIO gitter.im <https://gitter.im/platformio/platformio>`_ room
|
||||
(`issue #174 <https://github.com/platformio/platformio/issues/174>`_)
|
||||
* Global ``-f, --force`` option which will force to accept any
|
||||
confirmation prompts (`issue #152 <https://github.com/platformio/platformio/issues/152>`_)
|
||||
confirmation prompts
|
||||
(`issue #152 <https://github.com/platformio/platformio/issues/152>`_)
|
||||
* Run project with `platformio run --project-dir <http://docs.platformio.org/en/latest/userguide/cmd_run.html#cmdoption--project-dir>`_ option without changing the current working
|
||||
directory
|
||||
(`issue #192 <https://github.com/platformio/platformio/issues/192>`_)
|
||||
@ -33,6 +36,11 @@ Release History
|
||||
(`issue #168 <https://github.com/platformio/platformio/issues/168>`_)
|
||||
* Specify `platformio init --env-prefix <http://docs.platformio.org/en/latest/userguide/cmd_init.html#cmdoption--env-prefix>`__ when initialise/update project
|
||||
(`issue #182 <https://github.com/platformio/platformio/issues/182>`_)
|
||||
* Added new Armstrap boards
|
||||
(`issue #204 <https://github.com/platformio/platformio/issues/204>`_)
|
||||
* Updated SDK for `espressif <http://docs.platformio.org/en/latest/platforms/espressif.html>`__
|
||||
development platform to v1.1
|
||||
(`issue #179 <https://github.com/platformio/platformio/issues/179>`_)
|
||||
* Disabled automatic updates by default for platforms, packages and libraries
|
||||
(`issue #171 <https://github.com/platformio/platformio/issues/171>`_)
|
||||
* Fixed bug with creating copies of source files
|
||||
|
@ -49,6 +49,14 @@ pre-fill these data:
|
||||
|
||||
The full list with pre-configured boards is available here :ref:`platforms`.
|
||||
|
||||
.. option::
|
||||
--ide
|
||||
|
||||
Initialise PlatformIO project for the specified IDE which can be imported later
|
||||
via "Import Project" functionality.
|
||||
|
||||
A list with supported IDE is available within ``platformio init --help`` command.
|
||||
|
||||
.. option::
|
||||
--disable-auto-uploading
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
VERSION = (2, 0, "0a2")
|
||||
VERSION = (2, 0, "0rc1")
|
||||
__version__ = ".".join([str(s) for s in VERSION])
|
||||
|
||||
__title__ = "platformio"
|
||||
|
@ -106,20 +106,20 @@ env.Append(
|
||||
#
|
||||
|
||||
if env.subst("${PLATFORMFW_DIR}")[-3:] == "sam":
|
||||
env.VariantDir(
|
||||
env.VariantDirWrap(
|
||||
join("$BUILD_DIR", "FrameworkCMSISInc"),
|
||||
join("$PLATFORMFW_DIR", "system", "CMSIS", "CMSIS", "Include")
|
||||
)
|
||||
env.VariantDir(
|
||||
env.VariantDirWrap(
|
||||
join("$BUILD_DIR", "FrameworkDeviceInc"),
|
||||
join("$PLATFORMFW_DIR", "system", "CMSIS", "Device", "ATMEL")
|
||||
)
|
||||
env.VariantDir(
|
||||
env.VariantDirWrap(
|
||||
join("$BUILD_DIR", "FrameworkLibSam"),
|
||||
join("$PLATFORMFW_DIR", "system", "libsam")
|
||||
)
|
||||
|
||||
env.VariantDir(
|
||||
env.VariantDirWrap(
|
||||
join("$BUILD_DIR", "FrameworkArduinoInc"),
|
||||
join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}")
|
||||
)
|
||||
|
@ -25,7 +25,7 @@ env.Replace(
|
||||
PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-cmsis")
|
||||
)
|
||||
|
||||
env.VariantDir(
|
||||
env.VariantDirWrap(
|
||||
join("$BUILD_DIR", "FrameworkCMSIS"),
|
||||
join("$PLATFORMFW_DIR", "cores", "${BOARD_OPTIONS['build']['core']}")
|
||||
)
|
||||
|
@ -28,7 +28,7 @@ ENERGIA_VERSION = int(
|
||||
"version.txt")).read().replace(".", "").strip())
|
||||
|
||||
# include board variant
|
||||
env.VariantDir(
|
||||
env.VariantDirWrap(
|
||||
join("$BUILD_DIR", "FrameworkEnergiaVariant"),
|
||||
join("$PLATFORMFW_DIR", "variants", "${BOARD_OPTIONS['build']['variant']}")
|
||||
)
|
||||
|
@ -138,7 +138,7 @@ if BOARD_BUILDOPTS.get("core") == "lm4f":
|
||||
CPPDEFINES=["LM4F"]
|
||||
)
|
||||
|
||||
env.VariantDir(
|
||||
env.VariantDirWrap(
|
||||
join("$BUILD_DIR", "FrameworkLibOpenCM3Variant"),
|
||||
join("$PLATFORMFW_DIR", "include")
|
||||
)
|
||||
@ -166,7 +166,7 @@ env.Replace(
|
||||
)
|
||||
|
||||
libs = []
|
||||
env.VariantDir(
|
||||
env.VariantDirWrap(
|
||||
join("$BUILD_DIR", "FrameworkLibOpenCM3"),
|
||||
"$PLATFORMFW_DIR"
|
||||
)
|
||||
|
@ -134,7 +134,7 @@ def add_mbedlib(libname, libar):
|
||||
(libname.upper(), crc32(root)))
|
||||
if var_dir in env.get("CPPPATH"):
|
||||
continue
|
||||
env.VariantDir(var_dir, root)
|
||||
env.VariantDirWrap(var_dir, root)
|
||||
env.Append(CPPPATH=[var_dir])
|
||||
|
||||
|
||||
@ -221,7 +221,7 @@ if board_type in ("frdm_k22f", "frdm_k64f"):
|
||||
|
||||
for lib_path in eixdata.get("CPPPATH"):
|
||||
_vdir = join("$BUILD_DIR", "FrameworkMbedInc%d" % crc32(lib_path))
|
||||
env.VariantDir(_vdir, join(variant_dir, lib_path))
|
||||
env.VariantDirWrap(_vdir, join(variant_dir, lib_path))
|
||||
env.Append(CPPPATH=[_vdir])
|
||||
|
||||
env.Append(
|
||||
|
@ -22,7 +22,7 @@ env.Replace(
|
||||
PLATFORMFW_DIR=join("$PIOPACKAGES_DIR", "framework-spl")
|
||||
)
|
||||
|
||||
env.VariantDir(
|
||||
env.VariantDirWrap(
|
||||
join("$BUILD_DIR", "FrameworkSPLInc"),
|
||||
join("$PLATFORMFW_DIR", "${BOARD_OPTIONS['build']['core']}",
|
||||
"variants", "${BOARD_OPTIONS['build']['variant']}", "inc")
|
||||
|
@ -2,12 +2,13 @@
|
||||
# See LICENSE for details.
|
||||
|
||||
import atexit
|
||||
import json
|
||||
import re
|
||||
from os import getenv, listdir, remove, sep, walk
|
||||
from os.path import basename, dirname, isdir, isfile, join, normpath
|
||||
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, Exit, SConscript,
|
||||
SConscriptChdir)
|
||||
from SCons.Script import (COMMAND_LINE_TARGETS, DefaultEnvironment, Exit,
|
||||
SConscript, SConscriptChdir)
|
||||
from SCons.Util import case_sensitive_suffixes
|
||||
|
||||
from platformio.util import pioversion_to_intstr
|
||||
@ -60,6 +61,15 @@ def BuildFirmware(env):
|
||||
print env.Dump()
|
||||
Exit()
|
||||
|
||||
if "idedata" in COMMAND_LINE_TARGETS:
|
||||
_data = {"defines": [], "includes": []}
|
||||
for item in env.get("VARIANT_DIRS", []):
|
||||
_data['includes'].append(env.subst(item[1]))
|
||||
for item in env.get("CPPDEFINES", []):
|
||||
_data['defines'].append(env.subst(item))
|
||||
print json.dumps(_data)
|
||||
Exit()
|
||||
|
||||
return firmenv.Program(
|
||||
join("$BUILD_DIR", "firmware"),
|
||||
[firmenv.GlobCXXFiles(vdir) for vdir in vdirs],
|
||||
@ -94,6 +104,11 @@ def GlobCXXFiles(env, path):
|
||||
return files
|
||||
|
||||
|
||||
def VariantDirWrap(env, variant_dir, src_dir, duplicate=True):
|
||||
DefaultEnvironment().Append(VARIANT_DIRS=[(variant_dir, src_dir)])
|
||||
env.VariantDir(variant_dir, src_dir, duplicate)
|
||||
|
||||
|
||||
def VariantDirRecursive(env, variant_dir, src_dir, duplicate=True,
|
||||
ignore_pattern=None):
|
||||
if not ignore_pattern:
|
||||
@ -105,7 +120,7 @@ def VariantDirRecursive(env, variant_dir, src_dir, duplicate=True,
|
||||
_var_dir = variant_dir + root.replace(src_dir, "")
|
||||
if any([s in _var_dir.lower() for s in ignore_pattern]):
|
||||
continue
|
||||
env.VariantDir(_var_dir, _src_dir, duplicate)
|
||||
env.VariantDirWrap(_var_dir, _src_dir, duplicate)
|
||||
variants.append(_var_dir)
|
||||
return variants
|
||||
|
||||
@ -397,6 +412,7 @@ def generate(env):
|
||||
env.AddMethod(BuildFirmware)
|
||||
env.AddMethod(ProcessFlags)
|
||||
env.AddMethod(GlobCXXFiles)
|
||||
env.AddMethod(VariantDirWrap)
|
||||
env.AddMethod(VariantDirRecursive)
|
||||
env.AddMethod(BuildFramework)
|
||||
env.AddMethod(BuildLibrary)
|
||||
|
@ -1,6 +1,7 @@
|
||||
# Copyright (C) Ivan Kravets <me@ikravets.com>
|
||||
# See LICENSE for details.
|
||||
|
||||
import json
|
||||
from glob import glob
|
||||
from os import listdir, walk
|
||||
from os.path import basename, isdir, join
|
||||
@ -37,13 +38,30 @@ class ProjectGenerator(object):
|
||||
data[k] = v
|
||||
return data
|
||||
|
||||
@util.memoized
|
||||
def get_project_build_data(self):
|
||||
envdata = self.get_project_env()
|
||||
if "env_name" not in envdata:
|
||||
return None
|
||||
result = util.exec_command(
|
||||
["platformio", "run", "-t", "idedata", "-e", envdata['env_name']]
|
||||
)
|
||||
if result['returncode'] != 0 or '{"includes":' not in result['out']:
|
||||
return None
|
||||
|
||||
output = result['out']
|
||||
start_index = output.index('---\n{"includes":')
|
||||
stop_index = output.index('}\n===')
|
||||
try:
|
||||
return json.loads(output[start_index+4:stop_index+1])
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
return None
|
||||
|
||||
def get_project_name(self):
|
||||
return basename(self.project_dir)
|
||||
|
||||
@staticmethod
|
||||
def get_includes():
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def get_srcfiles():
|
||||
result = []
|
||||
@ -52,10 +70,6 @@ class ProjectGenerator(object):
|
||||
result.append(join(root, f))
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def get_defines():
|
||||
return []
|
||||
|
||||
def get_tpls(self):
|
||||
tpls_dir = join(util.get_source_dir(), "ide", "tpls", self.ide)
|
||||
return glob(join(tpls_dir, ".*.tpl")) + glob(join(tpls_dir, "*.tpl"))
|
||||
@ -75,10 +89,14 @@ class ProjectGenerator(object):
|
||||
def _gather_tplvars(self):
|
||||
self._tplvars.update(self.get_project_env())
|
||||
|
||||
build_data = self.get_project_build_data()
|
||||
|
||||
self._tplvars.update({
|
||||
"project_name": self.get_project_name(),
|
||||
"includes": self.get_includes(),
|
||||
"includes": (build_data['includes']
|
||||
if build_data and "includes" in build_data else []),
|
||||
"defines": (build_data['defines']
|
||||
if build_data and "defines" in build_data else []),
|
||||
"srcfiles": self.get_srcfiles(),
|
||||
"defines": self.get_defines(),
|
||||
"project_dir": self.project_dir
|
||||
})
|
||||
|
Reference in New Issue
Block a user