From a94dcda7f00b10cb22b5f2138b1c29bcfbe7de37 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 24 Mar 2015 08:53:06 +0200 Subject: Make meta-operations control build loop; add disfigure skeleton --- build/file.cxx | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 build/file.cxx (limited to 'build/file.cxx') diff --git a/build/file.cxx b/build/file.cxx new file mode 100644 index 0000000..7bb8bb6 --- /dev/null +++ b/build/file.cxx @@ -0,0 +1,68 @@ +// file : build/file.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include + +#include + +#include +#include +#include +#include + +using namespace std; + +namespace build +{ + void + source (const path& bf, scope& root, scope& base) + { + tracer trace ("source"); + + ifstream ifs (bf.string ()); + if (!ifs.is_open ()) + fail << "unable to open " << bf; + + level4 ([&]{trace << "sourcing " << bf;}); + + ifs.exceptions (ifstream::failbit | ifstream::badbit); + parser p; + + try + { + p.parse_buildfile (ifs, bf, root, base); + } + catch (const std::ios_base::failure&) + { + fail << "failed to read from " << bf; + } + } + + void + source_once (const path& bf, scope& root, scope& base, scope& once) + { + tracer trace ("source_once"); + + if (!once.buildfiles.insert (bf).second) + { + level4 ([&]{trace << "skipping already sourced " << bf;}); + return; + } + + source (bf, root, base); + } + + void + root_pre (scope& root) + { + tracer trace ("root_pre"); + + path bf (root.src_path () / path ("build/root.build")); + + if (!file_exists (bf)) + return; + + source_once (bf, root, root); + } +} -- cgit v1.1