prep abi tool for nuget release (#635)

* prep abi tool for nuget release

* PR feedback
This commit is contained in:
Scott Jones 2020-03-02 14:22:51 -08:00 коммит произвёл GitHub
Родитель b620d87ad9
Коммит b641e07694
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 149 добавлений и 25 удалений

5
.gitignore поставляемый
Просмотреть файл

@ -338,7 +338,4 @@ ASALocalRun/
# ignore test output
src/test/output/
src/test/python/output/
src/test/python/__pycache__/
# Ignore copied license
src/package/cppwinrt/vsix/LICENSE
src/test/python/__pycache__/

Просмотреть файл

@ -1 +1,2 @@
add_subdirectory(abi)
add_subdirectory(pywinrt)

Просмотреть файл

@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.9)
# The Microsoft.Windows.AbiWinRT NuGet package is only targeted at Visual Studio (on Windows)
if (WIN32 AND ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "x86"))
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/build_tools/nuget.exe" nuget_exe)
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" abiwinrt_nupkg_dir)
file(TO_NATIVE_PATH "${abiwinrt_nupkg_dir}/Microsoft.Windows.AbiWinRT.${XLANG_BUILD_VERSION}.nupkg" abiwinrt_nupkg)
get_target_property(abiwinrt_exe abi "abiwinrt_exe")
file(DOWNLOAD https://dist.nuget.org/win-x86-commandline/latest/nuget.exe ${nuget_exe})
add_custom_command(OUTPUT ${abiwinrt_nupkg}
COMMAND ${nuget_exe} pack ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.AbiWinRT.nuspec -Properties abiwinrt_exe=${abiwinrt_exe}; -Version ${XLANG_BUILD_VERSION} -OutputDirectory ${CMAKE_CURRENT_BINARY_DIR} -NonInteractive -Verbosity Detailed
DEPENDS ${XLANG_BUILD_VERSION_h} ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.AbiWinRT.nuspec
)
add_custom_target(make_abiwinrt_nupkg ALL DEPENDS ${abiwinrt_nupkg} abi)
set_target_properties(make_abiwinrt_nupkg PROPERTIES "abiwinrt_nupkg_dir" ${abiwinrt_nupkg_dir})
endif()

24
src/package/abi/LICENSE Normal file
Просмотреть файл

@ -0,0 +1,24 @@
WinRT ABI Header Generation Tool
Copyright (c) Microsoft Corporation
All rights reserved.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Просмотреть файл

@ -0,0 +1,22 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.5">
<id>Microsoft.Windows.AbiWinRT</id>
<version>1.0.0.0</version>
<title>WinRT ABI Header Build Support</title>
<authors>Microsoft</authors>
<owners>Microsoft</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Provides the abi.exe tool for generating ABI-level C++ headers for accessing the Windows API.</description>
<releaseNotes></releaseNotes>
<tags>native abi winrt nativepackage</tags>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<license type="file">LICENSE</license>
<projectUrl>https://github.com/microsoft/xlang/tree/master/src/tool/abi</projectUrl>
</metadata>
<files>
<file src="LICENSE"/>
<file src="$abiwinrt_exe$" target="bin"/>
<file src="readme.txt"/>
</files>
</package>

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<SignConfigXML>
<job configuration="Release" dest="__OUTPATHROOT__" jobname="AbiWinRT NuGet" approvers="">
<file src="__INPATHROOT__\Microsoft.Windows.AbiWinRT.*.nupkg" signType="CP-401405" dest="__OUTPATHROOT__\Microsoft.Windows.AbiWinRT.*.nupkg" />
</job>
</SignConfigXML>

Просмотреть файл

@ -0,0 +1,9 @@
========================================================================
The Microsoft.Windows.AbiWinRT NuGet package provides the abi.exe tool
for generating ABI-level C++ headers to access Windows Runtime APIs.
========================================================================
========================================================================
For more information, visit:
https://github.com/microsoft/xlang/tree/master/src/tool/abi
========================================================================

Просмотреть файл

@ -13,6 +13,7 @@ target_sources(abi PUBLIC
types.cpp
"${PROJECT_BINARY_DIR}/strings.cpp")
target_include_directories(abi PUBLIC ${XLANG_LIBRARY_PATH} ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR})
target_compile_definitions(abi PUBLIC "ABIWINRT_VERSION_STRING=\"${XLANG_BUILD_VERSION}\"")
GENERATE_STRING_LITERAL_FILES("${PROJECT_SOURCE_DIR}/strings/*.h" "strings" "xlang::strings" abi)
@ -23,3 +24,6 @@ else()
target_link_libraries(abi c++ c++abi c++experimental)
target_link_libraries(abi -lpthread)
endif()
file(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}/abi.exe" abiwinrt_exe)
set_target_properties(abi PROPERTIES "abiwinrt_exe" ${abiwinrt_exe})

