Avoid problem with long command for "gcc-ar" under Windows

This commit is contained in:
Ivan Kravets
2015-03-04 21:51:41 +02:00
parent 6f19839920
commit 386ad9a94b
4 changed files with 37 additions and 1 deletions

View File

@ -52,7 +52,7 @@ commonvars.AddVariables(
DefaultEnvironment(
tools=[
"gcc", "g++", "as", "ar", "gnulink",
"platformio", "upload"
"platformio", "pioupload", "pioar"
],
toolpath=[join("$PIOBUILDER_DIR", "tools")],
variables=commonvars,

View File

@ -30,6 +30,7 @@ def BeforeUpload(target, source, env): # pylint: disable=W0613,W0621
env.AutodetectUploadPort()
env.Append(UPLOADERFLAGS=["-P", "$UPLOAD_PORT"])
if env.subst("$BOARD") == "raspduino":
_rpi_sysgpio("/sys/class/gpio/export", 18)
_rpi_sysgpio("/sys/class/gpio/gpio18/direction", "out")

View File

@ -0,0 +1,35 @@
# Copyright (C) Ivan Kravets <me@ikravets.com>
# See LICENSE for details.
import atexit
from os import remove
from tempfile import mkstemp
MAX_SOURCES_LENGTH = 8000 # Windows CLI has limit with command length to 8192
def _huge_sources_hook(sources):
if len(str(sources)) < MAX_SOURCES_LENGTH:
return sources
_, tmp_file = mkstemp()
with open(tmp_file, "w") as f:
f.write(str(sources).replace("\\", "/"))
atexit.register(remove, tmp_file)
return "@%s" % tmp_file
def exists(_):
return True
def generate(env):
env.Replace(
_huge_sources_hook=_huge_sources_hook,
ARCOM=env.get("ARCOM", "").replace(
"$SOURCES", "${_huge_sources_hook(SOURCES)}"))
return env