From 9fa5f73d00905568e8979d0c93ec4a8f645c81d5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 9 Aug 2016 11:31:53 +0200 Subject: Implement support for C compilation We now have two new modules: cc (c-common) and c. --- build2/cc/windows-manifest.cxx | 136 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 build2/cc/windows-manifest.cxx (limited to 'build2/cc/windows-manifest.cxx') diff --git a/build2/cc/windows-manifest.cxx b/build2/cc/windows-manifest.cxx new file mode 100644 index 0000000..0666ef5 --- /dev/null +++ b/build2/cc/windows-manifest.cxx @@ -0,0 +1,136 @@ +// file : build2/cc/windows-manifest.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2016 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include +#include +#include +#include +#include +#include + +#include + +using namespace std; +using namespace butl; + +namespace build2 +{ + namespace cc + { + // Translate the compiler target CPU value to the processorArchitecture + // attribute value. + // + const char* + windows_manifest_arch (const string& tcpu) + { + const char* pa (tcpu == "i386" || tcpu == "i686" ? "x86" : + tcpu == "x86_64" ? "amd64" : + nullptr); + + if (pa == nullptr) + fail << "unable to translate CPU " << tcpu << " to manifest " + << "processor architecture"; + + return pa; + } + + // Generate a Windows manifest and if necessary create/update the manifest + // file corresponding to the exe{} target. Return the manifest file path. + // + path link:: + windows_manifest (file& t, bool rpath_assembly) const + { + tracer trace (x, "windows_manifest"); + + scope& rs (t.root_scope ()); + + const char* pa (windows_manifest_arch (cast (rs[x_target_cpu]))); + + string m; + + m += "\n"; + m += "= 3) + text << "cat >" << mf; + + try + { + ofdstream ofs (mf); + ofs << m; + ofs.close (); + } + catch (const ofdstream::failure& e) + { + fail << "unable to write to " << m << ": " << e.what (); + } + + return mf; + } + } +} -- cgit v1.1