Index: llvm/include/llvm/Support/WindowsManifestMerger.h =================================================================== --- /dev/null +++ llvm/include/llvm/Support/WindowsManifestMerger.h @@ -1,80 +0,0 @@ -//===-- WindowsManifestMerger.h ---------------------------------*- C++-*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===---------------------------------------------------------------------===// -// -// This file provides a utility for merging Microsoft .manifest files. These -// files are xml documents which contain meta-information about applications, -// such as whether or not admin access is required, system compatibility, -// versions, etc. Part of the linking process of an executable may require -// merging several of these .manifest files using a tree-merge following -// specific rules. Unfortunately, these rules are not documented well -// anywhere. However, a careful investigation of the behavior of the original -// Microsoft Manifest Tool (mt.exe) revealed the rules of this merge. As the -// saying goes, code is the best documentation, so please look below if you are -// interested in the exact merging requirements. -// -// Ref: -// https://msdn.microsoft.com/en-us/library/windows/desktop/aa374191(v=vs.85).aspx -// -//===---------------------------------------------------------------------===// - -#ifndef LLVM_INCLUDE_LLVM_SUPPORT_WINDOWS_MANIFEST_MERGER_H -#define LLVM_INCLUDE_LLVM_SUPPORT_WINDOWS_MANIFEST_MERGER_H - -#include "llvm/Config/config.h" -#include "llvm/Support/Error.h" - -#if LLVM_LIBXML2_ENABLED -#include -#endif - -namespace llvm { - -class MemoryBuffer; - -#if LLVM_LIBXML2_ENABLED -typedef xmlDocPtr XMLDocumentImpl; -typedef xmlNodePtr XMLNodeImpl; -#else -typedef void *XMLDocumentImpl; -typedef void *XMLNodeImpl; -#endif - -class WindowsManifestError : public ErrorInfo { -public: - static char ID; - WindowsManifestError(const Twine &Msg); - void log(raw_ostream &OS) const override; - -private: - std::string Msg; -}; - -class WindowsManifestMerger { -public: - ~WindowsManifestMerger(); - - Error merge(const MemoryBuffer &Manifest); - - // Returns vector containing merged xml manifest, or uninitialized vector for - // empty manifest. - std::unique_ptr getMergedManifest(); - -private: - static void errorCallback(void *Ctx, const char *Format, ...); - Error getParseError(); - -#if LLVM_LIBXML2_ENABLED - XMLDocumentImpl CombinedDoc = nullptr; - std::vector MergedDocs; -#endif - bool ParseErrorOccurred = false; -}; - -} // namespace llvm -#endif Index: llvm/include/llvm/module.modulemap =================================================================== --- llvm/include/llvm/module.modulemap +++ llvm/include/llvm/module.modulemap @@ -306,3 +306,9 @@ header "llvm/Support/DataTypes.h" export * } + +module LLVM_WindowsManifest { + requires cplusplus + umbrella "WindowsManifest" + module * { export * } +} Index: llvm/lib/CMakeLists.txt =================================================================== --- llvm/lib/CMakeLists.txt +++ llvm/lib/CMakeLists.txt @@ -25,3 +25,4 @@ add_subdirectory(ToolDrivers) add_subdirectory(XRay) add_subdirectory(Testing) +add_subdirectory(WindowsManifest) Index: llvm/lib/LLVMBuild.txt =================================================================== --- llvm/lib/LLVMBuild.txt +++ llvm/lib/LLVMBuild.txt @@ -42,6 +42,7 @@ Testing ToolDrivers Transforms + WindowsManifest [component_0] type = Group Index: llvm/lib/Support/CMakeLists.txt =================================================================== --- llvm/lib/Support/CMakeLists.txt +++ llvm/lib/Support/CMakeLists.txt @@ -27,9 +27,6 @@ if( UNIX AND NOT (BEOS OR HAIKU) ) set(system_libs ${system_libs} m) endif() - if( LLVM_LIBXML2_ENABLED ) - set(system_libs ${system_libs} ${LIBXML2_LIBS}) - endif() endif( MSVC OR MINGW ) add_llvm_library(LLVMSupport @@ -113,7 +110,6 @@ Triple.cpp Twine.cpp Unicode.cpp - WindowsManifestMerger.cpp YAMLParser.cpp YAMLTraits.cpp raw_os_ostream.cpp Index: llvm/lib/WindowsManifest/CMakeLists.txt =================================================================== --- /dev/null +++ llvm/lib/WindowsManifest/CMakeLists.txt @@ -0,0 +1,18 @@ +set(system_libs) +if( CMAKE_HOST_UNIX ) + if( LLVM_LIBXML2_ENABLED ) + set(system_libs ${system_libs} ${LIBXML2_LIBS}) + endif() +endif() + +add_llvm_library(LLVMWindowsManifest + WindowsManifestMerger.cpp + + ADDITIONAL_HEADER_DIRS + ${LLVM_MAIN_INCLUDE_DIR}/llvm/WindowsManifest + ${Backtrace_INCLUDE_DIRS} + + LINK_LIBS ${system_libs} + ) + +set_property(TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS "${system_libs}") Index: llvm/lib/WindowsManifest/LLVMBuild.txt =================================================================== --- llvm/lib/WindowsManifest/LLVMBuild.txt +++ llvm/lib/WindowsManifest/LLVMBuild.txt @@ -1,22 +1,22 @@ -;===- ./tools/llvm-mt/LLVMBuild.txt ---------------------------*- Conf -*--===; -; -; The LLVM Compiler Infrastructure -; -; This file is distributed under the University of Illinois Open Source -; License. See LICENSE.TXT for details. -; -;===------------------------------------------------------------------------===; -; -; This is an LLVMBuild description file for the components in this subdirectory. -; -; For more information on the LLVMBuild system, please see: -; -; http://llvm.org/docs/LLVMBuild.html -; -;===------------------------------------------------------------------------===; - -[component_0] -type = Tool -name = llvm-mt -parent = Tools -required_libraries = Option Support +;===- ./lib/WindowsManifest/LLVMBuild.txt ----------------------*- Conf -*--===; +; +; The LLVM Compiler Infrastructure +; +; This file is distributed under the University of Illinois Open Source +; License. See LICENSE.TXT for details. +; +;===------------------------------------------------------------------------===; +; +; This is an LLVMBuild description file for the components in this subdirectory. +; +; For more information on the LLVMBuild system, please see: +; +; http://llvm.org/docs/LLVMBuild.html +; +;===------------------------------------------------------------------------===; + +[component_0] +type = Library +name = WindowsManifest +parent = Libraries +required_libraries = Support Index: llvm/lib/WindowsManifest/WindowsManifestMerger.cpp =================================================================== --- llvm/lib/WindowsManifest/WindowsManifestMerger.cpp +++ llvm/lib/WindowsManifest/WindowsManifestMerger.cpp @@ -11,7 +11,7 @@ // //===---------------------------------------------------------------------===// -#include "llvm/Support/WindowsManifestMerger.h" +#include "llvm/WindowsManifest/WindowsManifestMerger.h" #include "llvm/Support/MemoryBuffer.h" #include Index: llvm/tools/llvm-mt/CMakeLists.txt =================================================================== --- llvm/tools/llvm-mt/CMakeLists.txt +++ llvm/tools/llvm-mt/CMakeLists.txt @@ -1,6 +1,7 @@ set(LLVM_LINK_COMPONENTS Option Support + WindowsManifest ) set(LLVM_TARGET_DEFINITIONS Opts.td) Index: llvm/tools/llvm-mt/LLVMBuild.txt =================================================================== --- llvm/tools/llvm-mt/LLVMBuild.txt +++ llvm/tools/llvm-mt/LLVMBuild.txt @@ -19,4 +19,4 @@ type = Tool name = llvm-mt parent = Tools -required_libraries = Option Support +required_libraries = Option Support WindowsManifest Index: llvm/tools/llvm-mt/llvm-mt.cpp =================================================================== --- llvm/tools/llvm-mt/llvm-mt.cpp +++ llvm/tools/llvm-mt/llvm-mt.cpp @@ -22,8 +22,8 @@ #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Process.h" #include "llvm/Support/Signals.h" -#include "llvm/Support/WindowsManifestMerger.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/WindowsManifest/WindowsManifestMerger.h" #include