Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:45

0001 //===-- WindowsManifestMerger.h ---------------------------------*- C++-*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===---------------------------------------------------------------------===//
0008 //
0009 // This file provides a utility for merging Microsoft .manifest files.  These
0010 // files are xml documents which contain meta-information about applications,
0011 // such as whether or not admin access is required, system compatibility,
0012 // versions, etc.  Part of the linking process of an executable may require
0013 // merging several of these .manifest files using a tree-merge following
0014 // specific rules.  Unfortunately, these rules are not documented well
0015 // anywhere.  However, a careful investigation of the behavior of the original
0016 // Microsoft Manifest Tool (mt.exe) revealed the rules of this merge.  As the
0017 // saying goes, code is the best documentation, so please look below if you are
0018 // interested in the exact merging requirements.
0019 //
0020 // Ref:
0021 // https://msdn.microsoft.com/en-us/library/windows/desktop/aa374191(v=vs.85).aspx
0022 //
0023 //===---------------------------------------------------------------------===//
0024 
0025 #ifndef LLVM_WINDOWSMANIFEST_WINDOWSMANIFESTMERGER_H
0026 #define LLVM_WINDOWSMANIFEST_WINDOWSMANIFESTMERGER_H
0027 
0028 #include "llvm/Support/Error.h"
0029 
0030 namespace llvm {
0031 
0032 class MemoryBuffer;
0033 class MemoryBufferRef;
0034 
0035 namespace windows_manifest {
0036 
0037 bool isAvailable();
0038 
0039 class WindowsManifestError : public ErrorInfo<WindowsManifestError, ECError> {
0040 public:
0041   static char ID;
0042   WindowsManifestError(const Twine &Msg);
0043   void log(raw_ostream &OS) const override;
0044 
0045 private:
0046   std::string Msg;
0047 };
0048 
0049 class WindowsManifestMerger {
0050 public:
0051   WindowsManifestMerger();
0052   ~WindowsManifestMerger();
0053   Error merge(MemoryBufferRef Manifest);
0054 
0055   // Returns vector containing merged xml manifest, or uninitialized vector for
0056   // empty manifest.
0057   std::unique_ptr<MemoryBuffer> getMergedManifest();
0058 
0059 private:
0060   class WindowsManifestMergerImpl;
0061   std::unique_ptr<WindowsManifestMergerImpl> Impl;
0062 };
0063 
0064 } // namespace windows_manifest
0065 } // namespace llvm
0066 #endif