Merge branch 'folder-fix' of git://github.com/gnusouth/ino into gnusouth-folder-fix

Esse commit está contido em:
Victor Nakoryakov
2013-09-23 22:06:16 +04:00
7 arquivos alterados com 122 adições e 31 exclusões
+1
Ver Arquivo
@@ -5,3 +5,4 @@ build
dist
ino.egg-info
doc/.build
.*.sw[op]
+1 -1
Ver Arquivo
@@ -9,7 +9,7 @@ doc:
$(MAKE) -f doc/Makefile html
install:
python setup.py install --root $(DESTDIR) --prefix $(PREFIX) --exec-prefix $(PREFIX)
env python2 setup.py install --root $(DESTDIR) --prefix $(PREFIX) --exec-prefix $(PREFIX)
.PHONY : doc
.PHONY : install
+11
Ver Arquivo
@@ -0,0 +1,11 @@
# ino TODO list:
- Make 'ino build' sensitive to changes all kinds of changes to arguments, so
that whenever, for instance, '--cppflags' changes, the code is
_automatically_ recompiled with the new options (rather than having to
manually invoke 'ino clean' as currently)
- For completeness, add --arflags and --objcopyflags in build.py
* Also create similar flags for all modules, so every program used by ino can
be specified (e.g. for 'ino serial')
<!-- vim: set ft=markdown: -->
+87 -22
Ver Arquivo
@@ -6,6 +6,7 @@ import inspect
import subprocess
import platform
import jinja2
import shlex
from jinja2.runtime import StrictUndefined
@@ -39,14 +40,74 @@ 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)
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')
def discover(self):
def discover(self, args):
self.e.find_arduino_dir('arduino_core_dir',
['hardware', 'arduino', 'cores', 'arduino'],
['Arduino.h'] if self.e.arduino_lib_version.major else ['WProgram.h'],
@@ -61,10 +122,10 @@ class Build(Command):
human_name='Arduino variants directory')
toolset = [
('cc', 'avr-gcc'),
('cxx', 'avr-g++'),
('ar', 'avr-ar'),
('objcopy', 'avr-objcopy'),
('cc', args.cc),
('cxx', args.cxx),
('ar', args.ar),
('objcopy', args.objcopy),
]
for tool_key, tool_binary in toolset:
@@ -72,33 +133,37 @@ class Build(Command):
tool_key, ['hardware', 'tools', 'avr', 'bin'],
items=[tool_binary], human_name=tool_binary)
def setup_flags(self, board_key):
board = self.e.board_model(board_key)
def setup_flags(self, args):
board = self.e.board_model(args.board_model)
mcu = '-mmcu=' + board['build']['mcu']
self.e['cflags'] = SpaceList([
# Hard-code the flags that are essential to building the sketch
self.e['cppflags'] = SpaceList([
mcu,
'-ffunction-sections',
'-fdata-sections',
'-g',
'-Os',
'-w',
'-DF_CPU=' + board['build']['f_cpu'],
'-DARDUINO=' + str(self.e.arduino_lib_version.as_int()),
'-I' + self.e['arduino_core_dir'],
])
])
# Add additional flags as specified
self.e['cppflags'] += SpaceList(shlex.split(args.cppflags))
if 'vid' in board['build']:
self.e['cflags'].append('-DUSB_VID=%s' % board['build']['vid'])
self.e['cppflags'].append('-DUSB_VID=%s' % board['build']['vid'])
if 'pid' in board['build']:
self.e['cflags'].append('-DUSB_PID=%s' % board['build']['pid'])
self.e['cppflags'].append('-DUSB_PID=%s' % board['build']['pid'])
if self.e.arduino_lib_version.major:
variant_dir = os.path.join(self.e.arduino_variants_dir,
board['build']['variant'])
self.e.cflags.append('-I' + variant_dir)
self.e.cppflags.append('-I' + variant_dir)
self.e['cxxflags'] = SpaceList(['-fno-exceptions'])
self.e['elfflags'] = SpaceList(['-Os', '-Wl,--gc-sections', mcu])
self.e['cflags'] = SpaceList(shlex.split(args.cflags))
self.e['cxxflags'] = SpaceList(shlex.split(args.cxxflags))
# Again, hard-code the flags that are essential to building the sketch
self.e['ldflags'] = SpaceList([mcu])
self.e['ldflags'] += SpaceList([
'-Wl,' + flag for flag in shlex.split(args.ldflags)
])
self.e['names'] = {
'obj': '%s.o',
@@ -199,11 +264,11 @@ class Build(Command):
scanned_libs.add(lib)
self.e['used_libs'] = used_libs
self.e['cflags'].extend(self.recursive_inc_lib_flags(used_libs))
self.e['cppflags'].extend(self.recursive_inc_lib_flags(used_libs))
def run(self, args):
self.discover()
self.setup_flags(args.board_model)
self.discover(args)
self.setup_flags(args)
self.create_jinja(verbose=args.verbose)
self.make('Makefile.sketch')
self.scan_dependencies()
+2 -2
Ver Arquivo
@@ -16,7 +16,7 @@
{% for source, target in cpp.items() %}
{{ target.path }} : {{ source.path }}
@mkdir -p {{ target.path|dirname }}
{{v}}{{ e.cc }} {{ e.cflags }} {{ inc_flags }} {{ iquote(source) }} -MM $^ > $@
{{v}}{{ e.cc }} {{ e.cppflags }} {{ inc_flags }} {{ iquote(source) }} -MM $^ > $@
{# prepend build path to a target in the generated file and
add .d file itself as a target so that changes in a header file would rebuild dependency files
See: http://make.paulandlesley.org/autodep.html #}
@@ -29,7 +29,7 @@
{{ output_filepath }} : {{ cpp.target_paths() }}
@echo {{ ('Scanning dependencies of ' ~ src_dir|basename)|colorize('cyan') }}
@mkdir -p {{ output_filepath|dirname }}
{{v}}cat $^ > $@;
{{v}}{{ 'cat $^ >' if cpp.target_paths() else 'touch' }} $@;
all : {{ output_filepath }}
@true
+3 -3
Ver Arquivo
@@ -15,11 +15,11 @@ include {{ target.path|depsname }}
{% endmacro %}
{% macro compile_c(filemap) %}
{{ compile(filemap, e.cc ~ ' ' ~ e.cflags) }}
{{ compile(filemap, e.cc ~ ' ' ~ e.cppflags ~ ' ' ~ e.cflags) }}
{% endmacro %}
{% macro compile_cpp(filemap) %}
{{ compile(filemap, e.cxx ~ ' ' ~ e.cflags ~ ' ' ~ e.cxxflags) }}
{{ compile(filemap, e.cxx ~ ' ' ~ e.cppflags ~ ' ' ~ e.cxxflags) }}
{% endmacro %}
{#
@@ -56,7 +56,7 @@ include {{ target.path|depsname }}
{% set elf = e.build_dir|pjoin('firmware.elf') %}
{{ elf }} : {{ objs }}
@echo {{ 'Linking firmware.elf'|colorize('green') }}
{{v}}{{ e.cc }} {{ e.elfflags }} -o $@ $^ -lm
{{v}}{{ e.cc }} {{ e.ldflags }} -o $@ $^ -lm
{#
# elf -> hex
+17 -3
Ver Arquivo
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python2
# -*- coding: utf-8; -*-
"""\
@@ -57,8 +57,22 @@ def main():
try:
e.process_args(args)
if current_command not in 'clean init' and not os.path.isdir(e.build_dir):
os.makedirs(e.build_dir)
# Create a .build directory if required
valid_project = os.path.isdir(e.src_dir)
run_anywhere = "init clean list-models serial"
if current_command not in run_anywhere:
if not valid_project:
raise Abort("No project found in this directory.")
# For valid projects create .build & lib
if not os.path.isdir(e.build_dir):
os.makedirs(e.build_dir)
if not os.path.isdir(e.lib_dir):
os.makedirs(e.lib_dir)
with open('lib/.holder', 'w') as f:
f.write("")
args.func(args)
except Abort as exc: