From 8d8a0efdb9b12b0e3905b8c5430b33d1c581d0fc Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 15 Aug 2016 20:14:09 +0300 Subject: [PATCH] Refactor long command hook for GCC and Windows CMD limitations --- platformio/builder/main.py | 4 ++-- .../builder/tools/{pioar.py => longcmdhook.py} | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) rename platformio/builder/tools/{pioar.py => longcmdhook.py} (77%) diff --git a/platformio/builder/main.py b/platformio/builder/main.py index 5bbabd15..f245d5d2 100644 --- a/platformio/builder/main.py +++ b/platformio/builder/main.py @@ -68,8 +68,8 @@ commonvars.AddVariables( DefaultEnvironment( tools=[ "ar", "as", "gcc", "g++", "gnulink", - "platformio", "pioplatform", - "piolib", "piotest", "pioupload", "pioar", "piomisc" + "longcmdhook", "platformio", "pioplatform", + "piolib", "piotest", "pioupload", "piomisc" ], # yapf: disable toolpath=[join(util.get_source_dir(), "builder", "tools")], variables=commonvars, diff --git a/platformio/builder/tools/pioar.py b/platformio/builder/tools/longcmdhook.py similarity index 77% rename from platformio/builder/tools/pioar.py rename to platformio/builder/tools/longcmdhook.py index d530892a..bfd14717 100644 --- a/platformio/builder/tools/pioar.py +++ b/platformio/builder/tools/longcmdhook.py @@ -19,12 +19,12 @@ from tempfile import gettempdir 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("\\", "/") if len(str(_sources)) < MAX_SOURCES_LENGTH: 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: # fix space in paths for line in _sources.split(".o "): @@ -41,9 +41,11 @@ def exists(_): def generate(env): - env.Replace( - _huge_sources_hook=_huge_sources_hook, - ARCOM=env.get("ARCOM", "").replace("$SOURCES", - "${_huge_sources_hook(SOURCES)}")) + env.Replace(_long_cmd_hook=long_cmd_hook) + coms = {} + for key in ("ARCOM", "LINKCOM"): + coms[key] = env.get(key, "").replace("$SOURCES", + "${_long_cmd_hook(SOURCES)}") + env.Replace(**coms) return env