mirror of
https://github.com/platformio/platformio-core.git
synced 2025-08-02 11:24:27 +02:00
Refactor long command hook for GCC and Windows CMD limitations
This commit is contained in:
@@ -68,8 +68,8 @@ commonvars.AddVariables(
|
|||||||
DefaultEnvironment(
|
DefaultEnvironment(
|
||||||
tools=[
|
tools=[
|
||||||
"ar", "as", "gcc", "g++", "gnulink",
|
"ar", "as", "gcc", "g++", "gnulink",
|
||||||
"platformio", "pioplatform",
|
"longcmdhook", "platformio", "pioplatform",
|
||||||
"piolib", "piotest", "pioupload", "pioar", "piomisc"
|
"piolib", "piotest", "pioupload", "piomisc"
|
||||||
], # yapf: disable
|
], # yapf: disable
|
||||||
toolpath=[join(util.get_source_dir(), "builder", "tools")],
|
toolpath=[join(util.get_source_dir(), "builder", "tools")],
|
||||||
variables=commonvars,
|
variables=commonvars,
|
||||||
|
@@ -19,12 +19,12 @@ from tempfile import gettempdir
|
|||||||
MAX_SOURCES_LENGTH = 8000 # Windows CLI has limit with command length to 8192
|
MAX_SOURCES_LENGTH = 8000 # Windows CLI has limit with command length to 8192
|
||||||
|
|
||||||
|
|
||||||
def _huge_sources_hook(sources):
|
def long_cmd_hook(sources):
|
||||||
_sources = str(sources).replace("\\", "/")
|
_sources = str(sources).replace("\\", "/")
|
||||||
if len(str(_sources)) < MAX_SOURCES_LENGTH:
|
if len(str(_sources)) < MAX_SOURCES_LENGTH:
|
||||||
return sources
|
return sources
|
||||||
|
|
||||||
tmp_file = join(gettempdir(), "pioarargs-%s" % md5(_sources).hexdigest())
|
tmp_file = join(gettempdir(), "longcmd-%s" % md5(_sources).hexdigest())
|
||||||
with open(tmp_file, "w") as f:
|
with open(tmp_file, "w") as f:
|
||||||
# fix space in paths
|
# fix space in paths
|
||||||
for line in _sources.split(".o "):
|
for line in _sources.split(".o "):
|
||||||
@@ -41,9 +41,11 @@ def exists(_):
|
|||||||
|
|
||||||
def generate(env):
|
def generate(env):
|
||||||
|
|
||||||
env.Replace(
|
env.Replace(_long_cmd_hook=long_cmd_hook)
|
||||||
_huge_sources_hook=_huge_sources_hook,
|
coms = {}
|
||||||
ARCOM=env.get("ARCOM", "").replace("$SOURCES",
|
for key in ("ARCOM", "LINKCOM"):
|
||||||
"${_huge_sources_hook(SOURCES)}"))
|
coms[key] = env.get(key, "").replace("$SOURCES",
|
||||||
|
"${_long_cmd_hook(SOURCES)}")
|
||||||
|
env.Replace(**coms)
|
||||||
|
|
||||||
return env
|
return env
|
Reference in New Issue
Block a user