mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-06 09:07:47 +08:00
[llvm] install tools in tools/llvm (#14399)
* [llvm] install tools in tools/llvm * remove the giant commented out block of code * update port-version * hopefully fix the port? There are still some issues, namely that the python scripts and DLLs that are copied into `tools/llvm` are not considered to be "installed by llvm", and thus are not removed when llvm is removed * format! * apparently REGEX REPLACE fails if a thing doesn't match * fix LLVM_REMOVE_EXTENSION_REGEX on windows * actually read the cmake regex docs... * fix the name of the variable * turns out CMAKE_MATCH_1 is the one I want * need to update VERSION for new policy * stop removing debug/bin * fix faulty merge
This commit is contained in:
parent
05170a1f60
commit
d9b179fd46
14
ports/llvm/0005-fix-tools-path.patch
Normal file
14
ports/llvm/0005-fix-tools-path.patch
Normal file
@ -0,0 +1,14 @@
|
||||
diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp
|
||||
index 53ba24efc00..0badcafe000 100644
|
||||
--- a/llvm/tools/llvm-config/llvm-config.cpp
|
||||
+++ b/llvm/tools/llvm-config/llvm-config.cpp
|
||||
@@ -304,8 +304,8 @@ int main(int argc, char **argv) {
|
||||
// Create an absolute path, and pop up one directory (we expect to be inside a
|
||||
// bin dir).
|
||||
sys::fs::make_absolute(CurrentPath);
|
||||
CurrentExecPrefix =
|
||||
- sys::path::parent_path(sys::path::parent_path(CurrentPath)).str();
|
||||
+ sys::path::parent_path(sys::path::parent_path(sys::path::parent_path(CurrentPath))).str();
|
||||
|
||||
// Check to see if we are inside a development tree by comparing to possible
|
||||
// locations (prefix style or CMake style).
|
@ -1,6 +1,6 @@
|
||||
Source: llvm
|
||||
Version: 10.0.0
|
||||
Port-Version: 6
|
||||
Port-Version: 7
|
||||
Homepage: https://llvm.org/
|
||||
Description: The LLVM Compiler Infrastructure
|
||||
Supports: !uwp
|
||||
|
@ -13,6 +13,7 @@ vcpkg_from_github(
|
||||
0002-fix-install-paths.patch
|
||||
0003-fix-vs2019-v16.6.patch
|
||||
0004-fix-dr-1734.patch
|
||||
0005-fix-tools-path.patch
|
||||
)
|
||||
|
||||
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
|
||||
@ -145,57 +146,30 @@ vcpkg_install_cmake()
|
||||
vcpkg_fixup_cmake_targets(CONFIG_PATH share/${PORT})
|
||||
if("clang" IN_LIST FEATURES)
|
||||
vcpkg_fixup_cmake_targets(CONFIG_PATH share/clang TARGET_PATH share/clang)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
|
||||
file(GLOB_RECURSE _llvm_release_targets
|
||||
"${CURRENT_PACKAGES_DIR}/share/llvm/*-release.cmake"
|
||||
)
|
||||
set(_clang_release_targets)
|
||||
if("clang" IN_LIST FEATURES)
|
||||
file(GLOB_RECURSE _clang_release_targets
|
||||
"${CURRENT_PACKAGES_DIR}/share/clang/*-release.cmake"
|
||||
)
|
||||
if(VCPKG_TARGET_IS_WINDOWS)
|
||||
set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)\.exe$]])
|
||||
else()
|
||||
set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)$]])
|
||||
endif()
|
||||
foreach(_target IN LISTS _llvm_release_targets _clang_release_targets)
|
||||
file(READ ${_target} _contents)
|
||||
# LLVM tools should be located in the bin folder because llvm-config expects to be inside a bin dir.
|
||||
# Rename `/tools/${PORT}` to `/bin` back because there is no way to avoid this in vcpkg_fixup_cmake_targets.
|
||||
string(REPLACE "{_IMPORT_PREFIX}/tools/${PORT}" "{_IMPORT_PREFIX}/bin" _contents "${_contents}")
|
||||
file(WRITE ${_target} "${_contents}")
|
||||
|
||||
file(GLOB LLVM_TOOL_FILES "${CURRENT_PACKAGES_DIR}/bin/*")
|
||||
set(LLVM_TOOLS)
|
||||
foreach(tool_file IN LISTS LLVM_TOOL_FILES)
|
||||
get_filename_component(tool_file "${tool_file}" NAME)
|
||||
if(tool_file MATCHES "${LLVM_EXECUTABLE_REGEX}")
|
||||
list(APPEND LLVM_TOOLS "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
vcpkg_copy_tools(
|
||||
TOOL_NAMES ${LLVM_TOOLS}
|
||||
AUTO_CLEAN)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
|
||||
file(GLOB_RECURSE _llvm_debug_targets
|
||||
"${CURRENT_PACKAGES_DIR}/share/llvm/*-debug.cmake"
|
||||
)
|
||||
set(_clang_debug_targets)
|
||||
if("clang" IN_LIST FEATURES)
|
||||
file(GLOB_RECURSE _clang_debug_targets
|
||||
"${CURRENT_PACKAGES_DIR}/share/clang/*-debug.cmake"
|
||||
)
|
||||
endif()
|
||||
foreach(_target IN LISTS _llvm_debug_targets _clang_debug_targets)
|
||||
file(READ ${_target} _contents)
|
||||
# LLVM tools should be located in the bin folder because llvm-config expects to be inside a bin dir.
|
||||
# Rename `/tools/${PORT}` to `/bin` back because there is no way to avoid this in vcpkg_fixup_cmake_targets.
|
||||
string(REPLACE "{_IMPORT_PREFIX}/tools/${PORT}" "{_IMPORT_PREFIX}/bin" _contents "${_contents}")
|
||||
# Debug shared libraries should have `d` suffix and should be installed in the `/bin` directory.
|
||||
# Rename `/debug/bin/` to `/bin`
|
||||
string(REPLACE "{_IMPORT_PREFIX}/debug/bin/" "{_IMPORT_PREFIX}/bin/" _contents "${_contents}")
|
||||
file(WRITE ${_target} "${_contents}")
|
||||
endforeach()
|
||||
|
||||
# Install debug shared libraries in the `/bin` directory
|
||||
file(GLOB _debug_shared_libs ${CURRENT_PACKAGES_DIR}/debug/bin/*${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
file(INSTALL ${_debug_shared_libs} DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
|
||||
|
||||
file(REMOVE_RECURSE
|
||||
${CURRENT_PACKAGES_DIR}/debug/bin
|
||||
${CURRENT_PACKAGES_DIR}/debug/include
|
||||
${CURRENT_PACKAGES_DIR}/debug/share
|
||||
)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
|
||||
endif()
|
||||
|
||||
# Handle copyright
|
||||
@ -204,5 +178,8 @@ if("clang" IN_LIST FEATURES)
|
||||
file(INSTALL ${SOURCE_PATH}/clang/LICENSE.TXT DESTINATION ${CURRENT_PACKAGES_DIR}/share/clang RENAME copyright)
|
||||
endif()
|
||||
|
||||
# Don't fail if the bin folder exists.
|
||||
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
|
||||
# LLVM still generates a few DLLs in the static build:
|
||||
# * libclang.dll
|
||||
# * LTO.dll
|
||||
# * Remarks.dll
|
||||
set(VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY enabled)
|
||||
|
@ -8,6 +8,9 @@ endif()
|
||||
if (DEFINED VCPKG_POLICY_DLLS_WITHOUT_EXPORTS)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyDLLsWithoutExports: ${VCPKG_POLICY_DLLS_WITHOUT_EXPORTS}\n")
|
||||
endif()
|
||||
if (DEFINED VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyDLLsInStaticLibrary: ${VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY}\n")
|
||||
endif()
|
||||
if (DEFINED VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES)
|
||||
file(APPEND ${BUILD_INFO_FILE_PATH} "PolicyMismatchedNumberOfBinaries: ${VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES}\n")
|
||||
endif()
|
||||
|
9
test.cmake
Normal file
9
test.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)\.exe$]])
|
||||
foreach(el "bugpoint.exe" "ld.lld.exe" "asdf.dll" "asdf")
|
||||
message(STATUS "Matching ${el}")
|
||||
if(el MATCHES "${LLVM_EXECUTABLE_REGEX}")
|
||||
message(STATUS "Matching ${el} - match (${CMAKE_MATCH_1}).")
|
||||
else()
|
||||
message(STATUS "Matching ${el} - no match.")
|
||||
endif()
|
||||
endforeach()
|
@ -1 +1 @@
|
||||
"2020.11.09"
|
||||
"2020.11.12"
|
||||
|
@ -243,6 +243,7 @@ namespace vcpkg::Build
|
||||
EMPTY_PACKAGE,
|
||||
DLLS_WITHOUT_LIBS,
|
||||
DLLS_WITHOUT_EXPORTS,
|
||||
DLLS_IN_STATIC_LIBRARY,
|
||||
MISMATCHED_NUMBER_OF_BINARIES,
|
||||
ONLY_RELEASE_CRT,
|
||||
EMPTY_INCLUDE_FOLDER,
|
||||
@ -254,7 +255,7 @@ namespace vcpkg::Build
|
||||
COUNT,
|
||||
};
|
||||
|
||||
// could be constexpr, but we want to generate this and that's not constexpr
|
||||
// could be constexpr, but we want to generate this and that's not constexpr in C++14
|
||||
extern const std::array<BuildPolicy, size_t(BuildPolicy::COUNT)> ALL_POLICIES;
|
||||
|
||||
const std::string& to_string(BuildPolicy policy);
|
||||
|
@ -203,6 +203,7 @@ namespace vcpkg::Build
|
||||
static const std::string NAME_EMPTY_PACKAGE = "PolicyEmptyPackage";
|
||||
static const std::string NAME_DLLS_WITHOUT_LIBS = "PolicyDLLsWithoutLIBs";
|
||||
static const std::string NAME_DLLS_WITHOUT_EXPORTS = "PolicyDLLsWithoutExports";
|
||||
static const std::string NAME_DLLS_IN_STATIC_LIBRARY = "PolicyDLLsInStaticLibrary";
|
||||
static const std::string NAME_MISMATCHED_NUMBER_OF_BINARIES = "PolicyMismatchedNumberOfBinaries";
|
||||
static const std::string NAME_ONLY_RELEASE_CRT = "PolicyOnlyReleaseCRT";
|
||||
static const std::string NAME_EMPTY_INCLUDE_FOLDER = "PolicyEmptyIncludeFolder";
|
||||
@ -231,6 +232,7 @@ namespace vcpkg::Build
|
||||
case BuildPolicy::EMPTY_PACKAGE: return NAME_EMPTY_PACKAGE;
|
||||
case BuildPolicy::DLLS_WITHOUT_LIBS: return NAME_DLLS_WITHOUT_LIBS;
|
||||
case BuildPolicy::DLLS_WITHOUT_EXPORTS: return NAME_DLLS_WITHOUT_EXPORTS;
|
||||
case BuildPolicy::DLLS_IN_STATIC_LIBRARY: return NAME_DLLS_IN_STATIC_LIBRARY;
|
||||
case BuildPolicy::MISMATCHED_NUMBER_OF_BINARIES: return NAME_MISMATCHED_NUMBER_OF_BINARIES;
|
||||
case BuildPolicy::ONLY_RELEASE_CRT: return NAME_ONLY_RELEASE_CRT;
|
||||
case BuildPolicy::EMPTY_INCLUDE_FOLDER: return NAME_EMPTY_INCLUDE_FOLDER;
|
||||
@ -249,6 +251,7 @@ namespace vcpkg::Build
|
||||
case BuildPolicy::EMPTY_PACKAGE: return "VCPKG_POLICY_EMPTY_PACKAGE";
|
||||
case BuildPolicy::DLLS_WITHOUT_LIBS: return "VCPKG_POLICY_DLLS_WITHOUT_LIBS";
|
||||
case BuildPolicy::DLLS_WITHOUT_EXPORTS: return "VCPKG_POLICY_DLLS_WITHOUT_EXPORTS";
|
||||
case BuildPolicy::DLLS_IN_STATIC_LIBRARY: return "VCPKG_POLICY_DLLS_IN_STATIC_LIBRARY";
|
||||
case BuildPolicy::MISMATCHED_NUMBER_OF_BINARIES: return "VCPKG_POLICY_MISMATCHED_NUMBER_OF_BINARIES";
|
||||
case BuildPolicy::ONLY_RELEASE_CRT: return "VCPKG_POLICY_ONLY_RELEASE_CRT";
|
||||
case BuildPolicy::EMPTY_INCLUDE_FOLDER: return "VCPKG_POLICY_EMPTY_INCLUDE_FOLDER";
|
||||
|
@ -561,9 +561,9 @@ namespace vcpkg::PostBuildLint
|
||||
return LintStatus::SUCCESS;
|
||||
}
|
||||
|
||||
static LintStatus check_no_dlls_present(const std::vector<fs::path>& dlls)
|
||||
static LintStatus check_no_dlls_present(const Build::BuildPolicies& policies, const std::vector<fs::path>& dlls)
|
||||
{
|
||||
if (dlls.empty())
|
||||
if (dlls.empty() || policies.is_enabled(BuildPolicy::DLLS_IN_STATIC_LIBRARY))
|
||||
{
|
||||
return LintStatus::SUCCESS;
|
||||
}
|
||||
@ -628,9 +628,12 @@ namespace vcpkg::PostBuildLint
|
||||
return LintStatus::SUCCESS;
|
||||
}
|
||||
|
||||
static LintStatus check_bin_folders_are_not_present_in_static_build(const Files::Filesystem& fs,
|
||||
static LintStatus check_bin_folders_are_not_present_in_static_build(const Build::BuildPolicies& policies,
|
||||
const Files::Filesystem& fs,
|
||||
const fs::path& package_dir)
|
||||
{
|
||||
if (policies.is_enabled(BuildPolicy::DLLS_IN_STATIC_LIBRARY)) return LintStatus::SUCCESS;
|
||||
|
||||
const fs::path bin = package_dir / "bin";
|
||||
const fs::path debug_bin = package_dir / "debug" / "bin";
|
||||
|
||||
@ -922,9 +925,9 @@ namespace vcpkg::PostBuildLint
|
||||
{
|
||||
auto dlls = release_dlls;
|
||||
dlls.insert(dlls.end(), debug_dlls.begin(), debug_dlls.end());
|
||||
error_count += check_no_dlls_present(dlls);
|
||||
error_count += check_no_dlls_present(build_info.policies, dlls);
|
||||
|
||||
error_count += check_bin_folders_are_not_present_in_static_build(fs, package_dir);
|
||||
error_count += check_bin_folders_are_not_present_in_static_build(build_info.policies, fs, package_dir);
|
||||
|
||||
if (!toolset.dumpbin.empty() && !build_info.policies.is_enabled(BuildPolicy::SKIP_DUMPBIN_CHECKS))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user