// file : build2/cc/windows-manifest.cxx -*- C++ -*- // copyright : Copyright (c) 2014-2017 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 // as well as whether it was changed. // pair link:: windows_manifest (const file& t, bool rpath_assembly) const { tracer trace (x, "link::windows_manifest"); const 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 io_error& e) { fail << "unable to write to " << m << ": " << e; } return make_pair (move (mf), true); } } }