Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions src/package/pywinrt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
cmake_minimum_required(VERSION 3.9)

# The Microsoft.Windows.CppWinRT 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}" pywinrt_nupkg_dir)
file(TO_NATIVE_PATH "${pywinrt_nupkg_dir}/Microsoft.Windows.PyWinRT.${XLANG_BUILD_VERSION}.nupkg" pywinrt_nupkg)

get_target_property(pywinrt_exe pywinrt "pywinrt_exe")

file(DOWNLOAD https://dist.nuget.org/win-x86-commandline/latest/nuget.exe ${nuget_exe})

add_custom_command(OUTPUT ${pywinrt_nupkg}
COMMAND ${nuget_exe} pack ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.PyWinRT.nuspec -Properties pywinrt_exe=${pywinrt_exe}; -Version ${XLANG_BUILD_VERSION} -OutputDirectory ${CMAKE_CURRENT_BINARY_DIR} -NonInteractive -Verbosity Detailed
DEPENDS ${XLANG_BUILD_VERSION_h} ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.PyWinRT.nuspec
)

add_custom_target(make_pywinrt_nupkg ALL DEPENDS ${pywinrt_nupkg} pywinrt)

set_target_properties(make_pywinrt_nupkg PROPERTIES "pywinrt_nupkg_dir" ${pywinrt_nupkg_dir})

endif()
add_subdirectory(tool)
32 changes: 32 additions & 0 deletions src/package/pywinrt/projection/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.12)

if(NOT DEFINED PACKAGE_ROOT_PATH)
message(FATAL_ERROR "PACKAGE_ROOT_PATH not defined")
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_compile_options(/await /bigobj /GL /GR- /permissive-)

project(_winrt)

if ("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "x64")
set(PYTHON_ROOT "${PACKAGE_ROOT_PATH}/tools/python")
elseif("$ENV{VSCMD_ARG_TGT_ARCH}" STREQUAL "x86")
set(PYTHON_ROOT "${PACKAGE_ROOT_PATH}/tools/pythonx86")
endif()

link_directories("${PYTHON_ROOT}/tools/libs")

file(GLOB sources "${PACKAGE_ROOT_PATH}/pywinrt/winrt/src/*.cpp")
add_library(_winrt MODULE ${sources})
set_target_properties(_winrt PROPERTIES SUFFIX ".pyd")
target_include_directories(_winrt PUBLIC "${PACKAGE_ROOT_PATH}/cppwinrt" "${PYTHON_ROOT}/tools/include")
target_link_libraries(_winrt PRIVATE onecore)

string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(APPEND CMAKE_MODULE_LINKER_FLAGS " /LTCG")

if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "19.20.27508.0")
string(APPEND CMAKE_CXX_FLAGS " /d2FH4")
endif()
10 changes: 10 additions & 0 deletions src/package/pywinrt/projection/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

$buildType = "Release"
$repoRootPath = (get-item $PSScriptRoot).parent.Parent.parent.Parent.FullName
$packageRootPath = "$repoRootPath/_build/Windows/packages".Replace('\', '/')
$sourcePath = $PSScriptRoot.Replace('\', '/')
$buildPath = "$packageRootPath\$env:VSCMD_ARG_TGT_ARCH-$buildType".Replace('\', '/')

cmake $sourcePath "-B$buildPath" -GNinja -DCMAKE_BUILD_TYPE=$buildType -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl "-DPACKAGE_ROOT_PATH=$packageRootPath"
cmake $sourcePath "-B$buildPath"
ninja -C "$buildPath" -v
41 changes: 41 additions & 0 deletions src/package/pywinrt/projection/configure.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
$windows_sdk = '10.0.17763.0'
$repoRootPath = (get-item $PSScriptRoot).parent.Parent.parent.Parent.FullName
$buildPath = "$repoRootPath/_build/Windows/packages"
$toolsPath = "$buildPath\tools"

$pywinrt_exe = Get-ChildItem $repoRootPath\_build\Windows\*\*\tool\python\pywinrt.exe |
Sort-Object -Descending | Select-Object -first 1

if (-not $pywinrt_exe) {
Write-Error "pywinrt not avaliable"
exit
}

mkdir $buildPath\tools -ErrorAction SilentlyContinue | Out-Null

$nuget_url = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$nuget_exe = join-path $toolsPath nuget.exe

if (-not(test-path $nuget_exe)) {
Invoke-WebRequest $nuget_url -OutFile $nuget_exe
}

& $nuget_exe install Microsoft.Windows.CppWinRT -ExcludeVersion -OutputDirectory $buildPath\tools
& $nuget_exe install python -ExcludeVersion -OutputDirectory $buildPath\tools
& $nuget_exe install pythonx86 -ExcludeVersion -OutputDirectory $buildPath\tools

$cppwinrt_exe = resolve-path $buildPath\tools\Microsoft.Windows.CppWinRT\bin\cppwinrt.exe
$CPPWINRT_PATH = join-path $buildPath cppwinrt
& $cppwinrt_exe ("-in", $windows_sdk, "-out", $CPPWINRT_PATH, "-verbose")

$pywinrt_path = join-path $buildPath pywinrt

$include = @("Windows.")
# $include = "Windows.Data.Json", "Windows.Devices.Geolocation", "Windows.Foundation", "Windows.Graphics.DirectX"
$include_param = $include | ForEach-Object{ "-include", "$_"}
$exclude = "Windows.UI.Comp", "Windows.UI.Xaml"
$exclude_param = $exclude | ForEach-Object{ "-exclude", "$_"}

$all_param = ("-in", $windows_sdk, "-out", ${pywinrt_path}, "-verbose") + $include_param + $exclude_param
& $pywinrt_exe $all_param

23 changes: 23 additions & 0 deletions src/package/pywinrt/tool/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 3.9)

# The Microsoft.Windows.CppWinRT 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}" pywinrt_nupkg_dir)
file(TO_NATIVE_PATH "${pywinrt_nupkg_dir}/Microsoft.Windows.PyWinRT.${XLANG_BUILD_VERSION}.nupkg" pywinrt_nupkg)

get_target_property(pywinrt_exe pywinrt "pywinrt_exe")

file(DOWNLOAD https://dist.nuget.org/win-x86-commandline/latest/nuget.exe ${nuget_exe})

add_custom_command(OUTPUT ${pywinrt_nupkg}
COMMAND ${nuget_exe} pack ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.PyWinRT.nuspec -Properties pywinrt_exe=${pywinrt_exe}; -Version ${XLANG_BUILD_VERSION} -OutputDirectory ${CMAKE_CURRENT_BINARY_DIR} -NonInteractive -Verbosity Detailed
DEPENDS ${XLANG_BUILD_VERSION_h} ${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.Windows.PyWinRT.nuspec
)

add_custom_target(make_pywinrt_nupkg ALL DEPENDS ${pywinrt_nupkg} pywinrt)

set_target_properties(make_pywinrt_nupkg PROPERTIES "pywinrt_nupkg_dir" ${pywinrt_nupkg_dir})

endif()
File renamed without changes.
File renamed without changes.