diff --git a/commands/compile/compile.go b/commands/compile/compile.go index 4c2815aac39..cf6dadc75c0 100644 --- a/commands/compile/compile.go +++ b/commands/compile/compile.go @@ -161,7 +161,10 @@ func Compile(ctx context.Context, req *rpc.CompileReq, outStream, errStream io.W if req.GetShowProperties() { err = builder.RunParseHardwareAndDumpBuildProperties(builderCtx) } else if req.GetPreprocess() { - err = builder.RunPreprocess(builderCtx) + if err = builder.RunPreprocess(builderCtx); err != nil { + return nil, fmt.Errorf("preprocessing sketch: %s", err) + } + return &rpc.CompileResp{}, nil } else { err = builder.RunBuilder(builderCtx) } diff --git a/legacy/builder/builder.go b/legacy/builder/builder.go index e83beba8ae2..39be76bbafb 100644 --- a/legacy/builder/builder.go +++ b/legacy/builder/builder.go @@ -30,6 +30,7 @@ package builder import ( + "fmt" "os" "reflect" "strconv" @@ -170,11 +171,15 @@ func (s *Preprocess) Run(ctx *types.Context) error { &WarnAboutArchIncompatibleLibraries{}, &PreprocessSketch{}, + } - &PrintPreprocessedSource{}, + if err := runCommands(ctx, commands, true); err != nil { + return err } - return runCommands(ctx, commands, true) + // Output arduino-preprocessed source + fmt.Println(ctx.Source) + return nil } type ParseHardwareAndDumpBuildProperties struct{} diff --git a/legacy/builder/print_preprocessed_source.go b/legacy/builder/print_preprocessed_source.go deleted file mode 100644 index 89a292ad0d6..00000000000 --- a/legacy/builder/print_preprocessed_source.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of Arduino Builder. - * - * Arduino Builder is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * As a special exception, you may use this file as part of a free software - * library without restriction. Specifically, if other files instantiate - * templates or use macros or inline functions from this file, or you compile - * this file and link it with other files to produce an executable, this - * file does not by itself cause the resulting executable to be covered by - * the GNU General Public License. This exception does not however - * invalidate any other reasons why the executable file might be covered by - * the GNU General Public License. - * - * Copyright 2015 Arduino LLC (http://www.arduino.cc/) - */ - -package builder - -import ( - "fmt" - - "github.com/arduino/arduino-cli/legacy/builder/types" -) - -type PrintPreprocessedSource struct{} - -func (s *PrintPreprocessedSource) Run(ctx *types.Context) error { - if ctx.SourceGccMinusE != "" { - fmt.Println(ctx.SourceGccMinusE) - } - return nil -}