Просмотреть файл

@ -21,9 +21,57 @@ auto output_directory(reader const& args)
return out.string();
}
void print_usage()
struct usage_exception {};
static constexpr option options[]
{
puts("Usage...");
{ "input", 0, option::no_max, "<spec>", "Windows metadata to include in generation" },
{ "reference", 0, option::no_max, "<spec>", "Windows metadata to reference from generation" },
{ "output", 0, 1, "<path>", "Location of generated headers" },
{ "include", 0, option::no_max, "<prefix>", "One or more prefixes to include in input" },
{ "exclude", 0, option::no_max, "<prefix>", "One or more prefixes to exclude from input" },
{ "verbose", 0, 0, {}, "Show detailed progress information" },
{ "ns-prefix", 0, 1, "<always|optional|never>", "Sets policy for prefixing type names with 'ABI' namespace (default: never)" },
{ "enum-class", 0, 0, {}, "Use 'MIDL_ENUM', rather than 'enum'" },
{ "lowercase-include-guard", 0, 0, {}, "Generate lowercase include guards for compatibility with Windows SDK headers" },
{ "enable-header-deprecation", 0, 0, {}, "Generate support for [[deprecated(...)]] attribute" },
{ "help", 0, option::no_max, {}, "Show detailed help with examples" },
};
static void print_usage(basic_writer& w)
{
static auto printColumns = [](basic_writer& w, std::string_view const& col1, std::string_view const& col2)
{
w.write_printf(" %-40s%s\n", col1.data(), col2.data());
};
static auto printOption = [](basic_writer& w, option const& opt)
{
if(opt.desc.empty())
{
return;
}
printColumns(w, w.write_temp("-% %", opt.name, opt.arg), opt.desc);
};
auto format = R"(
WinRT ABI Header Generation Tool v%
Copyright (c) Microsoft Corporation. All rights reserved.
abi.exe [options...]
Options:
% ^@<path> Response file containing command line options
Where <spec> is one or more of:
path Path to winmd file or recursively scanned folder
local Local ^%WinDir^%\System32\WinMetadata folder
sdk[+] Current version of Windows SDK [with extensions]
10.0.12345.0[+] Specific version of Windows SDK [with extensions]
)";
w.write(format, ABIWINRT_VERSION_STRING, bind_each(printOption, options));
}
int main(int const argc, char** argv)
@ -35,28 +83,13 @@ int main(int const argc, char** argv)
{
auto const start = high_resolution_clock::now();
static constexpr cmd::option options[]
{
// name, min, max
{ "input", 1 },
{ "reference", 0 },
{ "output", 0, 1 },
{ "include", 0 },
{ "exclude", 0 },
{ "verbose", 0, 0 },
{ "ns-prefix", 0, 1 },
{ "enum-class", 0, 0 },
{ "lowercase-include-guard", 0, 0 },
{ "enable-header-deprecation", 0, 0 }
};
reader args{ argc, argv, options };
if (!args)
if (!args || args.exists("help"))
{
print_usage();
return 1;
throw usage_exception{};
}
abi_configuration config;
config.verbose = args.exists("verbose");
config.output_directory = output_directory(args);
@ -231,6 +264,11 @@ int main(int const argc, char** argv)
w.write("time: %ms\n", static_cast<std::int64_t>(duration_cast<milliseconds>((high_resolution_clock::now() - start)).count()));
}
}
catch (usage_exception const&)
{
print_usage(w);
exitCode = 1;
}
catch (std::exception const& e)
{
exitCode = 1;