Skip to content

Commit 53fce35

Browse files
committed
rename of some flags (done to accommodate the proposed changes in platform.txt)
1 parent 7dcce32 commit 53fce35

File tree

5 files changed

+102
-102
lines changed

5 files changed

+102
-102
lines changed

cli/compile/compile.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ var (
5353
buildCachePath string // Builds of 'core.a' are saved into this path to be cached and reused.
5454
buildPath string // Path where to save compiled files.
5555
buildProperties []string // List of custom build properties separated by commas. Or can be used multiple times for multiple properties.
56-
keysPath string // The path of the dir where to search for the custom keys to sign and encrypt a binary. Used only by the platforms that supports it
57-
signKeyName string // The name of the custom signing key to use to sign a binary during the compile process. Used only by the platforms that supports it
58-
encryptKeyName string // The name of the custom encryption key to use to encrypt a binary during the compile process. Used only by the platforms that supports it
56+
keysKeychain string // The path of the dir where to search for the custom keys to sign and encrypt a binary. Used only by the platforms that supports it
57+
signKey string // The name of the custom signing key to use to sign a binary during the compile process. Used only by the platforms that supports it
58+
encryptKey string // The name of the custom encryption key to use to encrypt a binary during the compile process. Used only by the platforms that supports it
5959
warnings string // Used to tell gcc which warning level to use.
6060
verbose bool // Turns on verbose mode.
6161
quiet bool // Suppresses almost every output.
@@ -88,7 +88,7 @@ func NewCommand() *cobra.Command {
8888
" " + os.Args[0] + ` compile -b arduino:avr:uno --build-property "build.extra_flags=\"-DMY_DEFINE=\"hello world\"\"" /home/user/Arduino/MySketch` + "\n" +
8989
" " + os.Args[0] + ` compile -b arduino:avr:uno --build-property "build.extra_flags=-DPIN=2 \"-DMY_DEFINE=\"hello world\"\"" /home/user/Arduino/MySketch` + "\n" +
9090
" " + os.Args[0] + ` compile -b arduino:avr:uno --build-property build.extra_flags=-DPIN=2 --build-property "compiler.cpp.extra_flags=\"-DSSID=\"hello world\"\"" /home/user/Arduino/MySketch` + "\n" +
91-
" " + os.Args[0] + ` compile -b arduino:mbed_portenta:envie_m7:security=sien --keys-input-path /home/user/Arduino/keys --sign-key-name ecsdsa-p256-signing-key.pem --encrypt-key-name ecsdsa-p256-encrypt-key.pem /home/user/Arduino/MySketch` + "\n",
91+
" " + os.Args[0] + ` compile -b arduino:mbed_portenta:envie_m7:security=sien --keys-keychain /home/user/Arduino/keys --sign-key ecsdsa-p256-signing-key.pem --encrypt-key ecsdsa-p256-encrypt-key.pem /home/user/Arduino/MySketch` + "\n",
9292
Args: cobra.MaximumNArgs(1),
9393
Run: runCompileCommand,
9494
}
@@ -104,11 +104,11 @@ func NewCommand() *cobra.Command {
104104
tr("List of custom build properties separated by commas. Or can be used multiple times for multiple properties."))
105105
compileCommand.Flags().StringArrayVar(&buildProperties, "build-property", []string{},
106106
tr("Override a build property with a custom value. Can be used multiple times for multiple properties."))
107-
compileCommand.Flags().StringVar(&keysPath, "keys-input-path", "",
107+
compileCommand.Flags().StringVar(&keysKeychain, "keys-keychain", "",
108108
tr("The path of the dir to search for the custom keys to sign and encrypt a binary. Used only by the platforms that support it"))
109-
compileCommand.Flags().StringVar(&signKeyName, "sign-key-name", "",
109+
compileCommand.Flags().StringVar(&signKey, "sign-key", "",
110110
tr("The name of the custom signing key to use to sign a binary during the compile process. Used only by the platforms that support it"))
111-
compileCommand.Flags().StringVar(&encryptKeyName, "encrypt-key-name", "",
111+
compileCommand.Flags().StringVar(&encryptKey, "encrypt-key", "",
112112
tr("The name of the custom encryption key to use to encrypt a binary during the compile process. Used only by the platforms that support it"))
113113
compileCommand.Flags().StringVar(&warnings, "warnings", "none",
114114
tr(`Optional, can be: %s. Used to tell gcc which warning level to use (-W flag).`, "none, default, more, all"))
@@ -152,8 +152,8 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
152152

153153
sketchPath := arguments.InitSketchPath(path)
154154

155-
if keysPath != "" || signKeyName != "" || encryptKeyName != "" {
156-
arguments.CheckFlagsMandatory(cmd, "keys-input-path", "sign-key-name", "encrypt-key-name")
155+
if keysKeychain != "" || signKey != "" || encryptKey != "" {
156+
arguments.CheckFlagsMandatory(cmd, "keys-keychain", "sign-key", "encrypt-key")
157157
}
158158

159159
var overrides map[string]string
@@ -212,9 +212,9 @@ func runCompileCommand(cmd *cobra.Command, args []string) {
212212
CreateCompilationDatabaseOnly: compilationDatabaseOnly,
213213
SourceOverride: overrides,
214214
Library: library,
215-
KeysPath: keysPath,
216-
SignKeyName: signKeyName,
217-
EncryptKeyName: encryptKeyName,
215+
KeysKeychain: keysKeychain,
216+
SignKey: signKey,
217+
EncryptKey: encryptKey,
218218
}
219219
compileStdOut := new(bytes.Buffer)
220220
compileStdErr := new(bytes.Buffer)

commands/compile/compile.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,21 +129,21 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
129129
// so, if the flags to override the default keys are used, we try override the corresponding platform property nonetheless.
130130
// It's not possible to use the default name for the keys since there could be more tools to sign and encrypt.
131131
// So it's mandatory to use all the tree flags to sign and encrypt the binary
132-
if req.KeysPath != "" && req.SignKeyName != "" && req.EncryptKeyName != "" {
133-
keysDirPath := paths.New(req.KeysPath)
132+
if req.KeysKeychain != "" && req.SignKey != "" && req.EncryptKey != "" {
133+
keysDirPath := paths.New(req.KeysKeychain)
134134
if !keysDirPath.IsDir() {
135135
return nil, &arduino.NotFoundError{Message: tr("The path specified is not a directory: %s", keysDirPath), Cause: err}
136136
}
137-
signKeyPath := keysDirPath.Join(req.GetSignKeyName())
137+
signKeyPath := keysDirPath.Join(req.GetSignKey())
138138
if !signKeyPath.Exist() {
139139
return nil, &arduino.NotFoundError{Message: tr("The path of the specified signing key does not exist: %s", signKeyPath), Cause: err}
140140
}
141-
encryptKeyPath := keysDirPath.Join(req.GetEncryptKeyName())
141+
encryptKeyPath := keysDirPath.Join(req.GetEncryptKey())
142142
if !encryptKeyPath.Exist() {
143143
return nil, &arduino.NotFoundError{Message: tr("The path of the specified encryption key does not exist: %s", encryptKeyPath), Cause: err}
144144
}
145145
InstalledPlatformRelease := pm.GetInstalledPlatformRelease(targetPlatform)
146-
ReplaceSecurityKeys(InstalledPlatformRelease.Properties, req.KeysPath, req.SignKeyName, req.EncryptKeyName)
146+
ReplaceSecurityKeys(InstalledPlatformRelease.Properties, req.KeysKeychain, req.SignKey, req.EncryptKey)
147147
}
148148

149149
builderCtx := &types.Context{}
@@ -320,25 +320,25 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
320320

321321
// ReplaceSecurityKeys function will override the properties representing the security keys specified in the platform.txt file of a platform with the ones provided by the user.
322322
// The keys are stored in the keyPath
323-
// signKeyName is the key used to sign a binary
324-
// encryptKeyName is the key used to encrypt it
325-
func ReplaceSecurityKeys(properties *properties.Map, keysPath, signKeyName, encryptKeyName string) {
323+
// signKey is the key used to sign a binary
324+
// encryptKey is the key used to encrypt it
325+
func ReplaceSecurityKeys(properties *properties.Map, keysKKeysKeychain, signKey, encryptKey string) {
326326
toolsProps := properties.SubTree("tools").FirstLevelOf()
327327
for toolName, toolProps := range toolsProps {
328328
if toolProps.ContainsKey("keys.path") {
329329
key := "tools." + toolName + ".keys.path"
330-
properties.Set(key, keysPath)
331-
logrus.Tracef("Overriding Property: %s: %s", key, keysPath)
330+
properties.Set(key, keysKKeysKeychain)
331+
logrus.Tracef("Overriding Property: %s: %s", key, keysKKeysKeychain)
332332
}
333333
if toolProps.ContainsKey("sign.name") {
334334
key := "tools." + toolName + ".sign.name"
335-
properties.Set(key, signKeyName)
336-
logrus.Tracef("Overriding Property: %s: %s", key, signKeyName)
335+
properties.Set(key, signKey)
336+
logrus.Tracef("Overriding Property: %s: %s", key, signKey)
337337
}
338338
if toolProps.ContainsKey("encrypt.name") {
339339
key := "tools." + toolName + ".encrypt.name"
340-
properties.Set(key, encryptKeyName)
341-
logrus.Tracef("Overriding Property: %s: %s", key, encryptKeyName)
340+
properties.Set(key, encryptKey)
341+
logrus.Tracef("Overriding Property: %s: %s", key, encryptKey)
342342
}
343343
}
344344
}

0 commit comments

Comments
 (0)