Moved all build flag arg parsing into build.py

It is unnecessary to clutter environment.py since we don't require these
flags globally.
Esse commit está contido em:
Rob Cornish
2013-08-04 14:04:50 +10:00
commit b8404751f8
2 arquivos alterados com 60 adições e 99 exclusões
+60 -8
Ver Arquivo
@@ -40,18 +40,70 @@ class Build(Command):
name = 'build'
help_line = "Build firmware from the current directory project"
default_cc = 'avr-gcc'
default_cxx = 'avr-g++'
default_ar = 'avr-ar'
default_objcopy = 'avr-objcopy'
default_cppflags = '-ffunction-sections -fdata-sections -g -Os -w'
default_cflags = ''
default_cxxflags = '-fno-exceptions'
default_ldflags = '-Os --gc-sections'
def setup_arg_parser(self, parser):
super(Build, self).setup_arg_parser(parser)
self.e.add_board_model_arg(parser)
self.e.add_arduino_dist_arg(parser)
self.e.add_cc_arg(parser)
self.e.add_cxx_arg(parser)
self.e.add_ar_arg(parser)
self.e.add_objcopy_arg(parser)
self.e.add_cppflags_arg(parser)
self.e.add_cflags_arg(parser)
self.e.add_cxxflags_arg(parser)
self.e.add_ldflags_arg(parser)
parser.add_argument('-c', '--cc', metavar='COMPILER',
default=self.default_cc,
help='Specifies the compiler used for C files. If '
'a full path is not given, searches in Arduino '
'directories _before_ PATH. Default: %(default)s.')
parser.add_argument('-+', '--cxx', metavar='COMPILER',
default=self.default_cxx,
help='Specifies the compiler used for C++ files. '
'If a full path is not given, searches in Arduino '
'directories _before_ PATH. Default: %(default)s.')
parser.add_argument('-a', '--ar', metavar='AR',
default=self.default_ar,
help='Specifies the AR tool to use. If a full path '
'is not given, searches in Arduino directories '
'before PATH. Default: %(default)s.')
parser.add_argument('-o', '--objcopy', metavar='OBJCOPY',
default=self.default_objcopy,
help='Specifies the OBJCOPY to use. If a full path '
'is not given, searches in Arduino directories '
'before PATH. Default: %(default)s.')
parser.add_argument('-p', '--cppflags', metavar='FLAGS',
default=self.default_cppflags,
help='Flags that will be passed to the compiler. '
'Note that multiple (space-separated) flags must '
'be surrounded by quotes, e.g. '
'`--cflags="-DC1 -DC2"\' specifies flags to define '
'the constants C1 and C2. Default: %(default)s')
parser.add_argument('-f', '--cflags', metavar='FLAGS',
default=self.default_cflags,
help='Like --cppflags, but the flags specified are '
'only passed to compilations of C source files. '
'Default: %(default)s')
parser.add_argument('-x', '--cxxflags', metavar='FLAGS',
default=self.default_cxxflags,
help='Like --cppflags, but the flags specified '
'are only passed to compilations of C++ source '
'files. Default: %(default)s')
parser.add_argument('-l', '--ldflags', metavar='FLAGS',
default=self.default_ldflags,
help='Like --cppflags, but the flags specified '
'are only passed during the linking stage. Note '
'these flags should be specified as if `ld\' were '
'being invoked directly (i.e. the `-Wl,\' prefix '
'should be omitted). Default: %(default)s')
parser.add_argument('-v', '--verbose', default=False, action='store_true',
help='Verbose make output')
-91
Ver Arquivo
@@ -67,16 +67,6 @@ class Environment(dict):
if platform.system() == 'Darwin':
arduino_dist_dir_guesses.insert(0, '/Applications/Arduino.app/Contents/Resources/Java')
default_cc = 'avr-gcc'
default_cxx = 'avr-g++'
default_ar = 'avr-ar'
default_objcopy = 'avr-objcopy'
default_cppflags = '-ffunction-sections -fdata-sections -g -Os -w'
default_cflags = ''
default_cxxflags = '-fno-exceptions'
default_ldflags = '-Os --gc-sections'
default_board_model = 'uno'
ino = sys.argv[0]
@@ -221,87 +211,6 @@ class Environment(dict):
parser.add_argument('-d', '--arduino-dist', metavar='PATH',
help='Path to Arduino distribution, e.g. ~/Downloads/arduino-0022.\nTry to guess if not specified')
def add_cc_arg(self, parser):
help = '\n'.join([
'Specifies the compiler used for C files.',
'If a full path is not given, searches in',
'Arduino directories before PATH. Default:',
'%(default)s.'
])
parser.add_argument('-c', '--cc', metavar='COMPILER',
default=self.default_cc, help=help)
def add_cxx_arg(self, parser):
help = '\n'.join([
'Specifies the compiler used for C++ files.',
'If a full path is not given, searches in',
'Arduino directories before PATH. Default:',
'%(default)s.'
])
parser.add_argument('-+', '--cxx', metavar='COMPILER',
default=self.default_cxx, help=help)
def add_ar_arg(self, parser):
help = '\n'.join([
'Specifies the AR tool to use. If a full',
'path is not given, searches in Arduino',
'directories before PATH. Default: %(default)s.'
])
parser.add_argument('-a', '--ar', metavar='AR',
default=self.default_ar, help=help)
def add_objcopy_arg(self, parser):
help = '\n'.join([
'Specifies the OBJCOPY to use. If a full',
'path is not given, searches in Arduino',
'directories before PATH. Default: %(default)s.'
])
parser.add_argument('-o', '--objcopy', metavar='OBJCOPY',
default=self.default_objcopy, help=help)
def add_cppflags_arg(self, parser):
help = '\n'.join([
'Flags that will be passed to the compiler.',
'Note that multiple (space-separated) flags',
'must be surrounded by quotes, e.g.',
'`--cflags="-DC1 -DC2"\' specifies flags to',
'define the constants C1 and C2. Default:',
'%(default)s',
])
parser.add_argument('-p', '--cppflags', metavar='FLAGS',
default=self.default_cppflags, help=help)
def add_cflags_arg(self, parser):
help = '\n'.join([
'Like --cppflags, but the flags specified',
'are only passed to compilations of C source',
'files. Default: %(default)s',
])
parser.add_argument('-f', '--cflags', metavar='FLAGS',
default=self.default_cflags, help=help)
def add_cxxflags_arg(self, parser):
help = '\n'.join([
'Like --cppflags, but the flags specified',
'are only passed to compilations of C++ source',
'files. Default: %(default)s',
])
parser.add_argument('-x', '--cxxflags', metavar='FLAGS',
default=self.default_cxxflags, help=help)
def add_ldflags_arg(self, parser):
help = '\n'.join([
'Like --cppflags, but the flags specified',
'are only passed during the linking stage.',
'Note these flags should be specified as if',
'`ld\' were being invoked directly (i.e. the',
'`-Wl,\' prefix should be omitted). Default:',
'%(default)s',
])
parser.add_argument('-l', '--ldflags', metavar='FLAGS',
default=self.default_ldflags, help=help)
def serial_port_patterns(self):
system = platform.system()
if system == 'Linux':