Skip to content

Commit

Permalink
Command line option for allowing use of ./platform.sketch.txt file
Browse files Browse the repository at this point in the history
  • Loading branch information
phd committed Jul 25, 2018
1 parent 27ab6bc commit c730952
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions add_build_properties_from_sketch_platform_txt_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ import (
type AddBuildPropertiesFromSketchPlatformTxtFile struct{}

func (s *AddBuildPropertiesFromSketchPlatformTxtFile) Run(ctx *types.Context) error {
if !ctx.UsePlatformSketchTxt {
return nil
}

path := filepath.Join(filepath.Dir(ctx.Sketch.MainFile.Name), constants.FILE_PLATFORM_SKETCH_TXT)
if !utils.IsFileReadable(path) {
return nil
Expand Down
8 changes: 8 additions & 0 deletions arduino-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const FLAG_VID_PID = "vid-pid"
const FLAG_JOBS = "jobs"
const FLAG_TRACE = "trace"
const FLAG_EXPERIMENTAL = "experimental"
const FLAG_USE_PLATFORM_SKETCH_TXT = "use-platform-sketch-txt"

type foldersFlag []string

Expand Down Expand Up @@ -151,6 +152,7 @@ var vidPidFlag *string
var jobsFlag *int
var traceFlag *bool
var experimentalFeatures *bool
var usePlatformSketchTxt *bool

func init() {
compileFlag = flag.Bool(FLAG_ACTION_COMPILE, false, "compiles the given sketch")
Expand Down Expand Up @@ -179,6 +181,7 @@ func init() {
jobsFlag = flag.Int(FLAG_JOBS, 0, "specify how many concurrent gcc processes should run at the same time. Defaults to the number of available cores on the running machine")
traceFlag = flag.Bool(FLAG_TRACE, false, "traces the whole process lifecycle")
experimentalFeatures = flag.Bool(FLAG_EXPERIMENTAL, false, "enables experimental features")
usePlatformSketchTxt = flag.Bool(FLAG_USE_PLATFORM_SKETCH_TXT, false, "allow reading additional platform build properies from an optional platform.sketch.txt file")
}

func main() {
Expand Down Expand Up @@ -374,6 +377,11 @@ func main() {
}
}

// FLAG_USE_PLATFORM_SKETCH_TXT
if *usePlatformSketchTxt {
ctx.UsePlatformSketchTxt = true
}

if *warningsLevelFlag != "" {
ctx.WarningsLevel = *warningsLevelFlag
}
Expand Down
4 changes: 3 additions & 1 deletion test/try_build_of_problematic_sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ func TestTryBuild042(t *testing.T) {
}

func TestTryBuild043(t *testing.T) {
tryBuild(t, "sketch_with_platform_sketch_txt", "sketch_with_platform_sketch_txt.ino")
ctx := makeDefaultContext(t)
ctx.UsePlatformSketchTxt = true
tryBuildWithContext(t, ctx, "sketch_with_platform_sketch_txt", "sketch_with_platform_sketch_txt.ino")
}

func makeDefaultContext(t *testing.T) *types.Context {
Expand Down
2 changes: 2 additions & 0 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type Context struct {
SourceGccMinusE string
CodeCompletions string

UsePlatformSketchTxt bool

WarningsLevel string

// Libraries handling
Expand Down

0 comments on commit c730952

Please sign in to comment.