Skip to content

Commit 6faee1e

Browse files
committed
Command line option for allowing use of ./platform.sketch.txt file
1 parent 9ed3dd8 commit 6faee1e

4 files changed

+26
-0
lines changed

add_build_properties_from_platform_sketch_txt_file.go

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ import (
4242
type AddBuildPropertiesFromPlatformSketchTxtFile struct{}
4343

4444
func (s *AddBuildPropertiesFromPlatformSketchTxtFile) Run(ctx *types.Context) error {
45+
if !ctx.UsePlatformSketchTxt {
46+
return nil
47+
}
48+
4549
path := filepath.Join(filepath.Dir(ctx.Sketch.MainFile.Name), constants.FILE_PLATFORM_SKETCH_TXT)
4650
if !utils.IsFileReadable(path) {
4751
return nil

arduino-builder/main.go

+8
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ const FLAG_VID_PID = "vid-pid"
8989
const FLAG_JOBS = "jobs"
9090
const FLAG_TRACE = "trace"
9191
const FLAG_EXPERIMENTAL = "experimental"
92+
const FLAG_USE_PLATFORM_SKETCH_TXT = "use-platform-sketch-txt"
9293

9394
type foldersFlag []string
9495

@@ -151,6 +152,7 @@ var vidPidFlag *string
151152
var jobsFlag *int
152153
var traceFlag *bool
153154
var experimentalFeatures *bool
155+
var usePlatformSketchTxt *bool
154156

155157
func init() {
156158
compileFlag = flag.Bool(FLAG_ACTION_COMPILE, false, "compiles the given sketch")
@@ -179,6 +181,7 @@ func init() {
179181
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")
180182
traceFlag = flag.Bool(FLAG_TRACE, false, "traces the whole process lifecycle")
181183
experimentalFeatures = flag.Bool(FLAG_EXPERIMENTAL, false, "enables experimental features")
184+
usePlatformSketchTxt = flag.Bool(FLAG_USE_PLATFORM_SKETCH_TXT, false, "allow reading additional platform build properies from an optional platform.sketch.txt file")
182185
}
183186

184187
func main() {
@@ -374,6 +377,11 @@ func main() {
374377
}
375378
}
376379

380+
// FLAG_USE_PLATFORM_SKETCH_TXT
381+
if *usePlatformSketchTxt {
382+
ctx.UsePlatformSketchTxt = true
383+
}
384+
377385
if *warningsLevelFlag != "" {
378386
ctx.WarningsLevel = *warningsLevelFlag
379387
}

test/add_build_properties_from_platform_sketch_txt_file_test.go

+12
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,22 @@ import (
3939

4040
func TestAddBuildBoardPropertiesFromPlatformSketchTxtFile(t *testing.T) {
4141
ctx := makeDefaultContext(t)
42+
ctx.UsePlatformSketchTxt = true
4243

4344
sketchLocation := filepath.Join("sketch_with_platform_sketch_txt", "sketch_with_platform_sketch_txt.ino")
4445
ctx.SketchLocation = sketchLocation
4546

4647
err := builder.RunBuilder(ctx)
4748
require.NoError(t, err, "Unexpected build error for "+sketchLocation)
4849
}
50+
51+
func TestAddBuildBoardPropertiesFromPlatformSketchTxtFileDisabled(t *testing.T) {
52+
ctx := makeDefaultContext(t)
53+
ctx.UsePlatformSketchTxt = false
54+
55+
sketchLocation := filepath.Join("sketch_with_platform_sketch_txt", "sketch_with_platform_sketch_txt.ino")
56+
ctx.SketchLocation = sketchLocation
57+
58+
err := builder.RunBuilder(ctx)
59+
require.Error(t, err, "No expected build error for "+sketchLocation)
60+
}

types/context.go

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ type Context struct {
6464
SourceGccMinusE string
6565
CodeCompletions string
6666

67+
UsePlatformSketchTxt bool
68+
6769
WarningsLevel string
6870

6971
// Libraries handling

0 commit comments

Comments
 (0)