From 46e9b987ff689c1acfe29c7b980298408d1b95a6 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Mon, 5 Aug 2013 17:27:31 -0700 Subject: Add some stuff whose need became obvious when I tried to use it --- attoconf/_version.py | 2 +- attoconf/classy.py | 15 +++++++++++++++ attoconf/core.py | 3 +++ attoconf/lib/c.py | 5 +++-- attoconf/lib/lex.py | 34 ++++++++++++++++++++++++++++++++++ attoconf/lib/yacc.py | 34 ++++++++++++++++++++++++++++++++++ attoconf/types.py | 25 +++++++++++++++++++++++++ 7 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 attoconf/lib/lex.py create mode 100644 attoconf/lib/yacc.py create mode 100644 attoconf/types.py diff --git a/attoconf/_version.py b/attoconf/_version.py index 1b6e204..46ab4ff 100644 --- a/attoconf/_version.py +++ b/attoconf/_version.py @@ -7,7 +7,7 @@ major = 0 # Incremented for releases with compatible API additions. # This is the number that is usually incremented. -minor = 2 +minor = 3 # Incremented if there is a bugfix release. # Might not be contiguous. diff --git a/attoconf/classy.py b/attoconf/classy.py index f390ebc..c7ecf5e 100644 --- a/attoconf/classy.py +++ b/attoconf/classy.py @@ -90,10 +90,25 @@ class ClassyProject(Project): def features(self): ''' Customizations for this package (--enable-*). ''' + self.add_help('Optional Features:', hidden=False) + # TODO add '--disable-option-checking' + self.help.add_option('--disable-FEATURE', + help='do not include FEATURE (same as --enable-FEATURE=no)', + hidden=False) + self.help.add_option('--enable-FEATURE', + help='include FEATURE (same as --enable-FEATURE=yes)', + hidden=False) def packages(self): ''' Settings related to dependencies (--with-*). ''' + self.add_help('Optional Packages:', hidden=False) + self.help.add_option('--with-PACKAGE', + help='use PACKAGE (same as --with-PACKAGE=yes)', + hidden=False) + self.help.add_option('--without-PACKAGE', + help='do not use PACKAGE (same as --with-PACKAGE=no)', + hidden=False) if 0: # not sure if really needed def tests(self): diff --git a/attoconf/core.py b/attoconf/core.py index 38ba485..0134474 100644 --- a/attoconf/core.py +++ b/attoconf/core.py @@ -19,6 +19,7 @@ from __future__ import print_function, division, absolute_import from collections import namedtuple import os +import pipes import sys from .help import Help @@ -102,6 +103,8 @@ class Project(object): help_var = as_var(name) if help_def is None: help_def = init + if isinstance(help_def, list): + help_def = ' '.join(pipes.quote(a) for a in help_def) if help_def is not None: help = '%s [%s]' % (help, help_def) diff --git a/attoconf/lib/c.py b/attoconf/lib/c.py index 4d3f252..75bf931 100644 --- a/attoconf/lib/c.py +++ b/attoconf/lib/c.py @@ -111,6 +111,7 @@ def try_compile_link_cxx(build, body, CXXFLAGS=[], CPPFLAGS=[], LDFLAGS=[], LDLI LDFLAGS = build.vars['LDFLAGS'][0] + LDFLAGS LDLIBS = build.vars['LDLIBS'][0] + LDLIBS in_ = 'atto-test.cxx' + ins = [in_] out = 'atto-test' args = CXX + CXXFLAGS + CPPFLAGS + LDFLAGS + ins + LDLIBS + ['-o', out] @@ -252,7 +253,7 @@ class C(Link, Preprocess): self.add_option('CC', init=['gcc'], type=shell, check=cc, help='C compiler command', hidden=False) - self.add_option('CFLAGS', init=[], + self.add_option('CFLAGS', init=['-O2', '-g'], type=shell, check=cflags, help='C compiler flags', hidden=False) @@ -263,6 +264,6 @@ class Cxx(Link, Preprocess): self.add_option('CXX', init=['g++'], type=shell, check=cxx, help='C++ compiler command', hidden=False) - self.add_option('CXXFLAGS', init=[], + self.add_option('CXXFLAGS', init=['-O2', '-g'], type=shell, check=cxxflags, help='C++ compiler flags', hidden=False) diff --git a/attoconf/lib/lex.py b/attoconf/lib/lex.py new file mode 100644 index 0000000..d25455b --- /dev/null +++ b/attoconf/lib/lex.py @@ -0,0 +1,34 @@ +# Copyright 2013 Ben Longbons +# +# This file is part of attoconf. +# +# attoconf is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# attoconf is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with attoconf. If not, see . + +from __future__ import print_function, division, absolute_import + +from ..classy import ClassyProject +from .c import shell + +def flex(build, FLEX): + # TODO actually test it + pass + +class Flex(ClassyProject): + __slots__ = () + def vars(self): + super(Flex, self).vars() + self.add_option('FLEX', init=['flex'], + type=shell, check=flex, + help='Lexical analyzer command', + hidden=False) diff --git a/attoconf/lib/yacc.py b/attoconf/lib/yacc.py new file mode 100644 index 0000000..c8ddb03 --- /dev/null +++ b/attoconf/lib/yacc.py @@ -0,0 +1,34 @@ +# Copyright 2013 Ben Longbons +# +# This file is part of attoconf. +# +# attoconf is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# attoconf is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with attoconf. If not, see . + +from __future__ import print_function, division, absolute_import + +from ..classy import ClassyProject +from .c import shell + +def bison(build, BISON): + # TODO actually test it + pass + +class Bison(ClassyProject): + __slots__ = () + def vars(self): + super(Bison, self).vars() + self.add_option('BISON', init=['bison'], + type=shell, check=bison, + help='Lexical analyzer command', + hidden=False) diff --git a/attoconf/types.py b/attoconf/types.py new file mode 100644 index 0000000..6ddd37f --- /dev/null +++ b/attoconf/types.py @@ -0,0 +1,25 @@ +# Copyright 2013 Ben Longbons +# +# This file is part of attoconf. +# +# attoconf is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# attoconf is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with attoconf. If not, see . + +from __future__ import print_function, division, absolute_import + +def enum(*args): + def enum_type(s): + if s in args: + return s + raise ValueError('%r not in {%s}' % (s, ', '.join(args))) + return enum_type -- cgit v1.2.3-70-g09d2