in newt/cli/build_cmds.go [428:540]
func AddBuildCommands(cmd *cobra.Command) {
var printShellCmds bool
var executeShell bool
buildCmd := &cobra.Command{
Use: "build <target-name> [target-names...]",
Short: "Build one or more targets",
Run: func(cmd *cobra.Command, args []string) {
buildRunCmd(cmd, args, printShellCmds, executeShell)
},
}
buildCmd.Flags().BoolVarP(&printShellCmds, "printCmds", "p", false,
"Print executed build commands")
buildCmd.Flags().StringVarP(&util.InjectSyscfg, "syscfg", "S", "",
"Injected syscfg settings, key=value pairs separated by colon")
buildCmd.Flags().BoolVar(&executeShell, "executeShell", false,
"Execute build command using /bin/sh (Linux and MacOS only)")
cmd.AddCommand(buildCmd)
AddTabCompleteFn(buildCmd, func() []string {
return append(targetList(), "all")
})
cleanCmd := &cobra.Command{
Use: "clean <target-name> [target-names...] | all",
Short: "Delete build artifacts for one or more targets",
Run: cleanRunCmd,
}
cmd.AddCommand(cleanCmd)
AddTabCompleteFn(cleanCmd, func() []string {
return append(append(targetList(), unittestList()...), "all")
})
var exclude string
testCmd := &cobra.Command{
Use: "test <package-name> [package-names...] | all",
Short: "Executes unit tests for one or more packages",
Run: func(cmd *cobra.Command, args []string) {
testRunCmd(cmd, args, exclude, executeShell)
},
}
testCmd.Flags().StringVarP(&exclude, "exclude", "e", "", "Comma separated list of packages to exclude")
testCmd.Flags().BoolVar(&executeShell, "executeShell", false,
"Execute build command using /bin/sh (Linux and MacOS only)")
cmd.AddCommand(testCmd)
AddTabCompleteFn(testCmd, func() []string {
return append(testablePkgList(), "all", "allexcept")
})
loadHelpText := "Load application image on to the board for <target-name>"
loadCmd := &cobra.Command{
Use: "load <target-name>",
Short: "Load built target to board",
Long: loadHelpText,
Run: loadRunCmd,
}
cmd.AddCommand(loadCmd)
AddTabCompleteFn(loadCmd, targetList)
loadCmd.PersistentFlags().StringVarP(&extraJtagCmd, "extrajtagcmd", "", "",
"Extra commands to send to JTAG software")
loadCmd.PersistentFlags().StringVarP(&imgFileOverride, "imgfile", "", "",
"Path of .img file to load instead of target artifact")
debugHelpText := "Open a debugger session for <target-name>"
debugCmd := &cobra.Command{
Use: "debug <target-name>",
Short: "Open debugger session to target",
Long: debugHelpText,
Run: debugRunCmd,
}
debugCmd.PersistentFlags().StringVarP(&extraJtagCmd, "extrajtagcmd", "",
"", "Extra commands to send to JTAG software")
debugCmd.PersistentFlags().BoolVarP(&noGDB_flag, "noGDB", "n", false,
"Do not start GDB from command line")
debugCmd.PersistentFlags().StringVarP(&elfFileOverride, "elffile", "",
"", "Path of .elf file to debug instead of target artifact")
cmd.AddCommand(debugCmd)
AddTabCompleteFn(debugCmd, targetList)
sizeHelpText := "Calculate the size of target components specified by " +
"<target-name>."
var ram, flash bool
var section string
sizeCmd := &cobra.Command{
Use: "size <target-name>",
Short: "Size of target components",
Long: sizeHelpText,
Run: func(cmd *cobra.Command, args []string) {
sizeRunCmd(cmd, args, ram, flash, section)
},
}
sizeCmd.PersistentFlags().BoolVarP(&diffFriendly_flag, "diffable", "d", false,
"Produce diff-friendly output of statistics")
sizeCmd.Flags().BoolVarP(&ram, "ram", "R", false, "Print RAM statistics")
sizeCmd.Flags().BoolVarP(&flash, "flash", "F", false,
"Print FLASH statistics")
sizeCmd.Flags().StringVarP(§ion, "section", "S", "", "Print section statistics")
cmd.AddCommand(sizeCmd)
AddTabCompleteFn(sizeCmd, targetList)
}