PlatformIO Community

Build_flags cannot be multiline?

I’ve stumbled upon the following error during build when my build_flags is multiline:

ValueError: No escaped character:
  File "C:\.platformio\penv\lib\site-packages\platformio\builder\main.py", line 169:
    env.SConscript("$BUILD_SCRIPT")
  File "C:\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "C:\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py", line 287:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "C:\.platformio\platforms\ststm32\builder\main.py", line 99:
    target_elf = env.BuildProgram()
  File "C:\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 61:
    env.ProcessProgramDeps()
  File "C:\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 124:
    env.ProcessFlags(env.get("BUILD_FLAGS"))
  File "C:\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 222:
    env.Append(**env.ParseFlagsExtended(flags))
  File "C:\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 219:
    return self.method(*nargs, **kwargs)
  File "C:\.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py", line 185:
    for key, value in env.ParseFlags(str(raw)).items():
  File "C:\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 815:
    do_parse(arg)
  File "C:\.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py", line 711:
    params = shlex.split(arg)
  File "C:\.platformio\python3\lib\shlex.py", line 310:
    return list(lex)
  File "C:\.platformio\python3\lib\shlex.py", line 299:
    token = self.get_token()
  File "C:\.platformio\python3\lib\shlex.py", line 109:
    raw = self.read_token()
  File "C:\.platformio\python3\lib\shlex.py", line 210:
    raise ValueError("No escaped character")

However, when all build flags are on the same line, I get no such error. Is it a bug or by design?

So what exactly did you input as build_flags?

I’m sorry for omitting that. Please see my neighboring topic for full platformio.ini file: Linker cannot find the object file

build_flags = -DKEYGEN_SUPPORT -I${env.cryptincdir} -I${env.chibi_os}/os/hal/include -I${env.chibi_os}/os/hal/platforms/STM32 -I${env.chibi_os}/os/ports/GCC/ARMCMx -I${env.chibi_os}/os/ports/GCC/ARMCMx/STM32F10x -I${env.chibi_os}/os/ports/GCC/ARMCMx/cmsis -I${env.chibi_os}/os/kernel/include -I$PROJECT_DIR/boards/common -I${env.board_dir} -I${env.chibi_os}/os/various