Skip to content

Commit 1f7d7f8

Browse files
committed
Deprecate --build-properties flag in favor of --build-property
1 parent 32e0d95 commit 1f7d7f8

File tree

5 files changed

+43
-8
lines changed

5 files changed

+43
-8
lines changed

Diff for: cli/compile/compile.go

+16-8
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,16 @@ var (
5757
// NewCommand created a new `compile` command
5858
func NewCommand() *cobra.Command {
5959
command := &cobra.Command{
60-
Use: "compile",
61-
Short: "Compiles Arduino sketches.",
62-
Long: "Compiles Arduino sketches.",
63-
Example: " " + os.Args[0] + " compile -b arduino:avr:uno /home/user/Arduino/MySketch",
64-
Args: cobra.MaximumNArgs(1),
65-
Run: run,
60+
Use: "compile",
61+
Short: "Compiles Arduino sketches.",
62+
Long: "Compiles Arduino sketches.",
63+
Example: "" +
64+
" " + os.Args[0] + " compile -b arduino:avr:uno /home/user/Arduino/MySketch\n" +
65+
" " + os.Args[0] + " compile -b arduino:avr:uno --build-property='build.extra_flags=\"-DMY_DEFINE=\"hello world\"\"' /home/user/Arduino/MySketch\n" +
66+
" " + os.Args[0] + " compile -b arduino:avr:uno --build-property='build.extra_flags=-DPIN=2 \"-DMY_DEFINE=\"hello world\"\"' /home/user/Arduino/MySketch\n" +
67+
" " + os.Args[0] + " compile -b arduino:avr:uno --build-property=build.extra_flags=-DPIN=2 --build-property='compiler.cpp.extra_flags=\"-DSSID=\"hello world\"\"'-DMY_DEFINE=\"hello world\"' /home/user/Arduino/MySketch\n",
68+
Args: cobra.MaximumNArgs(1),
69+
Run: run,
6670
}
6771

6872
command.Flags().StringVarP(&fqbn, "fqbn", "b", "", "Fully Qualified Board Name, e.g.: arduino:avr:uno")
@@ -72,8 +76,10 @@ func NewCommand() *cobra.Command {
7276
command.Flags().StringVarP(&exportDir, "output-dir", "", "", "Save build artifacts in this directory.")
7377
command.Flags().StringVar(&buildPath, "build-path", "",
7478
"Path where to save compiled files. If omitted, a directory will be created in the default temporary path of your OS.")
75-
command.Flags().StringArrayVar(&buildProperties, "build-properties", []string{},
76-
"List of custom build properties separated by spaces. Or can be used multiple times for multiple properties.")
79+
command.Flags().StringSliceVar(&buildProperties, "build-properties", []string{},
80+
"List of custom build properties separated by commas. Or can be used multiple times for multiple properties.")
81+
command.Flags().StringArrayVar(&buildProperties, "build-property", []string{},
82+
"Override a build property with a custom value. Can be used multiple times for multiple properties.")
7783
command.Flags().StringVar(&warnings, "warnings", "none",
7884
`Optional, can be "none", "default", "more" and "all". Defaults to "none". Used to tell gcc which warning level to use (-W flag).`)
7985
command.Flags().BoolVarP(&verbose, "verbose", "v", false, "Optional, turns on verbose mode.")
@@ -95,6 +101,8 @@ func NewCommand() *cobra.Command {
95101

96102
configuration.Settings.BindPFlag("sketch.always_export_binaries", command.Flags().Lookup("export-binaries"))
97103

104+
command.Flags().MarkDeprecated("build-properties", "please use --build-property instead.")
105+
98106
return command
99107
}
100108

Diff for: test/testdata/sketch_with_multiple_defines/sketch_with_multiple_defines.ino

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ const int DEFAULT_PIN = PIN;
33
const String DEFAULT_SSID = SSID;
44

55
void setup() {
6+
Serial.begin(9600);
7+
Serial.println(DEFAULT_PIN);
8+
Serial.println(DEFAULT_SSID);
69
}
710

811
void loop() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
const int MY_FIRST_PIN = FIRST_PIN;
3+
const int MY_SECOND_PIN = SECOND_PIN;
4+
5+
void setup() {
6+
Serial.begin(9600);
7+
Serial.println(MY_FIRST_PIN);
8+
Serial.println(MY_SECOND_PIN);
9+
}
10+
11+
void loop() {
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
const int FOO = MY_DEFINE;
3+
4+
void setup() {
5+
Serial.begin(9600);
6+
Serial.println(FOO);
7+
}
8+
9+
void loop() {
10+
}

Diff for: test/testdata/sketch_with_single_define/sketch_with_single_define.ino renamed to test/testdata/sketch_with_single_string_define/sketch_with_single_string_define.ino

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
const String FOO = MY_DEFINE;
33

44
void setup() {
5+
Serial.begin(9600);
6+
Serial.println(FOO);
57
}
68

79
void loop() {

0 commit comments

Comments
 (0)