From a47653d24ca02ca41fbcf4d256cd94fcc2064547 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 2 Mar 2012 02:00:19 -0600 Subject: Make sure Python works during proof builds --- acprep | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index ee44b38e..939ef7ed 100755 --- a/acprep +++ b/acprep @@ -555,11 +555,6 @@ class PrepareBuild(CommandLineApp): help='Enable full warning flags') def main(self, *args): - if self.options.python: - self.configure_args.append('--enable-python') - if self.options.no_python: - self.configure_args.remove('--enable-python') - if args and args[0] in ['default', 'debug', 'opt', 'gcov', 'gprof']: self.current_flavor = args[0] args = args[1:] @@ -1126,6 +1121,10 @@ class PrepareBuild(CommandLineApp): self.configure_args.append('--enable-doxygen') if self.options.enable_cache: self.configure_args.append('--enable-cache') + if self.options.python: + self.configure_args.append('--enable-python') + if self.options.no_python: + self.configure_args.remove('--enable-python') if self.options.cpp0x: self.CXXFLAGS.append('-std=c++0x') -- cgit v1.2.3 From cabec6db1a9a6dab3dd190494a2a786aebe5f22f Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 7 Mar 2012 02:48:52 -0600 Subject: Use Boost 1.49 by default --- acprep | 54 +++++++++++++++++++----------------------------------- 1 file changed, 19 insertions(+), 35 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index 939ef7ed..bf0ef9ee 100755 --- a/acprep +++ b/acprep @@ -36,7 +36,7 @@ LEVELS = {'DEBUG': logging.DEBUG, 'ERROR': logging.ERROR, 'CRITICAL': logging.CRITICAL} -search_prefixes = [ '/opt/local', '/usr/local', '/sw', '/usr' ] +search_prefixes = [ '/usr/local', '/opt/local', '/sw', '/usr' ] class BoostInfo(object): log = None @@ -52,21 +52,6 @@ class BoostInfo(object): def configure(self, suffix = None, file_suffix = None, home_path = None, include_path = None, library_path = None): - path = library_path or self.library_path - if not isabs(path): - path = join(home_path or self.home_path, path) - if not exists(path) or not isdir(path) or \ - not self.check_for_boost_regex_lib(path, suffix or self.suffix, - file_suffix or self.file_suffix): - return False - - path = include_path or self.include_path - if not isabs(path): - path = join(home_path or self.home_path, path) - if not exists(path) or not isdir(path) or \ - not self.check_for_boost_regex_hpp(path): - return False - self.log.debug('Configuring Boost details') if suffix: self.log.debug('Setting Boost suffix to => ' + suffix) @@ -84,6 +69,21 @@ class BoostInfo(object): self.log.debug('Setting Boost lib directory to => ' + library_path) self.library_path = library_path + path = library_path or self.library_path + if not isabs(path): + path = join(home_path or self.home_path, path) + if not exists(path) or not isdir(path) or \ + not self.check_for_boost_regex_lib(path, suffix or self.suffix, + file_suffix or self.file_suffix): + return False + + path = include_path or self.include_path + if not isabs(path): + path = join(home_path or self.home_path, path) + if not exists(path) or not isdir(path) or \ + not self.check_for_boost_regex_hpp(path): + return False + self.configured = True return True # The object was configured @@ -254,8 +254,8 @@ class CommandLineApp(object): force_exit = True # If true, always ends run() with sys.exit() log_handler = None darwin_gcc = False - boost_version = "1_48_0" - boost_major = "1_48" + boost_version = "1_49_0" + boost_major = "1_49" options = { 'debug': False, @@ -1305,15 +1305,7 @@ class PrepareBuild(CommandLineApp): def locate_darwin_libraries(self): if self.current_flavor == 'debug': - if self.boost_info.configure( - home_path = '/usr/local/stow/boost_%s-%s' % \ - (self.boost_version, self.boost_inc_ident), - suffix = '-%s-sd-%s' % \ - (self.boost_lib_ident, self.boost_major), - file_suffix = '.dylib', - include_path = 'include/boost-%s' % self.boost_major): - pass - elif self.boost_info.configure( + if not self.options.use_clang and self.boost_info.configure( home_path = '/usr/local/stow/boost_%s-%s' % \ (self.boost_version, self.boost_inc_ident), suffix = '-%s-d-%s' % \ @@ -1327,14 +1319,6 @@ class PrepareBuild(CommandLineApp): else: if self.boost_info.configure(): pass - elif self.boost_info.configure( - home_path = '/usr/local/stow/boost_%s-%s' % \ - (self.boost_version, self.boost_inc_ident), - suffix = '-%s-s-%s' % \ - (self.boost_lib_ident, self.boost_major), - file_suffix = '.dylib', - include_path = 'include/boost-%s' % self.boost_major): - pass elif self.boost_info.configure( home_path = '/usr/local/stow/boost_%s-%s' % \ (self.boost_version, self.boost_inc_ident), -- cgit v1.2.3 From 79a4919777b839238bbaf61f0fb6bdf58959e43b Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 7 Mar 2012 14:29:52 -0600 Subject: Fix for optimizing building with Clang --- acprep | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index bf0ef9ee..06087572 100755 --- a/acprep +++ b/acprep @@ -1010,7 +1010,8 @@ class PrepareBuild(CommandLineApp): self.boost_inc_ident = "clang" self.boost_lib_ident = "clang-darwin28" - self.log.debug("Setting Python home to /opt/local") + global search_prefixes + search_prefixes = [ '/opt/local', '/usr/local', '/sw', '/usr' ] self.log.debug('Using Clang ident: %s/%s' % (self.boost_inc_ident, self.boost_lib_ident)) @@ -1319,7 +1320,7 @@ class PrepareBuild(CommandLineApp): else: if self.boost_info.configure(): pass - elif self.boost_info.configure( + elif not self.options.use_clang and self.boost_info.configure( home_path = '/usr/local/stow/boost_%s-%s' % \ (self.boost_version, self.boost_inc_ident), suffix = '-%s-%s' % \ -- cgit v1.2.3 From 62c04deb8719444d1f958d40fe6442b714bb7e50 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 11 Mar 2012 05:08:55 -0500 Subject: Quieted several compiler warnings from Clang --- acprep | 1 + src/option.h | 5 ++--- src/report.cc | 4 +++- src/value.cc | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index 06087572..d3639f54 100755 --- a/acprep +++ b/acprep @@ -1211,6 +1211,7 @@ class PrepareBuild(CommandLineApp): self.CXXFLAGS.append('-Wno-missing-prototypes') self.CXXFLAGS.append('-Wno-missing-noreturn') self.CXXFLAGS.append('-Wno-disabled-macro-expansion') + self.CXXFLAGS.append('-Wno-unused-parameter') self.CXXFLAGS.append('-fno-limit-debug-info') #self.CXXFLAGS.append('-Wold-style-cast') diff --git a/src/option.h b/src/option.h index f892b00e..36dba3a4 100644 --- a/src/option.h +++ b/src/option.h @@ -162,9 +162,8 @@ public: source = none; } - virtual void handler_thunk(const optional& whence) {} - virtual void handler_thunk(const optional& whence, - const string& str) {} + virtual void handler_thunk(const optional&) {} + virtual void handler_thunk(const optional&, const string&) {} value_t handler(call_scope_t& args) { if (wants_arg) { diff --git a/src/report.cc b/src/report.cc index 3151b211..1adbe9d0 100644 --- a/src/report.cc +++ b/src/report.cc @@ -195,7 +195,8 @@ void report_t::normalize_options(const string& verb) long date_width = (HANDLED(date_width_) ? lexical_cast(HANDLER(date_width_).str()) : - format_date(CURRENT_DATE(),FMT_PRINTED).length()); + static_cast + (format_date(CURRENT_DATE(),FMT_PRINTED).length())); long payee_width = (HANDLED(payee_width_) ? lexical_cast(HANDLER(payee_width_).str()) : long(double(cols) * 0.263157)); @@ -825,6 +826,7 @@ value_t report_t::fn_nail_down(call_scope_t& args) throw_(std::runtime_error, _("Attempting to nail down %1") << args[0].label()); } + return arg0; } value_t report_t::fn_lot_date(call_scope_t& args) diff --git a/src/value.cc b/src/value.cc index cae2a356..c14a7104 100644 --- a/src/value.cc +++ b/src/value.cc @@ -1468,7 +1468,7 @@ value_t value_t::exchange_commodities(const std::string& commodities, } } - int index = 0; + std::size_t index = 0; foreach (commodity_t * comm, comms) { switch (type()) { case AMOUNT: -- cgit v1.2.3 From 429cfc5c80e1cabcd73a7e071deb618c4a3f9334 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 15 Mar 2012 05:01:39 -0500 Subject: Don't use -fomit-frame-pointer when building optimized Makes stack traces impossible --- acprep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'acprep') diff --git a/acprep b/acprep index d3639f54..e79fae5b 100755 --- a/acprep +++ b/acprep @@ -1348,7 +1348,7 @@ class PrepareBuild(CommandLineApp): def setup_flavor_opt(self): self.CPPFLAGS.append('-DNDEBUG=1') - for i in ['-O3', '-fomit-frame-pointer']: + for i in ['-O3']: self.CXXFLAGS.append(i) self.CFLAGS.append(i) self.LDFLAGS.append(i) -- cgit v1.2.3 From 08f65eeadc288ecde4b8fb281e477958c8ae7cd5 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 29 Mar 2012 15:35:20 -0500 Subject: Allow serialization to be enabled again --- acprep | 6 ++ src/scope.h | 2 +- src/system.hh.in | 13 ++++- src/xact.h | 15 +++++ tools/configure.ac | 168 +++++++++++++++++++++++++++++++++++++++++++---------- 5 files changed, 169 insertions(+), 35 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index e79fae5b..ddf7639d 100755 --- a/acprep +++ b/acprep @@ -508,6 +508,12 @@ class PrepareBuild(CommandLineApp): op.add_option('', '--no-python', action='store_true', dest='no_python', default=False, help='Do not enable Python support by default') + op.add_option('', '--cache', action='store_true', + dest='enable_cache', default=False, + help='Enable use of Boost.Serialization (--cache)') + op.add_option('', '--doxygen', action='store_true', + dest='enable_doxygen', default=False, + help='Enable use of Doxygen to build ref manual ("make docs")') op.add_option('', '--enable-cache', action='store_true', dest='enable_cache', default=False, help='Enable use of Boost.Serialization (--cache)') diff --git a/src/scope.h b/src/scope.h index acaf7194..c43d73d6 100644 --- a/src/scope.h +++ b/src/scope.h @@ -483,7 +483,7 @@ public: #if defined(HAVE_BOOST_SERIALIZATION) protected: - explicit call_scope_t() { + explicit call_scope_t() : depth(0) { TRACE_CTOR(call_scope_t, ""); } diff --git a/src/system.hh.in b/src/system.hh.in index a38deb1f..552a591a 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -246,11 +246,18 @@ void serialize(Archive& ar, boost::intrusive_ptr& ptr, const unsigned int) } } -template -void serialize(Archive&, boost::function&, const unsigned int) -{ +template +void serialize(Archive&, boost::any&, const unsigned int) { + // jww (2012-03-29): Should we really ignore any fields entirely? + // These occur inside value_t::storage_t::data's variant. } +template +void serialize(Archive&, boost::blank&, const unsigned int) {} + +template +void serialize(Archive&, boost::function&, const unsigned int) {} + template void serialize(Archive& ar, istream_pos_type& pos, const unsigned int) { diff --git a/src/xact.h b/src/xact.h index df82258d..ce00242e 100644 --- a/src/xact.h +++ b/src/xact.h @@ -168,6 +168,21 @@ public: bool _overwrite_existing) : tag_data(_tag_data), overwrite_existing(_overwrite_existing), apply_to_post(NULL) {} + +#if defined(HAVE_BOOST_SERIALIZATION) +private: + /** Serialization. */ + deferred_tag_data_t() : apply_to_post(NULL) {} + + friend class boost::serialization::access; + + template + void serialize(Archive& ar, const unsigned int /* version */) { + ar & tag_data; + ar & overwrite_existing; + ar & apply_to_post; + } +#endif // HAVE_BOOST_SERIALIZATION }; typedef std::list deferred_notes_list; diff --git a/tools/configure.ac b/tools/configure.ac index e078ebc4..f7623f62 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -332,37 +332,143 @@ else fi # check for boost_serialization -#AC_CACHE_CHECK( -# [if boost_serialization is available], -# [boost_serialization_cpplib_avail_cv_], -# [boost_serialization_save_libs=$LIBS -# LIBS="-lboost_serialization$BOOST_SUFFIX -lboost_system$BOOST_SUFFIX $LIBS" -# AC_LANG_PUSH(C++) -# AC_LINK_IFELSE( -# [AC_LANG_PROGRAM( -# [[#include -# #include -# struct foo { -# int a; -# template -# void serialize(Archive & ar, const unsigned int) { -# ar & a; -# } -# };]], -# [[boost::archive::binary_oarchive oa(std::cout); -# foo x; -# oa << x;]])], -# [boost_serialization_cpplib_avail_cv_=true], -# [boost_serialization_cpplib_avail_cv_=false]) -# AC_LANG_POP -# LIBS=$boost_serialization_save_libs]) -# -#if [test x$boost_serialization_cpplib_avail_cv_ = xtrue -a x$cache = xtrue]; then -# AC_DEFINE([HAVE_BOOST_SERIALIZATION], [1], [Whether Boost.Serialization is available]) -# LIBS="-lboost_serialization$BOOST_SUFFIX $LIBS" -#fi -#AM_CONDITIONAL(HAVE_BOOST_SERIALIZATION, test x$boost_serialization_cpplib_avail_cv_ = xtrue -a x$cache = xtrue) -AM_CONDITIONAL(HAVE_BOOST_SERIALIZATION, false) +AC_CACHE_CHECK( + [if boost_serialization is available], + [boost_serialization_cpplib_avail_cv_], + [boost_serialization_save_libs=$LIBS + LIBS="-lboost_serialization$BOOST_SUFFIX -lboost_system$BOOST_SUFFIX $LIBS" + AC_LANG_PUSH(C++) + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + struct foo { + int a; + template + void serialize(Archive & ar, const unsigned int) { + ar & a; + } + };]], + [[boost::archive::binary_oarchive oa(std::cout); + foo x; + oa << x;]])], + [boost_serialization_cpplib_avail_cv_=true], + [boost_serialization_cpplib_avail_cv_=false]) + AC_LANG_POP + LIBS=$boost_serialization_save_libs]) + +if [test x$boost_serialization_cpplib_avail_cv_ = xtrue -a x$cache = xtrue]; then + AC_DEFINE([HAVE_BOOST_SERIALIZATION], [1], [Whether Boost.Serialization is available]) + LIBS="-lboost_serialization$BOOST_SUFFIX $LIBS" +fi +AM_CONDITIONAL(HAVE_BOOST_SERIALIZATION, test x$boost_serialization_cpplib_avail_cv_ = xtrue -a x$cache = xtrue) + +# check for expat or xmlparse +AC_ARG_ENABLE(xml, + [ --enable-xml Turn on support for XML parsing], + [case "${enableval}" in + yes) xml=true ;; + no) xml=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-xml) ;; + esac],[xml=true]) +AM_CONDITIONAL(USE_XML, test x$xml = xtrue) + +if [test x$xml = xtrue ]; then + AC_CACHE_CHECK( + [if libexpat is available], + [libexpat_avail_cv_], + [libexpat_save_libs=$LIBS + LIBS="-lexpat $LIBS" + AC_LANG_PUSH(C++) + AC_TRY_LINK( + [#include + extern "C" { + #include // expat XML parser + }], + [XML_Parser parser = XML_ParserCreate(NULL); + return parser != NULL;], + [libexpat_avail_cv_=true], + [libexpat_avail_cv_=false]) + AC_LANG_POP + LIBS=$libexpat_save_libs]) + + if [test x$libexpat_avail_cv_ = xtrue ]; then + AM_CONDITIONAL(HAVE_EXPAT, true) + LIBS="-lexpat $LIBS" + else + AM_CONDITIONAL(HAVE_EXPAT, false) + fi +else + AM_CONDITIONAL(HAVE_EXPAT, false) +fi + +if [test x$xml = xtrue ]; then + if [test x$libexpat_avail_cv_ = xfalse ]; then + AC_CACHE_CHECK( + [if libxmlparse is available], + [libxmlparse_avail_cv_], + [libxmlparse_save_libs=$LIBS + LIBS="-lxmlparse -lxmltok $LIBS" + AC_LANG_PUSH(C++) + AC_TRY_LINK( + [#include + extern "C" { + #include // expat XML parser + }], + [XML_Parser parser = XML_ParserCreate(NULL); + return parser != NULL;], + [libxmlparse_avail_cv_=true], + [libxmlparse_avail_cv_=false]) + AC_LANG_POP + LIBS=$libxmlparse_save_libs]) + + if [test x$libxmlparse_avail_cv_ = xtrue ]; then + AM_CONDITIONAL(HAVE_XMLPARSE, true) + LIBS="-lxmlparse -lxmltok $LIBS" + else + AM_CONDITIONAL(HAVE_XMLPARSE, false) + fi + else + AM_CONDITIONAL(HAVE_XMLPARSE, false) + fi +else + AM_CONDITIONAL(HAVE_XMLPARSE, false) +fi + +# check for libofx +AC_ARG_ENABLE(ofx, + [ --enable-ofx Turn on support for OFX/OCF parsing], + [case "${enableval}" in + yes) ofx=true ;; + no) ofx=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-ofx) ;; + esac],[ofx=true]) +AM_CONDITIONAL(USE_OFX, test x$ofx = xtrue) + +if [test x$ofx = xtrue ]; then + AC_CACHE_CHECK( + [if libofx is available], + [libofx_avail_cv_], + [libofx_save_libs=$LIBS + LIBS="-lofx $LIBS" + AC_LANG_PUSH(C++) + AC_TRY_LINK( + [#include ], + [ LibofxContextPtr libofx_context = libofx_get_new_context();], + [libofx_avail_cv_=true], + [libofx_avail_cv_=false]) + AC_LANG_POP + LIBS=$libofx_save_libs]) + + if [test x$libofx_avail_cv_ = xtrue ]; then + AM_CONDITIONAL(HAVE_LIBOFX, true) + LIBS="-lofx $LIBS" + else + AM_CONDITIONAL(HAVE_LIBOFX, false) + fi +else + AM_CONDITIONAL(HAVE_LIBOFX, false) +fi # check for Python if [ test x$python = xtrue ]; then -- cgit v1.2.3 From e3ac24301990a77a296d103388a64bea716ce5cd Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 8 Apr 2012 02:57:18 -0500 Subject: Started work on a "views" report document model --- acprep | 2 + src/views.cc | 259 +++++++++++++++++++++++++++++++ src/views.h | 457 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/xact.h | 4 + tools/Makefile.am | 2 + 5 files changed, 724 insertions(+) create mode 100644 src/views.cc create mode 100644 src/views.h (limited to 'acprep') diff --git a/acprep b/acprep index ddf7639d..72fcd642 100755 --- a/acprep +++ b/acprep @@ -1048,6 +1048,8 @@ class PrepareBuild(CommandLineApp): self.CXXFLAGS.append('-march=nocona') self.CXXFLAGS.append('-msse3') + self.CXXFLAGS.append('-DDOCUMENT_MODEL=1') + self.locate_darwin_libraries() def setup_for_system(self): diff --git a/src/views.cc b/src/views.cc new file mode 100644 index 00000000..bbd58ce2 --- /dev/null +++ b/src/views.cc @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of New Artisans LLC nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifdef DOCUMENT_MODEL + +#include + +#include "views.h" +#include "report.h" +#include "journal.h" +#include "xact.h" +#include "post.h" +#include "account.h" + +namespace ledger { + +r_xact_ptr r_journal_t::create_xact(xact_t * xact) +{ + r_xact_ptr x = new r_xact_t(this, xact); + add_xact(x); + assert(xact->data == NULL); + xact->data = &x; + return x; +} + +void r_journal_t::add_xact(r_xact_ptr xact) +{ + xacts.push_back(xact); +} + +r_post_ptr r_journal_t::add_post(post_t * post) +{ + r_xact_ptr x; + if (post->xact->data) + x = *static_cast(post->xact->data); + else + x = create_xact(post->xact); + + r_post_ptr p = create_post(post, x, create_account(post->account)); + return p; +} + +void r_journal_t::add_post(r_post_ptr post) +{ + posts.push_back(post); +} + +r_post_ptr r_journal_t::create_post(post_t * post, r_xact_ptr xact, + r_account_ptr account) +{ + r_post_ptr p = new r_post_t(this, post, xact, account); + + add_post(p); + xact->add_post(p); + account->add_post(p); + + return p; +} + +r_post_ptr r_journal_t::create_post(r_post_ptr post, r_xact_ptr xact, + r_account_ptr account) +{ + r_post_ptr temp(new r_post_t(*post.get())); + + add_post(temp); + + temp->set_xact(xact); + xact->add_post(temp); + + temp->set_account(account); + account->add_post(temp); + + return temp; +} + +r_account_ptr r_journal_t::create_account(account_t * account) +{ + return create_account(account->fullname()); +} + +r_account_ptr r_journal_t::create_account(const std::string& name) +{ + return master_ptr->create_account(name); +} + + +const optional r_item_t::position() const +{ + return ptr()->pos; +} + +date_t r_item_t::date() const +{ + return ptr()->date(); +} + +void r_item_t::set_date(const date_t& when) +{ +} + +item_t::state_t r_item_t::state() const +{ + return ptr()->state(); +} + +void r_item_t::set_state(item_t::state_t val) +{ +} + +string r_item_t::payee() const +{ + if (optional desc = get_tag(_("Payee"))) + return desc->as_string(); + else + return empty_string; +} + +void r_item_t::set_payee(const string& name) +{ +} + +void r_item_t::define(const symbol_t::kind_t, const string& name, + expr_t::ptr_op_t def) +{ + bind_scope_t bound_scope(*scope_t::default_scope, *this); + set_tag(name, def->calc(bound_scope)); +} + +expr_t::ptr_op_t r_item_t::lookup(const symbol_t::kind_t kind, + const string& name) +{ + if (kind != symbol_t::FUNCTION) + return NULL; + + switch (name[0]) { + } + + return base_item->lookup(kind, name); +} + + +string r_xact_t::description() +{ + return ptr()->description(); +} + +void r_xact_t::add_post(r_post_ptr post) +{ + posts.push_back(post); +} + +string r_xact_t::payee() const +{ + string desc(r_item_t::payee()); + if (desc.empty()) + return ptr()->payee; + else + return desc; +} + + +string r_post_t::description() +{ + return ptr()->description(); +} + +string r_post_t::payee() const +{ + string desc(r_item_t::payee()); + if (desc.empty()) + return const_cast(this)->xact()->payee(); + else + return desc; +} + + +string r_account_t::description() +{ + return string(_("account ")) + fullname(); +} + +void r_account_t::add_post(r_post_ptr post) +{ + posts.push_back(post); +} + +r_account_ptr r_account_t::create_account(const std::string& fname) +{ + string::size_type sep = fname.find(':'); + string head, tail; + if (sep == string::npos) { + head = fname; + } else { + head = string(fname, 0, sep); + tail = string(fname, sep + 1); + } + + std::pair result = + accounts.insert(r_accounts_map::value_type + (head, new r_account_t(journal_ptr, this, name))); + + r_account_ptr acct((*result.first).second); + if (tail.empty()) + return acct; + else + return acct->create_account(tail); +} + +string r_account_t::fullname() const +{ + if (! _fullname.empty()) { + return _fullname; + } else { + r_account_ptr first = NULL; + string fname = name; + + while (! first || first->parent_ptr) { + first = first ? first->parent_ptr : parent_ptr; + if (! first->name.empty()) + fname = first->name + ":" + fname; + } + + _fullname = fname; + + return fname; + } +} + +} // namespace ledger + +#endif /* DOCUMENT_MODEL */ diff --git a/src/views.h b/src/views.h new file mode 100644 index 00000000..f9a007b7 --- /dev/null +++ b/src/views.h @@ -0,0 +1,457 @@ +/* + * Copyright (c) 2003-2012, John Wiegley. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of New Artisans LLC nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * @addtogroup views + */ + +/** + * @file views.h + * @author John Wiegley + * + * @ingroup views + */ +#ifndef _VIEWS_H +#define _VIEWS_H + +#include "utils.h" + +#ifdef DOCUMENT_MODEL + +#include "scope.h" +#include "item.h" +#include "report.h" +#include "post.h" +#include "predicate.h" + +namespace ledger { + +class journal_t; +class xact_t; +class post_t; +class account_t; +class report_t; + +class r_base_t : public supports_flags, + public scope_t +{ +public: + r_base_t() : refc(0) { + TRACE_CTOR(r_base_t, ""); + } + r_base_t(const r_base_t& other) : refc(0) { + TRACE_CTOR(r_base_t, "copy"); + } + virtual ~r_base_t() { + TRACE_DTOR(r_base_t); + } + +protected: + /** + * `refc' holds the current reference count for each object. + */ + mutable int refc; + + /** + * Reference counting methods. The intrusive_ptr_* methods are used + * by boost::intrusive_ptr to manage the calls to acquire and release. + */ + void acquire() const { + VERIFY(refc >= 0); + refc++; + } + void release() const { + VERIFY(refc > 0); + if (--refc == 0) + checked_delete(this); + } + + friend inline void intrusive_ptr_add_ref(r_base_t * r_ptr) { + r_ptr->acquire(); + } + friend inline void intrusive_ptr_release(r_base_t * r_ptr) { + r_ptr->release(); + } +}; + +class r_journal_t; +class r_item_t; +class r_xact_t; +class r_post_t; +class r_account_t; + +typedef intrusive_ptr r_journal_ptr; +typedef intrusive_ptr r_item_ptr; +typedef intrusive_ptr r_xact_ptr; +typedef intrusive_ptr r_post_ptr; +typedef intrusive_ptr r_account_ptr; + +typedef std::list r_xacts_list; +typedef std::list r_posts_list; + +class r_journal_t : public r_base_t +{ + journal_t * base_journal; + + journal_t * ptr() { + return base_journal; + } + const journal_t * ptr() const { + return base_journal; + } + + r_account_ptr master_ptr; + r_xacts_list xacts; + r_posts_list posts; + + void set_master(r_account_ptr ptr) { + master_ptr = ptr; + } + +public: + r_journal_t(journal_t * _journal, r_account_ptr _master) + : r_base_t(), base_journal(_journal), master_ptr(_master) { + TRACE_CTOR(r_journal_t, "journal_t *, account_t *"); + } + r_journal_t(const r_journal_t& other) + : r_base_t(other), + base_journal(other.base_journal), + master_ptr(other.master_ptr), + xacts(other.xacts), + posts(other.posts) { + TRACE_CTOR(r_journal_t, "copy"); + } + virtual ~r_journal_t() { + TRACE_DTOR(r_journal_t); + } + + r_xact_ptr create_xact(xact_t * xact = NULL); + + void add_xact(r_xact_ptr xact); + + r_xacts_list::iterator xacts_begin() { + return xacts.begin(); + } + r_xacts_list::iterator xacts_end() { + return xacts.end(); + } + + r_post_ptr add_post(post_t * post); + void add_post(r_post_ptr post); + + r_post_ptr create_post(post_t * post = NULL, r_xact_ptr xact = NULL, + r_account_ptr account = NULL); + r_post_ptr create_post(r_post_ptr post, r_xact_ptr xact = NULL, + r_account_ptr account = NULL); + + r_posts_list::iterator posts_begin() { + return posts.begin(); + } + r_posts_list::iterator posts_end() { + return posts.end(); + } + + r_account_ptr create_account(account_t * account = NULL); + r_account_ptr create_account(const std::string& name); + + friend void to_xml(std::ostream& out, r_journal_ptr journal); +}; + +class r_item_t : public r_base_t +{ +protected: + item_t * base_item; + + item_t * ptr() { + return base_item; + } + const item_t * ptr() const { + return base_item; + } + + r_journal_ptr journal_ptr; + +public: + r_item_t(r_journal_ptr _journal_ptr, item_t * _item) + : r_base_t(), base_item(_item), journal_ptr(_journal_ptr) { + TRACE_CTOR(r_item_t, "r_journal_ptr, item_t *"); + } + r_item_t(const r_item_t& other) + : r_base_t(other), + base_item(other.base_item), + journal_ptr(other.journal_ptr) { + TRACE_CTOR(r_item_t, "copy"); + } + virtual ~r_item_t() { + TRACE_DTOR(r_item_t); + } + + const optional position() const; + + string id() const { + return ptr()->id(); + } + std::size_t seq() const { + return ptr()->seq(); + } + + date_t date() const; + void set_date(const date_t& when); + + item_t::state_t state() const; + void set_state(item_t::state_t val); + + string payee() const; + void set_payee(const string& name); + + optional note() const { + return ptr()->note; + } + + bool has_tag(const string& tag) const { + return ptr()->has_tag(tag); + } + bool has_tag(const mask_t& tag_mask, + const optional& value_mask = none) const { + return ptr()->has_tag(tag_mask, value_mask); + } + + optional get_tag(const string& tag) const { + return ptr()->get_tag(tag); + } + optional get_tag(const mask_t& tag_mask, + const optional& value_mask = none) const { + return ptr()->get_tag(tag_mask, value_mask); + } + + void set_tag(const string& tag, + const optional& value = none, + const bool overwrite_existing = true) { + ptr()->set_tag(tag, value, overwrite_existing); + } + + /** + * Symbol scope methods. + */ + virtual void define(const symbol_t::kind_t, const string&, + expr_t::ptr_op_t); + virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, + const string& name); + + friend class r_journal_t; + friend void to_xml(std::ostream& out, r_item_ptr item); +}; + +class r_xact_t : public r_item_t +{ + xact_t * ptr() { + return reinterpret_cast(base_item); + } + const xact_t * ptr() const { + return reinterpret_cast(base_item); + } + + r_posts_list posts; + +public: + r_xact_t(r_journal_ptr journal_ptr, xact_t * _xact) + : r_item_t(journal_ptr, reinterpret_cast(_xact)) { + TRACE_CTOR(r_xact_t, "r_journal_ptr, xact_t *"); + } + r_xact_t(const r_xact_t& other) + : r_item_t(other), + posts(other.posts) { + TRACE_CTOR(r_xact_t, "copy"); + } + virtual ~r_xact_t() { + TRACE_DTOR(r_xact_t); + } + + virtual string description(); + + void add_post(r_post_ptr post); + +#if 0 + r_post_ptr create_post(post_t * post = NULL, r_account_ptr account = NULL); + r_post_ptr create_post(r_post_ptr post, r_account_ptr account = NULL); +#endif + + r_posts_list::iterator posts_begin() { + return posts.begin(); + } + r_posts_list::iterator posts_end() { + return posts.end(); + } + + string code() const; + string payee() const; + + friend class r_journal_t; + friend void to_xml(std::ostream& out, r_xact_ptr xact); +}; + +class r_post_t : public r_item_t +{ + post_t * ptr() { + return reinterpret_cast(base_item); + } + const post_t * ptr() const { + return reinterpret_cast(base_item); + } + + r_xact_ptr xact_ptr; + r_account_ptr account_ptr; + + void set_xact(r_xact_ptr ptr) { + xact_ptr = ptr; + } + void set_account(r_account_ptr ptr) { + account_ptr = ptr; + } + +public: + r_post_t(r_journal_ptr journal_ptr, post_t * _post, + r_xact_ptr _xact_ptr, r_account_ptr _account_ptr) + : r_item_t(journal_ptr, reinterpret_cast(_post)), + xact_ptr(_xact_ptr), account_ptr(_account_ptr) { + TRACE_CTOR(r_post_t, "r_journal_ptr, post_t *, r_xact_ptr, r_account_ptr"); + } + r_post_t(const r_post_t& other) + : r_item_t(other), + xact_ptr(other.xact_ptr), + account_ptr(other.account_ptr) { + TRACE_CTOR(r_post_t, "copy"); + } + virtual ~r_post_t() { + TRACE_DTOR(r_post_t); + } + + virtual string description(); + + string payee() const; + + r_xact_ptr xact(); + r_account_ptr account(); + + value_t amount() const; + value_t cost() const; + + std::size_t count() const; + value_t running_total() const; + + optional checkin() const; + optional checkout() const; + + friend class r_journal_t; + friend void to_xml(std::ostream& out, r_post_ptr post); +}; + +typedef std::map r_accounts_map; + +class r_account_t : public r_base_t +{ + r_journal_ptr journal_ptr; + r_account_ptr parent_ptr; + r_accounts_map accounts; + r_posts_list posts; + + string name; + + mutable string _fullname; + +public: + r_account_t(r_journal_ptr _journal_ptr, r_account_ptr _parent_ptr, + string _name) + : r_base_t(), journal_ptr(_journal_ptr), parent_ptr(_parent_ptr), + name(_name) { + TRACE_CTOR(r_account_t, "r_journal_ptr, r_account_ptr, string"); + } + r_account_t(const r_account_t& other) + : r_base_t(other), + journal_ptr(other.journal_ptr), + parent_ptr(other.parent_ptr), + accounts(other.accounts), + posts(other.posts), + name(other.name), + _fullname(other._fullname) { + TRACE_CTOR(r_account_t, "copy"); + } + virtual ~r_account_t() { + TRACE_DTOR(r_account_t); + } + + virtual string description(); + + void add_post(r_post_ptr post); + + r_posts_list::iterator posts_begin() { + return posts.begin(); + } + r_posts_list::iterator posts_end() { + return posts.end(); + } + + r_account_ptr create_account(const std::string& name); + + string fullname() const; + + /** + * Symbol scope methods. + */ + virtual void define(const symbol_t::kind_t, const string&, + expr_t::ptr_op_t) {} + virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind, + const string& fname) { + return NULL; + } + + friend class r_journal_t; + friend void to_xml(std::ostream& out, r_account_ptr account); +}; + +template +void populate_journal(r_journal_ptr journal, report_t& report, + PostsIterator iter, predicate_t& pred) +{ + while (post_t * post = *iter) { + bind_scope_t bound_scope(report, *post); + if (pred.calc(bound_scope)) + journal->add_post(post); + + iter.increment(); + } +} + +} // namespace ledger + +#endif /* DOCUMENT_MODEL */ + +#endif // _VIEWS_H diff --git a/src/xact.h b/src/xact.h index ce00242e..0000e9c6 100644 --- a/src/xact.h +++ b/src/xact.h @@ -109,6 +109,10 @@ public: optional code; string payee; +#ifdef DOCUMENT_MODEL + void * data; +#endif + xact_t() { TRACE_CTOR(xact_t, ""); } diff --git a/tools/Makefile.am b/tools/Makefile.am index 232ce768..04f64530 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -79,6 +79,7 @@ libledger_report_la_SOURCES = \ src/chain.cc \ src/filters.cc \ src/report.cc \ + src/views.cc \ src/select.cc \ src/session.cc @@ -131,6 +132,7 @@ pkginclude_HEADERS = \ \ src/session.h \ src/select.h \ + src/views.h \ src/report.h \ src/filters.h \ src/chain.h \ -- cgit v1.2.3 From 86f5f8e520ed93ae5762384019f54f76a0777e26 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 12 Apr 2012 02:40:00 -0500 Subject: Set FLAVOR= on all make invocations --- acprep | 2 ++ 1 file changed, 2 insertions(+) (limited to 'acprep') diff --git a/acprep b/acprep index 72fcd642..a6efb2a7 100755 --- a/acprep +++ b/acprep @@ -1521,6 +1521,8 @@ class PrepareBuild(CommandLineApp): make_args.append('-j%d' % self.options.jobs) make_args.append('JOBS=%d' % self.options.jobs) + make_args.append('FLAVOR=%s' % self.current_flavor) + self.log.debug('Configure arguments => ' + str(config_args)) self.log.debug('Makefile arguments => ' + str(make_args)) -- cgit v1.2.3 From 1ad826c2bccabad844156a181735dd960f87d174 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 12 Apr 2012 14:49:32 -0500 Subject: Proof using both GCC and Clang --- acprep | 13 +++++++++++-- tools/proof | 9 ++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index a6efb2a7..0d7f3cd0 100755 --- a/acprep +++ b/acprep @@ -1673,8 +1673,17 @@ class PrepareBuild(CommandLineApp): def phase_rsync(self, *args): self.log.info('Executing phase: rsync') - source_copy_dir = join(self.ensure(self.products_directory()), - 'ledger-proof') + proof_dir = 'ledger-proof' + + if self.options.python: + proof_dir += "-python" + + if self.options.gcc47: + proof_dir += "-gcc47" + elif self.options.use_clang: + proof_dir += "-clang" + + source_copy_dir = join(self.ensure(self.products_directory()), proof_dir) self.execute('rsync', '-a', '--delete', '--exclude=.git/', '--exclude=b/', diff --git a/tools/proof b/tools/proof index 7eafd0ef..00c7f7d1 100755 --- a/tools/proof +++ b/tools/proof @@ -18,11 +18,18 @@ ledger_proof() { sudo rm -fr $DEST/ledger-proof date > $LOGDIR/ledger-proof.log + time nice -n 20 \ + ./acprep --debug --enable-doxygen --universal --gcc47 -j16 proof 2>&1 | \ + tee -a $LOGDIR/ledger-proof.log + + time nice -n 20 \ + ./acprep --debug --enable-doxygen --universal --python --gcc47 -j16 proof 2>&1 | \ + tee -a $LOGDIR/ledger-proof.log + time nice -n 20 \ ./acprep --debug --enable-doxygen --universal --clang -j16 proof 2>&1 | \ tee -a $LOGDIR/ledger-proof.log - sudo rm -fr $DEST/ledger-proof time nice -n 20 \ ./acprep --debug --enable-doxygen --universal --python --clang -j16 proof 2>&1 | \ tee -a $LOGDIR/ledger-proof.log -- cgit v1.2.3 From ee641f353c9a2216533800464d26afe86f1b028e Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 15 Apr 2012 01:17:01 -0500 Subject: Resolve some issues with proof builds --- acprep | 5 ++++- src/draft.cc | 14 +++++++------- src/draft.h | 9 +++++++++ src/xact.cc | 3 ++- test/LedgerHarness.py | 4 ++-- test/RegressTests.py | 3 ++- 6 files changed, 26 insertions(+), 12 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index 0d7f3cd0..4ebd6914 100755 --- a/acprep +++ b/acprep @@ -1643,7 +1643,10 @@ class PrepareBuild(CommandLineApp): isdir(self.build_directory()): self.log.info('=== Wiping build directory %s ===' % self.build_directory()) - shutil.rmtree(self.build_directory()) + try: + shutil.rmtree(self.build_directory()) + except: + self.execute('rm', '-fr', self.build_directory()) def phase_distcheck(self, *args): self.log.info('Executing phase: distcheck') diff --git a/src/draft.cc b/src/draft.cc index 7edf7edc..43c214cb 100644 --- a/src/draft.cc +++ b/src/draft.cc @@ -507,7 +507,6 @@ value_t template_command(call_scope_t& args) out << std::endl << std::endl; draft_t draft(args.value()); - out << _("--- Transaction template ---") << std::endl; draft.dump(out); @@ -517,15 +516,16 @@ value_t template_command(call_scope_t& args) value_t xact_command(call_scope_t& args) { report_t& report(find_scope(args)); - draft_t draft(args.value()); + draft_t draft(args.value()); - xact_t * new_xact = draft.insert(*report.session.journal.get()); + unique_ptr new_xact(draft.insert(*report.session.journal.get())); + if (new_xact.get()) { + // Only consider actual postings for the "xact" command + report.HANDLER(limit_).on("#xact", "actual"); - // Only consider actual postings for the "xact" command - report.HANDLER(limit_).on("#xact", "actual"); + report.xact_report(post_handler_ptr(new print_xacts(report)), *new_xact.get()); + } - if (new_xact) - report.xact_report(post_handler_ptr(new print_xacts(report)), *new_xact); return true; } diff --git a/src/draft.h b/src/draft.h index 46aa26e1..9023e6da 100644 --- a/src/draft.h +++ b/src/draft.h @@ -81,6 +81,15 @@ class draft_t : public expr_base_t xact_template_t() { TRACE_CTOR(xact_template_t, ""); } + xact_template_t(const xact_template_t& other) + : date(other.date), + code(other.code), + note(other.note), + payee_mask(other.payee_mask), + posts(other.posts) + { + TRACE_CTOR(xact_template_t, "copy"); + } ~xact_template_t() throw() { TRACE_DTOR(xact_template_t); } diff --git a/src/xact.cc b/src/xact.cc index 3f4b753c..226fd5ab 100644 --- a/src/xact.cc +++ b/src/xact.cc @@ -56,7 +56,8 @@ xact_base_t::~xact_base_t() // temporary is. assert(! post->has_flags(ITEM_TEMP)); - post->account->remove_post(post); + if (post->account) + post->account->remove_post(post); checked_delete(post); } } diff --git a/test/LedgerHarness.py b/test/LedgerHarness.py index 3477e720..3e797e85 100755 --- a/test/LedgerHarness.py +++ b/test/LedgerHarness.py @@ -44,8 +44,8 @@ class LedgerHarness: print "Cannot find source path at '%s'" % argv[2] sys.exit(1) - self.ledger = argv[1] - self.sourcepath = argv[2] + self.ledger = os.path.abspath(argv[1]) + self.sourcepath = os.path.abspath(argv[2]) self.succeeded = 0 self.failed = 0 self.verify = '--verify' in argv diff --git a/test/RegressTests.py b/test/RegressTests.py index a7d51ada..792c2d3e 100755 --- a/test/RegressTests.py +++ b/test/RegressTests.py @@ -184,7 +184,8 @@ if __name__ == '__main__': tests = [os.path.join(tests, x) for x in os.listdir(tests) if (x.endswith('.test') and - (not '_py.test' in x or harness.python))] + (not '_py.test' in x or (harness.python and + not harness.verify)))] if pool: pool.map(do_test, tests, 1) else: -- cgit v1.2.3 From 5a9b56f024a38cd497e5d8b7dce6c17c599d277f Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 23 Apr 2012 00:21:26 -0500 Subject: Use chmod before removing the proof build directory --- acprep | 1 + 1 file changed, 1 insertion(+) (limited to 'acprep') diff --git a/acprep b/acprep index 4ebd6914..88b84c08 100755 --- a/acprep +++ b/acprep @@ -1646,6 +1646,7 @@ class PrepareBuild(CommandLineApp): try: shutil.rmtree(self.build_directory()) except: + self.execute('chmod', '-R', 'u+w', self.build_directory()) self.execute('rm', '-fr', self.build_directory()) def phase_distcheck(self, *args): -- cgit v1.2.3 From 711281472bed4296dcc9f1a48da99327b28698bf Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 23 Apr 2012 00:21:48 -0500 Subject: Add support for g++ 4.8 --- acprep | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index 88b84c08..ba7afca4 100755 --- a/acprep +++ b/acprep @@ -532,9 +532,12 @@ class PrepareBuild(CommandLineApp): op.add_option('', '--gcc47', action='store_true', dest='gcc47', default=False, help='Require the use of gcc 4.7') + op.add_option('', '--gcc48', action='store_true', + dest='gcc48', default=False, + help='Require the use of gcc 4.8') op.add_option('', '--cpp0x', action='store_true', dest='cpp0x', default=False, - help='Use C++0x extensions (requires Clang or gcc 4.6/7)') + help='Use C++0x extensions (requires Clang or gcc 4.6/7/8)') op.add_option('', '--output', metavar='DIR', action="callback", callback=self.option_output, help='Build in the specified directory') @@ -1092,11 +1095,17 @@ class PrepareBuild(CommandLineApp): not self.options.gcc45 and \ not self.options.gcc46 and \ not self.options.gcc47 and \ + not self.options.gcc48 and \ exists('/usr/bin/g++-4.2'): self.envvars['CC'] = '/usr/bin/gcc-4.2' self.envvars['CXX'] = '/usr/bin/g++-4.2' self.envvars['LD'] = '/usr/bin/g++-4.2' self.darwin_gcc = True + elif exists('/usr/local/bin/g++-mp-4.8') and \ + self.options.gcc47: + self.envvars['CC'] = '/usr/local/bin/gcc-mp-4.8' + self.envvars['CXX'] = '/usr/local/bin/g++-mp-4.8' + self.envvars['LD'] = '/usr/local/bin/g++-mp-4.8' elif exists('/usr/local/bin/g++-mp-4.7') and \ self.options.gcc47: self.envvars['CC'] = '/usr/local/bin/gcc-mp-4.7' @@ -1345,7 +1354,8 @@ class PrepareBuild(CommandLineApp): def setup_flavor_debug(self): self.configure_args.append('--enable-debug') - if self.options.gcc45 or self.options.gcc46 or self.options.gcc47: + if self.options.gcc45 or self.options.gcc46 or \ + self.options.gcc47 or self.options.gcc48: self.CXXFLAGS.append('-g2') self.CXXFLAGS.append('-ggdb') self.LDFLAGS.append('-g2') @@ -1684,6 +1694,8 @@ class PrepareBuild(CommandLineApp): if self.options.gcc47: proof_dir += "-gcc47" + elif self.options.gcc48: + proof_dir += "-gcc48" elif self.options.use_clang: proof_dir += "-clang" -- cgit v1.2.3 From adbd99414b56a02cb3acf8c0251a434aa950eca1 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 23 Apr 2012 00:21:54 -0500 Subject: Remove some dead code --- acprep | 7 ------- 1 file changed, 7 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index ba7afca4..1eccef64 100755 --- a/acprep +++ b/acprep @@ -1037,14 +1037,7 @@ class PrepareBuild(CommandLineApp): (self.boost_inc_ident, self.boost_lib_ident)) if self.current_flavor == 'debug': - if exists('/usr/local/stow/icu-%s/include' % self.boost_inc_ident): - self.sys_include_dirs.insert( - 0, '/usr/local/stow/icu-%s/include' % self.boost_inc_ident) - self.sys_library_dirs.insert( - 0, '/usr/local/stow/icu-%s/lib' % self.boost_inc_ident) - self.configure_args.append('--disable-shared') - elif self.current_flavor == 'gcov': self.configure_args.append('--disable-shared') else: -- cgit v1.2.3 From 6af3f0448fe8b3bf3472504a3ee547a816ab381a Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 23 Apr 2012 00:22:12 -0500 Subject: More support for building with Clang --- acprep | 10 ++++++++-- lib/Makefile | 1 + lib/build.sh | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100755 lib/build.sh (limited to 'acprep') diff --git a/acprep b/acprep index 1eccef64..fa61ba98 100755 --- a/acprep +++ b/acprep @@ -1016,8 +1016,14 @@ class PrepareBuild(CommandLineApp): self.envvars['PYTHON_HOME'] = '/opt/local' if self.options.use_clang: - self.boost_inc_ident = "clang" - self.boost_lib_ident = "clang-darwin28" + self.log.info('Setting up for using Clang') + + self.boost_inc_ident = "clang31" + self.boost_lib_ident = "clang-darwin42" + + #self.CXXFLAGS.append('-std=c++11') + #self.CXXFLAGS.append('-stdlib=libc++') + #self.LDFLAGS.append('-stdlib=libc++') global search_prefixes search_prefixes = [ '/opt/local', '/usr/local', '/sw', '/usr' ] diff --git a/lib/Makefile b/lib/Makefile index 0f740996..ba7f5ffa 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -49,6 +49,7 @@ all: boost-build #icu-build boost-icu-build prepare-boost: perl -i -pe 's/local command = \[ common\.get-invocation-command darwin : g\+\+ : .*/local command = [ common.get-invocation-command darwin : g++ : $(CXX) ] ;/;' $(BOOST_SOURCE)/tools/build/v2/tools/darwin.jam perl -i -pe 's/flags darwin\.compile OPTIONS : -no-cpp-precomp -gdwarf-2 (-fexceptions )?;/flags darwin\.compile OPTIONS : -gdwarf-2 \1;/;' $(BOOST_SOURCE)/tools/build/v2/tools/darwin.jam + perl -i -pe 's/command = \[ common\.get-invocation-command clang-darwin : clang\+\+ $$/command = [ common.get-invocation-command clang-darwin : clang++-mp-3.1/;' $(BOOST_SOURCE)/tools/build/v2/tools/clang-darwin.jam boost-build: prepare-boost (cd $(BOOST_SOURCE) && \ diff --git a/lib/build.sh b/lib/build.sh new file mode 100755 index 00000000..2d18dc58 --- /dev/null +++ b/lib/build.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +# This build script is for OS X Lion users who have compiled openmpi and +# clang-3.1 from MacPorts. I build my own Boost instead of using MacPorts' +# Boost in order to get better debugging support, and to link with libc++. + +export PATH=$PATH:/opt/local/lib/openmpi/bin + +cat > ~/user-config.jam <-std=c++11 ; +EOF + +make CXX=clang++-mp-3.1 LD=clang++-mp-3.1 CC=clang-mp-3.1 OPTJ=-j16 \ + CXXFLAGS="-g -std=c++11 -stdlib=libc++" \ + LDFLAGS="-g -stdlib=libc++" \ + BOOST_TOOLSET=clang DIR_SUFFIX=clang31 \ + BOOST_DEFINES="include=/opt/local/include -sICU_PATH=/opt/local -sICONV_PATH=/opt/local cxxflags=\"-g -std=c++11 -stdlib=libc++\" linkflags=\"-g -stdlib=libc++\"" \ No newline at end of file -- cgit v1.2.3 From 72d10112512278b219220458a13dbc53f5b646f5 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Wed, 25 Apr 2012 03:08:03 -0500 Subject: Build-related changes --- acprep | 48 +++++++++++++++++++++++++++--------------------- lib/Makefile | 3 +-- lib/build.sh | 12 ++++++------ 3 files changed, 34 insertions(+), 29 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index fa61ba98..5915b3d3 100755 --- a/acprep +++ b/acprep @@ -535,9 +535,9 @@ class PrepareBuild(CommandLineApp): op.add_option('', '--gcc48', action='store_true', dest='gcc48', default=False, help='Require the use of gcc 4.8') - op.add_option('', '--cpp0x', action='store_true', - dest='cpp0x', default=False, - help='Use C++0x extensions (requires Clang or gcc 4.6/7/8)') + op.add_option('', '--cpp11', action='store_true', + dest='use_cpp11', default=False, + help='Use C++11 extensions (requires Clang or gcc 4.6/7/8)') op.add_option('', '--output', metavar='DIR', action="callback", callback=self.option_output, help='Build in the specified directory') @@ -1019,14 +1019,21 @@ class PrepareBuild(CommandLineApp): self.log.info('Setting up for using Clang') self.boost_inc_ident = "clang31" - self.boost_lib_ident = "clang-darwin42" - - #self.CXXFLAGS.append('-std=c++11') - #self.CXXFLAGS.append('-stdlib=libc++') - #self.LDFLAGS.append('-stdlib=libc++') - - global search_prefixes - search_prefixes = [ '/opt/local', '/usr/local', '/sw', '/usr' ] + self.boost_lib_ident = "clang-darwin" + + if self.options.use_cpp11: + self.CXXFLAGS.append('-std=c++11') + self.CXXFLAGS.append('-stdlib=libc++') + self.CXXFLAGS.append('-nostdlibinc') + self.CXXFLAGS.append('-isystem /usr/local/include') + self.CXXFLAGS.append('-isystem /usr/local/include/c++/v1') + self.CXXFLAGS.append('-isystem /usr/include') + + self.LDFLAGS.append('-stdlib=libc++') + self.LDFLAGS.append('/usr/local/lib/libc++.dylib') + else: + global search_prefixes + search_prefixes = [ '/opt/local', '/usr/local', '/sw', '/usr' ] self.log.debug('Using Clang ident: %s/%s' % (self.boost_inc_ident, self.boost_lib_ident)) @@ -1077,14 +1084,14 @@ class PrepareBuild(CommandLineApp): elif system == 'Darwin': if self.options.use_clang: - if exists('/opt/local/bin/clang++-mp-3.1'): - self.envvars['CC'] = '/opt/local/bin/clang-mp-3.1' - self.envvars['CXX'] = '/opt/local/bin/clang++-mp-3.1' - self.envvars['LD'] = '/opt/local/bin/clang++-mp-3.1' - elif exists('/usr/local/bin/clang++'): + if exists('/usr/local/bin/clang++'): self.envvars['CC'] = '/usr/local/bin/clang' self.envvars['CXX'] = '/usr/local/bin/clang++' self.envvars['LD'] = '/usr/local/bin/clang++' + elif exists('/opt/local/bin/clang++-mp-3.1'): + self.envvars['CC'] = '/opt/local/bin/clang-mp-3.1' + self.envvars['CXX'] = '/opt/local/bin/clang++-mp-3.1' + self.envvars['LD'] = '/opt/local/bin/clang++-mp-3.1' else: self.envvars['CC'] = 'clang' self.envvars['CXX'] = 'clang++' @@ -1143,9 +1150,6 @@ class PrepareBuild(CommandLineApp): if self.options.no_python: self.configure_args.remove('--enable-python') - if self.options.cpp0x: - self.CXXFLAGS.append('-std=c++0x') - if exists('/Users/johnw/Projects/ledger/plan/TODO'): self.setup_for_johnw() self.setup_system_directories() @@ -1323,7 +1327,8 @@ class PrepareBuild(CommandLineApp): def locate_darwin_libraries(self): if self.current_flavor == 'debug': - if not self.options.use_clang and self.boost_info.configure( + if (not self.options.use_clang or self.options.use_cpp11) and \ + self.boost_info.configure( home_path = '/usr/local/stow/boost_%s-%s' % \ (self.boost_version, self.boost_inc_ident), suffix = '-%s-d-%s' % \ @@ -1337,7 +1342,8 @@ class PrepareBuild(CommandLineApp): else: if self.boost_info.configure(): pass - elif not self.options.use_clang and self.boost_info.configure( + elif (not self.options.use_clang or self.options.use_cpp11) and \ + self.boost_info.configure( home_path = '/usr/local/stow/boost_%s-%s' % \ (self.boost_version, self.boost_inc_ident), suffix = '-%s-%s' % \ diff --git a/lib/Makefile b/lib/Makefile index ba7f5ffa..cb05e44d 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -49,12 +49,11 @@ all: boost-build #icu-build boost-icu-build prepare-boost: perl -i -pe 's/local command = \[ common\.get-invocation-command darwin : g\+\+ : .*/local command = [ common.get-invocation-command darwin : g++ : $(CXX) ] ;/;' $(BOOST_SOURCE)/tools/build/v2/tools/darwin.jam perl -i -pe 's/flags darwin\.compile OPTIONS : -no-cpp-precomp -gdwarf-2 (-fexceptions )?;/flags darwin\.compile OPTIONS : -gdwarf-2 \1;/;' $(BOOST_SOURCE)/tools/build/v2/tools/darwin.jam - perl -i -pe 's/command = \[ common\.get-invocation-command clang-darwin : clang\+\+ $$/command = [ common.get-invocation-command clang-darwin : clang++-mp-3.1/;' $(BOOST_SOURCE)/tools/build/v2/tools/clang-darwin.jam boost-build: prepare-boost (cd $(BOOST_SOURCE) && \ sh bootstrap.sh && \ - ./b2 $(OPTJ) debug --prefix=$(BOOST_STOW) \ + ./b2 $(OPTJ) debug release --prefix=$(BOOST_STOW) \ --build-dir=$(BOOST_BUILD) $(BOOST_FLAGS) install) icu-build: diff --git a/lib/build.sh b/lib/build.sh index 2d18dc58..28408d73 100755 --- a/lib/build.sh +++ b/lib/build.sh @@ -7,11 +7,11 @@ export PATH=$PATH:/opt/local/lib/openmpi/bin cat > ~/user-config.jam <-std=c++11 ; +using clang-darwin : : "/usr/local/bin/clang++" : -std=c++11 /usr/local/include ; EOF -make CXX=clang++-mp-3.1 LD=clang++-mp-3.1 CC=clang-mp-3.1 OPTJ=-j16 \ - CXXFLAGS="-g -std=c++11 -stdlib=libc++" \ - LDFLAGS="-g -stdlib=libc++" \ - BOOST_TOOLSET=clang DIR_SUFFIX=clang31 \ - BOOST_DEFINES="include=/opt/local/include -sICU_PATH=/opt/local -sICONV_PATH=/opt/local cxxflags=\"-g -std=c++11 -stdlib=libc++\" linkflags=\"-g -stdlib=libc++\"" \ No newline at end of file +# jww (2012-04-24): This is still linking against /usr/lib/libc++.1.dylib +# instead of /usr/local/lib/libc++.1.dylib +make CXX=clang++ LD=clang++ CC=clang OPTJ=-j20 \ + BOOST_TOOLSET=clang-darwin DIR_SUFFIX=clang31 \ + BOOST_DEFINES="-sICU_PATH=/usr/local cxxflags=\"-g -std=c++11 -nostdlibinc -I/usr/local/include -I/usr/local/include/c++/v1 -I/opt/local/include -I/usr/include -stdlib=libc++\" linkflags=\"-g -Z -L/usr/local/lib -L/opt/local/lib -L/usr/lib /usr/local/lib/libc++.dylib -stdlib=libc++\"" -- cgit v1.2.3 From 95429c70313855ca1865f8b1cf547fd38e51cbdf Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Thu, 26 Apr 2012 16:38:38 -0500 Subject: Removed unnecessary code from acprep --- acprep | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'acprep') diff --git a/acprep b/acprep index 5915b3d3..baf63f6e 100755 --- a/acprep +++ b/acprep @@ -1745,35 +1745,19 @@ class PrepareBuild(CommandLineApp): self.configure_flavor('opt', reset) - system_hh_gch = join(self.source_dir, 'src', 'system.hh.gch') - if exists(system_hh_gch): - os.remove(system_hh_gch) - self.log.info('=== Building opt ===') self.phase_make(*args) self.configure_flavor('gcov', reset) - system_hh_gch = join(self.source_dir, 'src', 'system.hh.gch') - if exists(system_hh_gch): - os.remove(system_hh_gch) - self.log.info('=== Building gcov ===') self.phase_make(*args) - system_hh_gch = join(self.source_dir, 'src', 'system.hh.gch') - if exists(system_hh_gch): - os.remove(system_hh_gch) - self.log.info('=== Building default ===') self.phase_make(*args) self.configure_flavor('debug', reset) - system_hh_gch = join(self.source_dir, 'src', 'system.hh.gch') - if exists(system_hh_gch): - os.remove(system_hh_gch) - self.log.info('=== Building debug ===') self.phase_make(*args) -- cgit v1.2.3