Skip to content

Commit c730952

Browse files
committed
Command line option for allowing use of ./platform.sketch.txt file
1 parent 27ab6bc commit c730952

4 files changed

+17
-1
lines changed

add_build_properties_from_sketch_platform_txt_file.go

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

4444
func (s *AddBuildPropertiesFromSketchPlatformTxtFile) 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/try_build_of_problematic_sketch_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,9 @@ func TestTryBuild042(t *testing.T) {
219219
}
220220

221221
func TestTryBuild043(t *testing.T) {
222-
tryBuild(t, "sketch_with_platform_sketch_txt", "sketch_with_platform_sketch_txt.ino")
222+
ctx := makeDefaultContext(t)
223+
ctx.UsePlatformSketchTxt = true
224+
tryBuildWithContext(t, ctx, "sketch_with_platform_sketch_txt", "sketch_with_platform_sketch_txt.ino")
223225
}
224226

225227
func makeDefaultContext(t *testing.T) *types.Context {

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)