Fix issue with `src_filter` option for Windows OS // Resolve #652

This commit is contained in:
Ivan Kravets
2016-05-10 15:36:00 +03:00
parent 69effbfedb
commit 056cc08d68
4 changed files with 39 additions and 34 deletions

View File

@ -14,6 +14,8 @@ PlatformIO 2.0
* Use HTTP mirror for Package Manager in a case with SSL errors * Use HTTP mirror for Package Manager in a case with SSL errors
(`issue #645 <https://github.com/platformio/platformio/issues/645>`_) (`issue #645 <https://github.com/platformio/platformio/issues/645>`_)
* Fixed bug with ``env_default`` when ``pio run -e`` is used * Fixed bug with ``env_default`` when ``pio run -e`` is used
* Fixed issue with ``src_filter`` option for Windows OS
(`issue #652 <https://github.com/platformio/platformio/issues/652>`_)
2.9.1 (2016-04-30) 2.9.1 (2016-04-30)
~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~

View File

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import base64
import json import json
import sys import sys
from os import environ from os import environ
@ -99,6 +100,12 @@ DefaultEnvironment(
) )
env = DefaultEnvironment() env = DefaultEnvironment()
# decode common variables
for k in commonvars.keys():
if k in env:
env[k] = base64.b64decode(env[k])
env.Prepend(LIBPATH=[join("$PIOPACKAGES_DIR", "ldscripts")]) env.Prepend(LIBPATH=[join("$PIOPACKAGES_DIR", "ldscripts")])
if "BOARD" in env: if "BOARD" in env:

View File

@ -164,14 +164,14 @@ class EnvironmentProcessor(object):
return result return result
def _get_build_variables(self): def _get_build_variables(self):
variables = ["PIOENV=" + self.name] variables = {"pioenv": self.name}
if self.upload_port: if self.upload_port:
variables.append("UPLOAD_PORT=%s" % self.upload_port) variables['upload_port'] = self.upload_port
for k, v in self.options.items(): for k, v in self.options.items():
k = k.upper() k = k.lower()
if k == "TARGETS" or (k == "UPLOAD_PORT" and self.upload_port): if k == "targets" or (k == "upload_port" and self.upload_port):
continue continue
variables.append("%s=%s" % (k, v)) variables[k] = v
return variables return variables
def _get_build_targets(self): def _get_build_targets(self):

View File

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import base64
import os import os
import re import re
import sys import sys
@ -400,10 +401,10 @@ class BasePlatform(object):
obsolated = pm.get_outdated() obsolated = pm.get_outdated()
return not set(self.get_packages().keys()).isdisjoint(set(obsolated)) return not set(self.get_packages().keys()).isdisjoint(set(obsolated))
def configure_default_packages(self, envoptions, targets): def configure_default_packages(self, variables, targets):
# enbale used frameworks # enbale used frameworks
for pkg_name in self.pkg_aliases_to_names(["framework"]): for pkg_name in self.pkg_aliases_to_names(["framework"]):
for framework in envoptions.get("framework", "").split(","): for framework in variables.get("framework", "").split(","):
framework = framework.lower().strip() framework = framework.lower().strip()
if not framework: if not framework:
continue continue
@ -441,15 +442,10 @@ class BasePlatform(object):
raise exception.PlatformNotInstalledYet(self.get_type()) raise exception.PlatformNotInstalledYet(self.get_type())
def run(self, variables, targets, verbose): def run(self, variables, targets, verbose):
assert isinstance(variables, list) assert isinstance(variables, dict)
assert isinstance(targets, list) assert isinstance(targets, list)
envoptions = {} self.configure_default_packages(variables, targets)
for v in variables:
_name, _value = v.split("=", 1)
envoptions[_name.lower()] = _value
self.configure_default_packages(envoptions, targets)
self._install_default_packages() self._install_default_packages()
self._verbose_level = int(verbose) self._verbose_level = int(verbose)
@ -458,23 +454,17 @@ class BasePlatform(object):
targets.remove("clean") targets.remove("clean")
targets.append("-c") targets.append("-c")
if "build_script" not in envoptions: if "build_script" not in variables:
variables.append("BUILD_SCRIPT=%s" % self.get_build_script()) variables['build_script'] = self.get_build_script()
if not isfile(variables['build_script']):
for v in variables: raise exception.BuildScriptNotFound(variables['build_script'])
if not v.startswith("BUILD_SCRIPT="):
continue
_, path = v.split("=", 1)
if not isfile(path):
raise exception.BuildScriptNotFound(path)
# append aliases of the installed packages # append aliases of the installed packages
installed_packages = PackageManager.get_installed() installed_packages = PackageManager.get_installed()
for name, options in self.get_packages().items(): for name, options in self.get_packages().items():
if "alias" not in options or name not in installed_packages: if "alias" not in options or name not in installed_packages:
continue continue
variables.append( variables['piopackage_%s' % options['alias']] = name
"PIOPACKAGE_%s=%s" % (options['alias'].upper(), name))
self._found_error = False self._found_error = False
result = self._run_scons(variables, targets) result = self._run_scons(variables, targets)
@ -498,16 +488,22 @@ class BasePlatform(object):
_PYTHONPATH.append(p) _PYTHONPATH.append(p)
os.environ['PYTHONPATH'] = os.pathsep.join(_PYTHONPATH) os.environ['PYTHONPATH'] = os.pathsep.join(_PYTHONPATH)
cmd = [
os.path.normpath(sys.executable),
join(util.get_home_dir(), "packages", "tool-scons",
"script", "scons"),
"-Q",
"-j %d" % self.get_job_nums(),
"--warn=no-no-parallel-support",
"-f", join(util.get_source_dir(), "builder", "main.py")
] + targets
# encode and append variables
for key, value in variables.items():
cmd.append("%s=%s" % (key.upper(), base64.b64encode(value)))
result = util.exec_command( result = util.exec_command(
[ cmd,
os.path.normpath(sys.executable),
join(util.get_home_dir(), "packages", "tool-scons",
"script", "scons"),
"-Q",
"-j %d" % self.get_job_nums(),
"--warn=no-no-parallel-support",
"-f", join(util.get_source_dir(), "builder", "main.py")
] + variables + targets,
stdout=util.AsyncPipe(self.on_run_out), stdout=util.AsyncPipe(self.on_run_out),
stderr=util.AsyncPipe(self.on_run_err) stderr=util.AsyncPipe(self.on_run_err)
) )