From ccca198c1b1730b0241911cb56dc8e3504958b2a Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Sun, 18 Sep 2016 20:50:08 -0700 Subject: [PATCH] Initial commit --- .gitignore | 286 ++++++++++ CHANGELOG.md | 20 + LICENSE.txt | 25 + README.md | 39 ++ docs/CONTRIBUTING.md | 33 ++ docs/EXAMPLES.md | 269 +++++++++ docs/EXAMPLE_fix_libpng.md | 206 +++++++ docs/FAQ.md | 90 +++ docs/PRIVACY.md | 48 ++ docs/ROADMAP.md | 3 + ports/boost/CONTROL | 3 + ports/boost/portfile.cmake | 93 ++++ ports/boost/user-config.jam | 10 + ports/cocos2d/portfile.cmake | 47 ++ ...-on-Windows.-Enable-install-target-f.patch | 107 ++++ ports/cpprestsdk/CONTROL | 4 + ports/cpprestsdk/portfile.cmake | 50 ++ ports/curl/CONTROL | 3 + ports/curl/portfile.cmake | 24 + ports/expat/CONTROL | 3 + ports/expat/portfile.cmake | 22 + ...DLLs-via-CMAKE_WINDOWS_EXPORT_ALL_SY.patch | 25 + ports/freetype/CONTROL | 3 + ports/freetype/portfile.cmake | 41 ++ ports/glew/CONTROL | 3 + ports/glew/portfile.cmake | 53 ++ ports/glfw3/CONTROL | 3 + ports/glfw3/portfile.cmake | 58 ++ ports/libjpeg-turbo/CONTROL | 3 + .../add-options-for-exes-docs-headers.patch | 201 +++++++ ports/libjpeg-turbo/portfile.cmake | 38 ++ ports/libpng/CONTROL | 4 + ports/libpng/portfile.cmake | 47 ++ ports/libpng/use-abort-on-all-platforms.patch | 17 + ports/libuv/CONTROL | 3 + ports/libuv/portfile.cmake | 105 ++++ ports/libwebsockets/CONTROL | 4 + ports/libwebsockets/portfile.cmake | 35 ++ ...pg123.vcxproj-to-use-VS-2015-along-w.patch | 244 ++++++++ ports/mpg123/CONTROL | 3 + ports/mpg123/portfile.cmake | 54 ++ ports/openal-soft/CONTROL | 3 + ports/openal-soft/portfile.cmake | 27 + ...V-should-follow-FHS-like-conventions.patch | 156 ++++++ ports/opencv/CONTROL | 4 + ports/opencv/portfile.cmake | 62 +++ ports/opengl/CONTROL | 3 + ports/opengl/portfile.cmake | 26 + ports/openssl/CMakeLists.txt | 68 +++ ports/openssl/CONTROL | 4 + ports/openssl/LICENSE | 127 +++++ ports/openssl/portfile.cmake | 46 ++ ports/range-v3/CONTROL | 3 + ports/range-v3/portfile.cmake | 12 + ports/rapidjson/CONTROL | 3 + ports/rapidjson/portfile.cmake | 15 + ports/sdl2/CONTROL | 3 + ports/sdl2/portfile.cmake | 43 ++ ports/sqlite3/CMakeLists.txt | 16 + ports/sqlite3/CONTROL | 3 + ports/sqlite3/portfile.cmake | 19 + ports/tcl/portfile.cmake | 63 +++ ports/tiff/CONTROL | 3 + ports/tiff/portfile.cmake | 36 ++ ports/tinyxml2/CONTROL | 3 + ports/tinyxml2/portfile.cmake | 22 + ports/tk/portfile.cmake | 63 +++ ports/zlib/CONTROL | 3 + ports/zlib/LICENSE | 20 + ports/zlib/portfile.cmake | 22 + scripts/bootstrap.ps1 | 31 ++ scripts/buildsystems/msbuild/applocal.ps1 | 27 + scripts/buildsystems/msbuild/vcpkg.targets | 58 ++ scripts/buildsystems/vcpkg.cmake | 52 ++ scripts/cmake/vcpkg_apply_patches.cmake | 19 + scripts/cmake/vcpkg_build_cmake.cmake | 17 + scripts/cmake/vcpkg_build_msbuild.cmake | 32 ++ scripts/cmake/vcpkg_common_functions.cmake | 10 + scripts/cmake/vcpkg_configure_cmake.cmake | 54 ++ scripts/cmake/vcpkg_copy_pdbs.cmake | 38 ++ scripts/cmake/vcpkg_download_distfile.cmake | 20 + .../vcpkg_execute_required_process.cmake | 21 + .../cmake/vcpkg_extract_source_archive.cmake | 14 + .../cmake/vcpkg_find_acquire_program.cmake | 51 ++ scripts/cmake/vcpkg_install_cmake.cmake | 17 + scripts/doVcpkgRelease.ps1 | 84 +++ scripts/fetchDependency.ps1 | 212 +++++++ scripts/ports.cmake | 85 +++ scripts/templates/portfile.in.cmake | 21 + toolsrc/VERSION.txt | 1 + toolsrc/include/BinaryParagraph.h | 30 + toolsrc/include/SourceParagraph.h | 20 + toolsrc/include/StatusParagraph.h | 41 ++ toolsrc/include/StatusParagraphs.h | 49 ++ toolsrc/include/expected.h | 81 +++ toolsrc/include/metrics.h | 19 + toolsrc/include/opt_bool.h | 11 + toolsrc/include/package_spec.h | 50 ++ toolsrc/include/package_spec_parse_result.h | 34 ++ toolsrc/include/post_build_lint.h | 8 + toolsrc/include/triplet.h | 55 ++ toolsrc/include/vcpkg.h | 37 ++ toolsrc/include/vcpkg_Checks.h | 49 ++ toolsrc/include/vcpkg_Commands.h | 67 +++ toolsrc/include/vcpkg_Environment.h | 17 + toolsrc/include/vcpkg_Files.h | 11 + toolsrc/include/vcpkg_Graphs.h | 119 ++++ toolsrc/include/vcpkg_Strings.h | 58 ++ toolsrc/include/vcpkg_System.h | 77 +++ toolsrc/include/vcpkg_cmd_arguments.h | 36 ++ toolsrc/include/vcpkg_paths.h | 29 + toolsrc/include/vcpkglib_helpers.h | 12 + toolsrc/src/BinaryParagraph.cpp | 82 +++ toolsrc/src/SourceParagraph.cpp | 21 + toolsrc/src/StatusParagraph.cpp | 87 +++ toolsrc/src/StatusParagraphs.cpp | 67 +++ toolsrc/src/commands_help.cpp | 55 ++ toolsrc/src/commands_installation.cpp | 219 ++++++++ toolsrc/src/commands_integration.cpp | 297 ++++++++++ toolsrc/src/commands_other.cpp | 293 ++++++++++ toolsrc/src/commands_remove.cpp | 43 ++ toolsrc/src/lib.cpp | 524 ++++++++++++++++++ toolsrc/src/main.cpp | 245 ++++++++ toolsrc/src/metrics.cpp | 425 ++++++++++++++ toolsrc/src/package_spec.cpp | 46 ++ toolsrc/src/package_spec_parse_result.cpp | 45 ++ toolsrc/src/post_build_lint.cpp | 356 ++++++++++++ toolsrc/src/test.cpp | 347 ++++++++++++ toolsrc/src/triplet.cpp | 59 ++ toolsrc/src/vcpkg.cpp | 178 ++++++ toolsrc/src/vcpkg_Checks.cpp | 41 ++ toolsrc/src/vcpkg_Environment.cpp | 87 +++ toolsrc/src/vcpkg_Files.cpp | 38 ++ toolsrc/src/vcpkg_Strings.cpp | 60 ++ toolsrc/src/vcpkg_System.cpp | 111 ++++ toolsrc/src/vcpkg_cmd_arguments.cpp | 255 +++++++++ toolsrc/src/vcpkg_metrics_uploader.cpp | 25 + toolsrc/src/vcpkg_paths.cpp | 48 ++ toolsrc/src/vcpkg_version.cpp | 25 + toolsrc/src/vcpkglib_helpers.cpp | 50 ++ toolsrc/vcpkg.sln | 78 +++ toolsrc/vcpkg/vcpkg.vcxproj | 161 ++++++ toolsrc/vcpkg/vcpkg.vcxproj.filters | 60 ++ toolsrc/vcpkgcommon/vcpkgcommon.vcxproj | 140 +++++ .../vcpkgcommon/vcpkgcommon.vcxproj.filters | 54 ++ toolsrc/vcpkglib/vcpkglib.vcxproj | 153 +++++ toolsrc/vcpkglib/vcpkglib.vcxproj.filters | 87 +++ toolsrc/vcpkgmetrics/vcpkgmetrics.vcxproj | 140 +++++ .../vcpkgmetrics/vcpkgmetrics.vcxproj.filters | 27 + .../vcpkgmetricsuploader.vcxproj | 144 +++++ .../vcpkgmetricsuploader.vcxproj.filters | 22 + toolsrc/vcpkgtest/vcpkgtest.vcxproj | 173 ++++++ toolsrc/vcpkgtest/vcpkgtest.vcxproj.filters | 22 + triplets/arm-uwp.cmake | 6 + triplets/x64-uwp.cmake | 6 + triplets/x64-windows.cmake | 0 triplets/x86-uwp.cmake | 6 + triplets/x86-windows.cmake | 0 158 files changed, 10389 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE.txt create mode 100644 README.md create mode 100644 docs/CONTRIBUTING.md create mode 100644 docs/EXAMPLES.md create mode 100644 docs/EXAMPLE_fix_libpng.md create mode 100644 docs/FAQ.md create mode 100644 docs/PRIVACY.md create mode 100644 docs/ROADMAP.md create mode 100644 ports/boost/CONTROL create mode 100644 ports/boost/portfile.cmake create mode 100644 ports/boost/user-config.jam create mode 100644 ports/cocos2d/portfile.cmake create mode 100644 ports/cpprestsdk/0001-Use-find_package-on-Windows.-Enable-install-target-f.patch create mode 100644 ports/cpprestsdk/CONTROL create mode 100644 ports/cpprestsdk/portfile.cmake create mode 100644 ports/curl/CONTROL create mode 100644 ports/curl/portfile.cmake create mode 100644 ports/expat/CONTROL create mode 100644 ports/expat/portfile.cmake create mode 100644 ports/freetype/0001-Support-Windows-DLLs-via-CMAKE_WINDOWS_EXPORT_ALL_SY.patch create mode 100644 ports/freetype/CONTROL create mode 100644 ports/freetype/portfile.cmake create mode 100644 ports/glew/CONTROL create mode 100644 ports/glew/portfile.cmake create mode 100644 ports/glfw3/CONTROL create mode 100644 ports/glfw3/portfile.cmake create mode 100644 ports/libjpeg-turbo/CONTROL create mode 100644 ports/libjpeg-turbo/add-options-for-exes-docs-headers.patch create mode 100644 ports/libjpeg-turbo/portfile.cmake create mode 100644 ports/libpng/CONTROL create mode 100644 ports/libpng/portfile.cmake create mode 100644 ports/libpng/use-abort-on-all-platforms.patch create mode 100644 ports/libuv/CONTROL create mode 100644 ports/libuv/portfile.cmake create mode 100644 ports/libwebsockets/CONTROL create mode 100644 ports/libwebsockets/portfile.cmake create mode 100644 ports/mpg123/0001-Modify-2010-libmpg123.vcxproj-to-use-VS-2015-along-w.patch create mode 100644 ports/mpg123/CONTROL create mode 100644 ports/mpg123/portfile.cmake create mode 100644 ports/openal-soft/CONTROL create mode 100644 ports/openal-soft/portfile.cmake create mode 100644 ports/opencv/0001-OpenCV-should-follow-FHS-like-conventions.patch create mode 100644 ports/opencv/CONTROL create mode 100644 ports/opencv/portfile.cmake create mode 100644 ports/opengl/CONTROL create mode 100644 ports/opengl/portfile.cmake create mode 100644 ports/openssl/CMakeLists.txt create mode 100644 ports/openssl/CONTROL create mode 100644 ports/openssl/LICENSE create mode 100644 ports/openssl/portfile.cmake create mode 100644 ports/range-v3/CONTROL create mode 100644 ports/range-v3/portfile.cmake create mode 100644 ports/rapidjson/CONTROL create mode 100644 ports/rapidjson/portfile.cmake create mode 100644 ports/sdl2/CONTROL create mode 100644 ports/sdl2/portfile.cmake create mode 100644 ports/sqlite3/CMakeLists.txt create mode 100644 ports/sqlite3/CONTROL create mode 100644 ports/sqlite3/portfile.cmake create mode 100644 ports/tcl/portfile.cmake create mode 100644 ports/tiff/CONTROL create mode 100644 ports/tiff/portfile.cmake create mode 100644 ports/tinyxml2/CONTROL create mode 100644 ports/tinyxml2/portfile.cmake create mode 100644 ports/tk/portfile.cmake create mode 100644 ports/zlib/CONTROL create mode 100644 ports/zlib/LICENSE create mode 100644 ports/zlib/portfile.cmake create mode 100644 scripts/bootstrap.ps1 create mode 100644 scripts/buildsystems/msbuild/applocal.ps1 create mode 100644 scripts/buildsystems/msbuild/vcpkg.targets create mode 100644 scripts/buildsystems/vcpkg.cmake create mode 100644 scripts/cmake/vcpkg_apply_patches.cmake create mode 100644 scripts/cmake/vcpkg_build_cmake.cmake create mode 100644 scripts/cmake/vcpkg_build_msbuild.cmake create mode 100644 scripts/cmake/vcpkg_common_functions.cmake create mode 100644 scripts/cmake/vcpkg_configure_cmake.cmake create mode 100644 scripts/cmake/vcpkg_copy_pdbs.cmake create mode 100644 scripts/cmake/vcpkg_download_distfile.cmake create mode 100644 scripts/cmake/vcpkg_execute_required_process.cmake create mode 100644 scripts/cmake/vcpkg_extract_source_archive.cmake create mode 100644 scripts/cmake/vcpkg_find_acquire_program.cmake create mode 100644 scripts/cmake/vcpkg_install_cmake.cmake create mode 100644 scripts/doVcpkgRelease.ps1 create mode 100644 scripts/fetchDependency.ps1 create mode 100644 scripts/ports.cmake create mode 100644 scripts/templates/portfile.in.cmake create mode 100644 toolsrc/VERSION.txt create mode 100644 toolsrc/include/BinaryParagraph.h create mode 100644 toolsrc/include/SourceParagraph.h create mode 100644 toolsrc/include/StatusParagraph.h create mode 100644 toolsrc/include/StatusParagraphs.h create mode 100644 toolsrc/include/expected.h create mode 100644 toolsrc/include/metrics.h create mode 100644 toolsrc/include/opt_bool.h create mode 100644 toolsrc/include/package_spec.h create mode 100644 toolsrc/include/package_spec_parse_result.h create mode 100644 toolsrc/include/post_build_lint.h create mode 100644 toolsrc/include/triplet.h create mode 100644 toolsrc/include/vcpkg.h create mode 100644 toolsrc/include/vcpkg_Checks.h create mode 100644 toolsrc/include/vcpkg_Commands.h create mode 100644 toolsrc/include/vcpkg_Environment.h create mode 100644 toolsrc/include/vcpkg_Files.h create mode 100644 toolsrc/include/vcpkg_Graphs.h create mode 100644 toolsrc/include/vcpkg_Strings.h create mode 100644 toolsrc/include/vcpkg_System.h create mode 100644 toolsrc/include/vcpkg_cmd_arguments.h create mode 100644 toolsrc/include/vcpkg_paths.h create mode 100644 toolsrc/include/vcpkglib_helpers.h create mode 100644 toolsrc/src/BinaryParagraph.cpp create mode 100644 toolsrc/src/SourceParagraph.cpp create mode 100644 toolsrc/src/StatusParagraph.cpp create mode 100644 toolsrc/src/StatusParagraphs.cpp create mode 100644 toolsrc/src/commands_help.cpp create mode 100644 toolsrc/src/commands_installation.cpp create mode 100644 toolsrc/src/commands_integration.cpp create mode 100644 toolsrc/src/commands_other.cpp create mode 100644 toolsrc/src/commands_remove.cpp create mode 100644 toolsrc/src/lib.cpp create mode 100644 toolsrc/src/main.cpp create mode 100644 toolsrc/src/metrics.cpp create mode 100644 toolsrc/src/package_spec.cpp create mode 100644 toolsrc/src/package_spec_parse_result.cpp create mode 100644 toolsrc/src/post_build_lint.cpp create mode 100644 toolsrc/src/test.cpp create mode 100644 toolsrc/src/triplet.cpp create mode 100644 toolsrc/src/vcpkg.cpp create mode 100644 toolsrc/src/vcpkg_Checks.cpp create mode 100644 toolsrc/src/vcpkg_Environment.cpp create mode 100644 toolsrc/src/vcpkg_Files.cpp create mode 100644 toolsrc/src/vcpkg_Strings.cpp create mode 100644 toolsrc/src/vcpkg_System.cpp create mode 100644 toolsrc/src/vcpkg_cmd_arguments.cpp create mode 100644 toolsrc/src/vcpkg_metrics_uploader.cpp create mode 100644 toolsrc/src/vcpkg_paths.cpp create mode 100644 toolsrc/src/vcpkg_version.cpp create mode 100644 toolsrc/src/vcpkglib_helpers.cpp create mode 100644 toolsrc/vcpkg.sln create mode 100644 toolsrc/vcpkg/vcpkg.vcxproj create mode 100644 toolsrc/vcpkg/vcpkg.vcxproj.filters create mode 100644 toolsrc/vcpkgcommon/vcpkgcommon.vcxproj create mode 100644 toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters create mode 100644 toolsrc/vcpkglib/vcpkglib.vcxproj create mode 100644 toolsrc/vcpkglib/vcpkglib.vcxproj.filters create mode 100644 toolsrc/vcpkgmetrics/vcpkgmetrics.vcxproj create mode 100644 toolsrc/vcpkgmetrics/vcpkgmetrics.vcxproj.filters create mode 100644 toolsrc/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj create mode 100644 toolsrc/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj.filters create mode 100644 toolsrc/vcpkgtest/vcpkgtest.vcxproj create mode 100644 toolsrc/vcpkgtest/vcpkgtest.vcxproj.filters create mode 100644 triplets/arm-uwp.cmake create mode 100644 triplets/x64-uwp.cmake create mode 100644 triplets/x64-windows.cmake create mode 100644 triplets/x86-uwp.cmake create mode 100644 triplets/x86-windows.cmake diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000000..003d607fd1a05c --- /dev/null +++ b/.gitignore @@ -0,0 +1,286 @@ +############################################################ +# Visual Studio - Start +############################################################ + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +############################################################ +# Visual Studio - End +############################################################ + + +############################################################ +# vcpkg - Start +############################################################ + +.vscode/ +buildtrees/ +downloads/ +installed/ +packages/ +scripts/buildsystems/tmp/ +*.exe +*.zip + +############################################################ +# vcpkg - End +############################################################ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000000000..6815dd52cebca2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +vcpkg (0.0.30) +-------------- + * DLLs are now accompanied with their corresponding PDBs. + * Rework removal commands. `vcpkg remove ` now uninstalls the package. `vcpkg remove --purge ` now uninstalls and also deletes the package. + * Rename option --arch to --triplet. + * Extensively rework directory tree layout to make it more intuitive. + * Improve post-build verification checks. + * Improve post-build verification messages; they are now more compact, more consistent and contain more suggestions on how to resolve the issues found. + * Fix `vcpkg integrate project` in cases where the path contained non-alphanumeric chars. + * Improve handling of paths. In general, commands with whitespace and non-ascii characters should be handled better now. + * Add colorized output for `vcpkg clean` and `vcpkg purge`. + * Add colorized output for many more errors. + * Improved `vcpkg update` to identify installed libraries that are out of sync with their portfiles. + * Added list of example port files to EXAMPLES.md + * Rename common CMake utilities to use prefix `vcpkg_`. + * [libpng] Fixed x86-uwp and x64-uwp builds. + * [libjpeg-turbo] Fixed x86-uwp and x64-uwp builds via suppressing static CRT linkage. + * [rapidjson] New library. + +-- vcpkg team WED, 18 Sep 2016 20:50:00 -0700 diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000000000..375184eafa27bf --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,25 @@ +Port Tree + +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. diff --git a/README.md b/README.md new file mode 100644 index 00000000000000..10d921d5c374bc --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Vcpkg + +## Overview +Vcpkg helps you get C and C++ libraries on Windows. This tool and ecosystem are currently in a preview state; your involvement is vital to its success. + +For short description of available commands, run `vcpkg help`. + +## Quick Start +If there is no `vcpkg.exe` (such as after a `git clone`), run +``` +C:\src\vcpkg> powershell -exec bypass scripts\bootstrap.ps1 +``` +Then, to hook up user-wide integration, run (note: requires admin on first use) +``` +C:\src\vcpkg> .\vcpkg integrate install +``` +Finally, install any packages with +``` +C:\src\vcpkg> .\vcpkg install sdl2 curl +``` + +## Examples +See the [`docs\EXAMPLES.md`](docs/EXAMPLES.md) document for specific walkthroughs, including using a package and adding a new package. + +See a 4 mm [demo in video](https://www.youtube.com/watch?v=y41WFKbQFTw). + +## Contributing +Vcpkg is built with your contributions. Here are some ways you can contribute: + +* [Submit Issues](https://github.com/Microsoft/vcpkg/issues) in vcpkg or existing packages +* [Submit Fixes and New Packages](https://github.com/Microsoft/vcpkg/pulls) + +Please refer to our [Contribution guidelines](docs/CONTRIBUTING.md) for more details. + +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. + +## License + +Code licensed under the [MIT License](LICENSE.txt). diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 00000000000000..6e019d977590f5 --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,33 @@ +# Contribution Guidelines + +Vcpkg is a community driven effort to build a productive and robust ecosystem of native libraries - your contributions are invaluable! + +## Issues + +The easiest way to contribute is by reporting issues with either `vcpkg.exe` or an existing package on [GitHub](https://github.com/Microsoft/vcpkg). When reporting an issue with `vcpkg.exe`, make sure to clearly state: +- The machine setup: "I'm using Windows 10 Anniversary Update. My machine is using the fr-fr locale. I successfully ran 'install boost'." +- The steps to reproduce: "I run 'vcpkg list'" +- The outcome you expected: "I expected to see 'boost:x86-windows'" +- The actual outcome: "I get no output at all" or "I get a crash dialog" + +When reporting an issue with a package, make sure to clearly state: +- The machine setup (as above) +- What package and version you're building: "opencv 3.1.0" +- Any relevant error logs from the build process. + +## Pull Requests + +We are happy to accept pull requests for fixes, features, new packages, and updates to existing packages. In order to avoid wasting your time, we highly encourage opening an issue to discuss whether the PR you're thinking about making will be acceptable. This is doubly true for features and new packages. + +### New package Guidelines + +We're glad you're interested in submitting a new package! Here are some guidelines to help you author an excellent portfile: +- Avoid functional patches. Patches should be considered a last resort to implement compatibility when there's no other way. +- When patches can't be avoided, do not modify the default behavior. The ideal lifecycle of a patch is to get merged upstream and no longer be needed. Try to keep this goal in mind when deciding how to patch something. +- Prefer to use the `vcpkg_xyz` functions over raw `execute_command` calls. This makes long term maintenance easier when new features (such as custom compiler flags or generators) are added. + +## Legal + +You will need to complete a Contributor License Agreement (CLA) before your pull request can be accepted. This agreement testifies that you are granting us permission to use the source code you are submitting, and that this work is being submitted under appropriate license that we can use it. + +You can complete the CLA by going through the steps at https://cla.microsoft.com. Once we have received the signed CLA, we'll review the request. You will only need to do this once. diff --git a/docs/EXAMPLES.md b/docs/EXAMPLES.md new file mode 100644 index 00000000000000..723e49bed39972 --- /dev/null +++ b/docs/EXAMPLES.md @@ -0,0 +1,269 @@ +# Vcpkg + +## Overview +Vcpkg helps you get C and C++ libraries on Windows. + +For short description of available commands, run `vcpkg help`. + +## Table of Contents +- Example 1: Using the C++ REST SDK + - Step 1: Build + - Step 2: Use + - Option A: VS Project (User-wide integration) + - Option B: CMake (Toolchain file) + - Option C: Other buildsystems + - Option D: VS Project (Individual Project integration) +- Example 2: Package a remote project (zlib) + + +## Example 1: C++ REST SDK + +### Step 1: Build + +First, we need to know what name C++ REST SDK goes by in the ports tree. To do that, we'll run the `search` command and inspect the output: +``` +PS D:\src\vcpkg> .\vcpkg search +boost 1.60 Peer-reviewed portable C++ source libraries +cpprestsdk 2.8 C++11 JSON, REST, and OAuth library The C++ RES... +curl 7.48.0 A library for transferring data with URLs +expat 2.1.1 XML parser library written in C +freetype 2.6.3 A library to render fonts. +glew 1.13.0 The OpenGL Extension Wrangler Library (GLEW) is a... +glfw3 3.1.2 GLFW is a free, Open Source, multi-platform libra... +libjpeg-turbo 1.4.90-1 libjpeg-turbo is a JPEG image codec that uses SIM... +libpng 1.6.24-1 libpng is a library implementing an interface for... +libuv 1.9.1 libuv is a multi-platform support library with a ... +libwebsockets 2.0.0 Libwebsockets is a lightweight pure C library bui... +mpg123 1.23.3 mpg123 is a real time MPEG 1.0/2.0/2.5 audio play... +openal-soft 1.17.2 OpenAL Soft is an LGPL-licensed, cross-platform, ... +opencv 3.1.0 computer vision library +opengl 10.0.10240.0 Open Graphics Library (OpenGL)[3][4][5] is a cros... +openssl 1.0.2h OpenSSL is an open source project that provides a... +range-v3 0.0.0-1 Range library for C++11/14/17. +rapidjson 1.0.2-1 A fast JSON parser/generator for C++ with both SA... +sdl2 2.0.4 Simple DirectMedia Layer is a cross-platform deve... +sqlite3 3120200 SQLite is a software library that implements a se... +tiff 4.0.6 A library that supports the manipulation of TIFF ... +tinyxml2 3.0.0 A simple, small, efficient, C++ XML parser +zlib 1.2.8 A compression library +``` +Looking at the list, we can see that the port is named "cpprestsdk". + +Installing is then as simple as using the `install` command. Since we haven't built this library before, we'll first see an error message indicating that the control file failed to load, then the port will automatically begin building (and install when completed). +``` +PS D:\src\vcpkg> .\vcpkg install cpprestsdk +-- CURRENT_INSTALLED_DIR=D:/src/vcpkg/installed/x86-windows +-- DOWNLOADS=D:/src/vcpkg/downloads +-- CURRENT_PACKAGES_DIR=D:/src/vcpkg/packages/cpprestsdk_x86-windows +-- CURRENT_BUILDTREES_DIR=D:/src/vcpkg/buildtrees/cpprestsdk +-- CURRENT_PORT_DIR=D:/src/vcpkg/ports/cpprestsdk/. +-- Cloning done +-- Adding worktree and patching done +-- Configuring x86-windows-rel +-- Configuring x86-windows-rel done +-- Configuring x86-windows-dbg +-- Configuring x86-windows-dbg done +-- Build x86-windows-rel +-- Build x86-windows-rel done +-- Build x86-windows-dbg +-- Build x86-windows-dbg done +-- Package x86-windows-rel +-- Package x86-windows-rel done +-- Package x86-windows-dbg +-- Package x86-windows-dbg done +Package cpprestsdk:x86-windows is installed +``` +In addition to installing, `vcpkg` caches a pristine copy of the built library inside the `packages\` directory (in this case, `packages\cpprestsdk_x86-windows`). This allows you to quickly uninstall and reinstall the library in the future using the `remove` and `install` commands. + +We can check that cpprestsdk was successfully installed for x86 windows desktop by running the `list` command. +``` +PS D:\src\vcpkg> .\vcpkg list +cpprestsdk:x86-windows 2.8 A modern C++11 library to connect with web servic... +``` + +To install for other architectures and platforms such as Universal Windows Platform or x64 Desktop, you can suffix the package name with `:`. +``` +PS D:\src\vcpkg> .\vcpkg install cpprestsdk:x86-uwp zlib:x64-windows +``` + +See `vcpkg help arch` for all supported targets. + + +### Step 2: Use + +#### Option A: VS Project (User-wide integration) + +The recommended and most productive way to use vcpkg is via user-wide integration, making the system available for all projects you build. The user-wide integration will require administrator access the first time it is used on a given machine. After the first use, administrator access is no longer required and the integration is on a per-user basis. +``` +PS D:\src\vcpkg> .\vcpkg integrate install +Applied user-wide integration for this vcpkg root. + +All C++ projects can now #include any installed libraries. +Linking will be handled automatically. +Installing new libraries will make them instantly available. +``` +*Note: You will need to restart Visual Studio or perform a Build to update intellisense with the changes.* + +To remove the integration for your user, you can use `vcpkg integrate remove`. + + +#### Option B: CMake (Toolchain File) + +The best way to use installed libraries with cmake is via the toolchain file `scripts\buildsystems\vcpkg.cmake`. To use this file, you simply need to add it onto your CMake command line as `-DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.cmake`. + +Let's first make a simple CMake project with a main file. +```cmake +# CMakeLists.txt +cmake_minimum_required(VERSION 3.0) +project(test) + +find_library(CPPREST_LIBRARY cpprest_2_8) +find_path(CPPREST_INCLUDE_DIR cpprest/version.h) + +include_directories(${CPPREST_INCLUDE_DIR}) +link_libraries(${CPPREST_LIBRARY}) +add_executable(main main.cpp) +``` +```cpp +// main.cpp +#include +#include + +int main() +{ + auto v = web::json::value::parse(U("[1,2,3,4]")); + printf("Success\n"); + return 0; +} +``` + +Then, we build our project in the normal CMake way: +``` +PS D:\src\cmake-test> mkdir build +PS D:\src\cmake-test> cd build +PS D:\src\cmake-test\build> cmake .. "-DCMAKE_TOOLCHAIN_FILE=D:\src\vcpkg\scripts\buildsystems\vcpkg.cmake" + // omitted CMake output here // +-- Build files have been written to: D:/src/cmake-test/build +PS D:\src\cmake-test\build> cmake --build . + // omitted MSBuild output here // +Build succeeded. + 0 Warning(s) + 0 Error(s) + +Time Elapsed 00:00:02.38 +PS D:\src\cmake-test\build> .\Debug\main.exe +Success +``` + + +#### Option C: Other buildsystems + +Libraries are installed into the `installed\` subfolder, partitioned by architecture (e.g. x86-windows): +* The header files are installed to `installed\x86-windows\include` +* Release `.lib` files are installed to `installed\x86-windows\lib` +* Release `.dll` files are installed to `installed\x86-windows\bin` +* Debug `.lib` files are installed to `installed\x86-windows\debug\lib` +* Debug `.dll` files are installed to `installed\x86-windows\debug\bin` + +See your build system specific documentation for how to use prebuilt binaries. + +Generally, to run any produced executables you will also need to either copy the needed `dll` files to the same folder as your `exe` or *prepend* the correct `bin` directory to your path. + +Example for setting the path for debug mode in powershell: +``` +PS D:\src\vcpkg> $env:path = "D:\src\vcpkg\installed\x86-windows\debug\bin;" + $env:path +``` + +#### Option D: VS Project (Individual Project integration) + +We also provide individual VS project integration through a NuGet package. This will modify the project file, so we do not recommend this approach for open source projects. +``` +PS D:\src\vcpkg> .\vcpkg integrate project +Created nupkg: D:\src\vcpkg\scripts\buildsystems\vcpkg.D.src.vcpkg.1.0.0.nupkg + +With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste: + Install-Package vcpkg.D.src.vcpkg -Source "D:/src/vcpkg/scripts/buildsystems" +``` +*Note: The generated NuGet package does not contain the actual libraries. It instead acts like a shortcut (or symlink) to the vcpkg install and will "automatically" update with any changes (install/remove) to the libraries. You do not need to regenerate or update the NuGet package.* + + +## Example 2: Package a remote project (zlib) + +### Bootstrap with `create` +First, locate a globally accessible archive of the library's sources. Zip, gzip, and bzip are all supported. Strongly prefer official sources or mirrors over unofficial mirrors. + +*Looking at zlib's website, the URL http://zlib.net/zlib128.zip looks appropriate.* + +Second, determine a suitable package name. This should be ASCII, lowercase, and recognizable to someone who knows the library's "human name". If the library is already packaged in another package manager, prefer that name. + +*Since zlib is already packaged as zlib, we will use the name zlib2 for this example.* + +Finally, if the server's name for the archive is not very descriptive (such as downloading a zipped commit or branch from GitHub), choose a nice archive name of the form `-.zip`. + +*`zlib128.zip` is a fine name, so no change needed.* + +All this information can then be passed into the `create` command, which will download the sources and bootstrap the packaging process inside `ports\`. + +``` +PS D:\src\vcpkg> .\vcpkg create zlib2 http://zlib.net/zlib128.zip zlib128.zip +-- Generated portfile: D:/src/vcpkg/ports/zlib2/portfile.cmake +``` + +### Create the CONTROL file +In addition to the generated `ports\\portfile.cmake`, We also need a `ports\\CONTROL` file. This file is a simply formatted set of fields describing the package's metadata. + +*For zlib2, we'll create the file `ports\zlib2\CONTROL` with the following contents:* +``` +Source: zlib2 +Version: 1.2.8 +Description: A Massively Spiffy Yet Delicately Unobtrusive Compression Library +``` + +### Tweak the generated portfile +The generated `portfile.cmake` will need some editing to correctly package most libraries in the wild, however we can start by trying out the build. + +``` +PS D:\src\vcpkg> .\vcpkg build zlib2 +-- CURRENT_INSTALLED_DIR=D:/src/vcpkg/installed/x86-windows +-- DOWNLOADS=D:/src/vcpkg/downloads +-- CURRENT_PACKAGES_DIR=D:/src/vcpkg/packages/zlib2_x86-windows +-- CURRENT_BUILDTREES_DIR=D:/src/vcpkg/buildtrees/zlib2 +-- CURRENT_PORT_DIR=D:/src/vcpkg/ports/zlib2 +-- Using cached D:/src/vcpkg/downloads/zlib128.zip +-- Extracting source D:/src/vcpkg/downloads/zlib128.zip +-- Extracting done +-- Configuring x86-windows-rel +CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:13 (message): + Command failed: C:/Program Files + (x86)/CMake/bin/cmake.exe;D:/src/vcpkg/buildtrees/zlib2/src/zlib128;-G;Ninja;-DCMAKE_VERBOSE_MAKEFILE=ON;-DCMAKE_BUILD_TYPE=Release;-DCMAKE_TOOLCHAIN_FILE=D:/src/vcpkg/triplets/x86-windows.cmake;-DCMAKE_PREFIX_PATH=D:/src/vcpkg/installed/x86-windows;- +DCMAKE_INSTALL_PREFIX=D:/src/vcpkg/packages/zlib2_x86-windows + + + Working Directory: D:/src/vcpkg/buildtrees/zlib2/x86-windows-rel + + See logs for more information: + + D:/src/vcpkg/buildtrees/zlib2/config-x86-windows-rel-out.log + D:/src/vcpkg/buildtrees/zlib2/config-x86-windows-rel-err.log + +Call Stack (most recent call first): + scripts/cmake/vcpkg_configure_cmake.cmake:15 (vcpkg_execute_required_process) + ports/zlib2/portfile.cmake:8 (vcpkg_configure_cmake) + scripts/ports.cmake:105 (include) + scripts/ports.cmake:184 (build) +``` + +At this point, it is a matter of reading the error messages and log files while steadily improving the quality of the portfile. Zlib required providing a discrete copy of the LICENSE to copy into the package, suppressing the build and installation of executables and headers, and removing the static libraries after they were installed. + +### Suggested example portfiles +In the `ports\` directory are many libraries that can be used as examples, including many that are not based on CMake. + +- Header only libraries + - rapidjson + - range-v3 +- MSBuild-based + - mpg123 + - glew +- Non-CMake, custom buildsystem + - openssl + - boost diff --git a/docs/EXAMPLE_fix_libpng.md b/docs/EXAMPLE_fix_libpng.md new file mode 100644 index 00000000000000..5b97457d5a6804 --- /dev/null +++ b/docs/EXAMPLE_fix_libpng.md @@ -0,0 +1,206 @@ +Fixing libpng:x86-uwp +===================== + +First, try building: + +``` +PS D:\src\cpp-packages> vcpkg install libpng:x86-uwp +-- SYSROOT=D:/src/cpp-packages/sysroot/x86-uwp +-- DISTDIR=D:/src/cpp-packages/distdir +-- CURRENT_SOFTWARE_DIR=D:/src/cpp-packages/software/libpng_x86-uwp +-- CURRENT_WORKSRC_DIR=D:/src/cpp-packages/worksrc/libpng +-- CURRENT_PORT_DIR=D:/src/cpp-packages/ports/libpng/. +-- Using cached D:/src/cpp-packages/distdir/libpng-1.6.24.tar.xz +-- Extracting done +-- Configuring x86-uwp-rel +-- Configuring x86-uwp-rel done +-- Configuring x86-uwp-dbg +-- Configuring x86-uwp-dbg done +-- Build x86-uwp-rel +CMake Error at scripts/cmake/execute_required_process.cmake:14 (message): + Command failed: C:/Program + Files/CMake/bin/cmake.exe;--build;.;--config;Release + + Working Directory: D:/src/cpp-packages/worksrc/libpng/x86-uwp-rel + + See logs for more information: + + D:\src\cpp-packages\worksrc\libpng\build-x86-uwp-rel-out.log + D:\src\cpp-packages\worksrc\libpng\build-x86-uwp-rel-err.log + +Call Stack (most recent call first): + scripts/cmake/build_standard_cmake.cmake:3 (execute_required_process) + ports/libpng/portfile.cmake:22 (build_standard_cmake) + scripts/ports.cmake:84 (include) + + +Error: build command failed +``` + +Next, looking at the above logs (build-...-out.log and build-...-err.log). + +``` +// build-x86-uwp-rel-out.log +... +"D:\src\cpp-packages\worksrc\libpng\x86-uwp-rel\ALL_BUILD.vcxproj" (default target) (1) -> +"D:\src\cpp-packages\worksrc\libpng\x86-uwp-rel\png.vcxproj" (default target) (3) -> +(ClCompile target) -> + D:\src\cpp-packages\worksrc\libpng\src\libpng-1.6.24\pngerror.c(775): warning C4013: 'ExitProcess' undefined; assuming extern returning int [D:\src\cpp-packages\worksrc\libpng\x86-uwp-rel\png.vcxproj] + + +"D:\src\cpp-packages\worksrc\libpng\x86-uwp-rel\ALL_BUILD.vcxproj" (default target) (1) -> +"D:\src\cpp-packages\worksrc\libpng\x86-uwp-rel\png.vcxproj" (default target) (3) -> +(Link target) -> + pngerror.obj : error LNK2019: unresolved external symbol _ExitProcess referenced in function _png_longjmp [D:\src\cpp-packages\worksrc\libpng\x86-uwp-rel\png.vcxproj] + D:\src\cpp-packages\worksrc\libpng\x86-uwp-rel\Release\libpng16.dll : fatal error LNK1120: 1 unresolved externals [D:\src\cpp-packages\worksrc\libpng\x86-uwp-rel\png.vcxproj] + + 1 Warning(s) + 2 Error(s) + +Time Elapsed 00:00:04.19 +``` +Taking a look at [MSDN](https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx) shows that `ExitProcess` is only available for desktop apps. Additionally, it's useful to see the surrounding context: + +```c +/* worksrc\libpng\src\libpng-1.6.24\pngerror.c:769 */ + /* If control reaches this point, png_longjmp() must not return. The only + * choice is to terminate the whole process (or maybe the thread); to do + * this the ANSI-C abort() function is used unless a different method is + * implemented by overriding the default configuration setting for + * PNG_ABORT(). + */ + PNG_ABORT(); +``` + +A recursive search for `PNG_ABORT` reveals the definition: +``` +PS D:\src\cpp-packages\worksrc\libpng\src\libpng-1.6.24> findstr /snipl "PNG_ABORT" * +CHANGES:701: Added PNG_SETJMP_SUPPORTED, PNG_SETJMP_NOT_SUPPORTED, and PNG_ABORT() macros +libpng-manual.txt:432:errors will result in a call to PNG_ABORT() which defaults to abort(). +libpng-manual.txt:434:You can #define PNG_ABORT() to a function that does something +libpng-manual.txt:2753:errors will result in a call to PNG_ABORT() which defaults to abort(). +libpng-manual.txt:2755:You can #define PNG_ABORT() to a function that does something +libpng-manual.txt:4226:PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()), +libpng.3:942:errors will result in a call to PNG_ABORT() which defaults to abort(). +libpng.3:944:You can #define PNG_ABORT() to a function that does something +libpng.3:3263:errors will result in a call to PNG_ABORT() which defaults to abort(). +libpng.3:3265:You can #define PNG_ABORT() to a function that does something +libpng.3:4736:PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()), +png.h:994: * will use it; otherwise it will call PNG_ABORT(). This function was +pngerror.c:773: * PNG_ABORT(). +pngerror.c:775: PNG_ABORT(); +pngpriv.h:459:#ifndef PNG_ABORT +pngpriv.h:461:# define PNG_ABORT() ExitProcess(0) +pngpriv.h:463:# define PNG_ABORT() abort() +``` + +This already gives us some great clues, but the full definition tells the complete story. + +```c +/* worksrc\libpng\src\libpng-1.6.24\pngpriv.h:459 */ +#ifndef PNG_ABORT +# ifdef _WINDOWS_ +# define PNG_ABORT() ExitProcess(0) +# else +# define PNG_ABORT() abort() +# endif +#endif +``` + +`abort()` is a standard CRT call and certainly available in UWP, so we just need to convince libpng to be more platform agnostic. The easiest and most reliable way to achive is to patch the code; while in this particular case we could pass in a compiler flag to override `PNG_ABORT` because this is a private header, in general it is more reliable to avoid adding more required compiler switches when possible (especially when it isn't already exposed as a CMake option). + +I recommend using git to create the patch file, since you'll already have it installed. +``` +PS D:\src\cpp-packages\worksrc\libpng\src\libpng-1.6.24> git init . +Initialized empty Git repository in D:/src/cpp-packages/worksrc/libpng/src/libpng-1.6.24/.git/ + +PS D:\src\cpp-packages\worksrc\libpng\src\libpng-1.6.24> git add . +warning: LF will be replaced by CRLF in ANNOUNCE. +The file will have its original line endings in your working directory. +... + +PS D:\src\cpp-packages\worksrc\libpng\src\libpng-1.6.24> git commit -m "temp" +[master (root-commit) 68f253f] temp + 422 files changed, 167717 insertions(+) +... +``` + +Now we can modify `pngpriv.h` to use `abort()` everywhere. +```c +/* worksrc\libpng\src\libpng-1.6.24\pngpriv.h:459 */ +#ifndef PNG_ABORT +# define PNG_ABORT() abort() +#endif +``` + +The output of `git diff` is already in patch format, so we just need to save the patch into the `ports/libpng` directory. +``` +PS worksrc\libpng\src\libpng-1.6.24> git diff | out-file -enc ascii ..\..\..\..\ports\libpng\use-abort-on-all-platforms.patch +``` + +Finally, we need to apply the patch after extracting the source. +```cmake +# ports\libpng\portfile.cmake +... +extract_source_archive(${ARCHIVE}) + +find_program(GIT git) +execute_required_process( + COMMAND ${GIT} init + WORKING_DIRECTORY ${CURRENT_WORKSRC_DIR}/src/libpng-1.6.24 + LOGNAME git-init +) +execute_process( + COMMAND ${GIT} apply "${CMAKE_CURRENT_LIST_DIR}/use-abort-on-all-platforms.patch" --ignore-whitespace --whitespace=nowarn + WORKING_DIRECTORY ${CURRENT_WORKSRC_DIR}/src/libpng-1.6.24 +) + +configure_standard_cmake( +... +``` + +To be completely sure this works from the top, we need to clear out all the caches. + +``` +PS D:\src\cpp-packages> vcpkg remove libpng:x86-uwp +Package libpng:x86-uwp was successfully removed +PS D:\src\cpp-packages> vcpkg purge libpng:x86-uwp +Cleaned up D:\src\cpp-packages\software\libpng_x86-uwp +PS D:\src\cpp-packages> vcpkg clean libpng +Cleaned up D:\src\cpp-packages\worksrc\libpng +``` + +Now we try a fresh, from scratch install. +``` +PS D:\src\cpp-packages> vcpkg install libpng:x86-uwp +-- SYSROOT=D:/src/cpp-packages/sysroot/x86-uwp +-- DISTDIR=D:/src/cpp-packages/distdir +-- CURRENT_SOFTWARE_DIR=D:/src/cpp-packages/software/libpng_x86-uwp +-- CURRENT_WORKSRC_DIR=D:/src/cpp-packages/worksrc/libpng +-- CURRENT_PORT_DIR=D:/src/cpp-packages/ports/libpng/. +-- Using cached D:/src/cpp-packages/distdir/libpng-1.6.24.tar.xz +-- Extracting source D:/src/cpp-packages/distdir/libpng-1.6.24.tar.xz +-- Extracting done +-- Configuring x86-uwp-rel +-- Configuring x86-uwp-rel done +-- Configuring x86-uwp-dbg +-- Configuring x86-uwp-dbg done +-- Build x86-uwp-rel +-- Build x86-uwp-rel done +-- Build x86-uwp-dbg +-- Build x86-uwp-dbg done +-- Package x86-uwp-rel +-- Package x86-uwp-rel done +-- Package x86-uwp-dbg +-- Package x86-uwp-dbg done +Package libpng:x86-uwp is installed +``` + +Finally, to fully commit and publish the changes, we need to bump the internal release number and add the patch file to source control. + +``` +# ports\libpng\CONTROL +Source: libpng +Version: 1.6.24-1 +Build-Depends: zlib +``` diff --git a/docs/FAQ.md b/docs/FAQ.md new file mode 100644 index 00000000000000..53ef6fa7c33df5 --- /dev/null +++ b/docs/FAQ.md @@ -0,0 +1,90 @@ +# Frequently Asked Questions: Vcpkg + +Vcpkg is a tool to acquire C++ open source library and rebuild them on Windows. + +## Can I contribute a new library? +Yes! Start out by reading our [contribution guidelines](CONTRIBUTING.md). + +## Can Vcpkg create pre-built binary packages? What is the binary format used by Vcpkg? +In the preview release, we do not have a supported way to distribute individual binary packages. This avoids the issue of trying to use a specific pre-built package against differently built dependencies. As such, we have also not specified a stable format for the built library packages. + +We instead recommend copying the entire system as a whole (which ensures that every package and its dependencies stay in sync with each other). + +## How will the libs will be updated locally? +The `vcpkg update` command lists all packages which are out-of-sync with your current portfiles. To update a package, follow the instructions in the command. + +## Can I build a private library with this tool? +Yes. Follow [Example #2](EXAMPLES.md#example-2) for creating a portfile using a fake URL. Then, either pre-seed the `downloads\` folder with a zip containing your private sources or replace the normal `vcpkg_download_distfile` and `vcpkg_extract_source_archive` with functions that unpack your source code. + +## Can I use a prebuilt private library with this tool? +Yes. The `portfile.cmake` for a library is fundamentally a script that places the headers and binaries into the correct arrangement in the `${CURRENT_PACKAGES_DIR}`, so to pull in prebuilt binaries you can write a portfile which directly downloads and arranges the files. + +To see an example of this, look at the [`opengl`](../ports/opengl/portfile.cmake) package which simply copies files out of the Windows SDK. + +## Which platforms I can target with Vcpkg? +We currently target Windows Desktop (x86 and x64) as well as the Universal Windows Platform (x86, x64, and ARM). See `vcpkg help triplet` for the current list. + +## Does `vcpkg.exe` run on Linux/OSX? +No, for this preview we are focusing on Windows as a host platform. If you'd be interested in having Vcpkg run on Linux or OSX, please let us know in an [issue](https://github.com/microsoft/vcpkg/issues). + +## How do I use different versions of a library on one machine? +Within a single instance of Vcpkg (e.g. one set of `installed\`, `packages\`, `ports\` and so forth), you can only have one version of a library installed (otherwise, the headers would conflict with each other!). This is because a package in Vcpkg corresponds to the `X-dev` or `X-devel` packages in other system package managers. + +To use different versions of a library (for different projects), we recommend making separate instances of Vcpkg and using the [per-project integration mechanisms](EXAMPLES.md#example-1-2-d). The versions of each library are specified by the files in `ports\`, so they are easily manipulated using standard VCS techniques. This makes it very easy to roll back the entire set of libraries to a consistent set of older versions which all work with each other. If you need to then pin a specific library forward, that is as easy as checking out the appropriate version of `ports\package\`. + +If your application is very sensitive to the versions of libraries, we recommend checking in the specific set of portfiles you need into your source control along with your project sources and using the `--vcpkg-root` option to redirect the working directory of `vcpkg.exe`. + +## How does Vcpkg protect my Privacy? +See the [Privacy document](PRIVACY.md) for all information regarding privacy. + +## Can I use my own CMake toolchain file with Vcpkg's toolchain file? +Yes. If you already have a CMake toolchain file, you will need to include our toolchain file at the end of yours. This should be as simple as an `include(\scripts\buildsystems\vcpkg.cmake)` directive. Alternatively, you could copy the contents of our `scripts\buildsystems\vcpkg.cmake` into the end of your existing toolchain file. + +## Can I use my own/specific flags for rebuilding libs? +Yes. In the current preview, there is not yet a standardized global way to change them, however you can edit individual portfiles and tweak the exact build process however you'd like. + +By saving the changes to the portfile (and checking them in), you'll get the same results even if you're rebuilding from scratch in the future and forgot what exact settings you used. + +## How is CMake used internally by Vcpkg? +Vcpkg uses CMake internally as a build scripting language. This is because CMake is already an extremely common build system for cross-platform open source libraries and is becoming very popular for C++ projects in general. It is easy to acquire on Windows (does not require system-wide installation) and reasonably legible for unfamiliar users. + +## How does my list of libraries get updated? +The list of libraries is enumerated from the `ports\` directory. By design, you can add and remove libraries from this directory as you see fit for yourself or your company (see [Example #2](EXAMPLES.md#example-2)). + +We recommend cloning directly from [GitHub](https://github.com/microsoft/vcpkg) and using `git pull` to update the list of portfiles. Once you've updated your portfiles, `vcpkg update` will indicate any installed libraries that are now out of date. + +## Will it support also downloading compiled binaries from a public or private server? +We do plan to eventually support downloading precompiled binaries, similar to other systems package managers. + +In a corporate scenario, we currently recommend building the libraries once and distributing the entire vcpkg root directory to everyone else on the project through some raw file transport such as a network share or HTTP host. + +## What Visual C++ toolsets are supported? +We plan to only support Visual Studio 2015 and above. + +## Can I acquire my package's sources by Git url+tag? +Yes, however we prefer compressed archives of the specific release/commit since the internal downloads and build trees are meant to be read only. Github provides archives for every commit, tag, and branch, so it's always possible to perform this substitution for repositories hosted there. + +See `ports\cpprestsdk\portfile.cmake` and `ports\opencv\portfile.cmake` for examples of using git directly. + +## Why not NuGet? +NuGet is a package manager for .NET libraries with a strong dependency on MSBuild. It does not meet the specific needs of Native C++ customers in at least three ways. + +- **Compilation Flavors**. With so many possible combinations of compilation options, the task of providing a truly complete set of options is intrinsicly impossible. Furthermore, the download size for reasonably complete binary packages becomes enormous. This makes it a requirement to split the results into multiple packages, but then searching becomes very difficult. + +- **Binary vs Source**. Very closely tied to the first point, NuGet is designed from the ground up to provide relatively small, prebuilt binaries. Due to the nature of native code, developers need to have access to the source code to ensure ABI compatibility, performance, integrity, and debuggability. + +- **Per-dll vs Per-application**. NuGet is highly project centric. This works well in managed languages with naturally stable ABIs, because base libraries can continue to evolve without breaking those higher up. However, in native languages where the ABI is much more fragile, the only robust strategy is to explicitly build each library against the exact dependencies that will be included in the final application. This is difficult to ensure in NuGet and leads to a highly disconnected and independently versioned ecosystem. + +## Why not Conan? +Conan.io is a publicly-federated, project-centric, cross-platform, C++ package manager written in python. Our primary differences are: + +- **Public federation vs private federation**. Conan relies on individuals publishing independent copies of each package. We believe this approach encourages a large number of packages that are all broken in different ways. We believe it is a waste of user's time to pick through the list of 20+ public packages for Boost 1.56 to determine the handful that will work for their particular situation. In contrast, we believe there should be a single, collaboratively maintained version which works for the vast majority of cases and allow users to hack freely on their private versions. We believe this will result in a set of high quality packages that are heavily tested with each other and form a fantastic base for any private modifications you need. + +- **Per-dll vs Per-application**. When dependencies are independently versioned on a library level, it encourages every build environment to be a completely unique, unable to take advantage of or contribute to a solid, well tested ecosystem. In contrast, by versioning all libraries together as a platform (similar to a system package manager), we hope to congregate testing and effort on very common sets of library versions to maximize the quality and stability of the ecosystem. This also completely designs out the ability for a library to ask for versions that conflict with the application's choices (I want openssl Z and boost X but X only works with openssl Y). + +- **Cross-platform vs single-platform**. While being hosted on many platforms is an excellent north star, we believe the level of system integration and stability provided by apt-get, yum, and homebrew is well worth needing to exchange `apt-get install libboost-all-dev` with `brew install boost` in automated scripts. We chose to make our system as easy as possible to integrate into a world with these very successful system managers -- one more line for `vcpkg install boost` -- instead of attempting to replace them where they are already so successful and well-loved. + +- **C++/CMake vs python**. While Python is an excellent language loved by many, we believe that transparency and familiarity are the most important factors when choosing a tool as important to your workflow as a package manager. Consequently, we chose to make the implementation languages be as universally accepted as possible: C++ should be used in a C++ package manager for C++ programmers. You should not be required to learn another language just to understand your package manager. + +## Why not Chocolatey? +Chocolatey is an excellent system for distributing desktop utilities. However, it is not designed to acquire redistributable developer assets and help you with debugging. Vcpkg, in comparison, is designed to get you the libraries you need to build your application and help you deliver through any platform you'd like (including Chocolatey!). diff --git a/docs/PRIVACY.md b/docs/PRIVACY.md new file mode 100644 index 00000000000000..f50c2938fa6c3e --- /dev/null +++ b/docs/PRIVACY.md @@ -0,0 +1,48 @@ + +# Privacy document for vcpkg + + +## Do you collect telemetry data? What is it used for? + +We do collect telemetry data from usage of "vcpkg.exe". We explicitly ONLY collect information from invocations of the tool itself; we do NOT add any tracking information into the produced libraries. +We use this information to understand the usage the issue and what we can do to improve the tool. + + +## What telemetry is collected? + +We collect the command line used, the time of invocation, and how long the command took. Some commands also add additional calculated information (such as the full set of libraries to install). We generate a completely random UUID on first use and attach it to each event. For this preview, we do not offer a mechanism to disable this data collection since it is critical for improving the product. In the full release, you will be able to opt-out with a simple configuration. For more information about how Microsoft protects your privacy, see https://privacy.microsoft.com/en-us/privacy. + +Here is an example of an event for the command line "vcpkg install zlib": +``` +[{ + "ver": 1, + "name": "Microsoft.ApplicationInsights.Event", + "time": "2016-09-01T00:19:10.949Z", + "sampleRate": 100.000000, + "seq": "0:0", + "iKey": "aaaaaaaa-4393-4dd9-ab8e-97e8fe6d7603", + "flags": 0.000000, + "tags": { + "ai.device.os": "Windows", + "ai.device.osVersion": "10.0.14912", + "ai.session.id": "aaaaaaaa-7c69-4b83-7d82-8a4198d7e88d", + "ai.user.id": "aaaaaaaa-c9ab-4bf5-0847-a3455f539754", + "ai.user.accountAcquisitionDate": "2016-08-20T00:38:09.860Z" + }, + "data": { + "baseType": "EventData", + "baseData": { + "ver": 2, + "name": "commandline_test7", + "properties": { "version":"0.0.30-9b4e44a693459c0a618f370681f837de6dd95a30","cmdline":"install zlib","command":"install","installplan":"zlib:x86-windows" }, + "measurements": { "elapsed_us":68064.355736 } + } + } +}] +``` +In the source code (included in every release), you can search for calls to the functions "TrackProperty" and "TrackMetric" to see every specific data point we collect. + + +## Is the data stored on my system? + +We store each event document in your temporary files directory. These will be cleaned out whenever you clear your temporary files. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md new file mode 100644 index 00000000000000..df6e3853eb22bf --- /dev/null +++ b/docs/ROADMAP.md @@ -0,0 +1,3 @@ +# Roadmap + + diff --git a/ports/boost/CONTROL b/ports/boost/CONTROL new file mode 100644 index 00000000000000..8307022f0b487c --- /dev/null +++ b/ports/boost/CONTROL @@ -0,0 +1,3 @@ +Source: boost +Version: 1.60 +Description: Peer-reviewed portable C++ source libraries diff --git a/ports/boost/portfile.cmake b/ports/boost/portfile.cmake new file mode 100644 index 00000000000000..acdfb9379c25af --- /dev/null +++ b/ports/boost/portfile.cmake @@ -0,0 +1,93 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE_FILE + URL "http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.bz2" + FILENAME "boost_1_60_0.tar.bz2" + MD5 65a840e1a0b13a558ff19eeb2c4f0cbe +) +vcpkg_extract_source_archive(${ARCHIVE_FILE}) + +if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/src/boost_1_60_0/b2.exe) + message(STATUS "Bootstrapping") + vcpkg_execute_required_process( + COMMAND "${CURRENT_BUILDTREES_DIR}/src/boost_1_60_0/bootstrap.bat" + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src/boost_1_60_0 + LOGNAME bootstrap + ) +endif() +message(STATUS "Bootstrapping done") + +set(B2_OPTIONS + --toolset=msvc + -j$ENV{NUMBER_OF_PROCESSORS} + -q + --without-python + threading=multi + link=shared + runtime-link=shared + --debug-configuration +) +if(TRIPLET_SYSTEM_ARCH MATCHES "x64") + list(APPEND B2_OPTIONS address-model=64) +endif() +if(TRIPLET_SYSTEM_NAME MATCHES "WindowsStore") + list(APPEND B2_OPTIONS windows-api=store) + set(ENV{BOOST_BUILD_PATH} ${CMAKE_CURRENT_LIST_DIR}) +endif() + +message(STATUS "Building ${TARGET_TRIPLET}-rel") +vcpkg_execute_required_process( + COMMAND "${CURRENT_BUILDTREES_DIR}/src/boost_1_60_0/b2.exe" + --stagedir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage + --build-dir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + ${B2_OPTIONS} + variant=release + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src/boost_1_60_0 + LOGNAME build-${TARGET_TRIPLET}-rel +) +message(STATUS "Building ${TARGET_TRIPLET}-rel done") +message(STATUS "Building ${TARGET_TRIPLET}-dbg") +vcpkg_execute_required_process( + COMMAND "${CURRENT_BUILDTREES_DIR}/src/boost_1_60_0/b2.exe" + --stagedir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage + --build-dir=${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + ${B2_OPTIONS} + variant=debug + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src/boost_1_60_0 + LOGNAME build-${TARGET_TRIPLET}-dbg +) +message(STATUS "Building ${TARGET_TRIPLET}-dbg done") + +message(STATUS "Packaging headers") +file( + COPY ${CURRENT_BUILDTREES_DIR}/src/boost_1_60_0/boost + DESTINATION ${CURRENT_PACKAGES_DIR}/include + PATTERN "config/user.hpp" EXCLUDE +) +file(COPY ${CURRENT_BUILDTREES_DIR}/src/boost_1_60_0/boost/config/user.hpp + DESTINATION ${CURRENT_PACKAGES_DIR}/include/boost/config/ +) +file(APPEND ${CURRENT_PACKAGES_DIR}/include/boost/config/user.hpp + "\n#define BOOST_ALL_DYN_LINK\n" +) +file(INSTALL ${CURRENT_BUILDTREES_DIR}/src/boost_1_60_0/LICENSE_1_0.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/boost RENAME copyright) +message(STATUS "Packaging headers done") + +message(STATUS "Packaging ${TARGET_TRIPLET}-rel") +file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage/lib/ + DESTINATION ${CURRENT_PACKAGES_DIR}/lib + FILES_MATCHING PATTERN "*.lib") +file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel/stage/lib/ + DESTINATION ${CURRENT_PACKAGES_DIR}/bin + FILES_MATCHING PATTERN "*.dll") +message(STATUS "Packaging ${TARGET_TRIPLET}-rel done") + +message(STATUS "Packaging ${TARGET_TRIPLET}-dbg") +file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage/lib/ + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib + FILES_MATCHING PATTERN "*.lib") +file(INSTALL ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg/stage/lib/ + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin + FILES_MATCHING PATTERN "*.dll") +message(STATUS "Packaging ${TARGET_TRIPLET}-dbg done") + +vcpkg_copy_pdbs() \ No newline at end of file diff --git a/ports/boost/user-config.jam b/ports/boost/user-config.jam new file mode 100644 index 00000000000000..58184920a6f638 --- /dev/null +++ b/ports/boost/user-config.jam @@ -0,0 +1,10 @@ +using msvc : 14.0 : : +"\"/AIC:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\store\\references\"" +/appcontainer +/nodefaultlibs +WindowsApp.lib +release:vcruntime.lib +debug:vcruntimed.lib +release:ucrt.lib +debug:ucrtd.lib +; diff --git a/ports/cocos2d/portfile.cmake b/ports/cocos2d/portfile.cmake new file mode 100644 index 00000000000000..b39180b400aa3d --- /dev/null +++ b/ports/cocos2d/portfile.cmake @@ -0,0 +1,47 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE_FILE + URL "https://github.com/cocos2d/cocos2d-x/archive/cocos2d-x-3.10.tar.gz" + FILENAME "cocos2d-x-3.10.tar.gz" + MD5 7c67068675ad28374448e844b0e463ff +) +vcpkg_download_distfile(DEPS_ARCHIVE_FILE + URL "https://github.com/cocos2d/cocos2d-x-3rd-party-libs-bin/archive/v3-deps-79.zip" + FILENAME "cocos2d-x-v3-deps-79.zip" + MD5 5d88ff867205080b9ee8da532437e891 +) + +vcpkg_extract_source_archive(${ARCHIVE_FILE}) + +if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/src/cocos2d-x-cocos2d-x-3.10/external/unzip) + message(STATUS "Extracting dependencies ${DEPS_ARCHIVE_FILE}") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/deps) + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} -E tar xjf ${DEPS_ARCHIVE_FILE} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/deps + LOGNAME extract-deps + ) + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/src/cocos2d-x-cocos2d-x-3.10/external) + file(RENAME ${CURRENT_BUILDTREES_DIR}/deps/cocos2d-x-3rd-party-libs-bin-3-deps-79 ${CURRENT_BUILDTREES_DIR}/src/cocos2d-x-cocos2d-x-3.10/external) +endif() +message(STATUS "Extracting dependencies done") + +file(REMOVE ${CURRENT_BUILDTREES_DIR}/src/cocos2d-x-cocos2d-x-3.10/cmake/Modules/FindGLFW3.cmake) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/cocos2d-x-cocos2d-x-3.10 + OPTIONS + -DUSE_CHIPMUNK=OFF + -DUSE_BOX2D=OFF + -DUSE_BULLET=OFF + -DUSE_RECAST=OFF + -DUSE_WEBP=OFF + -DBUILD_SHARED_LIBS=ON + -DUSE_PREBUILT_LIBS=OFF +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(INSTALL ${CURRENT_BUILDTREES_DIR}/src/cocos2d-x-cocos2d-x-3.10/licenses/LICENSE_cocos2d-x.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/cocos2d-x RENAME copyright) +vcpkg_copy_pdbs() + diff --git a/ports/cpprestsdk/0001-Use-find_package-on-Windows.-Enable-install-target-f.patch b/ports/cpprestsdk/0001-Use-find_package-on-Windows.-Enable-install-target-f.patch new file mode 100644 index 00000000000000..40e6a5ce35118a --- /dev/null +++ b/ports/cpprestsdk/0001-Use-find_package-on-Windows.-Enable-install-target-f.patch @@ -0,0 +1,107 @@ +From cc9d3ca4d1d16134a1976b89b58b11372a2798d5 Mon Sep 17 00:00:00 2001 +From: Robert Schumacher +Date: Wed, 4 May 2016 21:37:23 -0700 +Subject: [PATCH] Use find_package on Windows. Enable 'install' target for all + systems. + +--- + Release/CMakeLists.txt | 48 ++++++++++++++-------------------------------- + Release/src/CMakeLists.txt | 13 +++++++------ + 2 files changed, 21 insertions(+), 40 deletions(-) + +diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt +index cbe840b..3045948 100644 +--- a/Release/CMakeLists.txt ++++ b/Release/CMakeLists.txt +@@ -89,15 +89,6 @@ elseif(UNIX) # This includes OSX + + option(BUILD_SHARED_LIBS "Build shared Libraries." ON) + option(BUILD_SAMPLES "Build samples." ON) +- option(CASA_INSTALL_HEADERS "Install header files." ON) +- if(CASA_INSTALL_HEADERS) +- file(GLOB CASA_HEADERS_CPPREST include/cpprest/*.hpp include/cpprest/*.h include/cpprest/*.dat) +- install(FILES ${CASA_HEADERS_CPPREST} DESTINATION include/cpprest) +- file(GLOB CASA_HEADERS_PPLX include/pplx/*.hpp include/pplx/*.h) +- install(FILES ${CASA_HEADERS_PPLX} DESTINATION include/pplx) +- file(GLOB CASA_HEADERS_DETAILS include/cpprest/details/*.hpp include/cpprest/details/*.h include/cpprest/details/*.dat) +- install(FILES ${CASA_HEADERS_DETAILS} DESTINATION include/cpprest/details) +- endif() + elseif(WIN32) + option(BUILD_SHARED_LIBS "Build shared Libraries." ON) + option(BUILD_SAMPLES "Build samples." ON) +@@ -114,36 +105,25 @@ elseif(WIN32) + endif() + add_definitions(${Casablanca_DEFINITIONS} -D_WINSOCK_DEPRECATED_NO_WARNINGS -DWIN32) + +- if (NOT CPPREST_EXCLUDE_WEBSOCKETS) +- set(NUGET_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../packages") +- set(PACKAGE_PATHS) +- list(APPEND PACKAGE_PATHS "${NUGET_PATH}/boost.1.58.0.0/") +- list(APPEND PACKAGE_PATHS "${NUGET_PATH}/boost_system-vc140.1.58.0-vs140rc/") +- list(APPEND PACKAGE_PATHS "${NUGET_PATH}/boost_date_time-vc140.1.58.0-vs140rc/") +- list(APPEND PACKAGE_PATHS "${NUGET_PATH}/boost_regex-vc140.1.58.0-vs140rc/") +- list(APPEND PACKAGE_PATHS "${NUGET_PATH}/openssl.v140.windesktop.msvcstl.static.rt-dyn.x64.1.0.2.1/") +- list(APPEND PACKAGE_PATHS "${NUGET_PATH}/zlib.v140.windesktop.msvcstl.static.rt-dyn.1.2.8.8/") +- +- if (NOT WINDOWS_STORE AND NOT WINDOWS_PHONE) +- find_library(Boost_SYSTEM_LIBRARY libboost_system-vc140-mt-gd-1_58.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/address-model-64/lib) +- find_library(Boost_DATE_TIME_LIBRARY libboost_date_time-vc140-mt-gd-1_58.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/address-model-64/lib) +- find_library(Boost_REGEX_LIBRARY libboost_regex-vc140-mt-gd-1_58.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/address-model-64/lib) +- set(Boost_LIBRARIES ${Boost_REGEX_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_DATE_TIME_LIBRARY}) +- +- find_library(OpenSSL_libeay_LIBRARY libeay32.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/v140/windesktop/msvcstl/static/rt-dyn/x64/debug) +- find_library(OpenSSL_ssleay_LIBRARY ssleay32.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/v140/windesktop/msvcstl/static/rt-dyn/x64/debug) +- find_library(ZLIB_LIBRARY zlibstaticd.lib PATHS ${PACKAGE_PATHS} PATH_SUFFIXES lib/native/v140/windesktop/msvcstl/static/rt-dyn/x64/debug) +- set(OPENSSL_LIBRARIES ${OpenSSL_ssleay_LIBRARY} ${OpenSSL_libeay_LIBRARY} ${ZLIB_LIBRARY}) +- +- set(OPENSSL_INCLUDE_DIR "${NUGET_PATH}/openssl.v140.windesktop.msvcstl.static.rt-dyn.x64.1.0.2.1/build/native/include") +- endif() +- +- set(Boost_INCLUDE_DIR "${NUGET_PATH}/boost.1.58.0.0/lib/native/include") ++ if (NOT CPPREST_EXCLUDE_WEBSOCKETS AND NOT WINDOWS_STORE) ++ find_package(ZLIB REQUIRED) ++ find_package(OpenSSL REQUIRED) ++ find_package(Boost REQUIRED COMPONENTS regex system date_time) + endif() + else() + message(FATAL_ERROR "-- Unsupported Build Platform.") + endif() + ++option(CASA_INSTALL_HEADERS "Install header files." ON) ++if(CASA_INSTALL_HEADERS) ++ file(GLOB CASA_HEADERS_CPPREST include/cpprest/*.hpp include/cpprest/*.h include/cpprest/*.dat) ++ install(FILES ${CASA_HEADERS_CPPREST} DESTINATION include/cpprest) ++ file(GLOB CASA_HEADERS_PPLX include/pplx/*.hpp include/pplx/*.h) ++ install(FILES ${CASA_HEADERS_PPLX} DESTINATION include/pplx) ++ file(GLOB CASA_HEADERS_DETAILS include/cpprest/details/*.hpp include/cpprest/details/*.h include/cpprest/details/*.dat) ++ install(FILES ${CASA_HEADERS_DETAILS} DESTINATION include/cpprest/details) ++endif() ++ + # Compiler (not platform) specific settings + if(ANDROID) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-strict-aliasing") +diff --git a/Release/src/CMakeLists.txt b/Release/src/CMakeLists.txt +index cf086ed..3e5fffa 100644 +--- a/Release/src/CMakeLists.txt ++++ b/Release/src/CMakeLists.txt +@@ -144,10 +144,11 @@ elseif(ANDROID) + else() + set_target_properties(cpprest PROPERTIES + SOVERSION ${CPPREST_VERSION_MAJOR}.${CPPREST_VERSION_MINOR}) +- +- install( +- TARGETS cpprest +- LIBRARY DESTINATION lib +- ARCHIVE DESTINATION lib +- ) + endif() ++ ++install( ++ TARGETS cpprest ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++ ) +-- +2.8.1.windows.1 + diff --git a/ports/cpprestsdk/CONTROL b/ports/cpprestsdk/CONTROL new file mode 100644 index 00000000000000..eca83755ba9d4b --- /dev/null +++ b/ports/cpprestsdk/CONTROL @@ -0,0 +1,4 @@ +Source: cpprestsdk +Version: 2.8 +Description: C++11 JSON, REST, and OAuth library + The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services. \ No newline at end of file diff --git a/ports/cpprestsdk/portfile.cmake b/ports/cpprestsdk/portfile.cmake new file mode 100644 index 00000000000000..ba9ea77e325aae --- /dev/null +++ b/ports/cpprestsdk/portfile.cmake @@ -0,0 +1,50 @@ +include(vcpkg_common_functions) +find_program(GIT git) + +set(GIT_URL "https://github.com/Microsoft/cpprestsdk") +set(GIT_REF "3542f07") + +if(NOT EXISTS "${DOWNLOADS}/cpprestsdk.git") + message(STATUS "Cloning") + vcpkg_execute_required_process( + COMMAND ${GIT} clone --bare ${GIT_URL} ${DOWNLOADS}/cpprestsdk.git + WORKING_DIRECTORY ${DOWNLOADS} + LOGNAME clone + ) +endif() +message(STATUS "Cloning done") + +if(NOT EXISTS "${CURRENT_BUILDTREES_DIR}/src/.git") + message(STATUS "Adding worktree and patching") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}) + vcpkg_execute_required_process( + COMMAND ${GIT} worktree add -f --detach ${CURRENT_BUILDTREES_DIR}/src ${GIT_REF} + WORKING_DIRECTORY ${DOWNLOADS}/cpprestsdk.git + LOGNAME worktree + ) + message(STATUS "Patching") + vcpkg_execute_required_process( + COMMAND ${GIT} apply ${CMAKE_CURRENT_LIST_DIR}/0001-Use-find_package-on-Windows.-Enable-install-target-f.patch --ignore-whitespace --whitespace=fix + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src + LOGNAME patch + ) +endif() +message(STATUS "Adding worktree and patching done") + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/Release + OPTIONS + -DBUILD_TESTS=OFF + -DBUILD_SAMPLES=OFF + -DCPPREST_EXCLUDE_WEBSOCKETS=ON + OPTIONS_DEBUG + -DCASA_INSTALL_HEADERS=OFF +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(COPY ${CURRENT_BUILDTREES_DIR}/src/license.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/cpprestsdk) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/cpprestsdk/license.txt ${CURRENT_PACKAGES_DIR}/share/cpprestsdk/copyright) +vcpkg_copy_pdbs() + diff --git a/ports/curl/CONTROL b/ports/curl/CONTROL new file mode 100644 index 00000000000000..259803ab776f36 --- /dev/null +++ b/ports/curl/CONTROL @@ -0,0 +1,3 @@ +Source: curl +Version: 7.48.0 +Description: A library for transferring data with URLs \ No newline at end of file diff --git a/ports/curl/portfile.cmake b/ports/curl/portfile.cmake new file mode 100644 index 00000000000000..fc111574170e4f --- /dev/null +++ b/ports/curl/portfile.cmake @@ -0,0 +1,24 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE_FILE + URL "https://curl.haxx.se/download/curl-7.48.0.tar.bz2" + FILENAME "curl-7.48.0.tar.bz2" + MD5 d42e0fc34a5cace5739631cc040974fe +) +vcpkg_extract_source_archive(${ARCHIVE_FILE}) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/curl-7.48.0 + OPTIONS + -DBUILD_CURL_TESTS=OFF + -DBUILD_CURL_EXE=OFF + -DENABLE_MANUAL=OFF + OPTIONS_DEBUG + -DENABLE_DEBUG=ON +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(INSTALL ${CURRENT_BUILDTREES_DIR}/src/curl-7.48.0/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/curl RENAME copyright) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +vcpkg_copy_pdbs() \ No newline at end of file diff --git a/ports/expat/CONTROL b/ports/expat/CONTROL new file mode 100644 index 00000000000000..86d44652978720 --- /dev/null +++ b/ports/expat/CONTROL @@ -0,0 +1,3 @@ +Source: expat +Version: 2.1.1 +Description: XML parser library written in C \ No newline at end of file diff --git a/ports/expat/portfile.cmake b/ports/expat/portfile.cmake new file mode 100644 index 00000000000000..9a396774d3df6e --- /dev/null +++ b/ports/expat/portfile.cmake @@ -0,0 +1,22 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE_FILE + URL "http://downloads.sourceforge.net/project/expat/expat/2.1.1/expat-2.1.1.tar.bz2" + FILENAME "expat-2.1.1.tar.bz2" + MD5 7380a64a8e3a9d66a9887b01d0d7ea81 +) +vcpkg_extract_source_archive(${ARCHIVE_FILE}) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/expat-2.1.1 + OPTIONS + -DBUILD_examples=OFF + -DBUILD_tests=OFF + -DBUILD_tools=OFF +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include ${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig ${CURRENT_PACKAGES_DIR}/lib/pkgconfig) +file(INSTALL ${CURRENT_BUILDTREES_DIR}/src/expat-2.1.1/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/expat RENAME copyright) +vcpkg_copy_pdbs() \ No newline at end of file diff --git a/ports/freetype/0001-Support-Windows-DLLs-via-CMAKE_WINDOWS_EXPORT_ALL_SY.patch b/ports/freetype/0001-Support-Windows-DLLs-via-CMAKE_WINDOWS_EXPORT_ALL_SY.patch new file mode 100644 index 00000000000000..34318ad61c7673 --- /dev/null +++ b/ports/freetype/0001-Support-Windows-DLLs-via-CMAKE_WINDOWS_EXPORT_ALL_SY.patch @@ -0,0 +1,25 @@ +From 7286c233834117404f400e3cfd5500610ca56d9a Mon Sep 17 00:00:00 2001 +From: Robert Schumacher +Date: Sat, 7 May 2016 02:10:45 -0700 +Subject: [PATCH] Support Windows DLLs via CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS + +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f02ee51..774737d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -115,7 +115,7 @@ project(freetype) + + + if (WIN32 AND NOT MINGW AND BUILD_SHARED_LIBS) +- message(FATAL_ERROR "Building shared libraries on Windows needs MinGW") ++ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + endif () + + # Disallow in-source builds +-- +2.8.1.windows.1 + diff --git a/ports/freetype/CONTROL b/ports/freetype/CONTROL new file mode 100644 index 00000000000000..87454460eaae47 --- /dev/null +++ b/ports/freetype/CONTROL @@ -0,0 +1,3 @@ +Source: freetype +Version: 2.6.3 +Description: A library to render fonts. \ No newline at end of file diff --git a/ports/freetype/portfile.cmake b/ports/freetype/portfile.cmake new file mode 100644 index 00000000000000..641d2e5f9ed188 --- /dev/null +++ b/ports/freetype/portfile.cmake @@ -0,0 +1,41 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "http://download.savannah.gnu.org/releases/freetype/freetype-2.6.3.tar.bz2" + FILENAME "freetype-2.6.3.tar.bz2" + MD5 0037b25a8c090bc8a1218e867b32beb1 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_apply_patches( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/freetype-2.6.3 + PATCHES ${CMAKE_CURRENT_LIST_DIR}/0001-Support-Windows-DLLs-via-CMAKE_WINDOWS_EXPORT_ALL_SY.patch +) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/freetype-2.6.3 + OPTIONS + -DBUILD_SHARED_LIBS=ON +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include) +file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/include ${CURRENT_PACKAGES_DIR}/share) +file(RENAME ${CURRENT_PACKAGES_DIR}/debug/include/freetype2/freetype ${CURRENT_PACKAGES_DIR}/include/freetype2) +file(RENAME ${CURRENT_PACKAGES_DIR}/debug/include/freetype2/ft2build.h ${CURRENT_PACKAGES_DIR}/include/freetype2/ft2build.h) +file(RENAME ${CURRENT_PACKAGES_DIR}/lib/cmake/freetype ${CURRENT_PACKAGES_DIR}/share/freetype) +file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/cmake/freetype/freetype-config-debug.cmake ${CURRENT_PACKAGES_DIR}/share/freetype/freetype-config-debug.cmake) + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/cmake) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/lib/cmake) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(COPY + ${CURRENT_BUILDTREES_DIR}/src/freetype-2.6.3/docs/LICENSE.TXT + ${CURRENT_BUILDTREES_DIR}/src/freetype-2.6.3/docs/FTL.TXT + ${CURRENT_BUILDTREES_DIR}/src/freetype-2.6.3/docs/GPLv2.TXT + DESTINATION ${CURRENT_PACKAGES_DIR}/share/freetype +) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/freetype/LICENSE.TXT ${CURRENT_PACKAGES_DIR}/share/freetype/copyright) +vcpkg_copy_pdbs() + diff --git a/ports/glew/CONTROL b/ports/glew/CONTROL new file mode 100644 index 00000000000000..f38f2dc406a097 --- /dev/null +++ b/ports/glew/CONTROL @@ -0,0 +1,3 @@ +Source: glew +Version: 1.13.0 +Description: The OpenGL Extension Wrangler Library (GLEW) is a cross-platform open-source C/C++ extension loading library. \ No newline at end of file diff --git a/ports/glew/portfile.cmake b/ports/glew/portfile.cmake new file mode 100644 index 00000000000000..320db8043225b6 --- /dev/null +++ b/ports/glew/portfile.cmake @@ -0,0 +1,53 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE_FILE + URL "http://downloads.sourceforge.net/project/glew/glew/1.13.0/glew-1.13.0.tgz" + FILENAME "glew-1.13.0.tgz" + MD5 7cbada3166d2aadfc4169c4283701066 +) +vcpkg_extract_source_archive(${ARCHIVE_FILE}) + +if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/build/vc12/glew_shared14.vcxproj) + message(STATUS "Upgrading projects") + file(READ ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/build/vc12/glew_shared.vcxproj PROJ) + string(REPLACE + "v120" + "v140" + PROJ ${PROJ}) + string(REPLACE + "opengl32.lib%" + "opengl32.lib\;%" + PROJ ${PROJ}) + file(WRITE ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/build/vc12/glew_shared14.vcxproj ${PROJ}) +endif() +message(STATUS "Upgrading projects done") + +vcpkg_build_msbuild( + PROJECT_PATH ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/build/vc12/glew_shared14.vcxproj +) + +message(STATUS "Installing") +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/bin/Debug/Win32/glew32d.dll + ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/bin/Debug/Win32/glew32d.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin +) +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/bin/Release/Win32/glew32.dll + ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/bin/Release/Win32/glew32.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/bin +) +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/lib/Debug/Win32/glew32d.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib +) +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/lib/Release/Win32/glew32.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/lib +) +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/include/GL + DESTINATION ${CURRENT_PACKAGES_DIR}/include +) +file(INSTALL ${CURRENT_BUILDTREES_DIR}/src/glew-1.13.0/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/glew RENAME copyright) +vcpkg_copy_pdbs() +message(STATUS "Installing done") diff --git a/ports/glfw3/CONTROL b/ports/glfw3/CONTROL new file mode 100644 index 00000000000000..0015a9105fc8bb --- /dev/null +++ b/ports/glfw3/CONTROL @@ -0,0 +1,3 @@ +Source: glfw3 +Version: 3.1.2 +Description: GLFW is a free, Open Source, multi-platform library for OpenGL, OpenGL ES and Vulkan application development. It provides a simple, platform-independent API for creating windows, contexts and surfaces, reading input, handling events, etc. \ No newline at end of file diff --git a/ports/glfw3/portfile.cmake b/ports/glfw3/portfile.cmake new file mode 100644 index 00000000000000..cbfa6134db3eda --- /dev/null +++ b/ports/glfw3/portfile.cmake @@ -0,0 +1,58 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "https://github.com/glfw/glfw/releases/download/3.1.2/glfw-3.1.2.zip" + FILENAME "glfw-3.1.2.zip" + MD5 8023327bfe979b3fe735e449e2f54842 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/patch.stamp) + file(READ ${CURRENT_BUILDTREES_DIR}/src/glfw-3.1.2/src/glfw3Config.cmake.in CONFIG) + string(REPLACE "\"@GLFW_LIB_NAME@\"" "NAMES @GLFW_LIB_NAME@ @GLFW_LIB_NAME@dll" + CONFIG ${CONFIG} + ) + string(REPLACE "@PACKAGE_CMAKE_INSTALL_PREFIX@" "@PACKAGE_CMAKE_INSTALL_PREFIX@/../.." + CONFIG ${CONFIG} + ) + file(WRITE ${CURRENT_BUILDTREES_DIR}/src/glfw-3.1.2/src/glfw3Config.cmake.in ${CONFIG}) + file(APPEND ${CURRENT_BUILDTREES_DIR}/src/glfw-3.1.2/src/glfw3Config.cmake.in "set(GLFW3_LIBRARIES \${GLFW3_LIBRARY})\n") + file(WRITE ${CURRENT_BUILDTREES_DIR}/patch.stamp) +endif() + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/glfw-3.1.2 + OPTIONS + -DBUILD_SHARED_LIBS=ON + -DGLFW_BUILD_EXAMPLES=OFF + -DGLFW_BUILD_TESTS=OFF + -DGLFW_BUILD_DOCS=OFF + -DPACKAGE_CMAKE_INSTALL_PREFIX=\${CMAKE_CURRENT_LIST_DIR}/../.. + # OPTIONS_RELEASE -DOPTIMIZE=1 + # OPTIONS_DEBUG -DDEBUGGABLE=1 +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(MAKE_DIRECTORY + ${CURRENT_PACKAGES_DIR}/bin + ${CURRENT_PACKAGES_DIR}/debug/bin + ${CURRENT_PACKAGES_DIR}/share +) +file(RENAME ${CURRENT_PACKAGES_DIR}/lib/glfw3.dll ${CURRENT_PACKAGES_DIR}/bin/glfw3.dll) +file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/glfw3.dll ${CURRENT_PACKAGES_DIR}/debug/bin/glfw3.dll) + +file(RENAME ${CURRENT_PACKAGES_DIR}/lib/cmake/glfw ${CURRENT_PACKAGES_DIR}/share/glfw3) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/lib/cmake) +file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/cmake/glfw/glfwTargets-debug.cmake ${CURRENT_PACKAGES_DIR}/share/glfw3/glfwTargets-debug.cmake) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/lib/cmake) + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/glfw3.lib) +file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/lib/glfw3.lib) + +file(COPY ${CURRENT_BUILDTREES_DIR}/src/glfw-3.1.2/COPYING.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/glfw3) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/glfw3/COPYING.txt ${CURRENT_PACKAGES_DIR}/share/glfw3/copyright) +vcpkg_copy_pdbs() + diff --git a/ports/libjpeg-turbo/CONTROL b/ports/libjpeg-turbo/CONTROL new file mode 100644 index 00000000000000..9c5ee1d0752b42 --- /dev/null +++ b/ports/libjpeg-turbo/CONTROL @@ -0,0 +1,3 @@ +Source: libjpeg-turbo +Version: 1.4.90-1 +Description: libjpeg-turbo is a JPEG image codec that uses SIMD instructions (MMX, SSE2, NEON, AltiVec) to accelerate baseline JPEG compression and decompression on x86, x86-64, ARM, and PowerPC systems. diff --git a/ports/libjpeg-turbo/add-options-for-exes-docs-headers.patch b/ports/libjpeg-turbo/add-options-for-exes-docs-headers.patch new file mode 100644 index 00000000000000..5be2594c791cff --- /dev/null +++ b/ports/libjpeg-turbo/add-options-for-exes-docs-headers.patch @@ -0,0 +1,201 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bfb7661..5373cd7 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -55,6 +55,9 @@ option(WITH_JAVA "Build Java wrapper for the TurboJPEG library" FALSE) + option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_SIMD=0 WITH_TURBOJPEG=0 WITH_ARITH_ENC=0 WITH_ARITH_DEC=0)" FALSE) + option(ENABLE_STATIC "Build static libraries" TRUE) + option(ENABLE_SHARED "Build shared libraries" TRUE) ++option(ENABLE_EXECUTABLES "Build executables" TRUE) ++option(INSTALL_DOCS "Install doc files" TRUE) ++option(INSTALL_HEADERS "Install header files" TRUE) + + if(WITH_12BIT) + set(WITH_SIMD FALSE) +@@ -264,14 +267,16 @@ if(WITH_TURBOJPEG) + target_link_libraries(turbojpeg jpeg-static) + set_target_properties(turbojpeg PROPERTIES LINK_INTERFACE_LIBRARIES "") + +- add_executable(tjunittest tjunittest.c tjutil.c) +- target_link_libraries(tjunittest turbojpeg) ++ if(ENABLE_EXECUTABLES) ++ add_executable(tjunittest tjunittest.c tjutil.c) ++ target_link_libraries(tjunittest turbojpeg) + +- add_executable(tjbench tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c +- wrppm.c) +- target_link_libraries(tjbench turbojpeg jpeg-static) +- set_property(TARGET tjbench PROPERTY COMPILE_FLAGS +- "-DBMP_SUPPORTED -DPPM_SUPPORTED") ++ add_executable(tjbench tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c wrbmp.c ++ wrppm.c) ++ target_link_libraries(tjbench turbojpeg jpeg-static) ++ set_property(TARGET tjbench PROPERTY COMPILE_FLAGS ++ "-DBMP_SUPPORTED -DPPM_SUPPORTED") ++ endif() + endif() + + if(ENABLE_STATIC) +@@ -284,14 +289,16 @@ if(WITH_TURBOJPEG) + add_dependencies(turbojpeg-static simd) + endif() + +- add_executable(tjunittest-static tjunittest.c tjutil.c) +- target_link_libraries(tjunittest-static turbojpeg-static) ++ if(ENABLE_EXECUTABLES) ++ add_executable(tjunittest-static tjunittest.c tjutil.c) ++ target_link_libraries(tjunittest-static turbojpeg-static) + +- add_executable(tjbench-static tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c +- wrbmp.c wrppm.c) +- target_link_libraries(tjbench-static turbojpeg-static jpeg-static) +- set_property(TARGET tjbench-static PROPERTY COMPILE_FLAGS +- "-DBMP_SUPPORTED -DPPM_SUPPORTED") ++ add_executable(tjbench-static tjbench.c bmp.c tjutil.c rdbmp.c rdppm.c ++ wrbmp.c wrppm.c) ++ target_link_libraries(tjbench-static turbojpeg-static jpeg-static) ++ set_property(TARGET tjbench-static PROPERTY COMPILE_FLAGS ++ "-DBMP_SUPPORTED -DPPM_SUPPORTED") ++ endif() + endif() + endif() + +@@ -303,7 +310,7 @@ else() + set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c) + endif() + +-if(ENABLE_STATIC) ++if(ENABLE_STATIC AND ENABLE_EXECUTABLES) + add_executable(cjpeg-static cjpeg.c cdjpeg.c rdgif.c rdppm.c rdswitch.c + ${CJPEG_BMP_SOURCES}) + set_property(TARGET cjpeg-static PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) +@@ -319,10 +326,11 @@ if(ENABLE_STATIC) + set_property(TARGET jpegtran-static PROPERTY COMPILE_FLAGS "-DUSE_SETMODE") + endif() + +-add_executable(rdjpgcom rdjpgcom.c) +- +-add_executable(wrjpgcom wrjpgcom.c) ++if(ENABLE_EXECUTABLES) ++ add_executable(rdjpgcom rdjpgcom.c) + ++ add_executable(wrjpgcom wrjpgcom.c) ++endif() + + # + # Tests +@@ -880,24 +888,30 @@ add_custom_target(installer + + if(WITH_TURBOJPEG) + if(ENABLE_SHARED) +- install(TARGETS turbojpeg tjbench ++ install(TARGETS turbojpeg + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin) ++ if(ENABLE_EXECUTABLES) ++ install(TARGETS tjbench ++ RUNTIME DESTINATION bin) ++ endif() + endif() + if(ENABLE_STATIC) + install(TARGETS turbojpeg-static ARCHIVE DESTINATION lib) +- if(NOT ENABLE_SHARED) ++ if(NOT ENABLE_SHARED AND ENABLE_EXECUTABLES) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/tjbench-static.exe + DESTINATION bin RENAME tjbench.exe) + endif() + endif() +- install(FILES ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include) ++ if(INSTALL_HEADERS) ++ install(FILES ${CMAKE_SOURCE_DIR}/turbojpeg.h DESTINATION include) ++ endif() + endif() + + if(ENABLE_STATIC) + install(TARGETS jpeg-static ARCHIVE DESTINATION lib) +- if(NOT ENABLE_SHARED) ++ if(NOT ENABLE_SHARED AND ENABLE_EXECUTABLES) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/cjpeg-static.exe + DESTINATION bin RENAME cjpeg.exe) + install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/djpeg-static.exe +@@ -907,14 +921,20 @@ if(ENABLE_STATIC) + endif() + endif() + +-install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION bin) ++if(ENABLE_EXECUTABLES) ++ install(TARGETS rdjpgcom wrjpgcom RUNTIME DESTINATION bin) ++endif() + +-install(FILES ${CMAKE_SOURCE_DIR}/README.ijg ${CMAKE_SOURCE_DIR}/README.md +- ${CMAKE_SOURCE_DIR}/example.c ${CMAKE_SOURCE_DIR}/libjpeg.txt +- ${CMAKE_SOURCE_DIR}/structure.txt ${CMAKE_SOURCE_DIR}/usage.txt +- ${CMAKE_SOURCE_DIR}/wizard.txt +- DESTINATION doc) ++if(INSTALL_DOCS) ++ install(FILES ${CMAKE_SOURCE_DIR}/README.ijg ${CMAKE_SOURCE_DIR}/README.md ++ ${CMAKE_SOURCE_DIR}/example.c ${CMAKE_SOURCE_DIR}/libjpeg.txt ++ ${CMAKE_SOURCE_DIR}/structure.txt ${CMAKE_SOURCE_DIR}/usage.txt ++ ${CMAKE_SOURCE_DIR}/wizard.txt ++ DESTINATION doc) ++endif() + +-install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h +- ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h +- DESTINATION include) ++if(INSTALL_HEADERS) ++ install(FILES ${CMAKE_BINARY_DIR}/jconfig.h ${CMAKE_SOURCE_DIR}/jerror.h ++ ${CMAKE_SOURCE_DIR}/jmorecfg.h ${CMAKE_SOURCE_DIR}/jpeglib.h ++ DESTINATION include) ++endif() +diff --git a/sharedlib/CMakeLists.txt b/sharedlib/CMakeLists.txt +index d423cce..9da7c6e 100644 +--- a/sharedlib/CMakeLists.txt ++++ b/sharedlib/CMakeLists.txt +@@ -50,24 +50,31 @@ else() + set(DJPEG_BMP_SOURCES ../wrbmp.c ../wrtarga.c) + endif() + +-add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c +- ../rdswitch.c ${CJPEG_BMP_SOURCES}) +-set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) +-target_link_libraries(cjpeg jpeg) ++if(ENABLE_EXECUTABLES) ++ add_executable(cjpeg ../cjpeg.c ../cdjpeg.c ../rdgif.c ../rdppm.c ++ ../rdswitch.c ${CJPEG_BMP_SOURCES}) ++ set_property(TARGET cjpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) ++ target_link_libraries(cjpeg jpeg) + +-add_executable(djpeg ../djpeg.c ../cdjpeg.c ../rdcolmap.c ../rdswitch.c +- ../wrgif.c ../wrppm.c ${DJPEG_BMP_SOURCES}) +-set_property(TARGET djpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) +-target_link_libraries(djpeg jpeg) ++ add_executable(djpeg ../djpeg.c ../cdjpeg.c ../rdcolmap.c ../rdswitch.c ++ ../wrgif.c ../wrppm.c ${DJPEG_BMP_SOURCES}) ++ set_property(TARGET djpeg PROPERTY COMPILE_FLAGS ${COMPILE_FLAGS}) ++ target_link_libraries(djpeg jpeg) + +-add_executable(jpegtran ../jpegtran.c ../cdjpeg.c ../rdswitch.c ../transupp.c) +-target_link_libraries(jpegtran jpeg) +-set_property(TARGET jpegtran PROPERTY COMPILE_FLAGS "-DUSE_SETMODE") ++ add_executable(jpegtran ../jpegtran.c ../cdjpeg.c ../rdswitch.c ../transupp.c) ++ target_link_libraries(jpegtran jpeg) ++ set_property(TARGET jpegtran PROPERTY COMPILE_FLAGS "-DUSE_SETMODE") + +-add_executable(jcstest ../jcstest.c) +-target_link_libraries(jcstest jpeg) ++ add_executable(jcstest ../jcstest.c) ++ target_link_libraries(jcstest jpeg) + +-install(TARGETS jpeg cjpeg djpeg jpegtran ++ install(TARGETS cjpeg djpeg jpegtran ++ ARCHIVE DESTINATION lib ++ LIBRARY DESTINATION lib ++ RUNTIME DESTINATION bin) ++endif() ++ ++install(TARGETS jpeg + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin) diff --git a/ports/libjpeg-turbo/portfile.cmake b/ports/libjpeg-turbo/portfile.cmake new file mode 100644 index 00000000000000..82e5c6ab105d4e --- /dev/null +++ b/ports/libjpeg-turbo/portfile.cmake @@ -0,0 +1,38 @@ +include(vcpkg_common_functions) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libjpeg-turbo-1.4.90) + +vcpkg_download_distfile(ARCHIVE + URL "https://github.com/libjpeg-turbo/libjpeg-turbo/archive/1.4.90.zip" + FILENAME "libjpeg-turbo-1.4.90.zip" + MD5 dcd49a7100e41870faae988f608471af +) +vcpkg_extract_source_archive(${ARCHIVE}) +vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES "${CMAKE_CURRENT_LIST_DIR}/add-options-for-exes-docs-headers.patch" +) + +vcpkg_find_acquire_program(NASM) +get_filename_component(NASM_EXE_PATH ${NASM} DIRECTORY) +set(ENV{PATH} "${NASM_EXE_PATH};$ENV{PATH}") + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + OPTIONS + -DENABLE_STATIC=OFF + -DWITH_CRT_DLL=ON + -DENABLE_EXECUTABLES=OFF + -DINSTALL_DOCS=OFF + # OPTIONS_RELEASE -DOPTIMIZE=1 + OPTIONS_DEBUG -DINSTALL_HEADERS=OFF +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(COPY + ${SOURCE_PATH}/LICENSE.md + DESTINATION ${CURRENT_PACKAGES_DIR}/share/libjpeg-turbo +) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/libjpeg-turbo/LICENSE.md ${CURRENT_PACKAGES_DIR}/share/libjpeg-turbo/copyright) +vcpkg_copy_pdbs() diff --git a/ports/libpng/CONTROL b/ports/libpng/CONTROL new file mode 100644 index 00000000000000..239fa0cb29549e --- /dev/null +++ b/ports/libpng/CONTROL @@ -0,0 +1,4 @@ +Source: libpng +Version: 1.6.24-1 +Build-Depends: zlib +Description: libpng is a library implementing an interface for reading and writing PNG (Portable Network Graphics) format files. \ No newline at end of file diff --git a/ports/libpng/portfile.cmake b/ports/libpng/portfile.cmake new file mode 100644 index 00000000000000..a5e50658586dcb --- /dev/null +++ b/ports/libpng/portfile.cmake @@ -0,0 +1,47 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "http://download.sourceforge.net/libpng/libpng-1.6.24.tar.xz" + FILENAME "libpng-1.6.24.tar.xz" + MD5 ffcdbd549814787fa8010c372e35ff25 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +find_program(GIT git) +vcpkg_execute_required_process( + COMMAND ${GIT} init + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src/libpng-1.6.24 + LOGNAME git-init +) +execute_process( + COMMAND ${GIT} apply "${CMAKE_CURRENT_LIST_DIR}/use-abort-on-all-platforms.patch" --ignore-whitespace --whitespace=nowarn + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src/libpng-1.6.24 +) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libpng-1.6.24 + OPTIONS + -DPNG_STATIC=OFF + -DPNG_TESTS=OFF + -DSKIP_INSTALL_PROGRAMS=ON + -DSKIP_INSTALL_EXECUTABLES=ON + -DSKIP_INSTALL_FILES=ON + OPTIONS_DEBUG + -DSKIP_INSTALL_HEADERS=ON +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(REMOVE_RECURSE + ${CURRENT_PACKAGES_DIR}/debug/share +) +file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share) +file(RENAME ${CURRENT_PACKAGES_DIR}/lib/libpng ${CURRENT_PACKAGES_DIR}/share/libpng) +file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/libpng/libpng16-debug.cmake ${CURRENT_PACKAGES_DIR}/share/libpng/libpng16-debug.cmake) +file(REMOVE_RECURSE + ${CURRENT_PACKAGES_DIR}/debug/lib/libpng +) +file(COPY ${CURRENT_BUILDTREES_DIR}/src/libpng-1.6.24/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libpng) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/libpng/LICENSE ${CURRENT_PACKAGES_DIR}/share/libpng/copyright) +vcpkg_copy_pdbs() + diff --git a/ports/libpng/use-abort-on-all-platforms.patch b/ports/libpng/use-abort-on-all-platforms.patch new file mode 100644 index 00000000000000..0a629e05924294 --- /dev/null +++ b/ports/libpng/use-abort-on-all-platforms.patch @@ -0,0 +1,17 @@ +diff --git a/pngpriv.h b/pngpriv.h +index fe3355d..5a049b5 100644 +--- a/pngpriv.h ++++ b/pngpriv.h +@@ -457,11 +457,7 @@ + + /* Memory model/platform independent fns */ + #ifndef PNG_ABORT +-# ifdef _WINDOWS_ +-# define PNG_ABORT() ExitProcess(0) +-# else +-# define PNG_ABORT() abort() +-# endif ++# define PNG_ABORT() abort() + #endif + + /* These macros may need to be architecture dependent. */ diff --git a/ports/libuv/CONTROL b/ports/libuv/CONTROL new file mode 100644 index 00000000000000..32d44cf3945633 --- /dev/null +++ b/ports/libuv/CONTROL @@ -0,0 +1,3 @@ +Source: libuv +Version: 1.9.1 +Description: libuv is a multi-platform support library with a focus on asynchronous I/O. \ No newline at end of file diff --git a/ports/libuv/portfile.cmake b/ports/libuv/portfile.cmake new file mode 100644 index 00000000000000..0a830b8e4ad189 --- /dev/null +++ b/ports/libuv/portfile.cmake @@ -0,0 +1,105 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "https://github.com/libuv/libuv/archive/v1.9.1.zip" + FILENAME "libuv-v1.9.1.zip" + MD5 4d1e74197920455203954cd8b75f0a2f +) + +if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src) + message(STATUS "Extracting source ${ARCHIVE}") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src) + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} -E tar xzf ${ARCHIVE} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src + LOGNAME extract-${TARGET_TRIPLET} + ) +endif() + +find_program(PYTHON2 + NAMES python2 python + PATHS C:/python27 ENV PYTHON +) +if(NOT PYTHON2 MATCHES "NOTFOUND") + execute_process( + COMMAND ${PYTHON2} --version + OUTPUT_VARIABLE PYTHON_VER_CHECK_OUT + ERROR_VARIABLE PYTHON_VER_CHECK_ERR + ) + set(PYTHON_VER_CHECK "${PYTHON_VER_CHECK_OUT}${PYTHON_VER_CHECK_ERR}") + debug_message("PYTHON_VER_CHECK=${PYTHON_VER_CHECK}") + if(NOT PYTHON_VER_CHECK MATCHES "Python 2.7") + set(PYTHON2 PYTHON2-NOTFOUND) + find_program(PYTHON2 + NAMES python2 python + PATHS C:/python27 ENV PYTHON + NO_SYSTEM_ENVIRONMENT_PATH + ) + endif() +endif() + +if(PYTHON2 MATCHES "NOTFOUND") + message(FATAL_ERROR "libuv uses the GYP build system, which requires Python 2.7.\n" + "Python 2.7 was not found in the path or by searching inside C:\\Python27.\n" + "There is no portable redistributable for Python 2.7, so you will need to install the MSI located at:\n" + " https://www.python.org/ftp/python/2.7.11/python-2.7.11.amd64.msi\n" + ) +endif() + +set(ENV{GYP_MSVS_VERSION} 2015) +set(ENV{PYTHON} ${PYTHON2}) + +if(TRIPLET_SYSTEM_ARCH MATCHES "x86|x64") + message(STATUS "Building Release") + vcpkg_execute_required_process( + COMMAND cmd /c vcbuild.bat release ${TRIPLET_SYSTEM_ARCH} shared + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1 + LOGNAME ${TARGET_TRIPLET}-build-rel + ) + message(STATUS "Building Debug") + vcpkg_execute_required_process( + COMMAND cmd /c vcbuild.bat debug ${TRIPLET_SYSTEM_ARCH} shared + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1 + LOGNAME ${TARGET_TRIPLET}-build-dbg + ) +else() + message(FATAL_ERROR "Unsupported platform") +endif() + +file(MAKE_DIRECTORY + ${CURRENT_PACKAGES_DIR}/include + ${CURRENT_PACKAGES_DIR}/lib + ${CURRENT_PACKAGES_DIR}/bin + ${CURRENT_PACKAGES_DIR}/debug/lib + ${CURRENT_PACKAGES_DIR}/debug/bin + ${CURRENT_PACKAGES_DIR}/share/libuv + ) + +file(COPY + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/include/tree.h + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/include/uv.h + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/include/uv-version.h + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/include/uv-errno.h + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/include/uv-threadpool.h + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/include/uv-win.h + DESTINATION ${CURRENT_PACKAGES_DIR}/include) + +file(COPY + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/Debug/libuv.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) +file(COPY + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/Debug/libuv.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) +file(COPY + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/Release/libuv.dll + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) +file(COPY + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/Release/libuv.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/lib) +file(COPY + ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-src/libuv-1.9.1/LICENSE + DESTINATION ${CURRENT_PACKAGES_DIR}/share/libuv) + +file(RENAME + ${CURRENT_PACKAGES_DIR}/share/libuv/LICENSE + ${CURRENT_PACKAGES_DIR}/share/libuv/copyright) +vcpkg_copy_pdbs() diff --git a/ports/libwebsockets/CONTROL b/ports/libwebsockets/CONTROL new file mode 100644 index 00000000000000..866c0ccbc1c1ae --- /dev/null +++ b/ports/libwebsockets/CONTROL @@ -0,0 +1,4 @@ +Source: libwebsockets +Version: 2.0.0 +Build-Depends: zlib, openssl +Description: Libwebsockets is a lightweight pure C library built to use minimal CPU and memory resources, and provide fast throughput in both directions as client or server. \ No newline at end of file diff --git a/ports/libwebsockets/portfile.cmake b/ports/libwebsockets/portfile.cmake new file mode 100644 index 00000000000000..5aa1e3ff57e4c9 --- /dev/null +++ b/ports/libwebsockets/portfile.cmake @@ -0,0 +1,35 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "https://github.com/warmcat/libwebsockets/archive/v2.0.0.zip" + FILENAME "libwebsockets-v2.0.0.zip" + MD5 1947a1887dda5b5f9624048f4b6b1507 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/libwebsockets-2.0.0 + OPTIONS + -DLWS_WITH_STATIC=OFF + -DLWS_USE_BUNDLED_ZLIB=OFF + -DLWS_WITHOUT_TESTAPPS=ON + -DLWS_IPV6=ON + -DLWS_HTTP2=ON + # OPTIONS_RELEASE -DOPTIMIZE=1 + # OPTIONS_DEBUG -DDEBUGGABLE=1 +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/share) +file(RENAME ${CURRENT_PACKAGES_DIR}/cmake ${CURRENT_PACKAGES_DIR}/share/libwebsockets) +file(RENAME + ${CURRENT_PACKAGES_DIR}/debug/cmake/LibwebsocketsTargets-debug.cmake + ${CURRENT_PACKAGES_DIR}/share/libwebsockets/LibwebsocketsTargets-debug.cmake +) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/cmake) + +file(COPY ${CURRENT_BUILDTREES_DIR}/src/libwebsockets-2.0.0/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libwebsockets) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/libwebsockets/LICENSE ${CURRENT_PACKAGES_DIR}/share/libwebsockets/copyright) +vcpkg_copy_pdbs() diff --git a/ports/mpg123/0001-Modify-2010-libmpg123.vcxproj-to-use-VS-2015-along-w.patch b/ports/mpg123/0001-Modify-2010-libmpg123.vcxproj-to-use-VS-2015-along-w.patch new file mode 100644 index 00000000000000..7c68789e716036 --- /dev/null +++ b/ports/mpg123/0001-Modify-2010-libmpg123.vcxproj-to-use-VS-2015-along-w.patch @@ -0,0 +1,244 @@ +From aa43d3193302cd545ae2a45079b12af62bf13b38 Mon Sep 17 00:00:00 2001 +From: Robert Schumacher +Date: Sat, 7 May 2016 00:47:10 -0700 +Subject: [PATCH] Modify 2010/libmpg123.vcxproj to use VS 2015, along with + reverting #undef MPG123_EXPORT + +--- + ports/MSVC++/2010/libmpg123/libmpg123.vcxproj | 54 +++++++++++++++++++-------- + src/libmpg123/mpg123.h.in | 2 - + 2 files changed, 38 insertions(+), 18 deletions(-) + +diff --git a/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj b/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj +index afa7de2..84c8d25 100644 +--- a/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj ++++ b/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj +@@ -47,6 +47,10 @@ + libmpg123 + + ++ ++ false ++ v140 ++ + + DynamicLibrary + Unicode +@@ -154,7 +158,7 @@ + + + Disabled +- ../..;../../../../src/libmpg123;%(AdditionalIncludeDirectories) ++ ../..;../../../../src/libmpg123;../../../../src;../../../../src/compat;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;OPT_GENERIC;_DEBUG;%(PreprocessorDefinitions) + false + +@@ -178,7 +182,7 @@ + true + Speed + true +- ../..;../../../../src/libmpg123;%(AdditionalIncludeDirectories) ++ ../..;../../../../src/libmpg123;../../../../src;../../../../src/compat;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;OPT_GENERIC;%(PreprocessorDefinitions) + + +@@ -200,7 +204,7 @@ + + + Disabled +- ../..;../../../../src/libmpg123;%(AdditionalIncludeDirectories) ++ ../..;../../../../src/libmpg123;../../../../src;../../../../src/compat;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;OPT_GENERIC;_DEBUG;BUILD_MPG123_DLL;ACCURATE_ROUNDING;IEEE_FLOAT;%(PreprocessorDefinitions) + false + +@@ -231,7 +235,7 @@ + true + Speed + true +- ../..;../../../../src/libmpg123;%(AdditionalIncludeDirectories) ++ ../..;../../../../src/libmpg123;../../../../src;../../../../src/compat;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;OPT_GENERIC;BUILD_MPG123_DLL;%(PreprocessorDefinitions) + + +@@ -258,7 +262,7 @@ + + + Disabled +- ../..;../../../../src/libmpg123;%(AdditionalIncludeDirectories) ++ ../..;../../../../src/libmpg123;../../../../src;../../../../src/compat;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;OPT_MULTI;OPT_GENERIC;OPT_I386;OPT_I586;OPT_MMX;OPT_3DNOW;OPT_3DNOWEXT;OPT_SSE;%(PreprocessorDefinitions) + false + +@@ -278,6 +282,9 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_3dnowext.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct36_3dnowext.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Debug\dct36_3dnowext.o" "$(ProjectDir)..\libmpg123\Debug\dct36_3dnowext.asm" + ++cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_sse.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct36_sse.asm" ++yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Debug\dct36_sse.o" "$(ProjectDir)..\libmpg123\Debug\dct36_sse.asm" ++ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct64_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct64_3dnow.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Debug\dct64_3dnow.o" "$(ProjectDir)..\libmpg123\Debug\dct64_3dnow.asm" + +@@ -337,7 +344,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + + + +- dct36_3dnow.o;dct36_3dnowext.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) ++ dct36_3dnow.o;dct36_3dnowext.o;dct36_sse.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) + $(ProjectDir)Debug\$(ProjectName).lib + $(ProjectDir)\Debug;%(AdditionalLibraryDirectories) + +@@ -349,7 +356,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + true + Speed + true +- ../..;../../../../src/libmpg123;%(AdditionalIncludeDirectories) ++ ../..;../../../../src/libmpg123;../../../../src;../../../../src/compat;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;OPT_MULTI;OPT_GENERIC;OPT_I386;OPT_I586;OPT_MMX;OPT_3DNOW;OPT_3DNOWEXT;OPT_SSE;%(PreprocessorDefinitions) + + +@@ -371,6 +378,9 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_3dnowext.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct36_3dnowext.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Release\dct36_3dnowext.o" "$(ProjectDir)..\libmpg123\Release\dct36_3dnowext.asm" + ++cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_sse.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct36_sse.asm" ++yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Release\dct36_sse.o" "$(ProjectDir)..\libmpg123\Release\dct36_sse.asm" ++ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct64_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct64_3dnow.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Release\dct64_3dnow.o" "$(ProjectDir)..\libmpg123\Release\dct64_3dnow.asm" + +@@ -430,7 +440,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + + + +- dct36_3dnow.o;dct36_3dnowext.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) ++ dct36_3dnow.o;dct36_3dnowext.o;dct36_sse.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) + $(ProjectDir)Release\$(ProjectName).lib + $(ProjectDir)\Release;%(AdditionalLibraryDirectories) + +@@ -438,7 +448,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + + + Disabled +- ../..;../../../../src/libmpg123;%(AdditionalIncludeDirectories) ++ ../..;../../../../src/libmpg123;../../../../src;../../../../src/compat;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;BUILD_MPG123_DLL;OPT_MULTI;OPT_GENERIC;OPT_I386;OPT_I586;OPT_MMX;OPT_3DNOW;OPT_3DNOWEXT;OPT_SSE;_BIND_TO_CURRENT_VCLIBS_VERSION=1;%(PreprocessorDefinitions) + false + +@@ -460,6 +470,9 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_3dnowext.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct36_3dnowext.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Debug\dct36_3dnowext.o" "$(ProjectDir)..\libmpg123\Debug\dct36_3dnowext.asm" + ++cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_sse.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct36_sse.asm" ++yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Debug\dct36_sse.o" "$(ProjectDir)..\libmpg123\Debug\dct36_sse.asm" ++ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct64_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct64_3dnow.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Debug\dct64_3dnow.o" "$(ProjectDir)..\libmpg123\Debug\dct64_3dnow.asm" + +@@ -519,7 +532,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + + + +- dct36_3dnow.o;dct36_3dnowext.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) ++ dct36_3dnow.o;dct36_3dnowext.o;dct36_sse.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) + $(ProjectDir)Debug\$(ProjectName).dll + $(ProjectDir)\Debug;%(AdditionalLibraryDirectories) + true +@@ -540,7 +553,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + true + Speed + true +- ../..;../../../../src/libmpg123;%(AdditionalIncludeDirectories) ++ ../..;../../../../src/libmpg123;../../../../src;../../../../src/compat;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;BUILD_MPG123_DLL;OPT_MULTI;OPT_GENERIC;OPT_I386;OPT_I586;OPT_MMX;OPT_3DNOW;OPT_3DNOWEXT;OPT_SSE;_BIND_TO_CURRENT_VCLIBS_VERSION=1;%(PreprocessorDefinitions) + + +@@ -563,6 +576,9 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_3dnowext.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct36_3dnowext.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Release\dct36_3dnowext.o" "$(ProjectDir)..\libmpg123\Release\dct36_3dnowext.asm" + ++cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_sse.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct36_sse.asm" ++yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Release\dct36_sse.o" "$(ProjectDir)..\libmpg123\Release\dct36_sse.asm" ++ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct64_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct64_3dnow.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Release\dct64_3dnow.o" "$(ProjectDir)..\libmpg123\Release\dct64_3dnow.asm" + +@@ -622,7 +638,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + + + +- dct36_3dnow.o;dct36_3dnowext.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) ++ dct36_3dnow.o;dct36_3dnowext.o;dct36_sse.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) + $(ProjectDir)Release\$(ProjectName).dll + $(ProjectDir)\Release;%(AdditionalLibraryDirectories) + true +@@ -638,7 +654,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + + + Disabled +- ../..;../../../../src/libmpg123;%(AdditionalIncludeDirectories) ++ ../..;../../../../src/libmpg123;../../../../src;../../../../src/compat;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;BUILD_MPG123_DLL;OPT_MULTI;OPT_GENERIC;OPT_I386;OPT_I586;OPT_MMX;OPT_3DNOW;OPT_3DNOWEXT;OPT_SSE;NO_STRING;NO_ID3V2;NO_ICY;NO_DOWNSAMPLE;_BIND_TO_CURRENT_VCLIBS_VERSION=1;%(PreprocessorDefinitions) + false + +@@ -660,6 +676,9 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_3dnowext.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct36_3dnowext.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Debug\dct36_3dnowext.o" "$(ProjectDir)..\libmpg123\Debug\dct36_3dnowext.asm" + ++cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_sse.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct36_sse.asm" ++yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Debug\dct36_sse.o" "$(ProjectDir)..\libmpg123\Debug\dct36_sse.asm" ++ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct64_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Debug\dct64_3dnow.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Debug\dct64_3dnow.o" "$(ProjectDir)..\libmpg123\Debug\dct64_3dnow.asm" + +@@ -719,7 +738,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + + + +- dct36_3dnow.o;dct36_3dnowext.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) ++ dct36_3dnow.o;dct36_3dnowext.o;dct36_sse.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) + $(ProjectDir)Debug\$(ProjectName).dll + $(ProjectDir)\Debug;%(AdditionalLibraryDirectories) + true +@@ -740,7 +759,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + true + Speed + true +- ../..;../../../../src/libmpg123;%(AdditionalIncludeDirectories) ++ ../..;../../../../src/libmpg123;../../../../src;../../../../src/compat;%(AdditionalIncludeDirectories) + WIN32;_CRT_SECURE_NO_WARNINGS;BUILD_MPG123_DLL;OPT_MULTI;OPT_GENERIC;OPT_I386;OPT_I586;OPT_MMX;OPT_3DNOW;OPT_3DNOWEXT;OPT_SSE;NO_STRING;NO_ID3V2;NO_ICY;NO_DOWNSAMPLE;_BIND_TO_CURRENT_VCLIBS_VERSION=1;%(PreprocessorDefinitions) + + +@@ -763,6 +782,9 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_3dnowext.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct36_3dnowext.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Release\dct36_3dnowext.o" "$(ProjectDir)..\libmpg123\Release\dct36_3dnowext.asm" + ++cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct36_sse.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct36_sse.asm" ++yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Release\dct36_sse.o" "$(ProjectDir)..\libmpg123\Release\dct36_sse.asm" ++ + cl /I "..\.." /EP /TC "$(ProjectDir)..\..\..\..\src\libmpg123\dct64_3dnow.S" /nologo > "$(ProjectDir)..\libmpg123\Release\dct64_3dnow.asm" + yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\Release\dct64_3dnow.o" "$(ProjectDir)..\libmpg123\Release\dct64_3dnow.asm" + +@@ -822,7 +844,7 @@ yasm -a x86 -p gas -r raw -f win32 -g null -m x86 -o "$(ProjectDir)..\libmpg123\ + + + +- dct36_3dnow.o;dct36_3dnowext.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) ++ dct36_3dnow.o;dct36_3dnowext.o;dct36_sse.o;dct64_3dnow.o;dct64_3dnowext.o;dct64_mmx.o;dct64_sse.o;dct64_sse_float.o;equalizer_3dnow.o;getcpuflags.o;synth_3dnow.o;synth_3dnowext.o;synth_i586.o;synth_mmx.o;synth_sse.o;synth_sse_float.o;synth_stereo_sse_float.o;tabinit_mmx.o;synth_sse_accurate.o;synth_sse_s32.o;synth_stereo_sse_accurate.o;synth_stereo_sse_s32.o;%(AdditionalDependencies) + $(ProjectDir)Release\$(ProjectName).dll + $(ProjectDir)\Release;%(AdditionalLibraryDirectories) + true +diff --git a/src/libmpg123/mpg123.h.in b/src/libmpg123/mpg123.h.in +index a25d4d1..d95e41d 100644 +--- a/src/libmpg123/mpg123.h.in ++++ b/src/libmpg123/mpg123.h.in +@@ -1404,6 +1404,4 @@ MPG123_EXPORT int mpg123_replace_reader_handle( mpg123_handle *mh + } + #endif + +-#undef MPG123_EXPORT +- + #endif +-- +2.8.1.windows.1 + diff --git a/ports/mpg123/CONTROL b/ports/mpg123/CONTROL new file mode 100644 index 00000000000000..0c4a746a0d7a19 --- /dev/null +++ b/ports/mpg123/CONTROL @@ -0,0 +1,3 @@ +Source: mpg123 +Version: 1.23.3 +Description: mpg123 is a real time MPEG 1.0/2.0/2.5 audio player/decoder for layers 1, 2 and 3 (MPEG 1.0 layer 3 also known as MP3). \ No newline at end of file diff --git a/ports/mpg123/portfile.cmake b/ports/mpg123/portfile.cmake new file mode 100644 index 00000000000000..d7abb9bf8545b8 --- /dev/null +++ b/ports/mpg123/portfile.cmake @@ -0,0 +1,54 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "http://downloads.sourceforge.net/project/mpg123/mpg123/1.23.3/mpg123-1.23.3.tar.bz2" + FILENAME "mpg123-1.23.3.tar.bz2" + MD5 84e838650c4c593f4e66d1256e0468db +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_find_acquire_program(YASM) +get_filename_component(YASM_EXE_PATH ${YASM} DIRECTORY) +set(ENV{PATH} "${YASM_EXE_PATH};$ENV{PATH}") + +vcpkg_apply_patches( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3 + PATCHES ${CMAKE_CURRENT_LIST_DIR}/0001-Modify-2010-libmpg123.vcxproj-to-use-VS-2015-along-w.patch +) + +vcpkg_build_msbuild( + PROJECT_PATH ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3/ports/MSVC++/2010/libmpg123/libmpg123.vcxproj + RELEASE_CONFIGURATION Release_x86_Dll + DEBUG_CONFIGURATION Debug_x86_Dll +) + +message(STATUS "Installing") +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3/ports/MSVC++/2010/libmpg123/Debug/libmpg123.dll + ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3/ports/MSVC++/2010/libmpg123/Debug/libmpg123.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin +) +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3/ports/MSVC++/2010/libmpg123/Release/libmpg123.dll + ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3/ports/MSVC++/2010/libmpg123/Release/libmpg123.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/bin +) +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3/ports/MSVC++/2010/libmpg123/Debug/libmpg123.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib +) +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3/ports/MSVC++/2010/libmpg123/Release/libmpg123.lib + DESTINATION ${CURRENT_PACKAGES_DIR}/lib +) +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3/ports/MSVC++/mpg123.h + DESTINATION ${CURRENT_PACKAGES_DIR}/include +) +file(INSTALL + ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3/src/libmpg123/mpg123.h.in + DESTINATION ${CURRENT_PACKAGES_DIR}/include +) +file(INSTALL ${CURRENT_BUILDTREES_DIR}/src/mpg123-1.23.3/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/mpg123 RENAME copyright) +vcpkg_copy_pdbs() + +message(STATUS "Installing done") diff --git a/ports/openal-soft/CONTROL b/ports/openal-soft/CONTROL new file mode 100644 index 00000000000000..e54c98e64c03eb --- /dev/null +++ b/ports/openal-soft/CONTROL @@ -0,0 +1,3 @@ +Source: openal-soft +Version: 1.17.2 +Description: OpenAL Soft is an LGPL-licensed, cross-platform, software implementation of the OpenAL 3D audio API. \ No newline at end of file diff --git a/ports/openal-soft/portfile.cmake b/ports/openal-soft/portfile.cmake new file mode 100644 index 00000000000000..5e24d16303fd4e --- /dev/null +++ b/ports/openal-soft/portfile.cmake @@ -0,0 +1,27 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "http://openal-soft.org/openal-releases/openal-soft-1.17.2.tar.bz2" + FILENAME "openal-soft-1.17.2.tar.bz2" + MD5 1764e0d8fec499589b47ebc724e0913d +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/openal-soft-1.17.2 + OPTIONS + -DALSOFT_UTILS=OFF + -DALSOFT_NO_CONFIG_UTIL=ON + -DALSOFT_EXAMPLES=OFF + -DALSOFT_TESTS=OFF + -DALSOFT_CONFIG=OFF + -DALSOFT_HRTF_DEFS=OFF +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(COPY ${CURRENT_BUILDTREES_DIR}/src/openal-soft-1.17.2/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/openal-soft) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/openal-soft/COPYING ${CURRENT_PACKAGES_DIR}/share/openal-soft/copyright) +vcpkg_copy_pdbs() + diff --git a/ports/opencv/0001-OpenCV-should-follow-FHS-like-conventions.patch b/ports/opencv/0001-OpenCV-should-follow-FHS-like-conventions.patch new file mode 100644 index 00000000000000..1824aa339133b4 --- /dev/null +++ b/ports/opencv/0001-OpenCV-should-follow-FHS-like-conventions.patch @@ -0,0 +1,156 @@ +From e396a74da8e7c9c06f3145de65647d7d48524a07 Mon Sep 17 00:00:00 2001 +From: Robert Schumacher +Date: Thu, 5 May 2016 04:16:18 -0700 +Subject: [PATCH] OpenCV should follow FHS-like conventions + +--- + CMakeLists.txt | 11 +++++++---- + cmake/OpenCVGenConfig.cmake | 11 +++++------ + cmake/OpenCVGenHeaders.cmake | 8 ++++++-- + cmake/OpenCVModule.cmake | 4 +++- + data/CMakeLists.txt | 6 ++++-- + include/CMakeLists.txt | 6 ++++-- + 6 files changed, 29 insertions(+), 17 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 3ee50ff..8e3f57d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -250,6 +250,8 @@ OCV_OPTION(INSTALL_PYTHON_EXAMPLES "Install Python examples" OFF ) + OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID ) + OCV_OPTION(INSTALL_TO_MANGLED_PATHS "Enables mangled install paths, that help with side by side installs." OFF IF (UNIX AND NOT ANDROID AND NOT APPLE_FRAMEWORK AND BUILD_SHARED_LIBS) ) + OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binaries and test data" OFF) ++OCV_OPTION(INSTALL_HEADERS "Install header files" ON) ++OCV_OPTION(INSTALL_OTHER "Install other files" ON) + + # OpenCV build options + # =================================================== +@@ -315,7 +317,9 @@ else() + endif() + + if(WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows) +- if(DEFINED OpenCV_RUNTIME AND DEFINED OpenCV_ARCH) ++ if(DEFINED OpenCV_DISABLE_ARCH_PATH) ++ set(OpenCV_INSTALL_BINARIES_PREFIX "") ++ elseif(DEFINED OpenCV_RUNTIME AND DEFINED OpenCV_ARCH) + set(OpenCV_INSTALL_BINARIES_PREFIX "${OpenCV_ARCH}/${OpenCV_RUNTIME}/") + else() + message(STATUS "Can't detect runtime and/or arch") +@@ -379,7 +383,7 @@ else() + set(OPENCV_3P_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}") + set(OPENCV_SAMPLES_SRC_INSTALL_PATH samples/native) + set(OPENCV_JAR_INSTALL_PATH java) +- set(OPENCV_OTHER_INSTALL_PATH etc) ++ set(OPENCV_OTHER_INSTALL_PATH share/opencv) + else() + set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX}) + set(OPENCV_3P_LIB_INSTALL_PATH share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}) +@@ -736,8 +740,7 @@ endif() + # for UNIX it does not make sense as LICENSE and readme will be part of the package automatically + if(ANDROID OR NOT UNIX) + install(FILES ${OPENCV_LICENSE_FILE} +- PERMISSIONS OWNER_READ GROUP_READ WORLD_READ +- DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT libs) ++ DESTINATION ${CMAKE_INSTALL_PREFIX}/share/opencv RENAME copyright CONFIGURATIONS Release COMPONENT libs) + if(OPENCV_README_FILE) + install(FILES ${OPENCV_README_FILE} + PERMISSIONS OWNER_READ GROUP_READ WORLD_READ +diff --git a/cmake/OpenCVGenConfig.cmake b/cmake/OpenCVGenConfig.cmake +index dbfd7ca..94fc4a9 100644 +--- a/cmake/OpenCVGenConfig.cmake ++++ b/cmake/OpenCVGenConfig.cmake +@@ -139,14 +139,13 @@ if(WIN32) + configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" @ONLY) + if (CMAKE_HOST_SYSTEM_NAME MATCHES Windows) + if(BUILD_SHARED_LIBS) +- install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib" COMPONENT dev) +- install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev) ++ install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "cmake" COMPONENT dev) ++ install(EXPORT OpenCVModules DESTINATION "cmake" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev) + else() +- install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" COMPONENT dev) +- install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev) ++ install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "cmake" COMPONENT dev) ++ install(EXPORT OpenCVModules DESTINATION "cmake" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev) + endif() +- install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT dev) +- install(FILES "${OpenCV_SOURCE_DIR}/cmake/OpenCVConfig.cmake" DESTINATION "${CMAKE_INSTALL_PREFIX}/" COMPONENT dev) ++ install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" DESTINATION "cmake" COMPONENT dev) + else () + install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib/cmake/opencv-${OPENCV_VERSION}" COMPONENT dev) + install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib/cmake/opencv-${OPENCV_VERSION}" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev) +diff --git a/cmake/OpenCVGenHeaders.cmake b/cmake/OpenCVGenHeaders.cmake +index 2988979..810871b 100644 +--- a/cmake/OpenCVGenHeaders.cmake ++++ b/cmake/OpenCVGenHeaders.cmake +@@ -1,7 +1,9 @@ + # platform-specific config file + configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h") + configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/cvconfig.h") +-install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 COMPONENT dev) ++if(INSTALL_HEADERS) ++ install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 COMPONENT dev) ++endif() + + # ---------------------------------------------------------------------------- + # opencv_modules.hpp based on actual modules list +@@ -25,4 +27,6 @@ set(OPENCV_MODULE_DEFINITIONS_CONFIGMAKE "${OPENCV_MODULE_DEFINITIONS_CONFIGMAKE + #endforeach() + + configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/opencv_modules.hpp.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp") +-install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp" DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 COMPONENT dev) ++if(INSTALL_HEADERS) ++ install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp" DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 COMPONENT dev) ++endif() +diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake +index 3385385..530e53f 100644 +--- a/cmake/OpenCVModule.cmake ++++ b/cmake/OpenCVModule.cmake +@@ -879,7 +879,9 @@ macro(_ocv_create_module) + foreach(hdr ${OPENCV_MODULE_${m}_HEADERS}) + string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}") + if(NOT hdr2 MATCHES "opencv2/${m}/private.*" AND hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$" ) +- install(FILES ${hdr} OPTIONAL DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev) ++ if(INSTALL_HEADERS) ++ install(FILES ${hdr} OPTIONAL DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev) ++ endif() + endif() + endforeach() + endif() +diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt +index 1f0d720..86b9d89 100644 +--- a/data/CMakeLists.txt ++++ b/data/CMakeLists.txt +@@ -1,8 +1,10 @@ + file(GLOB HAAR_CASCADES haarcascades/*.xml) + file(GLOB LBP_CASCADES lbpcascades/*.xml) + +-install(FILES ${HAAR_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/haarcascades COMPONENT libs) +-install(FILES ${LBP_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/lbpcascades COMPONENT libs) ++if(INSTALL_OTHER) ++ install(FILES ${HAAR_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/haarcascades COMPONENT libs) ++ install(FILES ${LBP_CASCADES} DESTINATION ${OPENCV_OTHER_INSTALL_PATH}/lbpcascades COMPONENT libs) ++endif() + + if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH) + install(DIRECTORY "${OPENCV_TEST_DATA_PATH}/" DESTINATION "${OPENCV_TEST_DATA_INSTALL_PATH}" COMPONENT "tests") +diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt +index b4e48e6..58dccc7 100644 +--- a/include/CMakeLists.txt ++++ b/include/CMakeLists.txt +@@ -1,7 +1,9 @@ + file(GLOB old_hdrs "opencv/*.h*") +-install(FILES ${old_hdrs} ++if(INSTALL_HEADERS) ++ install(FILES ${old_hdrs} + DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv + COMPONENT dev) +-install(FILES "opencv2/opencv.hpp" ++ install(FILES "opencv2/opencv.hpp" + DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 + COMPONENT dev) ++endif() +\ No newline at end of file +-- +2.8.1.windows.1 + diff --git a/ports/opencv/CONTROL b/ports/opencv/CONTROL new file mode 100644 index 00000000000000..a227859297d2d6 --- /dev/null +++ b/ports/opencv/CONTROL @@ -0,0 +1,4 @@ +Source: opencv +Version: 3.1.0 +Build-Depends: zlib, libpng, libjpeg-turbo +Description: computer vision library diff --git a/ports/opencv/portfile.cmake b/ports/opencv/portfile.cmake new file mode 100644 index 00000000000000..9dcf0fdf7e665a --- /dev/null +++ b/ports/opencv/portfile.cmake @@ -0,0 +1,62 @@ +include(vcpkg_common_functions) + +find_program(GIT git) + +set(GIT_URL "https://github.com/Itseez/opencv") +set(GIT_REF "92387b1ef8fad15196dd5f7fb4931444a68bc93a") + +if(NOT EXISTS "${DOWNLOADS}/opencv.git") + message(STATUS "Cloning") + vcpkg_execute_required_process( + COMMAND ${GIT} clone --bare ${GIT_URL} ${DOWNLOADS}/opencv.git + WORKING_DIRECTORY ${DOWNLOADS} + LOGNAME clone + ) +endif() +message(STATUS "Cloning done") + +if(NOT EXISTS "${CURRENT_BUILDTREES_DIR}/src/.git") + message(STATUS "Adding worktree and patching") + vcpkg_execute_required_process( + COMMAND ${GIT} worktree add -f --detach ${CURRENT_BUILDTREES_DIR}/src ${GIT_REF} + WORKING_DIRECTORY ${DOWNLOADS}/opencv.git + LOGNAME worktree + ) + message(STATUS "Patching") + vcpkg_execute_required_process( + COMMAND ${GIT} am ${CMAKE_CURRENT_LIST_DIR}/0001-OpenCV-should-follow-FHS-like-conventions.patch --ignore-whitespace --whitespace=fix + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src + LOGNAME patch + ) +endif() +message(STATUS "Adding worktree and patching done") + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src + OPTIONS + -DBUILD_ZLIB=OFF + -DINSTALL_CREATE_DISTRIB=ON + -DBUILD_opencv_python2=OFF + -DBUILD_opencv_python3=OFF + -DBUILD_opencv_apps=OFF + -DBUILD_DOCS=OFF + -DBUILD_TESTS=OFF + -DBUILD_PERF_TESTS=OFF + -DOpenCV_DISABLE_ARCH_PATH=ON + -DWITH_FFMPEG=OFF + OPTIONS_DEBUG + -DINSTALL_HEADERS=OFF + -DINSTALL_OTHER=OFF +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(RENAME ${CURRENT_PACKAGES_DIR}/cmake/OpenCVConfig-version.cmake ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVConfig-version.cmake) +file(RENAME ${CURRENT_PACKAGES_DIR}/cmake/OpenCVConfig.cmake ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVConfig.cmake) +file(RENAME ${CURRENT_PACKAGES_DIR}/cmake/OpenCVModules.cmake ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules.cmake) +file(RENAME ${CURRENT_PACKAGES_DIR}/cmake/OpenCVModules-release.cmake ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules-release.cmake) +file(RENAME ${CURRENT_PACKAGES_DIR}/debug/cmake/OpenCVModules-debug.cmake ${CURRENT_PACKAGES_DIR}/share/opencv/OpenCVModules-debug.cmake) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/cmake) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/cmake) +vcpkg_copy_pdbs() diff --git a/ports/opengl/CONTROL b/ports/opengl/CONTROL new file mode 100644 index 00000000000000..05546ae5c66f5a --- /dev/null +++ b/ports/opengl/CONTROL @@ -0,0 +1,3 @@ +Source: opengl +Version: 10.0.10240.0 +Description: Open Graphics Library (OpenGL)[3][4][5] is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. \ No newline at end of file diff --git a/ports/opengl/portfile.cmake b/ports/opengl/portfile.cmake new file mode 100644 index 00000000000000..60986922a3395d --- /dev/null +++ b/ports/opengl/portfile.cmake @@ -0,0 +1,26 @@ +set(OPENGLPATH "C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.10240.0\\um\\${TRIPLET_SYSTEM_ARCH}\\OpenGL32.Lib") +set(LICENSEPATH "C:\\Program Files (x86)\\Windows Kits\\10\\Licenses\\10.0.10240.0\\sdk_license.rtf") +set(HEADERSPATH "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.10240.0\\um") + +if (NOT EXISTS "${OPENGLPATH}") + message(FATAL_ERROR "Cannot find Windows 10.0.10240.0 SDK. File does not exist: ${OPENGLPATH}") +endif() + +file(MAKE_DIRECTORY + ${CURRENT_PACKAGES_DIR}/include/gl + ${CURRENT_PACKAGES_DIR}/lib + ${CURRENT_PACKAGES_DIR}/debug/lib + ${CURRENT_PACKAGES_DIR}/share/opengl +) + +file(COPY ${LICENSEPATH} DESTINATION ${CURRENT_PACKAGES_DIR}/include/gl) +file(COPY + "${HEADERSPATH}\\gl\\GL.h" + "${HEADERSPATH}\\gl\\GLU.h" + DESTINATION ${CURRENT_PACKAGES_DIR}/include + ) +file(COPY ${OPENGLPATH} DESTINATION ${CURRENT_PACKAGES_DIR}/lib) +file(COPY ${OPENGLPATH} DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) +file(COPY ${LICENSEPATH} DESTINATION ${CURRENT_PACKAGES_DIR}/share/opengl) +file(WRITE ${CURRENT_PACKAGES_DIR}/share/opengl/copyright "See the accompanying sdk_license.rtf") +vcpkg_copy_pdbs() diff --git a/ports/openssl/CMakeLists.txt b/ports/openssl/CMakeLists.txt new file mode 100644 index 00000000000000..ff034bb9a632c5 --- /dev/null +++ b/ports/openssl/CMakeLists.txt @@ -0,0 +1,68 @@ +cmake_minimum_required(VERSION 3.0) +project(openssl NONE) + +include(vcpkg_execute_required_process) + +find_package(ZLIB REQUIRED) +find_program(PERL perl) +find_program(NMAKE nmake) + +message(STATUS "Extracting source ${OPENSSL_SOURCE_ARCHIVE}") +vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} -E tar xjf ${OPENSSL_SOURCE_ARCHIVE} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + LOGNAME extract-${TARGET_TRIPLET}-rel +) + +set(CONFIGURE_COMMAND ${PERL} Configure + no-idea + no-mdc2 + no-rc5 + no-asm + zlib-dynamic + --with-zlib-include=${ZLIB_INCLUDE_DIRS} +) + +if(TARGET_TRIPLET MATCHES "x86-windows") + set(OPENSSL_ARCH VC-WIN32) + set(OPENSSL_DO "ms\\do_ms.bat") +elseif(TARGET_TRIPLET MATCHES "x64") + set(OPENSSL_ARCH VC-WIN64A) + set(OPENSSL_DO "ms\\do_win64a.bat") +else() + message(FATAL_ERROR "Unsupported target triplet: ${TARGET_TRIPLET}") +endif() + +if(CMAKE_BUILD_TYPE MATCHES "Debug") + set(OPENSSLDIR ${CURRENT_PACKAGES_DIR}/debug) + list(GET ZLIB_LIBRARIES -1 ZLIB_DEBUG_LIBRARY) + list(APPEND CONFIGURE_COMMAND + debug-${OPENSSL_ARCH} + --openssldir=${OPENSSLDIR} + --with-zlib-lib=${ZLIB_DEBUG_LIBRARY} + ) +else() + set(OPENSSLDIR ${CURRENT_PACKAGES_DIR}) + list(APPEND CONFIGURE_COMMAND + ${OPENSSL_ARCH} + --openssldir=${OPENSSLDIR} + --with-zlib-lib=${ZLIB_LIBRARIES} + ) +endif() + +vcpkg_execute_required_process( + COMMAND ${CONFIGURE_COMMAND} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/openssl-${VERSION} + LOGNAME configure-perl-${TARGET_TRIPLET}-${CMAKE_BUILD_TYPE} +) +vcpkg_execute_required_process( + COMMAND ${OPENSSL_DO} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/openssl-${VERSION} + LOGNAME configure-do-${TARGET_TRIPLET}-${CMAKE_BUILD_TYPE} +) + +add_custom_command(OUTPUT ${OPENSSLDIR}/bin/ssleay32.dll ${OPENSSLDIR}/bin/libeay32.dll + COMMAND ${NMAKE} -f ms\\ntdll.mak install + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/openssl-${VERSION} +) +add_custom_target(openssl ALL DEPENDS ${OPENSSLDIR}/bin/ssleay32.dll ${OPENSSLDIR}/bin/libeay32.dll) \ No newline at end of file diff --git a/ports/openssl/CONTROL b/ports/openssl/CONTROL new file mode 100644 index 00000000000000..cc539a03e7392c --- /dev/null +++ b/ports/openssl/CONTROL @@ -0,0 +1,4 @@ +Source: openssl +Version: 1.0.2h +Build-Depends: zlib +Description: OpenSSL is an open source project that provides a robust, commercial-grade, and full-featured toolkit for the Transport Layer Security (TLS) and Secure Sockets Layer (SSL) protocols. It is also a general-purpose cryptography library. \ No newline at end of file diff --git a/ports/openssl/LICENSE b/ports/openssl/LICENSE new file mode 100644 index 00000000000000..e47d101f1025e8 --- /dev/null +++ b/ports/openssl/LICENSE @@ -0,0 +1,127 @@ + + LICENSE ISSUES + ============== + + The OpenSSL toolkit stays under a dual license, i.e. both the conditions of + the OpenSSL License and the original SSLeay license apply to the toolkit. + See below for the actual license texts. Actually both licenses are BSD-style + Open Source licenses. In case of any license issues related to OpenSSL + please contact openssl-core@openssl.org. + + OpenSSL License + --------------- + +/* ==================================================================== + * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + + Original SSLeay License + ----------------------- + +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ + diff --git a/ports/openssl/portfile.cmake b/ports/openssl/portfile.cmake new file mode 100644 index 00000000000000..1133bf4712c289 --- /dev/null +++ b/ports/openssl/portfile.cmake @@ -0,0 +1,46 @@ +include(vcpkg_common_functions) +vcpkg_find_acquire_program(PERL) +find_program(NMAKE nmake) + +get_filename_component(PERL_EXE_PATH ${PERL} DIRECTORY) +set(ENV{PATH} "${PERL_EXE_PATH};$ENV{PATH}") + +vcpkg_download_distfile(OPENSSL_SOURCE_ARCHIVE + URL "https://www.openssl.org/source/openssl-1.0.2h.tar.gz" + FILENAME "openssl-1.0.2h.tar.gz" + MD5 9392e65072ce4b614c1392eefc1f23d0 +) + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${CURRENT_BUILDTREES_DIR}/src/openssl-1.0.2h) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/openssl-1.0.2h + GENERATOR "NMake Makefiles" + OPTIONS + -DCURRENT_INSTALLED_DIR=${CURRENT_INSTALLED_DIR} + -DCURRENT_PACKAGES_DIR=${CURRENT_PACKAGES_DIR} + -DCURRENT_BUILDTREES_DIR=${CURRENT_BUILDTREES_DIR} + -DOPENSSL_SOURCE_ARCHIVE=${OPENSSL_SOURCE_ARCHIVE} + -DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH} + -DTRIPLET_SYSTEM_ARCH=${TRIPLET_SYSTEM_ARCH} + -DVERSION=1.0.2h + -DTARGET_TRIPLET=${TARGET_TRIPLET} +) + +vcpkg_build_cmake() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(REMOVE + ${CURRENT_PACKAGES_DIR}/debug/bin/openssl.exe + ${CURRENT_PACKAGES_DIR}/bin/openssl.exe + ${CURRENT_PACKAGES_DIR}/debug/openssl.cnf + ${CURRENT_PACKAGES_DIR}/openssl.cnf +) +if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/engines) + file(RENAME ${CURRENT_PACKAGES_DIR}/lib/engines ${CURRENT_PACKAGES_DIR}/bin/engines) +endif() +if(EXISTS ${CURRENT_PACKAGES_DIR}/debug/lib/engines) + file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/engines ${CURRENT_PACKAGES_DIR}/debug/bin/engines) +endif() +file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/openssl RENAME copyright) +vcpkg_copy_pdbs() diff --git a/ports/range-v3/CONTROL b/ports/range-v3/CONTROL new file mode 100644 index 00000000000000..a04b8d3b7ec215 --- /dev/null +++ b/ports/range-v3/CONTROL @@ -0,0 +1,3 @@ +Source: range-v3 +Version: 0.0.0-1 +Description: Range library for C++11/14/17. diff --git a/ports/range-v3/portfile.cmake b/ports/range-v3/portfile.cmake new file mode 100644 index 00000000000000..e71229d0f93390 --- /dev/null +++ b/ports/range-v3/portfile.cmake @@ -0,0 +1,12 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "https://github.com/Microsoft/Range-V3-VS2015/archive/ede9ad367fd5ec764fecb039c874614bd908e6b6.zip" + FILENAME "range-v3-ede9ad367fd5ec764fecb039c874614bd908e6b6.zip" + MD5 a33fcf63489d5c6d8fa92ef8746648ab +) +vcpkg_extract_source_archive(${ARCHIVE}) + +file(COPY ${CURRENT_BUILDTREES_DIR}/src/Range-V3-VS2015-ede9ad367fd5ec764fecb039c874614bd908e6b6/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/range-v3) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/range-v3/LICENSE.txt ${CURRENT_PACKAGES_DIR}/share/range-v3/copyright) +file(INSTALL ${CURRENT_BUILDTREES_DIR}/src/Range-V3-VS2015-ede9ad367fd5ec764fecb039c874614bd908e6b6/include DESTINATION ${CURRENT_PACKAGES_DIR} FILES_MATCHING PATTERN "*.hpp") +vcpkg_copy_pdbs() diff --git a/ports/rapidjson/CONTROL b/ports/rapidjson/CONTROL new file mode 100644 index 00000000000000..2ef641783d886d --- /dev/null +++ b/ports/rapidjson/CONTROL @@ -0,0 +1,3 @@ +Source: rapidjson +Version: 1.0.2-1 +Description: A fast JSON parser/generator for C++ with both SAX/DOM style API diff --git a/ports/rapidjson/portfile.cmake b/ports/rapidjson/portfile.cmake new file mode 100644 index 00000000000000..6d5cdadc6c6da4 --- /dev/null +++ b/ports/rapidjson/portfile.cmake @@ -0,0 +1,15 @@ +include(winports_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "https://github.com/miloyip/rapidjson/archive/879def80f2e466cdf4c86dc7e53ea2dd4cafaea0.zip" + FILENAME "rapidjson-879def80f2e466cdf4c86dc7e53ea2dd4cafaea0.zip" + MD5 5394c3bc23177b000e1992fb989edc53 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +# Put the licence file where vcpkg expects it +file(COPY ${CURRENT_BUILDTREES_DIR}/src/rapidjson-879def80f2e466cdf4c86dc7e53ea2dd4cafaea0/license.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/rapidjson) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/rapidjson/license.txt ${CURRENT_PACKAGES_DIR}/share/rapidjson/copyright) + +# Copy the rapidjson header files +file(INSTALL ${CURRENT_BUILDTREES_DIR}/src/rapidjson-879def80f2e466cdf4c86dc7e53ea2dd4cafaea0/include DESTINATION ${CURRENT_PACKAGES_DIR} FILES_MATCHING PATTERN "*.h") +vcpkg_copy_pdbs() diff --git a/ports/sdl2/CONTROL b/ports/sdl2/CONTROL new file mode 100644 index 00000000000000..5a05183f22214b --- /dev/null +++ b/ports/sdl2/CONTROL @@ -0,0 +1,3 @@ +Source: sdl2 +Version: 2.0.4 +Description: Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. \ No newline at end of file diff --git a/ports/sdl2/portfile.cmake b/ports/sdl2/portfile.cmake new file mode 100644 index 00000000000000..8d5a95feb401b0 --- /dev/null +++ b/ports/sdl2/portfile.cmake @@ -0,0 +1,43 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE_FILE + URL "http://libsdl.org/release/SDL2-2.0.4.tar.gz" + FILENAME "SDL2-2.0.4.tar.gz" + MD5 44fc4a023349933e7f5d7a582f7b886e +) +vcpkg_extract_source_archive(${ARCHIVE_FILE}) + +if(TRIPLET_SYSTEM_NAME MATCHES "WindowsStore") + vcpkg_build_msbuild( + PROJECT_PATH ${CURRENT_BUILDTREES_DIR}/src/SDL2-2.0.4/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj + ) + + file(COPY + ${CURRENT_BUILDTREES_DIR}/src/SDL2-2.0.4/VisualC-WinRT/UWP_VS2015/Debug/SDL-UWP/SDL2.dll + ${CURRENT_BUILDTREES_DIR}/src/SDL2-2.0.4/VisualC-WinRT/UWP_VS2015/Debug/SDL-UWP/SDL2.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin) + file(COPY + ${CURRENT_BUILDTREES_DIR}/src/SDL2-2.0.4/VisualC-WinRT/UWP_VS2015/Release/SDL-UWP/SDL2.dll + ${CURRENT_BUILDTREES_DIR}/src/SDL2-2.0.4/VisualC-WinRT/UWP_VS2015/Release/SDL-UWP/SDL2.pdb + DESTINATION ${CURRENT_PACKAGES_DIR}/bin) + file(COPY ${CURRENT_BUILDTREES_DIR}/src/SDL2-2.0.4/VisualC-WinRT/UWP_VS2015/Debug/SDL-UWP/SDL2.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib) + file(COPY ${CURRENT_BUILDTREES_DIR}/src/SDL2-2.0.4/VisualC-WinRT/UWP_VS2015/Release/SDL-UWP/SDL2.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib) + + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include) + file(MAKE_DIRECTORY ${CURRENT_PACKAGES_DIR}/include) + file(COPY ${CURRENT_BUILDTREES_DIR}/src/SDL2-2.0.4/include DESTINATION ${CURRENT_PACKAGES_DIR}/include) + file(RENAME ${CURRENT_PACKAGES_DIR}/include/include ${CURRENT_PACKAGES_DIR}/include/SDL2) +else() + vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/SDL2-2.0.4 + OPTIONS + -DSDL_STATIC=OFF + ) + + vcpkg_build_cmake() + vcpkg_install_cmake() + + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +endif() + +file(INSTALL ${CURRENT_BUILDTREES_DIR}/src/SDL2-2.0.4/COPYING.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/sdl2 RENAME copyright) +vcpkg_copy_pdbs() diff --git a/ports/sqlite3/CMakeLists.txt b/ports/sqlite3/CMakeLists.txt new file mode 100644 index 00000000000000..3d5f73a4ab9b45 --- /dev/null +++ b/ports/sqlite3/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.0) +project(sqlite3 C) + +include_directories(${SOURCE}) +add_library(sqlite3 SHARED ${SOURCE}/sqlite3.c) +target_compile_definitions(sqlite3 PRIVATE $<$:-DSQLITE_DEBUG> "-DSQLITE_API=__declspec(dllexport)") +if(TRIPLET_SYSTEM_NAME MATCHES "WindowsStore") + target_compile_definitions(sqlite3 PRIVATE -DSQLITE_OS_WINRT=1) +endif() + +install(TARGETS sqlite3 + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) +install(FILES ${SOURCE}/sqlite3.h ${SOURCE}/sqlite3ext.h DESTINATION include CONFIGURATIONS Release) diff --git a/ports/sqlite3/CONTROL b/ports/sqlite3/CONTROL new file mode 100644 index 00000000000000..88605148245af1 --- /dev/null +++ b/ports/sqlite3/CONTROL @@ -0,0 +1,3 @@ +Source: sqlite3 +Version: 3120200 +Description: SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. \ No newline at end of file diff --git a/ports/sqlite3/portfile.cmake b/ports/sqlite3/portfile.cmake new file mode 100644 index 00000000000000..b9cc6abe35814e --- /dev/null +++ b/ports/sqlite3/portfile.cmake @@ -0,0 +1,19 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "http://www.sqlite.org/2016/sqlite-amalgamation-3120200.zip" + FILENAME "sqlite-amalgamation-3120200.zip" + MD5 e3b10b952f075252169ac613068ccc97 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_configure_cmake( + SOURCE_PATH ${CMAKE_CURRENT_LIST_DIR} + OPTIONS + -DSOURCE=${CURRENT_BUILDTREES_DIR}/src/sqlite-amalgamation-3120200 +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(WRITE ${CURRENT_PACKAGES_DIR}/share/sqlite3/copyright "SQLite is in the Public Domain.\nhttp://www.sqlite.org/copyright.html\n") +vcpkg_copy_pdbs() diff --git a/ports/tcl/portfile.cmake b/ports/tcl/portfile.cmake new file mode 100644 index 00000000000000..16f9abdbd0dd14 --- /dev/null +++ b/ports/tcl/portfile.cmake @@ -0,0 +1,63 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "http://prdownloads.sourceforge.net/tcl/tcl8.6.5-src.tar.gz" + FILENAME "tcl8.6.5-src.tar.gz" + MD5 0e6426a4ca9401825fbc6ecf3d89a326 +) + +find_program(NMAKE nmake) + +if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/x86-windows-rel) + message(STATUS "Extracting source ${ARCHIVE} for Release") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-rel) + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} -E tar xjf ${ARCHIVE} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-rel + LOGNAME extract-x86-windows-rel + ) +endif() +if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/x86-windows-dbg) + message(STATUS "Extracting source ${ARCHIVE} for Debug") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-dbg) + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} -E tar xjf ${ARCHIVE} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-dbg + LOGNAME extract-x86-windows-dbg + ) +endif() +message(STATUS "Extracting done") + +message(STATUS "Building x86-windows-rel") +vcpkg_execute_required_process( + COMMAND ${NMAKE} -f makefile.vc release + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-rel/tcl8.6.5/win + LOGNAME build-x86-windows-rel +) +message(STATUS "Building x86-windows-rel done") + +message(STATUS "Building x86-windows-dbg") +vcpkg_execute_required_process( + COMMAND ${NMAKE} -f makefile.vc release OPTS=symbols + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-dbg/tcl8.6.5/win + LOGNAME build-x86-windows-rel +) +message(STATUS "Building x86-windows-dbg done") + +message(STATUS "Installing x86-windows-rel") +vcpkg_execute_required_process( + COMMAND ${NMAKE} -f makefile.vc install INSTALLDIR=${CURRENT_PACKAGES_DIR} SCRIPT_INSTALL_DIR=${CURRENT_PACKAGES_DIR}\\share\\tcltk\\tcl8.6 + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-rel/tcl8.6.5/win + LOGNAME install-x86-windows-rel +) +message(STATUS "Installing x86-windows-rel done") + +message(STATUS "Installing x86-windows-dbg") +vcpkg_execute_required_process( + COMMAND ${NMAKE} -f makefile.vc install INSTALLDIR=${CURRENT_PACKAGES_DIR}\\debug OPTS=symbols SCRIPT_INSTALL_DIR=${CURRENT_PACKAGES_DIR}\\debug\\share\\tcltk\\tcl8.6 + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-dbg/tcl8.6.5/win + LOGNAME install-x86-windows-dbg +) +message(STATUS "Installing x86-windows-dbg done") + +file(INSTALL ${CURRENT_BUILDTREES_DIR}/x86-windows-rel/tcl8.6.5/license.terms DESTINATION ${CURRENT_PACKAGES_DIR}/share/tcl RENAME copyright) +vcpkg_copy_pdbs() diff --git a/ports/tiff/CONTROL b/ports/tiff/CONTROL new file mode 100644 index 00000000000000..df11c0e9c21e72 --- /dev/null +++ b/ports/tiff/CONTROL @@ -0,0 +1,3 @@ +Source: tiff +Version: 4.0.6 +Description: A library that supports the manipulation of TIFF image files \ No newline at end of file diff --git a/ports/tiff/portfile.cmake b/ports/tiff/portfile.cmake new file mode 100644 index 00000000000000..9011db7b6fa6fd --- /dev/null +++ b/ports/tiff/portfile.cmake @@ -0,0 +1,36 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "ftp://ftp.remotesensing.org/pub/libtiff/tiff-4.0.6.tar.gz" + FILENAME "tiff-4.0.6.tar.gz" + MD5 d1d2e940dea0b5ad435f21f03d96dd72 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/tiff-4.0.6 + OPTIONS -Dcxx=OFF +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(REMOVE_RECURSE + ${CURRENT_PACKAGES_DIR}/debug/include + ${CURRENT_PACKAGES_DIR}/debug/share + ${CURRENT_PACKAGES_DIR}/share +) +file(COPY + ${CURRENT_BUILDTREES_DIR}/src/tiff-4.0.6/COPYRIGHT + DESTINATION ${CURRENT_PACKAGES_DIR}/share/tiff +) +file(RENAME + ${CURRENT_PACKAGES_DIR}/share/tiff/COPYRIGHT + ${CURRENT_PACKAGES_DIR}/share/tiff/c2 +) +file(RENAME + ${CURRENT_PACKAGES_DIR}/share/tiff/c2 + ${CURRENT_PACKAGES_DIR}/share/tiff/copyright +) +file(GLOB EXES ${CURRENT_PACKAGES_DIR}/bin/*.exe ${CURRENT_PACKAGES_DIR}/debug/bin/*.exe) +file(REMOVE ${EXES}) +vcpkg_copy_pdbs() diff --git a/ports/tinyxml2/CONTROL b/ports/tinyxml2/CONTROL new file mode 100644 index 00000000000000..b8bf3d76ac7873 --- /dev/null +++ b/ports/tinyxml2/CONTROL @@ -0,0 +1,3 @@ +Source: tinyxml2 +Version: 3.0.0 +Description: A simple, small, efficient, C++ XML parser \ No newline at end of file diff --git a/ports/tinyxml2/portfile.cmake b/ports/tinyxml2/portfile.cmake new file mode 100644 index 00000000000000..56c86d82a4933d --- /dev/null +++ b/ports/tinyxml2/portfile.cmake @@ -0,0 +1,22 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "https://github.com/leethomason/tinyxml2/archive/3.0.0.zip" + FILENAME "tinyxml2-3.0.0.zip" + MD5 851ffc79097239cdc03a952094ddf437 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/tinyxml2-3.0.0 + # OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 + # OPTIONS_RELEASE -DOPTIMIZE=1 + # OPTIONS_DEBUG -DDEBUGGABLE=1 +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(COPY ${CURRENT_BUILDTREES_DIR}/src/tinyxml2-3.0.0/readme.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/tinyxml2) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/tinyxml2/readme.md ${CURRENT_PACKAGES_DIR}/share/tinyxml2/copyright) +vcpkg_copy_pdbs() diff --git a/ports/tk/portfile.cmake b/ports/tk/portfile.cmake new file mode 100644 index 00000000000000..8b5f1f36ed17bc --- /dev/null +++ b/ports/tk/portfile.cmake @@ -0,0 +1,63 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "http://prdownloads.sourceforge.net/tcl/tk8.6.5-src.tar.gz" + FILENAME "tk8.6.5-src.tar.gz" + MD5 11dbbd425c3e0201f20d6a51482ce6c4 +) + +find_program(NMAKE nmake) + +if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/x86-windows-rel) + message(STATUS "Extracting source ${ARCHIVE} for Release") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-rel) + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} -E tar xjf ${ARCHIVE} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-rel + LOGNAME extract-x86-windows-rel + ) +endif() +if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/x86-windows-dbg) + message(STATUS "Extracting source ${ARCHIVE} for Debug") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-dbg) + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} -E tar xjf ${ARCHIVE} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-dbg + LOGNAME extract-x86-windows-dbg + ) +endif() +message(STATUS "Extracting done") + +message(STATUS "Building x86-windows-rel") +vcpkg_execute_required_process( + COMMAND ${NMAKE} -f makefile.vc release TCLDIR=${CURRENT_BUILDTREES_DIR}\\x86-windows-rel\\tcl8.6.5 + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-rel/tk8.6.5/win + LOGNAME build-x86-windows-rel +) +message(STATUS "Building x86-windows-rel done") + +message(STATUS "Building x86-windows-dbg") +vcpkg_execute_required_process( + COMMAND ${NMAKE} -f makefile.vc release OPTS=symbols TCLDIR=${CURRENT_BUILDTREES_DIR}\\x86-windows-dbg\\tcl8.6.5 + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-dbg/tk8.6.5/win + LOGNAME build-x86-windows-dbg +) +message(STATUS "Building x86-windows-dbg done") + +message(STATUS "Installing x86-windows-rel") +vcpkg_execute_required_process( + COMMAND ${NMAKE} -f makefile.vc install INSTALLDIR=${CURRENT_PACKAGES_DIR} SCRIPT_INSTALL_DIR=${CURRENT_PACKAGES_DIR}\\share\\tcltk\\tk8.6 + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-rel/tk8.6.5/win + LOGNAME install-x86-windows-rel +) +message(STATUS "Installing x86-windows-rel done") + +message(STATUS "Installing x86-windows-dbg") +vcpkg_execute_required_process( + COMMAND ${NMAKE} -f makefile.vc install INSTALLDIR=${CURRENT_PACKAGES_DIR}\\debug OPTS=symbols SCRIPT_INSTALL_DIR=${CURRENT_PACKAGES_DIR}\\debug\\share\\tcltk\\tk8.6 + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/x86-windows-dbg/tk8.6.5/win + LOGNAME install-x86-windows-dbg +) +message(STATUS "Installing x86-windows-dbg done") + +file(INSTALL ${CURRENT_BUILDTREES_DIR}/x86-windows-rel/tk8.6.5/license.terms DESTINATION ${CURRENT_PACKAGES_DIR}/share/tk RENAME copyright) +vcpkg_copy_pdbs() diff --git a/ports/zlib/CONTROL b/ports/zlib/CONTROL new file mode 100644 index 00000000000000..4828734801da2f --- /dev/null +++ b/ports/zlib/CONTROL @@ -0,0 +1,3 @@ +Source: zlib +Version: 1.2.8 +Description: A compression library \ No newline at end of file diff --git a/ports/zlib/LICENSE b/ports/zlib/LICENSE new file mode 100644 index 00000000000000..9b2f94711ce4f0 --- /dev/null +++ b/ports/zlib/LICENSE @@ -0,0 +1,20 @@ +Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu \ No newline at end of file diff --git a/ports/zlib/portfile.cmake b/ports/zlib/portfile.cmake new file mode 100644 index 00000000000000..cbd942aeb1a583 --- /dev/null +++ b/ports/zlib/portfile.cmake @@ -0,0 +1,22 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE_FILE + URL "http://zlib.net/zlib128.zip" + FILENAME "zlib128.zip" + MD5 126f8676442ffbd97884eb4d6f32afb4 +) +vcpkg_extract_source_archive(${ARCHIVE_FILE}) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/zlib-1.2.8 + OPTIONS + -DSKIP_INSTALL_FILES=ON + OPTIONS_DEBUG + -DSKIP_INSTALL_HEADERS=ON +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/zlibstatic.lib ${CURRENT_PACKAGES_DIR}/debug/lib/zlibstaticd.lib) +file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/zlib RENAME copyright) +vcpkg_copy_pdbs() diff --git a/scripts/bootstrap.ps1 b/scripts/bootstrap.ps1 new file mode 100644 index 00000000000000..568f569955f9e4 --- /dev/null +++ b/scripts/bootstrap.ps1 @@ -0,0 +1,31 @@ +[CmdletBinding()] +param( + [ValidateNotNullOrEmpty()] + [string]$disableMetrics = "0" +) + +$vcpkgRoot = (get-item $PSScriptRoot).parent.FullName + +$gitHash = git rev-parse HEAD +Write-Verbose("Git hash is " + $gitHash) +$gitStartOfHash = $gitHash.substring(0,6) +$vcpkgSourcesPath = "$vcpkgRoot\toolsrc" +Write-Verbose("vcpkg Path " + $vcpkgSourcesPath) + +if (!(Test-Path $vcpkgSourcesPath)) +{ + New-Item -ItemType directory -Path $vcpkgSourcesPath -force | Out-Null +} + +try{ + pushd $vcpkgSourcesPath + cmd /c "$env:VS140COMNTOOLS..\..\VC\vcvarsall.bat" x86 "&" msbuild "/p:VCPKG_VERSION=-$gitHash" "/p:DISABLE_METRICS=$disableMetrics" /p:Configuration=Release /p:Platform=x86 /m + + Write-Verbose("Placing vcpkg.exe in the correct location") + + Copy-Item $vcpkgSourcesPath\Release\vcpkg.exe $vcpkgRoot\vcpkg.exe | Out-Null + Copy-Item $vcpkgSourcesPath\Release\vcpkgmetricsuploader.exe $vcpkgRoot\scripts\vcpkgmetricsuploader.exe | Out-Null +} +finally{ + popd +} diff --git a/scripts/buildsystems/msbuild/applocal.ps1 b/scripts/buildsystems/msbuild/applocal.ps1 new file mode 100644 index 00000000000000..70528e0780ac59 --- /dev/null +++ b/scripts/buildsystems/msbuild/applocal.ps1 @@ -0,0 +1,27 @@ +[cmdletbinding()] +param([string]$targetBinary, [string]$installedDir, [string]$tlogFile) + +function resolve($targetBinary) { + $targetBinaryPath = Resolve-Path $targetBinary + $targetBinaryDir = Split-Path $targetBinaryPath -parent + + $a = $(link /dump /imports $targetBinary | ? { $_ -match "^ [^ ].*\.dll" } | % { $_ -replace "^ ","" }) + $a | % { + if (Test-Path "$installedDir\$_") { + if (Test-Path "$targetBinaryDir\$_") { + Write-Verbose "$_ is already present" + } + else { + Copy-Item $installedDir\$_ $targetBinaryDir + Write-Verbose "Copying $installedDir\$_ -> $_" + } + "$targetBinaryDir\$_" + if ($tlogFile) { Add-Content $tlogFile "$targetBinaryDir\$_" } + resolve("$targetBinaryDir\$_") + } else { + Write-Verbose "$installedDir\$_ not found" + } + } +} + +resolve($targetBinary) \ No newline at end of file diff --git a/scripts/buildsystems/msbuild/vcpkg.targets b/scripts/buildsystems/msbuild/vcpkg.targets new file mode 100644 index 00000000000000..3a74099f051578 --- /dev/null +++ b/scripts/buildsystems/msbuild/vcpkg.targets @@ -0,0 +1,58 @@ + + + true + x86-windows + + + + true + x86-uwp + + + + true + x64-windows + + + + true + x64-uwp + + + + true + arm-uwp + + + + $(Configuration) + + $(MSBuildThisFileDirectory)..\..\..\installed\$(VCPkgTriplet)\ + + + + + $(VCPkgRoot)debug\lib\*.lib;%(AdditionalDependencies) + $(VCPkgRoot)lib\*.lib;%(AdditionalDependencies) + + + $(VCPkgRoot)include;%(AdditionalIncludeDirectories) + + + + + + + + + + + + + diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake new file mode 100644 index 00000000000000..26cc8a57b49065 --- /dev/null +++ b/scripts/buildsystems/vcpkg.cmake @@ -0,0 +1,52 @@ +if(NOT VCPKG_TOOLCHAIN) + if(CMAKE_GENERATOR_PLATFORM MATCHES "^[Ww][Ii][Nn]32$") + set(_VCPKG_TARGET_TRIPLET_ARCH x86) + elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Xx]64$") + set(_VCPKG_TARGET_TRIPLET_ARCH x64) + elseif(CMAKE_GENERATOR_PLATFORM MATCHES "^[Aa][Rr][Mm]$") + set(_VCPKG_TARGET_TRIPLET_ARCH arm) + else() + if(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 Win64$") + set(_VCPKG_TARGET_TRIPLET_ARCH x64) + elseif(CMAKE_GENERATOR MATCHES "^Visual Studio 14 2015 ARM$") + set(_VCPKG_TARGET_TRIPLET_ARCH arm) + else() + set(_VCPKG_TARGET_TRIPLET_ARCH x86) + endif() + endif() + + if(WINDOWS_STORE OR WINDOWS_PHONE) + set(_VCPKG_TARGET_TRIPLET_PLAT uwp) + else() + set(_VCPKG_TARGET_TRIPLET_PLAT windows) + endif() + + set(_VCPKG_TARGET_TRIPLET ${_VCPKG_TARGET_TRIPLET_ARCH}-${_VCPKG_TARGET_TRIPLET_PLAT}) + + set(_VCPKG_TOOLCHAIN_DIR ${CMAKE_CURRENT_LIST_DIR}) + + if(CMAKE_BUILD_TYPE MATCHES "^Debug$" OR NOT DEFINED CMAKE_BUILD_TYPE) + list(APPEND CMAKE_PREFIX_PATH + ${CMAKE_CURRENT_LIST_DIR}/../installed/${_VCPKG_TARGET_TRIPLET}/debug + ) + endif() + list(APPEND CMAKE_PREFIX_PATH + ${CMAKE_CURRENT_LIST_DIR}/../installed/${_VCPKG_TARGET_TRIPLET} + ) + + include_directories(${CMAKE_CURRENT_LIST_DIR}/../installed/${_VCPKG_TARGET_TRIPLET}/include) + + option(OVERRIDE_ADD_EXECUTABLE "Automatically copy dependencies into the output directory for executables." ON) + if(OVERRIDE_ADD_EXECUTABLE) + function(add_executable name) + _add_executable(${ARGV}) + add_custom_command(TARGET ${name} POST_BUILD + COMMAND powershell -executionpolicy remotesigned -file ${_VCPKG_TOOLCHAIN_DIR}/msbuild/applocal.ps1 + -targetBinary $ + -installedDir "${_VCPKG_TOOLCHAIN_DIR}/../installed/${_VCPKG_TARGET_TRIPLET}$<$:/debug>/bin" + -OutVariable out + ) + endfunction() + endif() + set(VCPKG_TOOLCHAIN ON) +endif() diff --git a/scripts/cmake/vcpkg_apply_patches.cmake b/scripts/cmake/vcpkg_apply_patches.cmake new file mode 100644 index 00000000000000..939edbd14acda6 --- /dev/null +++ b/scripts/cmake/vcpkg_apply_patches.cmake @@ -0,0 +1,19 @@ +function(vcpkg_apply_patches) + cmake_parse_arguments(_ap "" "SOURCE_PATH" "PATCHES" ${ARGN}) + + find_program(GIT git) + set(PATCHNUM 0) + foreach(PATCH ${_ap_PATCHES}) + message(STATUS "Applying patch ${PATCH}") + set(LOGNAME patch-${TARGET_TRIPLET}-${PATCHNUM}) + execute_process( + COMMAND ${GIT} --work-tree=. apply "${PATCH}" --ignore-whitespace --whitespace=nowarn --verbose + OUTPUT_FILE ${CURRENT_BUILDTREES_DIR}/${LOGNAME}-out.log + ERROR_FILE ${CURRENT_BUILDTREES_DIR}/${LOGNAME}-err.log + WORKING_DIRECTORY ${_ap_SOURCE_PATH} + RESULT_VARIABLE error_code + ) + message(STATUS "Applying patch ${PATCH} done") + math(EXPR PATCHNUM "${PATCHNUM}+1") + endforeach() +endfunction() diff --git a/scripts/cmake/vcpkg_build_cmake.cmake b/scripts/cmake/vcpkg_build_cmake.cmake new file mode 100644 index 00000000000000..33990d9b060323 --- /dev/null +++ b/scripts/cmake/vcpkg_build_cmake.cmake @@ -0,0 +1,17 @@ +function(vcpkg_build_cmake) + message(STATUS "Build ${TARGET_TRIPLET}-rel") + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} --build . --config Release -- /p:VCPkgLocalAppDataDisabled=true + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + LOGNAME build-${TARGET_TRIPLET}-rel + ) + message(STATUS "Build ${TARGET_TRIPLET}-rel done") + + message(STATUS "Build ${TARGET_TRIPLET}-dbg") + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} --build . --config Debug -- /p:VCPkgLocalAppDataDisabled=true + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + LOGNAME build-${TARGET_TRIPLET}-dbg + ) + message(STATUS "Build ${TARGET_TRIPLET}-dbg done") +endfunction() diff --git a/scripts/cmake/vcpkg_build_msbuild.cmake b/scripts/cmake/vcpkg_build_msbuild.cmake new file mode 100644 index 00000000000000..bf7c1b5461ad77 --- /dev/null +++ b/scripts/cmake/vcpkg_build_msbuild.cmake @@ -0,0 +1,32 @@ +function(vcpkg_build_msbuild) + cmake_parse_arguments(_csc "" "PROJECT_PATH;RELEASE_CONFIGURATION;DEBUG_CONFIGURATION" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN}) + + if(NOT DEFINED _csc_RELEASE_CONFIGURATION) + set(_csc_RELEASE_CONFIGURATION Release) + endif() + if(NOT DEFINED _csc_DEBUG_CONFIGURATION) + set(_csc_DEBUG_CONFIGURATION Debug) + endif() + + message(STATUS "Building ${_csc_PROJECT_PATH} for Release") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + vcpkg_execute_required_process( + COMMAND msbuild ${_csc_PROJECT_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_RELEASE} + /p:Configuration=${_csc_RELEASE_CONFIGURATION} + /p:Platform=${TRIPLET_SYSTEM_ARCH} + /p:VCPkgLocalAppDataDisabled=true + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + LOGNAME build-${TARGET_TRIPLET}-rel + ) + + message(STATUS "Building ${_csc_PROJECT_PATH} for Debug") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + vcpkg_execute_required_process( + COMMAND msbuild ${_csc_PROJECT_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_DEBUG} + /p:Configuration=${_csc_DEBUG_CONFIGURATION} + /p:Platform=${TRIPLET_SYSTEM_ARCH} + /p:VCPkgLocalAppDataDisabled=true + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + LOGNAME build-${TARGET_TRIPLET}-dbg + ) +endfunction() \ No newline at end of file diff --git a/scripts/cmake/vcpkg_common_functions.cmake b/scripts/cmake/vcpkg_common_functions.cmake new file mode 100644 index 00000000000000..59824eb17c2726 --- /dev/null +++ b/scripts/cmake/vcpkg_common_functions.cmake @@ -0,0 +1,10 @@ +include(vcpkg_download_distfile) +include(vcpkg_extract_source_archive) +include(vcpkg_execute_required_process) +include(vcpkg_find_acquire_program) +include(vcpkg_build_cmake) +include(vcpkg_build_msbuild) +include(vcpkg_install_cmake) +include(vcpkg_configure_cmake) +include(vcpkg_apply_patches) +include(vcpkg_copy_pdbs) \ No newline at end of file diff --git a/scripts/cmake/vcpkg_configure_cmake.cmake b/scripts/cmake/vcpkg_configure_cmake.cmake new file mode 100644 index 00000000000000..aa85c8ff4ce180 --- /dev/null +++ b/scripts/cmake/vcpkg_configure_cmake.cmake @@ -0,0 +1,54 @@ +find_program(vcpkg_configure_cmake_NINJA ninja) +function(vcpkg_configure_cmake) + cmake_parse_arguments(_csc "" "SOURCE_PATH;GENERATOR" "OPTIONS;OPTIONS_DEBUG;OPTIONS_RELEASE" ${ARGN}) + + if(_csc_GENERATOR) + set(GENERATOR ${_csc_GENERATOR}) + elseif(TRIPLET_SYSTEM_NAME MATCHES "uwp" AND TRIPLET_SYSTEM_ARCH MATCHES "x86") + set(GENERATOR "Visual Studio 14 2015") + elseif(TRIPLET_SYSTEM_NAME MATCHES "uwp" AND TRIPLET_SYSTEM_ARCH MATCHES "x64") + set(GENERATOR "Visual Studio 14 2015 Win64") + elseif(TRIPLET_SYSTEM_NAME MATCHES "uwp" AND TRIPLET_SYSTEM_ARCH MATCHES "arm") + set(GENERATOR "Visual Studio 14 2015 ARM") + # elseif(NOT vcpkg_configure_cmake_NINJA MATCHES "NOTFOUND") + # set(GENERATOR "Ninja") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "x86") + set(GENERATOR "Visual Studio 14 2015") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "x64") + set(GENERATOR "Visual Studio 14 2015 Win64") + elseif(TRIPLET_SYSTEM_ARCH MATCHES "arm") + set(GENERATOR "Visual Studio 14 2015 ARM") + endif() + + file(REMOVE_RECURSE ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + + message(STATUS "Configuring ${TARGET_TRIPLET}-rel") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel) + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_RELEASE} + -G ${GENERATOR} + -DCMAKE_VERBOSE_MAKEFILE=ON + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_PREFIX_PATH=${CURRENT_INSTALLED_DIR} + -DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + LOGNAME config-${TARGET_TRIPLET}-rel + ) + message(STATUS "Configuring ${TARGET_TRIPLET}-rel done") + + message(STATUS "Configuring ${TARGET_TRIPLET}-dbg") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg) + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} ${_csc_SOURCE_PATH} ${_csc_OPTIONS} ${_csc_OPTIONS_DEBUG} + -G ${GENERATOR} + -DCMAKE_VERBOSE_MAKEFILE=ON + -DCMAKE_BUILD_TYPE=Debug + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_PREFIX_PATH=${CURRENT_INSTALLED_DIR}/debug\\\\\\\;${CURRENT_INSTALLED_DIR} + -DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR}/debug + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + LOGNAME config-${TARGET_TRIPLET}-dbg + ) + message(STATUS "Configuring ${TARGET_TRIPLET}-dbg done") +endfunction() \ No newline at end of file diff --git a/scripts/cmake/vcpkg_copy_pdbs.cmake b/scripts/cmake/vcpkg_copy_pdbs.cmake new file mode 100644 index 00000000000000..b99649d594c66d --- /dev/null +++ b/scripts/cmake/vcpkg_copy_pdbs.cmake @@ -0,0 +1,38 @@ +function(vcpkg_copy_pdbs) + function(merge_filelist OUTVAR INVAR) + set(MSG "") + foreach(VAR ${${INVAR}}) + set(MSG "${MSG} ${VAR}\n") + endforeach() + set(${OUTVAR} ${MSG} PARENT_SCOPE) + endfunction() + + file(GLOB_RECURSE DLLS ${CURRENT_PACKAGES_DIR}/bin/*.dll ${CURRENT_PACKAGES_DIR}/debug/bin/*.dll) + + set(DLLS_WITHOUT_MATCHING_PDBS) + + foreach(DLL ${DLLS}) + execute_process(COMMAND dumpbin /PDBPATH ${DLL} + COMMAND findstr PDB + OUTPUT_VARIABLE PDB_LINE + ERROR_QUIET + RESULT_VARIABLE error_code + ) + + if(NOT error_code AND PDB_LINE MATCHES "PDB file found at") + string(REGEX MATCH '.*' PDB_PATH ${PDB_LINE}) # Extract the path which is in single quotes + string(REPLACE ' "" PDB_PATH ${PDB_PATH}) # Remove single quotes + get_filename_component(DLL_DIR ${DLL} DIRECTORY) + file(COPY ${PDB_PATH} DESTINATION ${DLL_DIR}) + else() + list(APPEND DLLS_WITHOUT_MATCHING_PDBS ${DLL}) + endif() + endforeach() + + list(LENGTH DLLS_WITHOUT_MATCHING_PDBS UNMATCHED_DLLS_LENGTH) + if(UNMATCHED_DLLS_LENGTH GREATER 0) + merge_filelist(MSG DLLS_WITHOUT_MATCHING_PDBS) + message(STATUS "Warning: Could not find a matching pdb file for:\n${MSG}") + endif() + +endfunction() \ No newline at end of file diff --git a/scripts/cmake/vcpkg_download_distfile.cmake b/scripts/cmake/vcpkg_download_distfile.cmake new file mode 100644 index 00000000000000..7c36f5d97b0e9e --- /dev/null +++ b/scripts/cmake/vcpkg_download_distfile.cmake @@ -0,0 +1,20 @@ +# Usage: vcpkg_download_distfile( URL FILENAME MD5 <5981de...>) +function(vcpkg_download_distfile VAR) + set(oneValueArgs URL FILENAME MD5) + cmake_parse_arguments(vcpkg_download_distfile "" "${oneValueArgs}" "" ${ARGN}) + + if(EXISTS ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}) + message(STATUS "Using cached ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}") + file(MD5 ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME} FILE_HASH) + if(NOT FILE_HASH MATCHES ${vcpkg_download_distfile_MD5}) + message(FATAL_ERROR + "File does not have expected hash: ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME}\n" + " ${FILE_HASH} <> ${vcpkg_download_distfile_MD5}\n" + "Please delete the file and try again if this file should be downloaded again.") + endif() + else() + message(STATUS "Downloading ${vcpkg_download_distfile_URL}") + file(DOWNLOAD ${vcpkg_download_distfile_URL} ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME} EXPECTED_HASH MD5=${vcpkg_download_distfile_MD5}) + endif() + set(${VAR} ${DOWNLOADS}/${vcpkg_download_distfile_FILENAME} PARENT_SCOPE) +endfunction() diff --git a/scripts/cmake/vcpkg_execute_required_process.cmake b/scripts/cmake/vcpkg_execute_required_process.cmake new file mode 100644 index 00000000000000..bd6e56f7bf86cd --- /dev/null +++ b/scripts/cmake/vcpkg_execute_required_process.cmake @@ -0,0 +1,21 @@ +# Usage: vcpkg_execute_required_process(COMMAND [...] WORKING_DIRECTORY LOGNAME ) +function(vcpkg_execute_required_process) + cmake_parse_arguments(vcpkg_execute_required_process "" "WORKING_DIRECTORY;LOGNAME" "COMMAND" ${ARGN}) + #debug_message("vcpkg_execute_required_process(${vcpkg_execute_required_process_COMMAND})") + execute_process( + COMMAND ${vcpkg_execute_required_process_COMMAND} + OUTPUT_FILE ${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-out.log + ERROR_FILE ${CURRENT_BUILDTREES_DIR}/${vcpkg_execute_required_process_LOGNAME}-err.log + RESULT_VARIABLE error_code + WORKING_DIRECTORY ${vcpkg_execute_required_process_WORKING_DIRECTORY}) + #debug_message("error_code=${error_code}") + file(TO_NATIVE_PATH "${CURRENT_BUILDTREES_DIR}" NATIVE_BUILDTREES_DIR) + if(error_code) + message(FATAL_ERROR + "Command failed: ${vcpkg_execute_required_process_COMMAND}\n" + "Working Directory: ${vcpkg_execute_required_process_WORKING_DIRECTORY}\n" + "See logs for more information:\n" + " ${NATIVE_BUILDTREES_DIR}\\${vcpkg_execute_required_process_LOGNAME}-out.log\n" + " ${NATIVE_BUILDTREES_DIR}\\${vcpkg_execute_required_process_LOGNAME}-err.log\n") + endif() +endfunction() diff --git a/scripts/cmake/vcpkg_extract_source_archive.cmake b/scripts/cmake/vcpkg_extract_source_archive.cmake new file mode 100644 index 00000000000000..d970bb8b2003b4 --- /dev/null +++ b/scripts/cmake/vcpkg_extract_source_archive.cmake @@ -0,0 +1,14 @@ +include(vcpkg_execute_required_process) + +function(vcpkg_extract_source_archive ARCHIVE) + if(NOT EXISTS ${CURRENT_BUILDTREES_DIR}/src) + message(STATUS "Extracting source ${ARCHIVE}") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src) + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} -E tar xjf ${ARCHIVE} + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/src + LOGNAME extract + ) + endif() + message(STATUS "Extracting done") +endfunction() diff --git a/scripts/cmake/vcpkg_find_acquire_program.cmake b/scripts/cmake/vcpkg_find_acquire_program.cmake new file mode 100644 index 00000000000000..ce2cdaa26e0d78 --- /dev/null +++ b/scripts/cmake/vcpkg_find_acquire_program.cmake @@ -0,0 +1,51 @@ +function(vcpkg_find_acquire_program VAR) + if(${VAR} AND NOT ${VAR} MATCHES "-NOTFOUND") + return() + endif() + + unset(NOEXTRACT) + + if(VAR MATCHES "PERL") + set(PROGNAME perl) + set(PATHS ${DOWNLOADS}/tools/perl/perl/bin) + set(URL "http://strawberryperl.com/download/5.20.2.1/strawberry-perl-5.20.2.1-64bit-portable.zip") + set(ARCHIVE "strawberry-perl-5.20.2.1-64bit-portable.zip") + set(HASH 5fca4b3cfa7c9cc95e0c4fd8652eba80) + elseif(VAR MATCHES "NASM") + set(PROGNAME nasm) + set(PATHS ${DOWNLOADS}/tools/nasm/nasm-2.11.08) + set(URL "http://www.nasm.us/pub/nasm/releasebuilds/2.11.08/win32/nasm-2.11.08-win32.zip") + set(ARCHIVE "nasm-2.11.08-win32.zip") + set(HASH 46a31e22be69637f7a9ccba12874133f) + elseif(VAR MATCHES "YASM") + set(PROGNAME yasm) + set(PATHS ${DOWNLOADS}/tools/yasm) + set(URL "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win32.exe") + set(ARCHIVE "yasm.exe") + set(NOEXTRACT ON) + set(HASH 51e967dceddd1f84e67bff255df977b3) + else() + message(FATAL "unknown tool ${VAR} -- unable to acquire.") + endif() + + find_program(${VAR} ${PROGNAME} PATHS ${PATHS}) + if(${VAR} MATCHES "-NOTFOUND") + file(DOWNLOAD ${URL} ${DOWNLOADS}/${ARCHIVE} + EXPECTED_MD5 ${HASH} + SHOW_PROGRESS + ) + file(MAKE_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME}) + if(DEFINED NOEXTRACT) + file(COPY ${DOWNLOADS}/${ARCHIVE} DESTINATION ${DOWNLOADS}/tools/${PROGNAME}) + else() + execute_process( + COMMAND ${CMAKE_COMMAND} -E tar xzf ${DOWNLOADS}/${ARCHIVE} + WORKING_DIRECTORY ${DOWNLOADS}/tools/${PROGNAME} + ) + endif() + + find_program(${VAR} ${PROGNAME} PATHS ${PATHS}) + endif() + + set(${VAR} ${${VAR}} PARENT_SCOPE) +endfunction() diff --git a/scripts/cmake/vcpkg_install_cmake.cmake b/scripts/cmake/vcpkg_install_cmake.cmake new file mode 100644 index 00000000000000..14f1bc94d87d75 --- /dev/null +++ b/scripts/cmake/vcpkg_install_cmake.cmake @@ -0,0 +1,17 @@ +function(vcpkg_install_cmake) + message(STATUS "Package ${TARGET_TRIPLET}-rel") + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} --build . --config Release --target install + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel + LOGNAME package-${TARGET_TRIPLET}-rel + ) + message(STATUS "Package ${TARGET_TRIPLET}-rel done") + + message(STATUS "Package ${TARGET_TRIPLET}-dbg") + vcpkg_execute_required_process( + COMMAND ${CMAKE_COMMAND} --build . --config Debug --target install + WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg + LOGNAME package-${TARGET_TRIPLET}-dbg + ) + message(STATUS "Package ${TARGET_TRIPLET}-dbg done") +endfunction() diff --git a/scripts/doVcpkgRelease.ps1 b/scripts/doVcpkgRelease.ps1 new file mode 100644 index 00000000000000..935eea031a9661 --- /dev/null +++ b/scripts/doVcpkgRelease.ps1 @@ -0,0 +1,84 @@ +[CmdletBinding()] +param( + +) + +$version = git show HEAD:toolsrc/VERSION.txt +#Remove the quotes from the string +$version = $version.Substring(1, $version.length - 2) +$versionRegex = '^\d+\.\d+\.\d+$' +if (!($version -match $versionRegex)) +{ + throw [System.ArgumentException] ("Expected version in the form d.d.d but was " + $version) +} + +Write-Verbose("New version is " + $version) +$gitTagString = "v$version" + +# Intentionally doesn't have ^ (=starts with) to match remote tags as well +$matchingTags = git tag | Where-Object {$_ -match "$gitTagString$"} +if ($matchingTags.Length -gt 0) +{ + throw [System.ArgumentException] ("Git tag matches existing tags: " + $matchingTags) +} + +$gitHash = git rev-parse HEAD +Write-Verbose("Git hash is " + $gitHash) + +$vcpkgPath = (get-item $PSScriptRoot).parent.FullName +$gitStartOfHash = $gitHash.substring(0,6) +$versionWithStartOfHash = "$version-$gitStartOfHash" +$buildPath = "$vcpkgPath\build-$versionWithStartOfHash" +$releasePath = "$vcpkgPath\release-$versionWithStartOfHash" +Write-Verbose("Build Path " + $buildPath) +Write-Verbose("Release Path " + $releasePath) + +# 0 is metrics disabled, 1 is metrics enabled +for ($disableMetrics = 0; $disableMetrics -le 1; $disableMetrics++) +{ + + if (!(Test-Path $buildPath)) + { + New-Item -ItemType directory -Path $buildPath -force | Out-Null + } + + if (!(Test-Path $releasePath)) + { + New-Item -ItemType directory -Path $releasePath -force | Out-Null + } + + # Partial checkout for building vcpkg + $dotGitDir = "$vcpkgPath\.git" + $workTreeForBuildOnly = "$buildPath" + $checkoutThisDirForBuildOnly1 = ".\scripts" # Must be relative to the root of the repository + $checkoutThisDirForBuildOnly2 = ".\toolsrc" # Must be relative to the root of the repository + Write-Verbose("Creating partial temporary checkout: $buildPath") + git --git-dir="$dotGitDir" --work-tree="$workTreeForBuildOnly" checkout $gitHash -f -q -- $checkoutThisDirForBuildOnly1 + git --git-dir="$dotGitDir" --work-tree="$workTreeForBuildOnly" checkout $gitHash -f -q -- $checkoutThisDirForBuildOnly2 + + & "$buildPath\scripts\bootstrap.ps1" -disableMetrics $disableMetrics + + # Full checkout which will be a zip along with the executables from the previous step + $workTree = "$releasePath" + $checkoutThisDir = ".\" # Must be relative to the root of the repository + Write-Verbose("Creating temporary checkout: $releasePath") + git --git-dir=$dotGitDir --work-tree=$workTree checkout $gitHash -f -q -- $checkoutThisDir + + Copy-Item $buildPath\vcpkg.exe $releasePath\vcpkg.exe | Out-Null + Copy-Item $buildPath\scripts\vcpkgmetricsuploader.exe $releasePath\scripts\vcpkgmetricsuploader.exe | Out-Null + + Write-Verbose("Archiving") + $outputArchive = "$vcpkgPath\vcpkg-$versionWithStartOfHash.zip" + if ($disableMetrics -ne 0) + { + $outputArchive = "$vcpkgPath\vcpkg-$versionWithStartOfHash-external.zip" + } + Compress-Archive -Path "$releasePath\*" -CompressionLevel Optimal -DestinationPath $outputArchive -Force | Out-Null + + Write-Verbose("Removing temporary checkouts: $releasePath") + Remove-Item -recurse $buildPath | Out-Null + Remove-Item -recurse $releasePath | Out-Null + + Write-Verbose("Redistributable archive is: $outputArchive") +} +git tag $gitTagString \ No newline at end of file diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1 new file mode 100644 index 00000000000000..5873fd7274d5a6 --- /dev/null +++ b/scripts/fetchDependency.ps1 @@ -0,0 +1,212 @@ +[CmdletBinding()] +param( + [string]$Dependency +) + +Import-Module BitsTransfer + +$scriptsdir = split-path -parent $MyInvocation.MyCommand.Definition +$vcpkgroot = Split-path $scriptsdir -Parent +$downloadsdir = "$vcpkgroot\downloads" + +function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency) +{ + function hasGreaterOrEqualVersion([Parameter(Mandatory=$true)]$requiredVersion, [Parameter(Mandatory=$true)]$availableVersion) + { + if ($availableVersion[0] -gt $requiredVersion[0]) {return $true} + if ($availableVersion[0] -lt $requiredVersion[0]) {return $false} + + if ($availableVersion[1] -gt $requiredVersion[1]) {return $true} + if ($availableVersion[1] -lt $requiredVersion[1]) {return $false} + + return ($availableVersion[2] -ge $requiredVersion[2]) + } + + function promptForDownload([string]$title, [string]$message, [string]$yesDescription, [string]$noDescription) + { + if ((Test-Path "$downloadsdir\AlwaysAllowEverything") -Or (Test-Path "$downloadsdir\AlwaysAllowDownloads")) + { + return $true + } + + $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", $yesDescription + $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", $noDescription + $AlwaysAllowDownloads = New-Object System.Management.Automation.Host.ChoiceDescription "&Always Allow Downloads", ($yesDescription + "(Future download prompts will not be displayed)") + + $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no, $AlwaysAllowDownloads) + $result = $host.ui.PromptForChoice($title, $message, $options, 0) + + switch ($result) + { + 0 {return $true} + 1 {return $false} + 2 { + New-Item "$downloadsdir\AlwaysAllowDownloads" -type file -force | Out-Null + return $true + } + } + + throw "Unexpected result" + } + + + function performDownload( [Parameter(Mandatory=$true)][string]$Dependency, + [Parameter(Mandatory=$true)][string]$url, + [Parameter(Mandatory=$true)][string]$downloaddir, + [Parameter(Mandatory=$true)][string]$downloadPath, + [Parameter(Mandatory=$true)][string]$downloadVersion, + [Parameter(Mandatory=$true)][string]$requiredVersion) + { + if (Test-Path $downloadPath) + { + return + } + + $title = "Download " + $Dependency + $message = ("No suitable version of " + $Dependency + " was found (requires $requiredVersion or higher). Download portable version?") + $yesDescription = "Downloads " + $Dependency + " v" + $downloadVersion +" app-locally." + $noDescription = "Does not download " + $Dependency + "." + + $userAllowedDownload = promptForDownload $title $message $yesDescription $noDescription + if (!$userAllowedDownload) + { + throw [System.IO.FileNotFoundException] ("Could not detect suitable version of " + $Dependency + " and download not allowed") + } + + if (!(Test-Path $downloaddir)) + { + New-Item -ItemType directory -Path $downloaddir | Out-Null + } + + if ($Dependency -ne "git") # git fails with BITS + { + Start-BitsTransfer -Source $url -Destination $downloadPath -ErrorAction SilentlyContinue + } + else + { + if (!(Test-Path $downloadPath)) + { + Write-Host("Downloading $Dependency...") + (New-Object System.Net.WebClient).DownloadFile($url, $downloadPath) + } + } + } + + # Enums (without resorting to C#) are only available on powershell 5+. + $ExtractionType_NO_EXTRACTION_REQUIRED = 0 + $ExtractionType_ZIP = 1 + $ExtractionType_SELF_EXTRACTING_7Z = 2 + + + # Using this to wait for the execution to finish + function Invoke-Command() + { + param ( [string]$program = $(throw "Please specify a program" ), + [string]$argumentString = "", + [switch]$waitForExit ) + + $psi = new-object "Diagnostics.ProcessStartInfo" + $psi.FileName = $program + $psi.Arguments = $argumentString + $proc = [Diagnostics.Process]::Start($psi) + if ( $waitForExit ) + { + $proc.WaitForExit(); + } + } + + function Expand-ZIPFile($file, $destination) + { + Write-Host($file) + Write-Host($destination) + $shell = new-object -com shell.application + $zip = $shell.NameSpace($file) + foreach($item in $zip.items()) + { + # Piping to Out-Null is used to block until finished + $shell.Namespace($destination).copyhere($item) | Out-Null + } + } + + if($Dependency -eq "cmake") + { + $requiredVersion = "3.5.0" + $downloadVersion = "3.5.2" + $url = "https://cmake.org/files/v3.5/cmake-3.5.2-win32-x86.zip" + $downloadName = "cmake-3.5.2-win32-x86.zip" + $expectedDownloadedFileHash = "671073aee66b3480a564d0736792e40570a11e861bb34819bb7ae7858bbdfb80" + $executableFromDownload = "$downloadsdir\cmake-3.5.2-win32-x86\bin\cmake.exe" + $extractionType = $ExtractionType_ZIP + } + elseif($Dependency -eq "nuget") + { + $requiredVersion = "1.0.0" + $downloadVersion = "3.4.3" + $url = "https://dist.nuget.org/win-x86-commandline/v3.4.3/nuget.exe" + $downloadName = "nuget.exe" + $expectedDownloadedFileHash = "3B1EA72943968D7AF6BACDB4F2F3A048A25AFD14564EF1D8B1C041FDB09EBB0A" + $executableFromDownload = "$downloadsdir\nuget.exe" + $extractionType = $ExtractionType_NO_EXTRACTION_REQUIRED + } + elseif($Dependency -eq "git") + { + $requiredVersion = "2.0.0" + $downloadVersion = "2.8.3" + $url = "https://github.com/git-for-windows/git/releases/download/v2.8.3.windows.1/PortableGit-2.8.3-32-bit.7z.exe" # We choose the 32-bit version + $downloadName = "PortableGit-2.8.3-32-bit.7z.exe" + $expectedDownloadedFileHash = "DE52D070219E9C4EC1DB179F2ADBF4B760686C3180608F0382A1F8C7031E72AD" + # There is another copy of git.exe in PortableGit\bin. However, an installed version of git add the cmd dir to the PATH. + # Therefore, choosing the cmd dir here as well. + $executableFromDownload = "$downloadsdir\PortableGit\cmd\git.exe" + $extractionType = $ExtractionType_SELF_EXTRACTING_7Z + } + else + { + throw "Unknown program requested" + } + + $downloadPath = "$downloadsdir\$downloadName" + performDownload $Dependency $url $downloadsdir $downloadPath $downloadVersion $requiredVersion + + #calculating the hash + $hashAlgorithm = [Security.Cryptography.HashAlgorithm]::Create("SHA256") + $fileAsByteArray = [io.File]::ReadAllBytes($downloadPath) + $hashByteArray = $hashAlgorithm.ComputeHash($fileAsByteArray) + $downloadedFileHash = -Join ($hashByteArray | ForEach {"{0:x2}" -f $_}) + + if ($expectedDownloadedFileHash -ne $downloadedFileHash) + { + throw [System.IO.FileNotFoundException] ("Mismatching hash of the downloaded " + $Dependency) + } + + if ($extractionType -eq $ExtractionType_NO_EXTRACTION_REQUIRED) + { + # do nothing + } + elseif($extractionType -eq $ExtractionType_ZIP) + { + if (-not (Test-Path $executableFromDownload)) # consider renaming the extraction folder to make sure the extraction finished + { + # Expand-Archive $downloadPath -dest "$downloadsdir" -Force # Requires powershell 5+ + Expand-ZIPFile -File $downloadPath -Destination $downloadsdir + } + } + elseif($extractionType -eq $ExtractionType_SELF_EXTRACTING_7Z) + { + if (-not (Test-Path $executableFromDownload)) + { + Invoke-Command $downloadPath "-y" -waitForExit:$true + } + } + else + { + throw "Invalid extraction type" + } + + if (-not (Test-Path $executableFromDownload)) + { + throw [System.IO.FileNotFoundException] ("Could not detect or download " + $Dependency) + } +} + +SelectProgram $Dependency \ No newline at end of file diff --git a/scripts/ports.cmake b/scripts/ports.cmake new file mode 100644 index 00000000000000..51afc8d6155aec --- /dev/null +++ b/scripts/ports.cmake @@ -0,0 +1,85 @@ +cmake_minimum_required(VERSION 3.5) +get_filename_component(VCPKG_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) + +string(REGEX REPLACE "([^-]*)-([^-]*)" "\\1" TRIPLET_SYSTEM_ARCH ${TARGET_TRIPLET}) +string(REGEX REPLACE "([^-]*)-([^-]*)" "\\2" TRIPLET_SYSTEM_NAME ${TARGET_TRIPLET}) + +if(NOT EXISTS ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake) + message(FATAL_ERROR "Unsupported target triplet. Toolchain file does not exist: ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake") +endif() + +set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT_DIR}/triplets/${TARGET_TRIPLET}.cmake) +list(APPEND CMAKE_MODULE_PATH ${VCPKG_ROOT_DIR}/scripts/cmake) +set(CURRENT_INSTALLED_DIR ${VCPKG_ROOT_DIR}/installed/${TARGET_TRIPLET} CACHE PATH "Location to install final packages") +set(DOWNLOADS ${VCPKG_ROOT_DIR}/downloads CACHE PATH "Location to download sources and tools") +set(PACKAGES_DIR ${VCPKG_ROOT_DIR}/packages CACHE PATH "Location to store package images") +set(BUILDTREES_DIR ${VCPKG_ROOT_DIR}/buildtrees CACHE PATH "Location to perform actual extract+config+build") + +if(PORT) + set(CURRENT_BUILDTREES_DIR ${BUILDTREES_DIR}/${PORT}) + set(CURRENT_PACKAGES_DIR ${PACKAGES_DIR}/${PORT}_${TARGET_TRIPLET}) +endif() + +macro(debug_message) + if(DEFINED PORT_DEBUG AND PORT_DEBUG) + message(STATUS "[DEBUG] ${ARGN}") + endif() +endmacro() + +if(CMD MATCHES "^SCAFFOLD$") + if(EXISTS ports/${PORT}/portfile.cmake) + message(FATAL_ERROR "Portfile already exists: '${VCPKG_ROOT_DIR}/ports/${PORT}/portfile.cmake'") + endif() + if(NOT FILENAME) + get_filename_component(FILENAME "${URL}" NAME) + endif() + string(REGEX REPLACE "(\\.(zip|gz|tar|tgz|bz2))+\$" "" ROOT_NAME ${FILENAME}) + if(EXISTS ${DOWNLOADS}/${FILENAME}) + message(STATUS "Using pre-downloaded: ${DOWNLOADS}/${FILENAME}") + message(STATUS "If this is not desired, delete the file and ${VCPKG_ROOT_DIR}/ports/${PORT}/portfile.cmake") + else() + include(vcpkg_download_distfile) + file(DOWNLOAD ${URL} ${DOWNLOADS}/${FILENAME} STATUS error_code) + if(NOT error_code MATCHES "0;") + message(FATAL_ERROR "Error downloading file: ${error_code}") + endif() + endif() + file(MD5 ${DOWNLOADS}/${FILENAME} MD5) + + file(MAKE_DIRECTORY ports/${PORT}) + configure_file(scripts/templates/portfile.in.cmake ports/${PORT}/portfile.cmake @ONLY) + + message(STATUS "Generated portfile: ${VCPKG_ROOT_DIR}/ports/${PORT}/portfile.cmake") +elseif(CMD MATCHES "^BUILD$") + if(NOT DEFINED CURRENT_PORT_DIR) + message(FATAL_ERROR "CURRENT_PORT_DIR was not defined") + endif() + set(TO_CMAKE_PATH "${CURRENT_PORT_DIR}" CURRENT_PORT_DIR) + if(NOT EXISTS ${CURRENT_PORT_DIR}) + message(FATAL_ERROR "Cannot find port: ${PORT}\n Directory does not exist: ${CURRENT_PORT_DIR}") + endif() + if(NOT EXISTS ${CURRENT_PORT_DIR}/portfile.cmake) + message(FATAL_ERROR "Port is missing portfile: ${CURRENT_PORT_DIR}/portfile.cmake") + endif() + if(NOT EXISTS ${CURRENT_PORT_DIR}/CONTROL) + message(FATAL_ERROR "Port is missing control file: ${CURRENT_PORT_DIR}/CONTROL") + endif() + + message(STATUS "CURRENT_INSTALLED_DIR=${CURRENT_INSTALLED_DIR}") + message(STATUS "DOWNLOADS=${DOWNLOADS}") + + message(STATUS "CURRENT_PACKAGES_DIR=${CURRENT_PACKAGES_DIR}") + message(STATUS "CURRENT_BUILDTREES_DIR=${CURRENT_BUILDTREES_DIR}") + message(STATUS "CURRENT_PORT_DIR=${CURRENT_PORT_DIR}") + + unset(PACKAGES_DIR) + unset(BUILDTREES_DIR) + + file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}) + if(EXISTS ${CURRENT_PACKAGES_DIR}) + message(FATAL_ERROR "Unable to remove directory: ${CURRENT_PACKAGES_DIR}\n Files are likely in use.") + endif() + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR} ${CURRENT_PACKAGES_DIR}) + + include(${CURRENT_PORT_DIR}/portfile.cmake) +endif() diff --git a/scripts/templates/portfile.in.cmake b/scripts/templates/portfile.in.cmake new file mode 100644 index 00000000000000..b29e2b68250818 --- /dev/null +++ b/scripts/templates/portfile.in.cmake @@ -0,0 +1,21 @@ +include(vcpkg_common_functions) +vcpkg_download_distfile(ARCHIVE + URL "@URL@" + FILENAME "@FILENAME@" + MD5 @MD5@ +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_configure_cmake( + SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/@ROOT_NAME@ + # OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2 + # OPTIONS_RELEASE -DOPTIMIZE=1 + # OPTIONS_DEBUG -DDEBUGGABLE=1 +) + +vcpkg_build_cmake() +vcpkg_install_cmake() + +# Handle copyright +#file(COPY ${CURRENT_BUILDTREES_DIR}/src/@ROOT_NAME@/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/@PORT@) +#file(RENAME ${CURRENT_PACKAGES_DIR}/share/@PORT@/LICENSE ${CURRENT_PACKAGES_DIR}/share/@PORT@/copyright) \ No newline at end of file diff --git a/toolsrc/VERSION.txt b/toolsrc/VERSION.txt new file mode 100644 index 00000000000000..f723d10e051827 --- /dev/null +++ b/toolsrc/VERSION.txt @@ -0,0 +1 @@ +"0.0.30" \ No newline at end of file diff --git a/toolsrc/include/BinaryParagraph.h b/toolsrc/include/BinaryParagraph.h new file mode 100644 index 00000000000000..88d6e84b1b8746 --- /dev/null +++ b/toolsrc/include/BinaryParagraph.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include "SourceParagraph.h" +#include "triplet.h" + +namespace vcpkg +{ + struct BinaryParagraph + { + BinaryParagraph(); + explicit BinaryParagraph(const std::unordered_map& fields); + BinaryParagraph(const SourceParagraph& spgh, const triplet& target_triplet); + + std::string displayname() const; + + std::string fullstem() const; + + std::string dir() const; + + std::string name; + std::string version; + std::string description; + std::string maintainer; + triplet target_triplet; + std::vector depends; + }; + + std::ostream& operator<<(std::ostream& os, const BinaryParagraph& pgh); +} diff --git a/toolsrc/include/SourceParagraph.h b/toolsrc/include/SourceParagraph.h new file mode 100644 index 00000000000000..72dca832465a4d --- /dev/null +++ b/toolsrc/include/SourceParagraph.h @@ -0,0 +1,20 @@ +#pragma once + +#include +#include + +namespace vcpkg +{ + struct SourceParagraph + { + SourceParagraph(); + + explicit SourceParagraph(const std::unordered_map& fields); + + std::string name; + std::string version; + std::string description; + std::string maintainer; + std::vector depends; + }; +} diff --git a/toolsrc/include/StatusParagraph.h b/toolsrc/include/StatusParagraph.h new file mode 100644 index 00000000000000..1386bbdf4495d5 --- /dev/null +++ b/toolsrc/include/StatusParagraph.h @@ -0,0 +1,41 @@ +#pragma once + +#include +#include "BinaryParagraph.h" + +namespace vcpkg +{ + enum class install_state_t + { + error, + not_installed, + half_installed, + installed, + }; + + enum class want_t + { + error, + unknown, + install, + hold, + deinstall, + purge + }; + + struct StatusParagraph + { + StatusParagraph(); + explicit StatusParagraph(const std::unordered_map& fields); + + BinaryParagraph package; + want_t want; + install_state_t state; + }; + + std::ostream& operator<<(std::ostream& os, const StatusParagraph& pgh); + + std::string to_string(install_state_t f); + + std::string to_string(want_t f); +} diff --git a/toolsrc/include/StatusParagraphs.h b/toolsrc/include/StatusParagraphs.h new file mode 100644 index 00000000000000..9446d432c251a7 --- /dev/null +++ b/toolsrc/include/StatusParagraphs.h @@ -0,0 +1,49 @@ +#pragma once +#include "StatusParagraph.h" +#include + +namespace vcpkg +{ + struct StatusParagraphs + { + StatusParagraphs(); + explicit StatusParagraphs(std::vector>&& ps); + + using container = std::vector>; + using iterator = container::reverse_iterator; + using const_iterator = container::const_reverse_iterator; + + const_iterator find(const std::string& name, const triplet& target_triplet) const; + iterator find(const std::string& name, const triplet& target_triplet); + iterator find_installed(const std::string& name, const triplet& target_triplet); + + iterator insert(std::unique_ptr); + + friend std::ostream& operator<<(std::ostream&, const StatusParagraphs&); + + auto end() + { + return paragraphs.rend(); + } + + auto end() const + { + return paragraphs.rend(); + } + + auto begin() + { + return paragraphs.rbegin(); + } + + auto begin() const + { + return paragraphs.rbegin(); + } + + private: + std::vector> paragraphs; + }; + + std::ostream& operator<<(std::ostream&, const StatusParagraphs&); +} diff --git a/toolsrc/include/expected.h b/toolsrc/include/expected.h new file mode 100644 index 00000000000000..affabcc023be89 --- /dev/null +++ b/toolsrc/include/expected.h @@ -0,0 +1,81 @@ +#pragma once + +#include "vcpkg_Checks.h" + +namespace vcpkg +{ + template + class expected + { + public: + // Constructors are intentionally implicit + expected(const std::error_code& ec) : m_error_code(ec), m_t() + { + } + + expected(std::errc ec) : expected(std::make_error_code(ec)) + { + } + + expected(const T& t) : m_error_code(), m_t(t) + { + } + + expected(T&& t) : m_error_code(), m_t(std::move(t)) + { + } + + expected() : expected(std::error_code(), T()) + { + } + + expected(const expected&) = default; + expected(expected&&) = default; + expected& operator=(const expected&) = default; + expected& operator=(expected&&) = default; + + std::error_code error_code() const + { + return this->m_error_code; + } + + T&& get_or_throw() && + { + throw_if_error(); + return std::move(this->m_t); + } + + const T& get_or_throw() const & + { + throw_if_error(); + return this->m_t; + } + + const T* get() const + { + if (m_error_code) + { + return nullptr; + } + return &this->m_t; + } + + T* get() + { + if (m_error_code) + { + return nullptr; + } + return &this->m_t; + } + + private: + void throw_if_error() const + { + Checks::check_throw(!this->m_error_code, this->m_error_code.message().c_str()); + } + + std::error_code m_error_code; + T m_t; + }; +} diff --git a/toolsrc/include/metrics.h b/toolsrc/include/metrics.h new file mode 100644 index 00000000000000..52662cd97b1589 --- /dev/null +++ b/toolsrc/include/metrics.h @@ -0,0 +1,19 @@ +#pragma once + +#include + +namespace vcpkg +{ + void SetSendMetrics(bool should_send_metrics); + void SetPrintMetrics(bool should_print_metrics); + void SetUserInformation(const std::string& user_id, const std::string& first_use_time); + void InitUserInformation(std::string& user_id, std::string& first_use_time); + + void TrackMetric(const std::string& name, double value); + void TrackProperty(const std::string& name, const std::string& value); + void TrackProperty(const std::string& name, const std::wstring& value); + bool GetCompiledMetricsEnabled(); + + void Upload(const std::string& payload); + void Flush(); +} diff --git a/toolsrc/include/opt_bool.h b/toolsrc/include/opt_bool.h new file mode 100644 index 00000000000000..3856366c8a89a0 --- /dev/null +++ b/toolsrc/include/opt_bool.h @@ -0,0 +1,11 @@ +#pragma once + +namespace vcpkg +{ + enum class opt_bool + { + unspecified, + enabled, + disabled + }; +} diff --git a/toolsrc/include/package_spec.h b/toolsrc/include/package_spec.h new file mode 100644 index 00000000000000..b8ed1e088edf86 --- /dev/null +++ b/toolsrc/include/package_spec.h @@ -0,0 +1,50 @@ +#pragma once +#include +#include "package_spec_parse_result.h" +#include "triplet.h" +#include "expected.h" + +namespace vcpkg +{ + struct package_spec + { + std::string name; + triplet target_triplet; + + std::string dir() const; + }; + + expected parse(const std::string& spec, const triplet& default_target_triplet); + + std::string to_string(const package_spec& spec); + + std::string to_printf_arg(const package_spec& spec); + + bool operator==(const package_spec& left, const package_spec& right); + + std::ostream& operator<<(std::ostream& os, const package_spec& spec); +} //namespace vcpkg + +namespace std +{ + template <> + struct hash + { + size_t operator()(const vcpkg::package_spec& value) const + { + size_t hash = 17; + hash = hash * 31 + std::hash()(value.name); + hash = hash * 31 + std::hash()(value.target_triplet); + return hash; + } + }; + + template <> + struct equal_to + { + bool operator()(const vcpkg::package_spec& left, const vcpkg::package_spec& right) const + { + return left == right; + } + }; +} // namespace std diff --git a/toolsrc/include/package_spec_parse_result.h b/toolsrc/include/package_spec_parse_result.h new file mode 100644 index 00000000000000..e59622951529dc --- /dev/null +++ b/toolsrc/include/package_spec_parse_result.h @@ -0,0 +1,34 @@ +#pragma once +#include + +namespace vcpkg +{ + enum class package_spec_parse_result + { + success = 0, + too_many_colons + }; + + struct package_spec_parse_result_category_impl final : std::error_category + { + virtual const char* name() const noexcept override; + + virtual std::string message(int ev) const noexcept override; + }; + + const std::error_category& package_spec_parse_result_category(); + + std::error_code make_error_code(package_spec_parse_result e); + + package_spec_parse_result to_package_spec_parse_result(int i); + + package_spec_parse_result to_package_spec_parse_result(std::error_code ec); +} + +// Enable implicit conversion to std::error_code +namespace std +{ + template <> + struct is_error_code_enum : ::std::true_type + {}; +} diff --git a/toolsrc/include/post_build_lint.h b/toolsrc/include/post_build_lint.h new file mode 100644 index 00000000000000..bc916a7afbe0a0 --- /dev/null +++ b/toolsrc/include/post_build_lint.h @@ -0,0 +1,8 @@ +#pragma once +#include "package_spec.h" +#include "vcpkg_paths.h" + +namespace vcpkg +{ + void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths); +} diff --git a/toolsrc/include/triplet.h b/toolsrc/include/triplet.h new file mode 100644 index 00000000000000..f9d1e9483ae5e8 --- /dev/null +++ b/toolsrc/include/triplet.h @@ -0,0 +1,55 @@ +#pragma once + +#include + +namespace vcpkg +{ + struct triplet + { + static const triplet X86_WINDOWS; + static const triplet X64_WINDOWS; + static const triplet X86_UWP; + static const triplet X64_UWP; + static const triplet ARM_UWP; + + std::string value; + + std::string architecture() const; + + std::string system() const; + }; + + bool operator==(const triplet& left, const triplet& right); + + bool operator!=(const triplet& left, const triplet& right); + + std::string to_string(const triplet& spec); + + std::string to_printf_arg(const triplet& spec); + + std::ostream& operator<<(std::ostream& os, const triplet& spec); +} + +namespace std +{ + template <> + struct hash + { + size_t operator()(const vcpkg::triplet& t) const + { + std::hash hasher; + size_t hash = 17; + hash = hash * 31 + hasher(t.value); + return hash; + } + }; + + template <> + struct equal_to + { + bool operator()(const vcpkg::triplet& left, const vcpkg::triplet& right) const + { + return left == right; + } + }; +} // namespace std diff --git a/toolsrc/include/vcpkg.h b/toolsrc/include/vcpkg.h new file mode 100644 index 00000000000000..264d61fa959b76 --- /dev/null +++ b/toolsrc/include/vcpkg.h @@ -0,0 +1,37 @@ +#pragma once + +#include +#include +#include +#include "package_spec.h" +#include "BinaryParagraph.h" +#include "StatusParagraphs.h" +#include "vcpkg_paths.h" + +namespace vcpkg +{ + namespace fs = std::tr2::sys; + + extern bool g_do_dry_run; + + std::vector> get_paragraphs(const fs::path& control_path); + std::vector> parse_paragraphs(const std::string& str); + std::string shorten_description(const std::string& desc); + + fs::path find_available_package(const vcpkg_paths& paths, const package_spec& spec); + fs::path find_available_port_file(const vcpkg_paths& paths, const package_spec& spec); + fs::path control_file_for_package(const fs::path& package_path); + + StatusParagraphs database_load_check(const vcpkg_paths& paths); + + std::vector get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db); + + void install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db); + void deinstall_package(const vcpkg_paths& paths, const package_spec& spec, StatusParagraphs& status_db); + + void search_file(const vcpkg_paths& paths, const std::string& file_substr, const StatusParagraphs& status_db); + + void binary_import(const vcpkg_paths& paths, const fs::path& include_directory, const fs::path& project_directory, const BinaryParagraph& control_file_data); + + const std::string& version(); +} // namespace vcpkg diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h new file mode 100644 index 00000000000000..05bd0e729576ca --- /dev/null +++ b/toolsrc/include/vcpkg_Checks.h @@ -0,0 +1,49 @@ +#pragma once + +#include "vcpkg_Strings.h" + +namespace vcpkg {namespace Checks +{ + __declspec(noreturn) void unreachable(); + + // Part of the reason these exist is to not include extra headers in this one to avoid circular #includes. + _declspec(noreturn) void exit_with_message(const char* errorMessage); + + template + _declspec(noreturn) void exit_with_message(const char* errorMessageTemplate, const Args&... errorMessageArgs) + { + exit_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + } + + _declspec(noreturn) void throw_with_message(const char* errorMessage); + + template + _declspec(noreturn) void throw_with_message(const char* errorMessageTemplate, const Args&... errorMessageArgs) + { + throw_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...)); + } + + void check_throw(bool expression, const char* errorMessage); + + template + void check_throw(bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs) + { + if (!expression) + { + // Only create the string if the expression is false + throw_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + } + } + + void check_exit(bool expression, const char* errorMessage); + + template + void check_exit(bool expression, const char* errorMessageTemplate, const Args&... errorMessageArgs) + { + if (!expression) + { + // Only create the string if the expression is false + exit_with_message(Strings::format(errorMessageTemplate, errorMessageArgs...).c_str()); + } + } +}} diff --git a/toolsrc/include/vcpkg_Commands.h b/toolsrc/include/vcpkg_Commands.h new file mode 100644 index 00000000000000..c706c131cbfcf5 --- /dev/null +++ b/toolsrc/include/vcpkg_Commands.h @@ -0,0 +1,67 @@ +#pragma once + +#include "vcpkg_cmd_arguments.h" +#include "vcpkg_paths.h" + +namespace vcpkg +{ + extern const char*const INTEGRATE_COMMAND_HELPSTRING; + + void print_usage(); + void print_example(const char* command_and_arguments); + void update_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths); + + void build_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet); + void build_external_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet); + void install_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet); + void remove_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet); + + void edit_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet); + void create_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet); + + void search_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths); + void list_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths); + void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths); + void owns_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths); + void internal_test_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths); + + void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths); + + void integrate_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths); + + void help_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths); + void help_topic_valid_triplet(const vcpkg_paths& paths); + + void version_command(const vcpkg_cmd_arguments& args); + void contact_command(const vcpkg_cmd_arguments& args); + + using command_type_a = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet); + using command_type_b = void(*)(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths); + using command_type_c = void(*)(const vcpkg_cmd_arguments& args); + + template + struct package_name_and_function + { + std::string name; + T function; + }; + + const std::vector>& get_available_commands_type_a(); + const std::vector>& get_available_commands_type_b(); + const std::vector>& get_available_commands_type_c(); + + template + T find_command(const std::string& command_name, const std::vector> available_commands) + { + for (const package_name_and_function& cmd : available_commands) + { + if (cmd.name == command_name) + { + return cmd.function; + } + } + + // not found + return nullptr; + } +} diff --git a/toolsrc/include/vcpkg_Environment.h b/toolsrc/include/vcpkg_Environment.h new file mode 100644 index 00000000000000..877ac7deb527b9 --- /dev/null +++ b/toolsrc/include/vcpkg_Environment.h @@ -0,0 +1,17 @@ +#pragma once +#include "vcpkg_paths.h" + +namespace vcpkg {namespace Environment +{ + void ensure_nuget_on_path(const vcpkg_paths& paths); + + void ensure_git_on_path(const vcpkg_paths& paths); + + void ensure_cmake_on_path(const vcpkg_paths& paths); + + inline void ensure_utilities_on_path(const vcpkg_paths& paths) + { + ensure_cmake_on_path(paths); + ensure_git_on_path(paths); + } +}} diff --git a/toolsrc/include/vcpkg_Files.h b/toolsrc/include/vcpkg_Files.h new file mode 100644 index 00000000000000..d23742f74fc415 --- /dev/null +++ b/toolsrc/include/vcpkg_Files.h @@ -0,0 +1,11 @@ +#pragma once + +#include "expected.h" +#include + +namespace vcpkg {namespace Files +{ + void check_is_directory(const std::tr2::sys::path& dirpath); + + expected get_contents(const std::tr2::sys::path& file_path) noexcept; +}} diff --git a/toolsrc/include/vcpkg_Graphs.h b/toolsrc/include/vcpkg_Graphs.h new file mode 100644 index 00000000000000..81b189f0eb7a4d --- /dev/null +++ b/toolsrc/include/vcpkg_Graphs.h @@ -0,0 +1,119 @@ +#pragma once + +#include + +namespace vcpkg { namespace Graphs +{ + enum class ExplorationStatus + { + // We have not visited this vertex + NOT_EXPLORED, + + // We have visited this vertex but haven't visited all vertices in its subtree + PARTIALLY_EXPLORED, + + // We have visited this vertex and all vertices in its subtree + FULLY_EXPLORED + }; + + template + class Graph + { + static void find_topological_sort_internal(V vertex, + ExplorationStatus& status, + const std::unordered_map>& adjacency_list, + std::unordered_map& exploration_status, + std::vector& sorted) + { + status = ExplorationStatus::PARTIALLY_EXPLORED; + + for (V neighbour : adjacency_list.at(vertex)) + { + ExplorationStatus& neighbour_status = exploration_status[neighbour]; + if (neighbour_status == ExplorationStatus::NOT_EXPLORED) + { + find_topological_sort_internal(neighbour, neighbour_status, adjacency_list, exploration_status, sorted); + } + else if (neighbour_status == ExplorationStatus::PARTIALLY_EXPLORED) + { + throw std::runtime_error("cycle in graph"); + } + } + + status = ExplorationStatus::FULLY_EXPLORED; + sorted.push_back(vertex); + } + + public: + + void add_vertex(V v) + { + this->vertices[v]; + } + + // TODO: Change with iterators + void add_vertices(const std::vector& vs) + { + for (const V& v : vs) + { + this->vertices[v]; + } + } + + void add_edge(V u, V v) + { + this->vertices[v]; + this->vertices[u].push_back(v); + } + + std::vector find_topological_sort() const + { + std::unordered_map indegrees = count_indegrees(); + + std::vector sorted; + sorted.reserve(indegrees.size()); + + std::unordered_map exploration_status; + exploration_status.reserve(indegrees.size()); + + for (auto& pair : indegrees) + { + if (pair.second == 0) // Starting from vertices with indegree == 0. Not required. + { + V vertex = pair.first; + ExplorationStatus& status = exploration_status[vertex]; + if (status == ExplorationStatus::NOT_EXPLORED) + { + find_topological_sort_internal(vertex, status, this->vertices, exploration_status, sorted); + } + } + } + + return sorted; + } + + std::unordered_map count_indegrees() const + { + std::unordered_map indegrees; + + for (auto& pair : this->vertices) + { + indegrees[pair.first]; + for (V neighbour : pair.second) + { + ++indegrees[neighbour]; + } + } + + return indegrees; + } + + const std::unordered_map>& adjacency_list() const + { + return this->vertices; + } + + private: + std::unordered_map> vertices; + }; +}} diff --git a/toolsrc/include/vcpkg_Strings.h b/toolsrc/include/vcpkg_Strings.h new file mode 100644 index 00000000000000..f4b9892928ae8f --- /dev/null +++ b/toolsrc/include/vcpkg_Strings.h @@ -0,0 +1,58 @@ +#pragma once + +#include + +namespace vcpkg {namespace Strings {namespace details +{ + inline const char* to_printf_arg(const std::string& s) + { + return s.c_str(); + } + + inline const char* to_printf_arg(const char* s) + { + return s; + } + + inline int to_printf_arg(const int s) + { + return s; + } + + std::string format_internal(const char* fmtstr, ...); + + inline const wchar_t* to_wprintf_arg(const std::wstring& s) + { + return s.c_str(); + } + + inline const wchar_t* to_wprintf_arg(const wchar_t* s) + { + return s; + } + + std::wstring format_internal(const wchar_t* fmtstr, ...); +}}} + +namespace vcpkg {namespace Strings +{ + template + std::string format(const char* fmtstr, const Args&...args) + { + using vcpkg::Strings::details::to_printf_arg; + return details::format_internal(fmtstr, to_printf_arg(to_printf_arg(args))...); + } + + template + std::wstring format(const wchar_t* fmtstr, const Args&...args) + { + using vcpkg::Strings::details::to_wprintf_arg; + return details::format_internal(fmtstr, to_wprintf_arg(to_wprintf_arg(args))...); + } + + std::wstring utf8_to_utf16(const std::string& s); + + std::string utf16_to_utf8(const std::wstring& w); + + std::string::const_iterator case_insensitive_find(const std::string& s, const std::string& pattern); +}} diff --git a/toolsrc/include/vcpkg_System.h b/toolsrc/include/vcpkg_System.h new file mode 100644 index 00000000000000..f47fc9aabac9e9 --- /dev/null +++ b/toolsrc/include/vcpkg_System.h @@ -0,0 +1,77 @@ +#pragma once + +#include "vcpkg_Strings.h" + +#include + +namespace vcpkg {namespace System +{ + std::tr2::sys::path get_exe_path_of_current_process(); + + struct exit_code_and_output + { + int exit_code; + std::string output; + }; + + int cmd_execute(const wchar_t* cmd_line); + + inline int cmd_execute(const std::wstring& cmd_line) + { + return cmd_execute(cmd_line.c_str()); + } + + exit_code_and_output cmd_execute_and_capture_output(const wchar_t* cmd_line); + + inline exit_code_and_output cmd_execute_and_capture_output(const std::wstring& cmd_line) + { + return cmd_execute_and_capture_output(cmd_line.c_str()); + } + + enum class color + { + success = 10, + error = 12, + warning = 14, + }; + + void print(const char* message); + void println(const char* message); + void print(color c, const char* message); + void println(color c, const char* message); + + template + void print(const char* messageTemplate, const Args&... messageArgs) + { + return print(Strings::format(messageTemplate, messageArgs...).c_str()); + } + + template + void print(color c, const char* messageTemplate, const Args&... messageArgs) + { + return print(c, Strings::format(messageTemplate, messageArgs...).c_str()); + } + + template + void println(const char* messageTemplate, const Args&... messageArgs) + { + return println(Strings::format(messageTemplate, messageArgs...).c_str()); + } + + template + void println(color c, const char* messageTemplate, const Args&... messageArgs) + { + return println(c, Strings::format(messageTemplate, messageArgs...).c_str()); + } + + struct Stopwatch + { + int64_t start_time, end_time, freq; + + void start(); + void stop(); + double microseconds() const; + }; + + std::wstring wdupenv_str(const wchar_t* varname) noexcept; +}} diff --git a/toolsrc/include/vcpkg_cmd_arguments.h b/toolsrc/include/vcpkg_cmd_arguments.h new file mode 100644 index 00000000000000..0df3d1222dcf73 --- /dev/null +++ b/toolsrc/include/vcpkg_cmd_arguments.h @@ -0,0 +1,36 @@ +#pragma once + +#include +#include +#include +#include "opt_bool.h" +#include "package_spec.h" +#include "vcpkg_paths.h" +#include "StatusParagraphs.h" + +namespace vcpkg +{ + struct vcpkg_cmd_arguments + { + static vcpkg_cmd_arguments create_from_command_line(const int argc, const wchar_t* const* const argv); + + static vcpkg_cmd_arguments create_from_arg_sequence(const std::string* arg_begin, const std::string* arg_end); + + std::unique_ptr vcpkg_root_dir; + std::unique_ptr target_triplet; + opt_bool debug = opt_bool::unspecified; + opt_bool sendmetrics = opt_bool::unspecified; + opt_bool printmetrics = opt_bool::unspecified; + + std::string command; + std::vector command_arguments; + std::unordered_set check_and_get_optional_command_arguments(const std::vector& valid_options) const; + + void check_max_args(size_t arg_count, const char* example_text = nullptr) const; + std::vector parse_all_arguments_as_package_specs(const triplet& default_target_triplet, const char* example_text = nullptr) const; + std::vector extract_package_specs_with_unmet_dependencies(const vcpkg_paths& paths, const triplet& default_target_triplet, const StatusParagraphs& status_db) const; + + private: + std::unordered_set optional_command_arguments; + }; +} diff --git a/toolsrc/include/vcpkg_paths.h b/toolsrc/include/vcpkg_paths.h new file mode 100644 index 00000000000000..58ab45bc583d19 --- /dev/null +++ b/toolsrc/include/vcpkg_paths.h @@ -0,0 +1,29 @@ +#pragma once +#include +#include "expected.h" + +namespace vcpkg +{ + struct vcpkg_paths + { + static expected create(const std::tr2::sys::path& vcpkg_root_dir); + + std::tr2::sys::path root; + std::tr2::sys::path packages; + std::tr2::sys::path buildtrees; + std::tr2::sys::path downloads; + std::tr2::sys::path ports; + std::tr2::sys::path installed; + std::tr2::sys::path triplets; + + std::tr2::sys::path buildsystems; + std::tr2::sys::path buildsystems_msbuild_targets; + + std::tr2::sys::path vcpkg_dir; + std::tr2::sys::path vcpkg_dir_status_file; + std::tr2::sys::path vcpkg_dir_info; + std::tr2::sys::path vcpkg_dir_updates; + + std::tr2::sys::path ports_cmake; + }; +} diff --git a/toolsrc/include/vcpkglib_helpers.h b/toolsrc/include/vcpkglib_helpers.h new file mode 100644 index 00000000000000..e15b59b0b6665f --- /dev/null +++ b/toolsrc/include/vcpkglib_helpers.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +namespace vcpkg {namespace details +{ + void optional_field(const std::unordered_map& fields, std::string& out, const std::string& fieldname); + + void required_field(const std::unordered_map& fields, std::string& out, const std::string& fieldname); + + void parse_depends(const std::string& depends_string, std::vector& out); +}} diff --git a/toolsrc/src/BinaryParagraph.cpp b/toolsrc/src/BinaryParagraph.cpp new file mode 100644 index 00000000000000..274bd879ee1f81 --- /dev/null +++ b/toolsrc/src/BinaryParagraph.cpp @@ -0,0 +1,82 @@ +#include "BinaryParagraph.h" +#include "vcpkglib_helpers.h" +#include "vcpkg_Checks.h" + +using namespace vcpkg::details; + +namespace vcpkg +{ + BinaryParagraph::BinaryParagraph() = default; + + BinaryParagraph::BinaryParagraph(const std::unordered_map& fields) + { + details::required_field(fields, name, "Package"); + required_field(fields, version, "Version"); + required_field(fields, target_triplet.value, "Architecture"); + { + std::string multi_arch; + required_field(fields, multi_arch, "Multi-Arch"); + Checks::check_throw(multi_arch == "same", "Multi-Arch must be 'same' but was %s", multi_arch); + } + optional_field(fields, description, "Description"); + std::string deps; + optional_field(fields, deps, "Depends"); + if (!deps.empty()) + { + depends.clear(); + parse_depends(deps, depends); + } + optional_field(fields, maintainer, "Maintainer"); + } + + BinaryParagraph::BinaryParagraph(const SourceParagraph& spgh, const triplet& target_triplet) + { + this->name = spgh.name; + this->version = spgh.version; + this->description = spgh.description; + this->maintainer = spgh.maintainer; + this->depends = spgh.depends; + this->target_triplet = target_triplet; + } + + std::string BinaryParagraph::displayname() const + { + return Strings::format("%s:%s", this->name, this->target_triplet); + } + + std::string BinaryParagraph::dir() const + { + return Strings::format("%s_%s", this->name, this->target_triplet); + } + + std::string BinaryParagraph::fullstem() const + { + return Strings::format("%s_%s_%s", this->name, this->version, this->target_triplet); + } + + std::ostream& operator<<(std::ostream& os, const BinaryParagraph& p) + { + os << "Package: " << p.name << "\n"; + os << "Version: " << p.version << "\n"; + if (!p.depends.empty()) + { + os << "Depends: " << p.depends.front(); + + auto b = p.depends.begin() + 1; + auto e = p.depends.end(); + for (; b != e; ++b) + { + os << ", " << *b; + } + + os << "\n"; + } + os << "Architecture: " << p.target_triplet << "\n"; + os << "Multi-Arch: same\n"; + if (!p.maintainer.empty()) + os << "Maintainer: " << p.maintainer << "\n"; + if (!p.description.empty()) + os << "Description: " << p.description << "\n"; + return os; + } +} diff --git a/toolsrc/src/SourceParagraph.cpp b/toolsrc/src/SourceParagraph.cpp new file mode 100644 index 00000000000000..7e3b0403ec7796 --- /dev/null +++ b/toolsrc/src/SourceParagraph.cpp @@ -0,0 +1,21 @@ +#include "SourceParagraph.h" +#include "vcpkglib_helpers.h" + +using namespace vcpkg::details; + +vcpkg::SourceParagraph::SourceParagraph() = default; + +vcpkg::SourceParagraph::SourceParagraph(const std::unordered_map& fields) +{ + required_field(fields, name, "Source"); + required_field(fields, version, "Version"); + optional_field(fields, description, "Description"); + std::string deps; + optional_field(fields, deps, "Build-Depends"); + if (!deps.empty()) + { + depends.clear(); + parse_depends(deps, depends); + } + optional_field(fields, maintainer, "Maintainer"); +} diff --git a/toolsrc/src/StatusParagraph.cpp b/toolsrc/src/StatusParagraph.cpp new file mode 100644 index 00000000000000..09a3b4d451183c --- /dev/null +++ b/toolsrc/src/StatusParagraph.cpp @@ -0,0 +1,87 @@ +#include "StatusParagraph.h" +#include "vcpkglib_helpers.h" + +using namespace vcpkg::details; + +namespace vcpkg +{ + StatusParagraph::StatusParagraph() : want(want_t::error), state(install_state_t::error) + { + } + + std::ostream& operator<<(std::ostream& os, const StatusParagraph& p) + { + os << p.package; + os << "Status: " << to_string(p.want) << " ok " << to_string(p.state) << "\n"; + return os; + } + + StatusParagraph::StatusParagraph(const std::unordered_map& fields) + : package(fields) + { + std::string status_field; + required_field(fields, status_field, "Status"); + + auto b = status_field.begin(); + auto mark = b; + auto e = status_field.end(); + + // Todo: improve error handling + while (b != e && *b != ' ') + ++b; + + want = [](const std::string& text) + { + if (text == "unknown") + return want_t::unknown; + if (text == "install") + return want_t::install; + if (text == "hold") + return want_t::hold; + if (text == "deinstall") + return want_t::deinstall; + if (text == "purge") + return want_t::purge; + return want_t::error; + }(std::string(mark, b)); + + if (std::distance(b, e) < 4) + return; + b += 4; + + state = [](const std::string& text) + { + if (text == "not-installed") + return install_state_t::not_installed; + if (text == "installed") + return install_state_t::installed; + if (text == "half-installed") + return install_state_t::half_installed; + return install_state_t::error; + }(std::string(b, e)); + } + + std::string to_string(install_state_t f) + { + switch (f) + { + case install_state_t::half_installed: return "half-installed"; + case install_state_t::installed: return "installed"; + case install_state_t::not_installed: return "not-installed"; + default: return "error"; + } + } + + std::string to_string(want_t f) + { + switch (f) + { + case want_t::deinstall: return "deinstall"; + case want_t::hold: return "hold"; + case want_t::install: return "install"; + case want_t::purge: return "purge"; + case want_t::unknown: return "unknown"; + default: return "error"; + } + } +} diff --git a/toolsrc/src/StatusParagraphs.cpp b/toolsrc/src/StatusParagraphs.cpp new file mode 100644 index 00000000000000..463e3e3b8ac826 --- /dev/null +++ b/toolsrc/src/StatusParagraphs.cpp @@ -0,0 +1,67 @@ +#include "StatusParagraphs.h" +#include +#include "vcpkg_Checks.h" + +namespace vcpkg +{ + StatusParagraphs::StatusParagraphs() = default; + + StatusParagraphs::StatusParagraphs(std::vector>&& ps) + : paragraphs(std::move(ps)) + { + }; + + StatusParagraphs::const_iterator StatusParagraphs::find(const std::string& name, const triplet& target_triplet) const + { + return std::find_if(begin(), end(), [&](const auto& pgh) + { + return pgh->package.name == name && pgh->package.target_triplet == target_triplet; + }); + } + + StatusParagraphs::iterator StatusParagraphs::find(const std::string& name, const triplet& target_triplet) + { + return std::find_if(begin(), end(), [&](const auto& pgh) + { + return pgh->package.name == name && pgh->package.target_triplet == target_triplet; + }); + } + + StatusParagraphs::iterator StatusParagraphs::find_installed(const std::string& name, const triplet& target_triplet) + { + auto it = find(name, target_triplet); + if (it != end() && (*it)->want == want_t::install) + { + return it; + } + + return end(); + } + + StatusParagraphs::iterator StatusParagraphs::insert(std::unique_ptr pgh) + { + Checks::check_throw(pgh != nullptr, "Inserted null paragraph"); + auto ptr = find(pgh->package.name, pgh->package.target_triplet); + if (ptr == end()) + { + paragraphs.push_back(std::move(pgh)); + return paragraphs.rbegin(); + } + else + { + // consume data from provided pgh. + **ptr = std::move(*pgh); + return ptr; + } + } + + std::ostream& vcpkg::operator<<(std::ostream& os, const StatusParagraphs& l) + { + for (auto& pgh : l.paragraphs) + { + os << *pgh; + os << "\n"; + } + return os; + } +} diff --git a/toolsrc/src/commands_help.cpp b/toolsrc/src/commands_help.cpp new file mode 100644 index 00000000000000..4e1ae9c496f502 --- /dev/null +++ b/toolsrc/src/commands_help.cpp @@ -0,0 +1,55 @@ +#include "vcpkg_Commands.h" +#include "vcpkg.h" +#include "vcpkg_System.h" + +namespace vcpkg +{ + void version_command(const vcpkg_cmd_arguments& args) + { + args.check_max_args(0); + System::println("Vcpkg package management program version %s\n" + "\n" + "Vcpkg is provided \"as-is\" without warranty of any kind, express or implied.\n" + "All rights reserved.", vcpkg::version() + ); + exit(EXIT_SUCCESS); + } + + void help_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + { + args.check_max_args(1); + if (args.command_arguments.empty()) + { + print_usage(); + exit(EXIT_SUCCESS); + } + const auto& topic = args.command_arguments[0]; + if (topic == "triplet") + { + help_topic_valid_triplet(paths); + } + else + { + System::println(System::color::error, "Error: unknown topic %s", topic); + print_usage(); + exit(EXIT_FAILURE); + } + exit(EXIT_SUCCESS); + } + + void contact_command(const vcpkg_cmd_arguments& /*args*/) + { + System::println("Send an email to vcpkg@microsoft.com with any feedback."); + exit(EXIT_SUCCESS); + } + + void help_topic_valid_triplet(const vcpkg_paths& paths) + { + System::println("Available architecture triplets:"); + auto it = fs::directory_iterator(paths.triplets); + for (; it != fs::directory_iterator(); ++it) + { + System::println(" %s", it->path().stem().filename().string()); + } + } +} diff --git a/toolsrc/src/commands_installation.cpp b/toolsrc/src/commands_installation.cpp new file mode 100644 index 00000000000000..f6a774b8db451e --- /dev/null +++ b/toolsrc/src/commands_installation.cpp @@ -0,0 +1,219 @@ +#include "vcpkg_Commands.h" +#include "vcpkg.h" +#include +#include +#include +#include "vcpkg_Environment.h" +#include "metrics.h" +#include "vcpkg_Files.h" +#include "post_build_lint.h" +#include "vcpkg_System.h" + +namespace vcpkg +{ + static void create_binary_control_file(const vcpkg_paths& paths, const fs::path& port_dir, const triplet& target_triplet) + { + auto pghs = get_paragraphs(port_dir / "CONTROL"); + Checks::check_exit(pghs.size() == 1, "Error: invalid control file"); + auto bpgh = BinaryParagraph(SourceParagraph(pghs[0]), target_triplet); + const fs::path binary_control_file = paths.packages / bpgh.dir() / "CONTROL"; + std::ofstream(binary_control_file) << bpgh; + } + + static void build_internal(const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir) + { + const fs::path ports_cmake_script_path = paths.ports_cmake; + const std::wstring vs140comntools = System::wdupenv_str(L"VS140COMNTOOLS"); + + const std::wstring command = Strings::format(LR"("%s..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")", + vs140comntools, + Strings::utf8_to_utf16(spec.target_triplet.architecture()), + Strings::utf8_to_utf16(spec.name), + Strings::utf8_to_utf16(spec.target_triplet.value), + port_dir.generic_wstring(), + ports_cmake_script_path.generic_wstring()); + + System::Stopwatch timer; + timer.start(); + int return_code = System::cmd_execute(command); + timer.stop(); + TrackMetric("buildtimeus-" + to_string(spec), timer.microseconds()); + + if (return_code != 0) + { + System::println(System::color::error, "Error: build command failed"); + TrackProperty("error", "build failed"); + TrackProperty("build_error", std::to_string(return_code)); + exit(EXIT_FAILURE); + } + + perform_all_checks(spec, paths); + + create_binary_control_file(paths, port_dir, spec.target_triplet); + + // const fs::path port_buildtrees_dir = paths.buildtrees / spec.name; + // delete_directory(port_buildtrees_dir); + } + + static void build_internal(const package_spec& spec, const vcpkg_paths& paths) + { + return build_internal(spec, paths, paths.ports / spec.name); + } + + void install_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) + { + StatusParagraphs status_db = database_load_check(paths); + + std::vector specs = args.extract_package_specs_with_unmet_dependencies(paths, default_target_triplet, status_db); + Checks::check_exit(!specs.empty(), "Specs cannot be empty"); + std::string specs_string = to_string(specs[0]); + for (size_t i = 1; i < specs.size(); ++i) + { + specs_string.push_back(','); + specs_string.append(to_string(specs[i])); + } + TrackProperty("installplan", specs_string); + Environment::ensure_utilities_on_path(paths); + + for (const package_spec& spec : specs) + { + if (status_db.find_installed(spec.name, spec.target_triplet) != status_db.end()) + { + System::println(System::color::success, "Package %s is already installed", spec); + continue; + } + + fs::path package_path = find_available_package(paths, spec); + + expected file_contents = Files::get_contents(package_path / "CONTROL"); + + try + { + if (file_contents.error_code()) + { + build_internal(spec, paths); + file_contents = Files::get_contents(package_path / "CONTROL"); + if (file_contents.error_code()) + { + file_contents.get_or_throw(); + } + } + + auto pghs = parse_paragraphs(file_contents.get_or_throw()); + Checks::check_throw(pghs.size() == 1, "multiple paragraphs in control file"); + install_package(paths, BinaryParagraph(pghs[0]), status_db); + System::println(System::color::success, "Package %s is installed", spec); + } + catch (const std::exception& e) + { + System::println(System::color::error, "Error: Could not install package %s: %s", spec, e.what()); + exit(EXIT_FAILURE); + } + } + + exit(EXIT_SUCCESS); + } + + void search_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + { + args.check_max_args(1); + + if (args.command_arguments.size() == 1) + { + System::println(System::color::warning, "Search strings are not yet implemented; showing full list of packages."); + } + + auto begin_it = fs::directory_iterator(paths.ports); + auto end_it = fs::directory_iterator(); + for (; begin_it != end_it; ++begin_it) + { + const auto& path = begin_it->path(); + + try + { + auto pghs = get_paragraphs(path / "CONTROL"); + if (pghs.empty()) + continue; + auto srcpgh = SourceParagraph(pghs[0]); + std::cout << std::left + << std::setw(20) << srcpgh.name << ' ' + << std::setw(16) << srcpgh.version << ' ' + << shorten_description(srcpgh.description) << '\n'; + } + catch (std::runtime_error const&) + { + } + } + + System::println("\nIf your library is not listed, please open an issue at:\n" + " https://github.com/Microsoft/vcpkg/issues"); + + exit(EXIT_SUCCESS); + } + + void cache_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + { + args.check_max_args(0); + + auto begin_it = fs::directory_iterator(paths.packages); + auto end_it = fs::directory_iterator(); + + if (begin_it == end_it) + { + System::println("No packages are cached."); + exit(EXIT_SUCCESS); + } + + for (; begin_it != end_it; ++begin_it) + { + const auto& path = begin_it->path(); + + auto file_contents = Files::get_contents(path / "CONTROL"); + if (auto text = file_contents.get()) + { + auto pghs = parse_paragraphs(*text); + if (pghs.size() != 1) + continue; + + auto src = BinaryParagraph(pghs[0]); + System::println(src.displayname().c_str()); + } + } + + exit(EXIT_SUCCESS); + } + + void build_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) + { + std::vector specs = args.parse_all_arguments_as_package_specs(default_target_triplet); + Environment::ensure_utilities_on_path(paths); + for (const package_spec& spec : specs) + { + build_internal(spec, paths); + } + exit(EXIT_SUCCESS); + } + + void build_external_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) + { + if (args.command_arguments.size() != 2) + { + System::println(System::color::error, "Error: buildexternal requires the package name and the directory containing the CONTROL file"); + print_example(R"(buildexternal mylib C:\path\to\mylib\)"); + exit(EXIT_FAILURE); + } + + expected current_spec = vcpkg::parse(args.command_arguments[0], default_target_triplet); + if (auto spec = current_spec.get()) + { + Environment::ensure_utilities_on_path(paths); + const fs::path port_dir = args.command_arguments.at(1); + build_internal(*spec, paths, port_dir); + exit(EXIT_SUCCESS); + } + + System::println(System::color::error, "Error: %s: %s", current_spec.error_code().message(), args.command_arguments[0]); + print_example(Strings::format("%s zlib:x64-windows", args.command).c_str()); + exit(EXIT_FAILURE); + } +} diff --git a/toolsrc/src/commands_integration.cpp b/toolsrc/src/commands_integration.cpp new file mode 100644 index 00000000000000..e1b63038a97c52 --- /dev/null +++ b/toolsrc/src/commands_integration.cpp @@ -0,0 +1,297 @@ +#define WIN32_LEAN_AND_MEAN +#include +#include +#include "vcpkg_Commands.h" +#include "vcpkg.h" +#include +#include +#include +#include "vcpkg_Environment.h" +#include "vcpkg_Checks.h" +#include "vcpkg_System.h" + +namespace vcpkg +{ + static const fs::path old_system_wide_targets_file = "C:/Program Files (x86)/MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.nuget.targets"; + static const fs::path system_wide_targets_file = "C:/Program Files (x86)/MSBuild/14.0/Microsoft.Common.Targets/ImportBefore/vcpkg.system.targets"; + + static std::string create_appdata_targets_shortcut(const std::string& target_path) noexcept + { + return Strings::format(R"###( + + + +)###", target_path, target_path); + } + + static std::string create_system_targets_shortcut() noexcept + { + return R"###( + + + $(LOCALAPPDATA)\vcpkg\vcpkg.user + + + +)###"; + } + + static std::string create_nuget_targets_file(const fs::path& msbuild_vcpkg_targets_file) noexcept + { + const std::string as_string = msbuild_vcpkg_targets_file.string(); + + return Strings::format(R"###( + + + + + + +)###", as_string, as_string); + } + + static std::string create_nuget_props_file() noexcept + { + return R"###( + + + true + + +)###"; + } + + static std::string get_nuget_id(const fs::path& vcpkg_root_dir) + { + std::string dir_id = vcpkg_root_dir.generic_string(); + std::replace(dir_id.begin(), dir_id.end(), '/', '.'); + dir_id.erase(1, 1); // Erasing the ":" + + // NuGet id cannot have invalid characters. We will only use alphanumeric and dot. + dir_id.erase(std::remove_if(dir_id.begin(), dir_id.end(), [](char c) + { + return !isalnum(c) && (c != '.'); + }), dir_id.end()); + + const std::string nuget_id = "vcpkg." + dir_id; + return nuget_id; + } + + static std::string create_nuspec_file(const fs::path& vcpkg_root_dir, const std::string& nuget_id, const std::string& nupkg_version) + { + const std::string nuspec_file_content_template = R"( + + + @NUGET_ID@ + @VERSION@ + cpp-packages + + This package imports all libraries currently installed in @VCPKG_DIR@. This package does not contain any libraries and instead refers to the folder directly (like a symlink). + + + + + + + +)"; + + std::string nuspec_file_content = std::regex_replace(nuspec_file_content_template, std::regex("@NUGET_ID@"), nuget_id); + nuspec_file_content = std::regex_replace(nuspec_file_content, std::regex("@VCPKG_DIR@"), vcpkg_root_dir.string()); + nuspec_file_content = std::regex_replace(nuspec_file_content, std::regex("@VERSION@"), nupkg_version); + return nuspec_file_content; + } + + enum class elevation_prompt_user_choice + { + yes, + no + }; + + static elevation_prompt_user_choice elevated_cmd_execute(const std::string& param) + { + SHELLEXECUTEINFO shExInfo = {0}; + shExInfo.cbSize = sizeof(shExInfo); + shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS; + shExInfo.hwnd = nullptr; + shExInfo.lpVerb = "runas"; + shExInfo.lpFile = "cmd"; // Application to start + + shExInfo.lpParameters = param.c_str(); // Additional parameters + shExInfo.lpDirectory = nullptr; + shExInfo.nShow = SW_HIDE; + shExInfo.hInstApp = nullptr; + + if (!ShellExecuteExA(&shExInfo)) + { + return elevation_prompt_user_choice::no; + } + if (shExInfo.hProcess == nullptr) + { + return elevation_prompt_user_choice::no; + } + WaitForSingleObject(shExInfo.hProcess, INFINITE); + CloseHandle(shExInfo.hProcess); + return elevation_prompt_user_choice::yes; + } + + static fs::path get_appdata_targets_path() + { + return fs::path(System::wdupenv_str(L"LOCALAPPDATA")) / "vcpkg" / "vcpkg.user.targets"; + } + + static void integrate_install(const vcpkg_paths& paths) + { + // TODO: This block of code should eventually be removed + { + if (fs::exists(old_system_wide_targets_file)) + { + const std::string param = Strings::format(R"(/c DEL "%s" /Q > nul)", old_system_wide_targets_file.string()); + elevation_prompt_user_choice user_choice = elevated_cmd_execute(param); + switch (user_choice) + { + case elevation_prompt_user_choice::yes: + break; + case elevation_prompt_user_choice::no: + System::println(System::color::warning, "Warning: Previous integration file was not removed"); + exit(EXIT_FAILURE); + default: + Checks::unreachable(); + } + } + } + + const fs::path tmp_dir = paths.buildsystems / "tmp"; + fs::create_directory(paths.buildsystems); + fs::create_directory(tmp_dir); + + if (!fs::exists(system_wide_targets_file)) + { + const fs::path sys_src_path = tmp_dir / "vcpkg.system.targets"; + std::ofstream(sys_src_path) << create_system_targets_shortcut(); + + const std::string param = Strings::format(R"(/c COPY "%s" "%s" /Y > nul)", sys_src_path.string(), system_wide_targets_file.string()); + elevation_prompt_user_choice user_choice = elevated_cmd_execute(param); + switch (user_choice) + { + case elevation_prompt_user_choice::yes: + break; + case elevation_prompt_user_choice::no: + System::println(System::color::warning, "Warning: integration was not applied"); + exit(EXIT_FAILURE); + default: + Checks::unreachable(); + } + } + + const fs::path appdata_src_path = tmp_dir / "vcpkg.user.targets"; + std::ofstream(appdata_src_path) << create_appdata_targets_shortcut(paths.buildsystems_msbuild_targets.string()); + auto appdata_dst_path = get_appdata_targets_path(); + + if (!fs::copy_file(appdata_src_path, appdata_dst_path, fs::copy_options::overwrite_existing)) + { + System::println(System::color::error, "Error: Failed to copy file: %s -> %s", appdata_src_path.string(), appdata_dst_path.string()); + exit(EXIT_FAILURE); + } + System::println(System::color::success, "Applied user-wide integration for this vcpkg root."); + System::println("\n" + "All C++ projects can now #include any installed libraries.\n" + "Linking will be handled automatically.\n" + "Installing new libraries will make them instantly available."); + + exit(EXIT_SUCCESS); + } + + static void integrate_remove() + { + auto path = get_appdata_targets_path(); + if (!fs::exists(path)) + { + System::println(System::color::success, "User-wide integration is not installed"); + exit(EXIT_SUCCESS); + } + + const std::wstring cmd_line = Strings::format(LR"(DEL "%s")", get_appdata_targets_path().native()); + const int exit_code = System::cmd_execute(cmd_line); + if (exit_code) + { + System::println(System::color::error, "Error: Unable to remove user-wide integration: %d", exit_code); + exit(exit_code); + } + System::println(System::color::success, "User-wide integration was removed"); + exit(EXIT_SUCCESS); + } + + static void integrate_project(const vcpkg_paths& paths) + { + Environment::ensure_nuget_on_path(paths); + + const fs::path& buildsystems_dir = paths.buildsystems; + const fs::path tmp_dir = buildsystems_dir / "tmp"; + fs::create_directory(buildsystems_dir); + fs::create_directory(tmp_dir); + + const fs::path targets_file_path = tmp_dir / "vcpkg.nuget.targets"; + const fs::path props_file_path = tmp_dir / "vcpkg.nuget.props"; + const fs::path nuspec_file_path = tmp_dir / "vcpkg.nuget.nuspec"; + const std::string nuget_id = get_nuget_id(paths.root); + const std::string nupkg_version = "1.0.0"; + + std::ofstream(targets_file_path) << create_nuget_targets_file(paths.buildsystems_msbuild_targets); + std::ofstream(props_file_path) << create_nuget_props_file(); + std::ofstream(nuspec_file_path) << create_nuspec_file(paths.root, nuget_id, nupkg_version); + + // Using all forward slashes for the command line + const std::wstring cmd_line = Strings::format(LR"(nuget.exe pack -OutputDirectory "%s" "%s" > nul)", buildsystems_dir.native(), nuspec_file_path.native()); + + const int exit_code = System::cmd_execute(cmd_line); + + const fs::path nuget_package = buildsystems_dir / Strings::format("%s.%s.nupkg", nuget_id, nupkg_version); + if (exit_code != 0 || !fs::exists(nuget_package)) + { + System::println(System::color::error, "Error: NuGet package creation failed"); + exit(EXIT_FAILURE); + } + + System::println(System::color::success, "Created nupkg: %s", nuget_package.string()); + + System::println(R"( +With a project open, go to Tools->NuGet Package Manager->Package Manager Console and paste: + Install-Package %s -Source "%s" +)", nuget_id, buildsystems_dir.generic_string()); + + exit(EXIT_SUCCESS); + } + + const char* const INTEGRATE_COMMAND_HELPSTRING = + " vcpkg integrate install Make installed packages available user-wide. Requires admin privileges on first use\n" + " vcpkg integrate remove Remove user-wide integration\n" + " vcpkg integrate project Generate a referencing nuget package for individual VS project use\n"; + + void integrate_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + { + if (args.command_arguments.size() != 1) + { + std::cout << "Commands:\n" << + INTEGRATE_COMMAND_HELPSTRING << + "\n"; + exit(EXIT_FAILURE); + } + + if (args.command_arguments[0] == "install") + { + return integrate_install(paths); + } + if (args.command_arguments[0] == "remove") + { + return integrate_remove(); + } + if (args.command_arguments[0] == "project") + { + return integrate_project(paths); + } + + System::println(System::color::error, "Unknown parameter %s for integrate", args.command_arguments[0]); + exit(EXIT_FAILURE); + } +} diff --git a/toolsrc/src/commands_other.cpp b/toolsrc/src/commands_other.cpp new file mode 100644 index 00000000000000..c7dcc2586d4550 --- /dev/null +++ b/toolsrc/src/commands_other.cpp @@ -0,0 +1,293 @@ +#include "vcpkg_Commands.h" +#include +#include +#include "vcpkg_Environment.h" +#include "vcpkg.h" +#include "vcpkg_System.h" +#include "vcpkg_Files.h" + +namespace vcpkg +{ + void print_usage() + { + std::cout << "Commands:\n" + " vcpkg search [pat] Search for packages available to be built\n" + " vcpkg install Install a package\n" + " vcpkg remove Uninstall a package. \n" + " vcpkg remove --purge Uninstall and delete a package. \n" + " vcpkg list List installed packages\n" + " vcpkg update Display list of packages for updating\n" + "\n" + << INTEGRATE_COMMAND_HELPSTRING << + "\n" + " vcpkg edit Open up a port for editing (uses %EDITOR%, default 'code')\n" + " vcpkg import Import a pre-built library\n" + " vcpkg create \n" + " [archivename] Create a new package\n" + " vcpkg owns Search for files in installed packages\n" + " vcpkg cache List cached compiled packages\n" + " vcpkg version Display version information\n" + " vcpkg contact Display contact information to send feedback\n" + "\n" + //"internal commands:\n" + //" --check-build-deps \n" + //" --create-binary-control \n" + //"\n" + "Options:\n" + " --triplet Specify the target architecture triplet.\n" + " (default: x86-windows, see 'vcpkg help triplet')\n" + "\n" + " --vcpkg-root Specify the vcpkg root directory\n" + " (default: %VCPKG_ROOT%)\n" + "\n" + "For more help (including examples) see the accompanying README.md." + "\n"; + } + + void print_example(const char* command_and_arguments) + { + std::cout << + "Example:\n" + " vcpkg " << command_and_arguments << "\n"; + } + + void update_command(const vcpkg_cmd_arguments& /*args*/, const vcpkg_paths& paths) + { + auto status_db = database_load_check(paths); + + std::unordered_map src_names_to_versions; + + auto begin_it = fs::directory_iterator(paths.ports); + auto end_it = fs::directory_iterator(); + for (; begin_it != end_it; ++begin_it) + { + const auto& path = begin_it->path(); + try + { + auto pghs = get_paragraphs(path / "CONTROL"); + if (pghs.empty()) + continue; + auto srcpgh = SourceParagraph(pghs[0]); + src_names_to_versions.emplace(srcpgh.name, srcpgh.version); + } + catch (std::runtime_error const&) + { + } + } + + std::string packages_list; + + std::vector packages_output; + for (auto&& pgh : database_load_check(paths)) + { + if (pgh->state == install_state_t::not_installed && pgh->want == want_t::purge) + continue; + auto it = src_names_to_versions.find(pgh->package.name); + if (it == src_names_to_versions.end()) + { + // Package was not installed from portfile + continue; + } + if (it->second != pgh->package.version) + { + packages_output.push_back(Strings::format("%-27s %s -> %s", + pgh->package.displayname(), + pgh->package.version, + it->second)); + packages_list.append(" " + pgh->package.displayname()); + } + } + std::sort(packages_output.begin(), packages_output.end()); + if (packages_output.empty()) + { + System::println("No packages need updating."); + } + else + { + System::println("The following packages differ from their port versions:"); + for (auto&& package : packages_output) + { + System::println(" %s", package.c_str()); + } + System::println("\nTo update these packages, run\n vcpkg remove --purge ...\n vcpkg install ..."); + } + + auto version_file = Files::get_contents(paths.root / "toolsrc" / "VERSION.txt"); + if (auto version_contents = version_file.get()) + { + int maj1, min1, rev1; + auto num1 = sscanf_s(version_contents->c_str(), "\"%d.%d.%d\"", &maj1, &min1, &rev1); + + int maj2, min2, rev2; + auto num2 = sscanf_s(version().c_str(), "%d.%d.%d-", &maj2, &min2, &rev2); + + if (num1 == 3 && num2 == 3) + { + if (maj1 != maj2 || min1 != min2 || rev1 != rev2) + { + System::println("Different source is available for vcpkg (%d.%d.%d -> %d.%d.%d). Use scripts\\bootstrap.ps1 to update.", + maj2, min2, rev2, + maj1, min1, rev1); + } + } + } + + exit(EXIT_SUCCESS); + } + + void edit_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) + { + static auto example = "edit zlib"; + args.check_max_args(1, example); + package_spec spec = args.parse_all_arguments_as_package_specs(default_target_triplet, example).at(0); + + // Find editor + std::wstring env_EDITOR = System::wdupenv_str(L"EDITOR"); + if (env_EDITOR.empty()) + env_EDITOR = LR"(C:\Program Files (x86)\Microsoft VS Code\Code.exe)"; + + auto portpath = paths.ports / spec.name; + std::wstring cmdLine = Strings::format(LR"("%s" "%s" "%s")", env_EDITOR, portpath.native(), (portpath / "portfile.cmake").native()); + exit(System::cmd_execute(cmdLine)); + } + + void create_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) + { + args.check_max_args(3); + package_spec spec = args.parse_all_arguments_as_package_specs(default_target_triplet).at(0); + if (args.command_arguments.size() < 2) + { + System::println(System::color::error, "Error: create requires the archive's URL as the second argument."); + print_usage(); + exit(EXIT_FAILURE); + } + Environment::ensure_utilities_on_path(paths); + + // Space OR define the FILENAME with proper spacing + std::wstring custom_filename = L" "; + if (args.command_arguments.size() >= 3) + { + custom_filename = Strings::format(L" -DFILENAME=%s ", Strings::utf8_to_utf16(args.command_arguments.at(2))); + } + + const std::wstring cmdline = Strings::format(LR"(cmake -DCMD=SCAFFOLD -DPORT=%s -DTARGET_TRIPLET=%s -DURL=%s%s-P "%s")", + Strings::utf8_to_utf16(spec.name), + Strings::utf8_to_utf16(spec.target_triplet.value), + Strings::utf8_to_utf16(args.command_arguments.at(1)), + custom_filename, + paths.ports_cmake.generic_wstring()); + + exit(System::cmd_execute(cmdline)); + } + + void list_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + { + args.check_max_args(0); + + std::vector packages_output; + for (auto&& pgh : database_load_check(paths)) + { + if (pgh->state == install_state_t::not_installed && pgh->want == want_t::purge) + continue; + packages_output.push_back(Strings::format("%-27s %-16s %s", + pgh->package.displayname(), + pgh->package.version, + shorten_description(pgh->package.description))); + } + std::sort(packages_output.begin(), packages_output.end()); + for (auto&& package : packages_output) + { + System::println(package.c_str()); + } + if (packages_output.empty()) + { + System::println("No packages are installed. Did you mean `search`?"); + } + exit(EXIT_SUCCESS); + } + + void import_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + { + if (args.command_arguments.size() != 3) + { + System::println(System::color::error, "Error: %s requires 3 parameters", args.command); + print_example(Strings::format(R"(%s C:\path\to\CONTROLfile C:\path\to\includedir C:\path\to\projectdir)", args.command).c_str()); + exit(EXIT_FAILURE); + } + + const fs::path control_file_path(args.command_arguments[0]); + const fs::path include_directory(args.command_arguments[1]); + const fs::path project_directory(args.command_arguments[2]); + + auto pghs = get_paragraphs(control_file_path); + Checks::check_throw(pghs.size() == 1, "Invalid control file for package"); + + StatusParagraph spgh; + spgh.package = BinaryParagraph(pghs[0]); + auto& control_file_data = spgh.package; + + vcpkg::binary_import(paths, include_directory, project_directory, control_file_data); + exit(EXIT_SUCCESS); + } + + void owns_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths) + { + args.check_max_args(1); + if (args.command_arguments.size() == 0) + { + System::println(System::color::error, "Error: owns requires a pattern to search for as the first argument."); + std::cout << + "example:\n" + " vcpkg owns .dll\n"; + exit(EXIT_FAILURE); + } + StatusParagraphs status_db = database_load_check(paths); + search_file(paths, args.command_arguments[0], status_db); + exit(EXIT_SUCCESS); + } + + void internal_test_command(const vcpkg_cmd_arguments& /*args*/, const vcpkg_paths& /*paths*/) + { + // auto data = FormatEventData("test"); + // Track(data); + exit(EXIT_SUCCESS); + } + + const std::vector>& get_available_commands_type_a() + { + static std::vector> t = { + {"install", install_command}, + {"remove", remove_command}, + {"build", build_command}, + {"edit", edit_command}, + {"create", create_command}, + {"build_external", build_external_command} + }; + return t; + } + + const std::vector>& get_available_commands_type_b() + { + static std::vector> t = { + {"help", help_command}, + {"search", search_command}, + {"list", list_command}, + {"integrate", integrate_command}, + {"owns", owns_command}, + {"update", update_command}, + {"import", import_command}, + {"cache", cache_command}, + {"internal_test", internal_test_command}, + }; + return t; + } + + const std::vector>& get_available_commands_type_c() + { + static std::vector> t = { + {"version", &version_command}, + {"contact", &contact_command} + }; + return t; + } +} diff --git a/toolsrc/src/commands_remove.cpp b/toolsrc/src/commands_remove.cpp new file mode 100644 index 00000000000000..f5315ccb19d024 --- /dev/null +++ b/toolsrc/src/commands_remove.cpp @@ -0,0 +1,43 @@ +#include "vcpkg_Commands.h" +#include "vcpkg.h" +#include "vcpkg_System.h" + +namespace vcpkg +{ + static const std::string OPTION_PURGE = "--purge"; + + static void delete_directory(const fs::path& directory) + { + std::error_code ec; + fs::remove_all(directory, ec); + if (!ec) + { + System::println(System::color::success, "Cleaned up %s", directory.string()); + } + if (fs::exists(directory)) + { + System::println(System::color::warning, "Some files in %s were unable to be removed. Close any editors operating in this directory and retry.", directory.string()); + } + } + + void remove_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) + { + const std::unordered_set options = args.check_and_get_optional_command_arguments({OPTION_PURGE}); + auto status_db = database_load_check(paths); + + std::vector specs = args.parse_all_arguments_as_package_specs(default_target_triplet); + bool alsoRemoveFolderFromPackages = options.find(OPTION_PURGE) != options.end(); + + for (const package_spec& spec : specs) + { + deinstall_package(paths, spec, status_db); + + if (alsoRemoveFolderFromPackages) + { + const fs::path spec_package_dir = paths.packages / spec.dir(); + delete_directory(spec_package_dir); + } + } + exit(EXIT_SUCCESS); + } +} diff --git a/toolsrc/src/lib.cpp b/toolsrc/src/lib.cpp new file mode 100644 index 00000000000000..2a3b95182688f0 --- /dev/null +++ b/toolsrc/src/lib.cpp @@ -0,0 +1,524 @@ +#include "vcpkg.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "vcpkg_Files.h" +#include "vcpkg_System.h" + +using namespace vcpkg; + +bool vcpkg::g_do_dry_run = false; + +namespace +{ + template + auto find_or_default(const M& map, const K& key, const V& val) + { + auto it = map.find(key); + if (it == map.end()) + return decltype(it->second)(val); + else + return it->second; + } +} + +namespace +{ + std::fstream open_status_file(const vcpkg_paths& paths, std::ios_base::openmode mode = std::ios_base::app | std::ios_base::in | std::ios_base::out | std::ios_base::binary) + { + return std::fstream(paths.vcpkg_dir_status_file, mode); + } +} + +static StatusParagraphs load_current_database(const fs::path& vcpkg_dir_status_file, const fs::path& vcpkg_dir_status_file_old) +{ + if (!fs::exists(vcpkg_dir_status_file)) + { + if (!fs::exists(vcpkg_dir_status_file_old)) + { + // no status file, use empty db + return StatusParagraphs(); + } + + fs::rename(vcpkg_dir_status_file_old, vcpkg_dir_status_file); + } + + auto text = Files::get_contents(vcpkg_dir_status_file).get_or_throw(); + auto pghs = parse_paragraphs(text); + + std::vector> status_pghs; + for (auto&& p : pghs) + { + status_pghs.push_back(std::make_unique(p)); + } + + return StatusParagraphs(std::move(status_pghs)); +} + +StatusParagraphs vcpkg::database_load_check(const vcpkg_paths& paths) +{ + auto updates_dir = paths.vcpkg_dir_updates; + + std::error_code ec; + fs::create_directory(paths.installed, ec); + fs::create_directory(paths.vcpkg_dir, ec); + fs::create_directory(paths.vcpkg_dir_info, ec); + fs::create_directory(updates_dir, ec); + + const fs::path& status_file = paths.vcpkg_dir_status_file; + const fs::path status_file_old = status_file.parent_path() / "status-old"; + const fs::path status_file_new = status_file.parent_path() / "status-new"; + + StatusParagraphs current_status_db = load_current_database(status_file, status_file_old); + + auto b = fs::directory_iterator(updates_dir); + auto e = fs::directory_iterator(); + if (b == e) + { + // updates directory is empty, control file is up-to-date. + return current_status_db; + } + + for (; b != e; ++b) + { + if (!fs::is_regular_file(b->status())) + continue; + if (b->path().filename() == "incomplete") + continue; + + auto text = Files::get_contents(b->path()).get_or_throw(); + auto pghs = parse_paragraphs(text); + for (auto&& p : pghs) + { + current_status_db.insert(std::make_unique(p)); + } + } + + std::fstream(status_file_new, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc) << current_status_db; + + if (fs::exists(status_file_old)) + fs::remove(status_file_old); + if (fs::exists(status_file)) + fs::rename(status_file, status_file_old); + fs::rename(status_file_new, status_file); + fs::remove(status_file_old); + + b = fs::directory_iterator(updates_dir); + for (; b != e; ++b) + { + if (!fs::is_regular_file(b->status())) + continue; + fs::remove(b->path()); + } + + return current_status_db; +} + +static fs::path listfile_path(const vcpkg_paths& paths, const BinaryParagraph& pgh) +{ + return paths.vcpkg_dir_info / (pgh.fullstem() + ".list"); +} + +static std::string get_fullpkgname_from_listfile(const fs::path& path) +{ + auto ret = path.stem().generic_u8string(); + std::replace(ret.begin(), ret.end(), '_', ':'); + return ret; +} + +fs::path vcpkg::control_file_for_package(const fs::path& package) +{ + return package / "CONTROL"; +} + +fs::path vcpkg::find_available_package(const vcpkg_paths& paths, const package_spec& spec) +{ + return paths.packages / Strings::format("%s_%s", spec.name, spec.target_triplet); +} + +fs::path vcpkg::find_available_port_file(const vcpkg_paths& paths, const package_spec& spec) +{ + return paths.ports / spec.name; +} + +static fs::path prefix_path_for_package(const vcpkg_paths& paths, const BinaryParagraph& pgh) +{ + return find_available_package(paths, {pgh.name, pgh.target_triplet}); +} + +static void write_update(const vcpkg_paths& paths, const StatusParagraph& p) +{ + static int update_id = 0; + auto my_update_id = update_id++; + auto tmp_update_filename = paths.vcpkg_dir_updates / "incomplete"; + auto update_filename = paths.vcpkg_dir_updates / std::to_string(my_update_id); + std::fstream fs(tmp_update_filename, std::ios_base::out | std::ios_base::binary | std::ios_base::trunc); + fs << p; + fs.close(); + fs::rename(tmp_update_filename, update_filename); +} + +static void install_and_write_listfile(const vcpkg_paths& paths, const BinaryParagraph& bpgh) +{ + std::fstream listfile(listfile_path(paths, bpgh), std::ios_base::out | std::ios_base::binary | std::ios_base::trunc); + + auto package_prefix_path = prefix_path_for_package(paths, bpgh); + auto prefix_length = package_prefix_path.native().size(); + + std::error_code ec; + fs::create_directory(paths.installed / bpgh.target_triplet.value, ec); + listfile << bpgh.target_triplet << "\n"; + + for (auto it = fs::recursive_directory_iterator(package_prefix_path); it != fs::recursive_directory_iterator(); ++it) + { + const auto& filename = it->path().filename(); + if (fs::is_regular_file(it->status()) && (filename == "CONTROL" || filename == "control")) + { + // Do not copy the control file + continue; + } + + auto suffix = it->path().generic_u8string().substr(prefix_length + 1); + auto target = paths.installed / bpgh.target_triplet.value / suffix; + + auto status = it->status(ec); + if (ec) + { + System::println(System::color::error, "failed: %s", ec.message()); + continue; + } + if (fs::is_directory(status)) + { + fs::create_directory(target, ec); + if (ec) + { + System::println(System::color::error, "failed: %s", ec.message()); + } + + listfile << bpgh.target_triplet << "/" << suffix << "\n"; + } + else if (fs::is_regular_file(status)) + { + fs::copy_file(*it, target, ec); + if (ec) + { + System::println(System::color::error, "failed: %s", ec.message()); + } + listfile << bpgh.target_triplet << "/" << suffix << "\n"; + } + else if (!fs::status_known(status)) + { + std::cout << "unknown status: " << *it << "\n"; + } + else + std::cout << "warning: file does not exist: " << *it << "\n"; + } + + listfile.close(); +} + +// TODO: Refactoring between this function and install_package +std::vector vcpkg::get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db) +{ + std::vector> pghs; + const fs::path packages_dir_control_file_path = find_available_package(paths, spec) / "CONTROL"; + + if (fs::exists(packages_dir_control_file_path)) + { + try + { + pghs = get_paragraphs(packages_dir_control_file_path); + } + catch (std::runtime_error) + { + // ?? + } + + Checks::check_throw(pghs.size() == 1, "Invalid control file for package"); + return BinaryParagraph(pghs[0]).depends; + } + + const fs::path ports_dir_control_file_path = find_available_port_file(paths, spec) / "CONTROL"; + try + { + pghs = get_paragraphs(ports_dir_control_file_path); + } + catch (std::runtime_error) + { + // ?? + } + + Checks::check_exit(pghs.size() == 1, "Invalid control file for package %s", spec); + return SourceParagraph(pghs[0]).depends; +} + +void vcpkg::install_package(const vcpkg_paths& paths, const BinaryParagraph& binary_paragraph, StatusParagraphs& status_db) +{ + StatusParagraph spgh; + spgh.package = binary_paragraph; + spgh.want = want_t::install; + spgh.state = install_state_t::half_installed; + for (const std::string& dependency : spgh.package.depends) + { + if (status_db.find_installed(dependency, spgh.package.target_triplet) == status_db.end()) + { + std::abort(); + } + } + write_update(paths, spgh); + status_db.insert(std::make_unique(spgh)); + + install_and_write_listfile(paths, spgh.package); + + spgh.state = install_state_t::installed; + write_update(paths, spgh); + status_db.insert(std::make_unique(spgh)); +} + +enum class deinstall_plan +{ + not_installed, + dependencies_not_satisfied, + should_deinstall +}; + +static deinstall_plan deinstall_package_plan( + const StatusParagraphs::iterator package_it, + const StatusParagraphs& status_db, + std::vector& dependencies_out) +{ + dependencies_out.clear(); + + if (package_it == status_db.end() || (*package_it)->state == install_state_t::not_installed) + { + return deinstall_plan::not_installed; + } + + auto& pkg = (*package_it)->package; + + for (auto&& inst_pkg : status_db) + { + if (inst_pkg->want != want_t::install) + continue; + if (inst_pkg->package.target_triplet != pkg.target_triplet) + continue; + + const auto& deps = inst_pkg->package.depends; + + if (std::find(deps.begin(), deps.end(), pkg.name) != deps.end()) + { + dependencies_out.push_back(inst_pkg.get()); + } + } + + if (!dependencies_out.empty()) + return deinstall_plan::dependencies_not_satisfied; + + return deinstall_plan::should_deinstall; +} + +void vcpkg::deinstall_package(const vcpkg_paths& paths, const package_spec& spec, StatusParagraphs& status_db) +{ + auto package_it = status_db.find(spec.name, spec.target_triplet); + if (package_it == status_db.end()) + { + System::println(System::color::success, "Package %s is not installed", spec); + return; + } + + auto& pkg = **package_it; + + std::vector deps; + auto plan = deinstall_package_plan(package_it, status_db, deps); + switch (plan) + { + case deinstall_plan::not_installed: + System::println(System::color::success, "Package %s is not installed", spec); + return; + case deinstall_plan::dependencies_not_satisfied: + System::println(System::color::error, "Error: Cannot remove package %s:", spec); + for (auto&& dep : deps) + { + System::println(" %s depends on %s", dep->package.displayname(), pkg.package.displayname()); + } + exit(EXIT_FAILURE); + case deinstall_plan::should_deinstall: + break; + default: + Checks::unreachable(); + } + + pkg.want = want_t::purge; + pkg.state = install_state_t::half_installed; + write_update(paths, pkg); + + std::fstream listfile(listfile_path(paths, pkg.package), std::ios_base::in | std::ios_base::binary); + if (listfile) + { + std::vector dirs_touched; + std::string suffix; + while (std::getline(listfile, suffix)) + { + if (!suffix.empty() && suffix.back() == '\r') + suffix.pop_back(); + + std::error_code ec; + + auto target = paths.installed / suffix; + + auto status = fs::status(target, ec); + if (ec) + { + System::println(System::color::error, "failed: %s", ec.message()); + continue; + } + + if (fs::is_directory(status)) + { + dirs_touched.push_back(target); + } + else if (fs::is_regular_file(status)) + { + fs::remove(target, ec); + if (ec) + { + System::println(System::color::error, "failed: %s", ec.message()); + } + } + else if (!fs::status_known(status)) + { + System::println(System::color::warning, "Warning: unknown status: %s", target.string()); + } + else + { + System::println(System::color::warning, "Warning: ???: %s", target.string()); + } + } + + auto b = dirs_touched.rbegin(); + auto e = dirs_touched.rend(); + for (; b != e; ++b) + { + if (fs::directory_iterator(*b) == fs::directory_iterator()) + { + std::error_code ec; + fs::remove(*b, ec); + if (ec) + { + System::println(System::color::error, "failed: %s", ec.message()); + } + } + } + + listfile.close(); + fs::remove(listfile_path(paths, pkg.package)); + } + + pkg.state = install_state_t::not_installed; + write_update(paths, pkg); + System::println(System::color::success, "Package %s was successfully removed", pkg.package.displayname()); +} + +void vcpkg::search_file(const vcpkg_paths& paths, const std::string& file_substr, const StatusParagraphs& status_db) +{ + std::string line; + + for (auto&& pgh : status_db) + { + if (pgh->state != install_state_t::installed) + continue; + + std::fstream listfile(listfile_path(paths, pgh->package)); + while (std::getline(listfile, line)) + { + if (line.empty()) + { + continue; + } + + if (line.find(file_substr) != std::string::npos) + { + System::println("%s: %s", pgh->package.displayname(), line); + } + } + } +} + +namespace +{ + struct Binaries + { + std::vector dlls; + std::vector libs; + }; + + Binaries detect_files_in_directory_ending_with(const fs::path& path) + { + Files::check_is_directory(path); + + Binaries binaries; + + for (auto it = fs::recursive_directory_iterator(path); it != fs::recursive_directory_iterator(); ++it) + { + fs::path file = *it; + // Skip if directory ????? + if (file.extension() == ".dll") + { + binaries.dlls.push_back(file); + } + else if (file.extension() == ".lib") + { + binaries.libs.push_back(file); + } + } + + return binaries; + } + + void copy_files_into_directory(const std::vector& files, const fs::path& destination_folder) + { + fs::create_directory(destination_folder); + + for (auto const& src_path : files) + { + fs::path dest_path = destination_folder / src_path.filename(); + fs::copy(src_path, dest_path, fs::copy_options::overwrite_existing); + } + } + + void place_library_files_in(const fs::path& include_directory, const fs::path& project_directory, const fs::path& destination_path) + { + Files::check_is_directory(include_directory); + Files::check_is_directory(project_directory); + Files::check_is_directory(destination_path); + Binaries debug_binaries = detect_files_in_directory_ending_with(project_directory / "Debug"); + Binaries release_binaries = detect_files_in_directory_ending_with(project_directory / "Release"); + + fs::path destination_include_directory = destination_path / "include"; + fs::copy(include_directory, destination_include_directory, fs::copy_options::recursive | fs::copy_options::overwrite_existing); + + copy_files_into_directory(release_binaries.dlls, destination_path / "bin"); + copy_files_into_directory(release_binaries.libs, destination_path / "lib"); + + fs::create_directory(destination_path / "debug"); + copy_files_into_directory(debug_binaries.dlls, destination_path / "debug" / "bin"); + copy_files_into_directory(debug_binaries.libs, destination_path / "debug" / "lib"); + } +} + +void vcpkg::binary_import(const vcpkg_paths& paths, const fs::path& include_directory, const fs::path& project_directory, const BinaryParagraph& control_file_data) +{ + fs::path library_destination_path = prefix_path_for_package(paths, control_file_data); + fs::create_directory(library_destination_path); + place_library_files_in(include_directory, project_directory, library_destination_path); + + fs::path control_file_path = library_destination_path / "CONTROL"; + std::ofstream(control_file_path) << control_file_data; +} diff --git a/toolsrc/src/main.cpp b/toolsrc/src/main.cpp new file mode 100644 index 00000000000000..bba1f3c636dbad --- /dev/null +++ b/toolsrc/src/main.cpp @@ -0,0 +1,245 @@ +#define WIN32_LEAN_AND_MEAN +#include + +#include +#include +#include +#include +#include "vcpkg.h" +#include "vcpkg_Commands.h" +#include "metrics.h" +#include +#include "vcpkg_Files.h" +#include "vcpkg_System.h" + +using namespace vcpkg; + +bool g_debugging = false; + +void invalid_command(const std::string& cmd) +{ + System::println(System::color::error, "invalid command: %s", cmd); + print_usage(); + exit(EXIT_FAILURE); +} + +static void inner(const vcpkg_cmd_arguments& args) +{ + TrackProperty("command", args.command); + if (args.command.empty()) + { + print_usage(); + exit(EXIT_FAILURE); + } + + if (auto command_function = find_command(args.command, get_available_commands_type_c())) + { + return command_function(args); + } + + fs::path vcpkg_root_dir; + if (args.vcpkg_root_dir != nullptr) + { + vcpkg_root_dir = fs::absolute(Strings::utf8_to_utf16(*args.vcpkg_root_dir)); + } + else + { + auto vcpkg_root_dir_env = System::wdupenv_str(L"VCPKG_ROOT"); + + if (!vcpkg_root_dir_env.empty()) + vcpkg_root_dir = fs::absolute(vcpkg_root_dir_env); + else + vcpkg_root_dir = fs::absolute(System::get_exe_path_of_current_process()).parent_path(); + } + + const expected expected_paths = vcpkg_paths::create(vcpkg_root_dir); + Checks::check_exit(!expected_paths.error_code(), "Error: Invalid vcpkg root directory %s: %s", vcpkg_root_dir.string(), expected_paths.error_code().message()); + const vcpkg_paths paths = expected_paths.get_or_throw(); + int exit_code = _wchdir(paths.root.c_str()); + Checks::check_exit(exit_code == 0, "Changing the working dir failed"); + + if (auto command_function = find_command(args.command, get_available_commands_type_b())) + { + return command_function(args, paths); + } + + triplet default_target_triplet = triplet::X86_WINDOWS; + + if (args.target_triplet != nullptr) + { + const std::string& target_triplet = *args.target_triplet; + + auto it = fs::directory_iterator(paths.triplets); + for (; it != fs::directory_iterator(); ++it) + { + std::string triplet_file_name = it->path().stem().generic_u8string(); + if (target_triplet == triplet_file_name) // TODO: fuzzy compare + { + default_target_triplet = {triplet_file_name}; + break; + } + } + + if (it == fs::directory_iterator()) + { + System::println(System::color::error, "Error: invalid triplet: %s", target_triplet); + TrackProperty("error", "invalid triplet: " + target_triplet); + help_topic_valid_triplet(paths); + exit(EXIT_FAILURE); + } + } + + if (auto command_function = find_command(args.command, get_available_commands_type_a())) + { + return command_function(args, paths, default_target_triplet); + } + + return invalid_command(args.command); +} + +static void loadConfig() +{ + fs::path localappdata; + { + // Config path in AppDataLocal + wchar_t* localappdatapath = nullptr; + if (S_OK != SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, nullptr, &localappdatapath)) + __fastfail(1); + localappdata = localappdatapath; + CoTaskMemFree(localappdatapath); + } + + try + { + std::string config_contents = Files::get_contents(localappdata / "vcpkg" / "config").get_or_throw(); + + std::unordered_map keys; + auto pghs = parse_paragraphs(config_contents); + if (pghs.size() > 0) + keys = pghs[0]; + + for (size_t x = 1; x < pghs.size(); ++x) + { + for (auto&& p : pghs[x]) + keys.insert(p); + } + + auto user_id = keys["User-Id"]; + auto user_time = keys["User-Since"]; + Checks::check_throw(!user_id.empty() && !user_time.empty(), ""); // Use as goto to the catch statement + + SetUserInformation(user_id, user_time); + return; + } + catch (...) + { + } + + // config file not found, could not be read, or invalid + std::string user_id, user_time; + InitUserInformation(user_id, user_time); + SetUserInformation(user_id, user_time); + try + { + std::error_code ec; + fs::create_directory(localappdata / "vcpkg", ec); + std::ofstream(localappdata / "vcpkg" / "config", std::ios_base::out | std::ios_base::trunc) + << "User-Id: " << user_id << "\n" + << "User-Since: " << user_time << "\n"; + } + catch (...) + { + } +} + +static System::Stopwatch g_timer; + +static std::string trim_path_from_command_line(const std::string& full_command_line) +{ + Checks::check_exit(full_command_line.size() > 0, "Internal failure - cannot have empty command line"); + + if (full_command_line[0] == '"') + { + auto it = std::find(full_command_line.cbegin() + 1, full_command_line.cend(), '"'); + if (it != full_command_line.cend()) // Skip over the quote + ++it; + while (it != full_command_line.cend() && *it == ' ') // Skip over a space + ++it; + return std::string(it, full_command_line.cend()); + } + + auto it = std::find(full_command_line.cbegin(), full_command_line.cend(), ' '); + while (it != full_command_line.cend() && *it == ' ') + ++it; + return std::string(it, full_command_line.cend()); +} + +int wmain(const int argc, const wchar_t* const* const argv) +{ + if (argc == 0) + std::abort(); + + std::cout.sync_with_stdio(false); + std::cout.imbue(std::locale::classic()); + + g_timer.start(); + atexit([]() + { + g_timer.stop(); + TrackMetric("elapsed_us", g_timer.microseconds()); + Flush(); + }); + + TrackProperty("version", version()); + + const std::string trimmed_command_line = trim_path_from_command_line(Strings::utf16_to_utf8(GetCommandLineW())); + TrackProperty("cmdline", trimmed_command_line); + loadConfig(); + + const vcpkg_cmd_arguments args = vcpkg_cmd_arguments::create_from_command_line(argc, argv); + + if (args.printmetrics != opt_bool::unspecified) + SetPrintMetrics(args.printmetrics == opt_bool::enabled); + if (args.sendmetrics != opt_bool::unspecified) + SetSendMetrics(args.sendmetrics == opt_bool::enabled); + + if (args.debug != opt_bool::unspecified) + { + g_debugging = (args.debug == opt_bool::enabled); + } + + if (g_debugging) + { + inner(args); + exit(EXIT_FAILURE); + } + + std::string exc_msg; + try + { + inner(args); + exit(EXIT_FAILURE); + } + catch (std::exception& e) + { + exc_msg = e.what(); + } + catch (...) + { + exc_msg = "unknown error(...)"; + } + TrackProperty("error", exc_msg); + std::cerr + << "vcpkg.exe has crashed.\n" + << "Please send an email to:\n" + << " vcpkg@microsoft.com\n" + << "containing a brief summary of what you were trying to do and the following data blob:\n" + << "\n" + << "Version=" << version() << "\n" + << "EXCEPTION='" << exc_msg << "'\n" + << "CMD=\n"; + for (int x = 0; x < argc; ++x) + std::cerr << argv[x] << "|\n"; + std::cerr + << "\n"; +} diff --git a/toolsrc/src/metrics.cpp b/toolsrc/src/metrics.cpp new file mode 100644 index 00000000000000..610c71ed1186d7 --- /dev/null +++ b/toolsrc/src/metrics.cpp @@ -0,0 +1,425 @@ +#include "metrics.h" +#include +#include +#include +#include +#include +#include +#include +#define WIN32_LEAN_AND_MEAN +#include +#include +#include +#include +#include "vcpkg_Strings.h" +#include "vcpkg_System.h" + +namespace fs = std::tr2::sys; + +namespace vcpkg +{ + static std::string GetCurrentDateTime() + { + struct tm newtime; + time_t now; + int milli; + std::array date; + date.fill(0); + + struct _timeb timebuffer; + + _ftime_s(&timebuffer); + now = timebuffer.time; + milli = timebuffer.millitm; + + errno_t err = gmtime_s(&newtime, &now); + if (err) + { + return ""; + } + + strftime(&date[0], date.size(), "%Y-%m-%dT%H:%M:%S", &newtime); + return std::string(&date[0]) + "." + std::to_string(milli) + "Z"; + } + + static std::string GenerateRandomUUID() + { + int partSizes[] = {8, 4, 4, 4, 12}; + char uuid[37]; + memset(uuid, 0, sizeof(uuid)); + int num; + srand(static_cast(time(nullptr))); + int index = 0; + for (int part = 0; part < 5; part++) + { + if (part > 0) + { + uuid[index] = '-'; + index++; + } + + // Generating UUID format version 4 + // http://en.wikipedia.org/wiki/Universally_unique_identifier + for (int i = 0; i < partSizes[part]; i++ , index++) + { + if (part == 2 && i == 0) + { + num = 4; + } + else if (part == 4 && i == 0) + { + num = (rand() % 4) + 8; + } + else + { + num = rand() % 16; + } + + if (num < 10) + { + uuid[index] = static_cast('0' + num); + } + else + { + uuid[index] = static_cast('a' + (num - 10)); + } + } + } + + return uuid; + } + + static const std::string& get_session_id() + { + static const std::string id = GenerateRandomUUID(); + return id; + } + + static std::string to_json_string(const std::string& str) + { + std::string encoded = "\""; + for (auto&& ch : str) + { + if (ch == '\\') + { + encoded.append("\\\\"); + } + else if (ch == '"') + { + encoded.append("\\\""); + } + else if (ch < 0x20 || ch >= 0x80) + { + // Note: this treats incoming Strings as Latin-1 + static constexpr const char hex[16] = { + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + encoded.append("\\u00"); + encoded.push_back(hex[ch / 16]); + encoded.push_back(hex[ch % 16]); + } + else + { + encoded.push_back(ch); + } + } + encoded.push_back('"'); + return encoded; + } + + static std::string get_os_version_string() + { + std::wstring path; + path.resize(MAX_PATH); + auto n = GetSystemDirectoryW(&path[0], static_cast(path.size())); + path.resize(n); + path += L"\\kernel32.dll"; + + auto versz = GetFileVersionInfoSizeW(path.c_str(), nullptr); + if (versz == 0) + return ""; + + std::vector verbuf; + verbuf.resize(versz); + + if (!GetFileVersionInfoW(path.c_str(), 0, static_cast(verbuf.size()), &verbuf[0])) + return ""; + + void* rootblock; + UINT rootblocksize; + if (!VerQueryValueW(&verbuf[0], L"\\", &rootblock, &rootblocksize)) + return ""; + + auto rootblock_ffi = static_cast(rootblock); + + return Strings::format("%d.%d.%d", + static_cast(HIWORD(rootblock_ffi->dwProductVersionMS)), + static_cast(LOWORD(rootblock_ffi->dwProductVersionMS)), + static_cast(HIWORD(rootblock_ffi->dwProductVersionLS))); + } + + struct MetricMessage + { + std::string user_id = GenerateRandomUUID(); + std::string user_timestamp; + std::string timestamp = GetCurrentDateTime(); + std::string properties; + std::string measurements; + + void TrackProperty(const std::string& name, const std::string& value) + { + if (properties.size() != 0) + properties.push_back(','); + properties.append(to_json_string(name)); + properties.push_back(':'); + properties.append(to_json_string(value)); + } + + void TrackMetric(const std::string& name, double value) + { + if (measurements.size() != 0) + measurements.push_back(','); + measurements.append(to_json_string(name)); + measurements.push_back(':'); + measurements.append(std::to_string(value)); + } + + std::string format_event_data_template() const + { + const std::string& session_id = get_session_id(); + return Strings::format(R"([{ + "ver": 1, + "name": "Microsoft.ApplicationInsights.Event", + "time": "%s", + "sampleRate": 100.000000, + "seq": "0:0", + "iKey": "b4e88960-4393-4dd9-ab8e-97e8fe6d7603", + "flags": 0.000000, + "tags": { + "ai.device.os": "Windows", + "ai.device.osVersion": "%s", + "ai.session.id": "%s", + "ai.user.id": "%s", + "ai.user.accountAcquisitionDate": "%s" + }, + "data": { + "baseType": "EventData", + "baseData": { + "ver": 2, + "name": "commandline_test7", + "properties": { %s }, + "measurements": { %s } + } + } +}])", + timestamp, + get_os_version_string(), + session_id, + user_id, + user_timestamp, + properties, + measurements); + } + }; + + static MetricMessage g_metricmessage; + static bool g_should_send_metrics = +#if defined(NDEBUG) && (DISABLE_METRICS == 0) +true +#else + false +#endif + ; + static bool g_should_print_metrics = false; + + bool GetCompiledMetricsEnabled() + { + return DISABLE_METRICS == 0; + } + + void SetUserInformation(const std::string& user_id, const std::string& first_use_time) + { + g_metricmessage.user_id = user_id; + g_metricmessage.user_timestamp = first_use_time; + } + + void InitUserInformation(std::string& user_id, std::string& first_use_time) + { + user_id = GenerateRandomUUID(); + first_use_time = GetCurrentDateTime(); + } + + void SetSendMetrics(bool should_send_metrics) + { + g_should_send_metrics = should_send_metrics; + } + + void SetPrintMetrics(bool should_print_metrics) + { + g_should_print_metrics = should_print_metrics; + } + + void TrackMetric(const std::string& name, double value) + { + g_metricmessage.TrackMetric(name, value); + } + + void TrackProperty(const std::string& name, const std::wstring& value) + { + // Note: this is not valid UTF-16 -> UTF-8, it just yields a close enough approximation for our purposes. + std::string converted_value; + converted_value.resize(value.size()); + std::transform( + value.begin(), value.end(), + converted_value.begin(), + [](wchar_t ch) + { + return static_cast(ch); + }); + + g_metricmessage.TrackProperty(name, converted_value); + } + + void TrackProperty(const std::string& name, const std::string& value) + { + g_metricmessage.TrackProperty(name, value); + } + + void Upload(const std::string& payload) + { + HINTERNET hSession = nullptr, hConnect = nullptr, hRequest = nullptr; + BOOL bResults = FALSE; + + hSession = WinHttpOpen(L"vcpkg/1.0", + WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, + WINHTTP_NO_PROXY_NAME, + WINHTTP_NO_PROXY_BYPASS, + 0); + if (hSession) + hConnect = WinHttpConnect(hSession, L"dc.services.visualstudio.com", INTERNET_DEFAULT_HTTPS_PORT, 0); + + if (hConnect) + hRequest = WinHttpOpenRequest(hConnect, + L"POST", + L"/v2/track", + nullptr, + WINHTTP_NO_REFERER, + WINHTTP_DEFAULT_ACCEPT_TYPES, + WINHTTP_FLAG_SECURE); + + if (hRequest) + { + if (MAXDWORD <= payload.size()) + abort(); + std::wstring hdrs = L"Content-Type: application/json\r\n"; + bResults = WinHttpSendRequest(hRequest, + hdrs.c_str(), static_cast(hdrs.size()), + (void*)&payload[0], static_cast(payload.size()), static_cast(payload.size()), + 0); + } + + if (bResults) + { + bResults = WinHttpReceiveResponse(hRequest, nullptr); + } + + DWORD http_code = 0, junk = sizeof(DWORD); + + if (bResults) + { + bResults = WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, nullptr, &http_code, &junk, WINHTTP_NO_HEADER_INDEX); + } + + std::vector responseBuffer; + if (bResults) + { + DWORD availableData = 0, readData = 0, totalData = 0; + + while ((bResults = WinHttpQueryDataAvailable(hRequest, &availableData)) && availableData > 0) + { + responseBuffer.resize(responseBuffer.size() + availableData); + + bResults = WinHttpReadData(hRequest, &responseBuffer.data()[totalData], availableData, &readData); + + if (!bResults) + { + break; + } + + totalData += readData; + + responseBuffer.resize(totalData); + } + } + + if (!bResults) + { +#ifndef NDEBUG + __debugbreak(); + auto err = GetLastError(); + std::cerr << "[DEBUG] failed to connect to server: " << err << "\n"; +#endif + } + + if (hRequest) + WinHttpCloseHandle(hRequest); + if (hConnect) + WinHttpCloseHandle(hConnect); + if (hSession) + WinHttpCloseHandle(hSession); + } + + static fs::path get_bindir() + { + wchar_t buf[_MAX_PATH ]; + int bytes = GetModuleFileNameW(nullptr, buf, _MAX_PATH); + if (bytes == 0) + std::abort(); + return fs::path(buf, buf + bytes); + } + + void Flush() + { + std::string payload = g_metricmessage.format_event_data_template(); + if (g_should_print_metrics) + std::cerr << payload << "\n"; + if (!g_should_send_metrics) + return; + + // Upload(payload); + + wchar_t temp_folder[MAX_PATH]; + GetTempPathW(MAX_PATH, temp_folder); + + const fs::path temp_folder_path = temp_folder; + const fs::path temp_folder_path_exe = temp_folder_path / "vcpkgmetricsuploader.exe"; + + if (true) + { + const fs::path exe_path = []() -> fs::path + { + auto vcpkgdir = get_bindir().parent_path(); + auto path = vcpkgdir / "vcpkgmetricsuploader.exe"; + if (fs::exists(path)) + return path; + + path = vcpkgdir / "scripts" / "vcpkgmetricsuploader.exe"; + if (fs::exists(path)) + return path; + + return L""; + }(); + + std::error_code ec; + fs::copy_file(exe_path, temp_folder_path_exe, fs::copy_options::skip_existing, ec); + if (ec) + return; + } + + const fs::path vcpkg_metrics_txt_path = temp_folder_path / ("vcpkg" + GenerateRandomUUID() + ".txt"); + std::ofstream(vcpkg_metrics_txt_path) << payload; + + const std::wstring cmdLine = Strings::format(L"start %s %s", temp_folder_path_exe.native(), vcpkg_metrics_txt_path.native()); + System::cmd_execute(cmdLine); + } +} diff --git a/toolsrc/src/package_spec.cpp b/toolsrc/src/package_spec.cpp new file mode 100644 index 00000000000000..ece5f91e96d4c8 --- /dev/null +++ b/toolsrc/src/package_spec.cpp @@ -0,0 +1,46 @@ +#include "package_spec.h" + +namespace vcpkg +{ + expected parse(const std::string& spec, const triplet& default_target_triplet) + { + auto pos = spec.find(':'); + if (pos == std::string::npos) + { + return package_spec{spec, default_target_triplet}; + } + + auto pos2 = spec.find(':', pos + 1); + if (pos2 != std::string::npos) + { + return std::error_code(package_spec_parse_result::too_many_colons); + } + + return package_spec{spec.substr(0, pos), spec.substr(pos + 1)}; + } + + std::string package_spec::dir() const + { + return Strings::format("%s_%s", this->name, this->target_triplet); + } + + std::string to_string(const package_spec& spec) + { + return Strings::format("%s:%s", spec.name, spec.target_triplet); + } + + std::string to_printf_arg(const package_spec& spec) + { + return to_string(spec); + } + + bool operator==(const package_spec& left, const package_spec& right) + { + return left.name == right.name && left.target_triplet == right.target_triplet; + } + + std::ostream& operator<<(std::ostream& os, const package_spec& spec) + { + return os << to_string(spec); + } +} diff --git a/toolsrc/src/package_spec_parse_result.cpp b/toolsrc/src/package_spec_parse_result.cpp new file mode 100644 index 00000000000000..757b6df533180a --- /dev/null +++ b/toolsrc/src/package_spec_parse_result.cpp @@ -0,0 +1,45 @@ +#include +#include +#include "package_spec_parse_result.h" + +namespace vcpkg +{ + const char* package_spec_parse_result_category_impl::name() const noexcept + { + return "package_spec_parse_result"; + } + + std::string package_spec_parse_result_category_impl::message(int ev) const noexcept + { + switch (static_cast(ev)) + { + case package_spec_parse_result::success: + return "OK"; + case package_spec_parse_result::too_many_colons: + return "Too many colons"; + default: + Checks::unreachable(); + } + } + + const std::error_category& package_spec_parse_result_category() + { + static package_spec_parse_result_category_impl instance; + return instance; + } + + std::error_code make_error_code(package_spec_parse_result e) + { + return std::error_code(static_cast(e), package_spec_parse_result_category()); + } + + package_spec_parse_result to_package_spec_parse_result(int i) + { + return static_cast(i); + } + + package_spec_parse_result to_package_spec_parse_result(std::error_code ec) + { + return to_package_spec_parse_result(ec.value()); + } +} diff --git a/toolsrc/src/post_build_lint.cpp b/toolsrc/src/post_build_lint.cpp new file mode 100644 index 00000000000000..3c4c5938d1c0e5 --- /dev/null +++ b/toolsrc/src/post_build_lint.cpp @@ -0,0 +1,356 @@ +#include +#include "vcpkg_paths.h" +#include "package_spec.h" +#include +#include +#include "vcpkg_System.h" + +namespace fs = std::tr2::sys; + +namespace vcpkg +{ + enum class lint_status + { + SUCCESS = 0, + ERROR = 1 + }; + + static const fs::path DUMPBIN_EXE = R"(C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\dumpbin.exe)"; + + namespace + { + void print_vector_of_files(const std::vector& paths) + { + System::println(""); + for (const fs::path& p : paths) + { + System::println(" %s", p.generic_string()); + } + System::println(""); + } + + template + void recursive_find_matching_paths_in_dir(const fs::path& dir, const Pred predicate, std::vector& output) + { + std::copy_if(fs::recursive_directory_iterator(dir), fs::recursive_directory_iterator(), std::back_inserter(output), predicate); + } + + void recursive_find_files_with_extension_in_dir(const fs::path& dir, const std::string& extension, std::vector& output) + { + recursive_find_matching_paths_in_dir(dir, [&extension](const fs::path& current) + { + return !fs::is_directory(current) && current.extension() == extension; + }, output); + } + } + + static lint_status check_for_files_in_include_directory(const package_spec& spec, const vcpkg_paths& paths) + { + const fs::path include_dir = paths.packages / spec.dir() / "include"; + if (!fs::exists(include_dir) || fs::is_empty(include_dir)) + { + System::println(System::color::warning, "The folder /include is empty. This indicates the library was not correctly installed."); + return lint_status::ERROR; + } + + return lint_status::SUCCESS; + } + + static lint_status check_for_files_in_debug_include_directory(const package_spec& spec, const vcpkg_paths& paths) + { + const fs::path debug_include_dir = paths.packages / spec.dir() / "debug" / "include"; + std::vector files_found; + + recursive_find_matching_paths_in_dir(debug_include_dir, [&](const fs::path& current) + { + return !fs::is_directory(current) && current.extension() != ".ifc"; + }, files_found); + + if (!files_found.empty()) + { + System::println(System::color::warning, "Include files should not be duplicated into the /debug/include directory. If this cannot be disabled in the project cmake, use\n" + " file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)" + ); + return + lint_status::ERROR; + } + + return + lint_status::SUCCESS; + } + + static lint_status check_for_files_in_debug_share_directory(const package_spec& spec, const vcpkg_paths& paths) + { + const fs::path debug_share = paths.packages / spec.dir() / "debug" / "share"; + + if (fs::exists(debug_share) && !fs::is_empty(debug_share)) + { + System::println(System::color::warning, "No files should be present in /debug/share"); + return lint_status::ERROR; + } + + return lint_status::SUCCESS; + } + + static lint_status check_folder_lib_cmake(const package_spec& spec, const vcpkg_paths& paths) + { + const fs::path lib_cmake = paths.packages / spec.dir() / "lib" / "cmake"; + if (fs::exists(lib_cmake)) + { + System::println(System::color::warning, "The /lib/cmake folder should be moved to just /cmake"); + return lint_status::ERROR; + } + + return lint_status::SUCCESS; + } + + static lint_status check_for_misplaced_cmake_files(const package_spec& spec, const vcpkg_paths& paths) + { + const fs::path current_packages_dir = paths.packages / spec.dir(); + std::vector misplaced_cmake_files; + recursive_find_files_with_extension_in_dir(current_packages_dir / "cmake", ".cmake", misplaced_cmake_files); + recursive_find_files_with_extension_in_dir(current_packages_dir / "debug" / "cmake", ".cmake", misplaced_cmake_files); + recursive_find_files_with_extension_in_dir(current_packages_dir / "lib" / "cmake", ".cmake", misplaced_cmake_files); + recursive_find_files_with_extension_in_dir(current_packages_dir / "debug" / "lib" / "cmake", ".cmake", misplaced_cmake_files); + + if (!misplaced_cmake_files.empty()) + { + System::println(System::color::warning, "The following cmake files were found outside /share/%s. Please place cmake files in /share/%s.", spec.name, spec.name); + print_vector_of_files(misplaced_cmake_files); + return lint_status::ERROR; + } + + return lint_status::SUCCESS; + } + + static lint_status check_folder_debug_lib_cmake(const package_spec& spec, const vcpkg_paths& paths) + { + const fs::path lib_cmake_debug = paths.packages / spec.dir() / "debug" / "lib" / "cmake"; + if (fs::exists(lib_cmake_debug)) + { + System::println(System::color::warning, "The /debug/lib/cmake folder should be moved to just /debug/cmake"); + return lint_status::ERROR; + } + + return lint_status::SUCCESS; + } + + static lint_status check_for_dlls_in_lib_dirs(const package_spec& spec, const vcpkg_paths& paths) + { + std::vector dlls; + recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "lib", ".dll", dlls); + recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "lib", ".dll", dlls); + + if (!dlls.empty()) + { + System::println(System::color::warning, "\nThe following dlls were found in /lib and /debug/lib. Please move them to /bin or /debug/bin, respectively."); + print_vector_of_files(dlls); + return lint_status::ERROR; + } + + return lint_status::SUCCESS; + } + + static lint_status check_for_copyright_file(const package_spec& spec, const vcpkg_paths& paths) + { + const fs::path copyright_file = paths.packages / spec.dir() / "share" / spec.name / "copyright"; + if (fs::exists(copyright_file)) + { + return lint_status::SUCCESS; + } + const fs::path current_buildtrees_dir = paths.buildtrees / spec.name; + const fs::path current_buildtrees_dir_src = current_buildtrees_dir / "src"; + + std::vector potential_copyright_files; + // Only searching one level deep + for (auto it = fs::recursive_directory_iterator(current_buildtrees_dir_src); it != fs::recursive_directory_iterator(); ++it) + { + if (it.depth() > 1) + { + continue; + } + + const std::string filename = it->path().filename().string(); + if (filename == "LICENSE" || filename == "LICENSE.txt" || filename == "COPYING") + { + potential_copyright_files.push_back(it->path()); + } + } + + System::println(System::color::warning, "The software license must be available at ${CURRENT_PACKAGES_DIR}/share/%s/copyright .", spec.name); + if (potential_copyright_files.size() == 1) // if there is only one candidate, provide the cmake lines needed to place it in the proper location + { + const fs::path found_file = potential_copyright_files[0]; + const fs::path relative_path = found_file.string().erase(0, current_buildtrees_dir.string().size() + 1); // The +1 is needed to remove the "/" + System::println("\n file(COPY ${CURRENT_BUILDTREES_DIR}/%s DESTINATION ${CURRENT_PACKAGES_DIR}/share/%s)\n" + " file(RENAME ${CURRENT_PACKAGES_DIR}/share/%s/%s ${CURRENT_PACKAGES_DIR}/share/%s/copyright)", + relative_path.generic_string(), spec.name, spec.name, found_file.filename().generic_string(), spec.name); + return lint_status::ERROR; + } + + if (potential_copyright_files.size() > 1) + { + System::println(System::color::warning, "The following files are potential copyright files:"); + print_vector_of_files(potential_copyright_files); + } + + const fs::path current_packages_dir = paths.packages / spec.dir(); + System::println(" %s/share/%s/copyright", current_packages_dir.generic_string(), spec.name); + + return lint_status::ERROR; + } + + static lint_status check_for_exes(const package_spec& spec, const vcpkg_paths& paths) + { + std::vector exes; + recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "bin", ".exe", exes); + recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "bin", ".exe", exes); + + if (!exes.empty()) + { + System::println(System::color::warning, "The following EXEs were found in /bin and /debug/bin. EXEs are not valid distribution targets."); + print_vector_of_files(exes); + return lint_status::ERROR; + } + + return lint_status::SUCCESS; + } + + static lint_status check_exports_of_dlls(const std::vector& dlls) + { + std::vector dlls_with_no_exports; + for (const fs::path& dll : dlls) + { + const std::wstring cmd_line = Strings::format(LR"("%s" /exports "%s")", DUMPBIN_EXE.native(), dll.native()); + System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line); + Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); + + if (ec_data.output.find("ordinal hint RVA name") == std::string::npos) + { + dlls_with_no_exports.push_back(dll); + } + } + + if (!dlls_with_no_exports.empty()) + { + System::println(System::color::warning, "The following DLLs have no exports:"); + print_vector_of_files(dlls_with_no_exports); + System::println(System::color::warning, "DLLs without any exports are likely a bug in the build script."); + return lint_status::ERROR; + } + + return lint_status::SUCCESS; + } + + static lint_status check_uwp_bit_of_dlls(const std::string& expected_system_name, const std::vector& dlls) + { + if (expected_system_name != "uwp") + { + return lint_status::SUCCESS; + } + + std::vector dlls_with_improper_uwp_bit; + for (const fs::path& dll : dlls) + { + const std::wstring cmd_line = Strings::format(LR"("%s" /headers "%s")", DUMPBIN_EXE.native(), dll.native()); + System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line); + Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); + + if (ec_data.output.find("App Container") == std::string::npos) + { + dlls_with_improper_uwp_bit.push_back(dll); + } + } + + if (!dlls_with_improper_uwp_bit.empty()) + { + System::println(System::color::warning, "The following DLLs do not have the App Container bit set:"); + print_vector_of_files(dlls_with_improper_uwp_bit); + System::println(System::color::warning, "This bit is required for Windows Store apps."); + return lint_status::ERROR; + } + + return lint_status::SUCCESS; + } + + struct file_and_arch + { + fs::path file; + std::string actual_arch; + }; + + static lint_status check_architecture(const std::string& expected_architecture, const std::vector& files) + { + std::vector binaries_with_invalid_architecture; + for (const fs::path& f : files) + { + const std::wstring cmd_line = Strings::format(LR"("%s" /headers "%s" | findstr machine)", DUMPBIN_EXE.native(), f.native()); + System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(cmd_line); + Checks::check_exit(ec_data.exit_code == 0, "Running command:\n %s\n failed", Strings::utf16_to_utf8(cmd_line)); + + if (Strings::case_insensitive_find(ec_data.output, expected_architecture) == ec_data.output.end()) + { + binaries_with_invalid_architecture.push_back({f, ec_data.output}); + } + } + + if (!binaries_with_invalid_architecture.empty()) + { + System::println(System::color::warning, "The following files were built for an incorrect architecture:"); + System::println(""); + for (const file_and_arch& b : binaries_with_invalid_architecture) + { + System::println(" %s", b.file.generic_string()); + System::println("Expected %s, but was:\n %s", expected_architecture, b.actual_arch); + } + System::println(""); + + return lint_status::ERROR; + } + + return lint_status::SUCCESS; + } + + static void operator +=(unsigned int& left, const lint_status& right) + { + left += static_cast(right); + } + + void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths) + { + System::println("-- Performing post-build validation"); + unsigned int error_count = 0; + error_count += check_for_files_in_include_directory(spec, paths); + error_count += check_for_files_in_debug_include_directory(spec, paths); + error_count += check_for_files_in_debug_share_directory(spec, paths); + error_count += check_folder_lib_cmake(spec, paths); + error_count += check_for_misplaced_cmake_files(spec, paths); + error_count += check_folder_debug_lib_cmake(spec, paths); + error_count += check_for_dlls_in_lib_dirs(spec, paths); + error_count += check_for_copyright_file(spec, paths); + error_count += check_for_exes(spec, paths); + + std::vector dlls; + recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "bin", ".dll", dlls); + recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "bin", ".dll", dlls); + + error_count += check_exports_of_dlls(dlls); + error_count += check_uwp_bit_of_dlls(spec.target_triplet.system(), dlls); + error_count += check_architecture(spec.target_triplet.architecture(), dlls); + + std::vector libs; + recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "lib", ".lib", libs); + recursive_find_files_with_extension_in_dir(paths.packages / spec.dir() / "debug" / "lib", ".lib", libs); + + error_count += check_architecture(spec.target_triplet.architecture(), libs); + + if (error_count != 0) + { + const fs::path portfile = paths.ports / spec.name / "portfile.cmake"; + System::println(System::color::error, "Found %d error(s). Please correct the portfile:\n %s", error_count, portfile.string()); + exit(EXIT_FAILURE); + } + + System::println("-- Performing post-build validation done"); + } +} diff --git a/toolsrc/src/test.cpp b/toolsrc/src/test.cpp new file mode 100644 index 00000000000000..82113abaa3ed8f --- /dev/null +++ b/toolsrc/src/test.cpp @@ -0,0 +1,347 @@ +#include "CppUnitTest.h" +#include "vcpkg.h" + +#pragma comment(lib,"version") +#pragma comment(lib,"winhttp") + +using namespace Microsoft::VisualStudio::CppUnitTestFramework; + +namespace Microsoft { namespace VisualStudio { namespace CppUnitTestFramework +{ + template <> + inline std::wstring ToString(const vcpkg::package_spec_parse_result& t) + { + return ToString(static_cast(t)); + } +}}} + +namespace UnitTest1 +{ + TEST_CLASS(ControlParsing) + { + public: + TEST_METHOD(SourceParagraph_Construct_Minimum) + { + vcpkg::SourceParagraph pgh({ + {"Source", "zlib"}, + {"Version", "1.2.8"} + }); + + Assert::AreEqual("zlib", pgh.name.c_str()); + Assert::AreEqual("1.2.8", pgh.version.c_str()); + Assert::AreEqual("", pgh.maintainer.c_str()); + Assert::AreEqual("", pgh.description.c_str()); + Assert::AreEqual(size_t(0), pgh.depends.size()); + } + + TEST_METHOD(SourceParagraph_Construct_Maximum) + { + vcpkg::SourceParagraph pgh({ + {"Source", "s"}, + {"Version", "v"}, + {"Maintainer", "m"}, + {"Description", "d"}, + {"Build-Depends", "bd"} + }); + Assert::AreEqual("s", pgh.name.c_str()); + Assert::AreEqual("v", pgh.version.c_str()); + Assert::AreEqual("m", pgh.maintainer.c_str()); + Assert::AreEqual("d", pgh.description.c_str()); + Assert::AreEqual(size_t(1), pgh.depends.size()); + Assert::AreEqual("bd", pgh.depends[0].c_str()); + } + + TEST_METHOD(SourceParagraph_Two_Depends) + { + vcpkg::SourceParagraph pgh({ + {"Source", "zlib"}, + {"Version", "1.2.8"}, + {"Build-Depends", "z, openssl"} + }); + + Assert::AreEqual(size_t(2), pgh.depends.size()); + Assert::AreEqual("z", pgh.depends[0].c_str()); + Assert::AreEqual("openssl", pgh.depends[1].c_str()); + } + + TEST_METHOD(SourceParagraph_Three_Depends) + { + vcpkg::SourceParagraph pgh({ + {"Source", "zlib"}, + {"Version", "1.2.8"}, + {"Build-Depends", "z, openssl, xyz"} + }); + + Assert::AreEqual(size_t(3), pgh.depends.size()); + Assert::AreEqual("z", pgh.depends[0].c_str()); + Assert::AreEqual("openssl", pgh.depends[1].c_str()); + Assert::AreEqual("xyz", pgh.depends[2].c_str()); + } + + TEST_METHOD(BinaryParagraph_Construct_Minimum) + { + vcpkg::BinaryParagraph pgh({ + {"Package", "zlib"}, + {"Version", "1.2.8"}, + {"Architecture", "a"}, + {"Multi-Arch", "same"}, + }); + + Assert::AreEqual("zlib", pgh.name.c_str()); + Assert::AreEqual("1.2.8", pgh.version.c_str()); + Assert::AreEqual("", pgh.maintainer.c_str()); + Assert::AreEqual("", pgh.description.c_str()); + Assert::AreEqual("a", pgh.target_triplet.value.c_str()); + Assert::AreEqual(size_t(0), pgh.depends.size()); + } + + TEST_METHOD(BinaryParagraph_Construct_Maximum) + { + vcpkg::BinaryParagraph pgh({ + {"Package", "s"}, + {"Version", "v"}, + {"Architecture", "a"}, + {"Multi-Arch", "same"}, + {"Maintainer", "m"}, + {"Description", "d"}, + {"Depends", "bd"} + }); + Assert::AreEqual("s", pgh.name.c_str()); + Assert::AreEqual("v", pgh.version.c_str()); + Assert::AreEqual("m", pgh.maintainer.c_str()); + Assert::AreEqual("d", pgh.description.c_str()); + Assert::AreEqual(size_t(1), pgh.depends.size()); + Assert::AreEqual("bd", pgh.depends[0].c_str()); + } + + TEST_METHOD(BinaryParagraph_Three_Depends) + { + vcpkg::BinaryParagraph pgh({ + {"Package", "zlib"}, + {"Version", "1.2.8"}, + {"Architecture", "a"}, + {"Multi-Arch", "same"}, + {"Depends", "a, b, c"}, + }); + + Assert::AreEqual(size_t(3), pgh.depends.size()); + Assert::AreEqual("a", pgh.depends[0].c_str()); + Assert::AreEqual("b", pgh.depends[1].c_str()); + Assert::AreEqual("c", pgh.depends[2].c_str()); + } + + TEST_METHOD(parse_paragraphs_empty) + { + const char* str = ""; + auto pghs = vcpkg::parse_paragraphs(str); + Assert::IsTrue(pghs.empty()); + } + + TEST_METHOD(parse_paragraphs_one_field) + { + const char* str = "f1: v1"; + auto pghs = vcpkg::parse_paragraphs(str); + Assert::AreEqual(size_t(1), pghs.size()); + Assert::AreEqual(size_t(1), pghs[0].size()); + Assert::AreEqual("v1", pghs[0]["f1"].c_str()); + } + + TEST_METHOD(parse_paragraphs_one_pgh) + { + const char* str = + "f1: v1\n" + "f2: v2"; + auto pghs = vcpkg::parse_paragraphs(str); + Assert::AreEqual(size_t(1), pghs.size()); + Assert::AreEqual(size_t(2), pghs[0].size()); + Assert::AreEqual("v1", pghs[0]["f1"].c_str()); + Assert::AreEqual("v2", pghs[0]["f2"].c_str()); + } + + TEST_METHOD(parse_paragraphs_two_pgh) + { + const char* str = + "f1: v1\n" + "f2: v2\n" + "\n" + "f3: v3\n" + "f4: v4"; + auto pghs = vcpkg::parse_paragraphs(str); + Assert::AreEqual(size_t(2), pghs.size()); + Assert::AreEqual(size_t(2), pghs[0].size()); + Assert::AreEqual("v1", pghs[0]["f1"].c_str()); + Assert::AreEqual("v2", pghs[0]["f2"].c_str()); + Assert::AreEqual(size_t(2), pghs[1].size()); + Assert::AreEqual("v3", pghs[1]["f3"].c_str()); + Assert::AreEqual("v4", pghs[1]["f4"].c_str()); + } + + TEST_METHOD(parse_paragraphs_field_names) + { + const char* str = + "1:\n" + "f:\n" + "F:\n" + "0:\n" + "F-2:\n"; + auto pghs = vcpkg::parse_paragraphs(str); + Assert::AreEqual(size_t(1), pghs.size()); + Assert::AreEqual(size_t(5), pghs[0].size()); + } + + TEST_METHOD(parse_paragraphs_multiple_blank_lines) + { + const char* str = + "f1: v1\n" + "f2: v2\n" + "\n" + "\n" + "f3: v3\n" + "f4: v4"; + auto pghs = vcpkg::parse_paragraphs(str); + Assert::AreEqual(size_t(2), pghs.size()); + } + + TEST_METHOD(parse_paragraphs_empty_fields) + { + const char* str = + "f1:\n" + "f2: "; + auto pghs = vcpkg::parse_paragraphs(str); + Assert::AreEqual(size_t(1), pghs.size()); + Assert::AreEqual(size_t(2), pghs[0].size()); + Assert::AreEqual("", pghs[0]["f1"].c_str()); + Assert::AreEqual("", pghs[0]["f2"].c_str()); + Assert::AreEqual(size_t(2), pghs[0].size()); + } + + TEST_METHOD(parse_paragraphs_multiline_fields) + { + const char* str = + "f1: simple\n" + " f1\r\n" + "f2:\r\n" + " f2\r\n" + " continue\r\n"; + auto pghs = vcpkg::parse_paragraphs(str); + Assert::AreEqual(size_t(1), pghs.size()); + Assert::AreEqual("simple\n f1", pghs[0]["f1"].c_str()); + Assert::AreEqual("\n f2\n continue", pghs[0]["f2"].c_str()); + } + + TEST_METHOD(parse_paragraphs_crlfs) + { + const char* str = + "f1: v1\r\n" + "f2: v2\r\n" + "\r\n" + "f3: v3\r\n" + "f4: v4"; + auto pghs = vcpkg::parse_paragraphs(str); + Assert::AreEqual(size_t(2), pghs.size()); + Assert::AreEqual(size_t(2), pghs[0].size()); + Assert::AreEqual("v1", pghs[0]["f1"].c_str()); + Assert::AreEqual("v2", pghs[0]["f2"].c_str()); + Assert::AreEqual(size_t(2), pghs[1].size()); + Assert::AreEqual("v3", pghs[1]["f3"].c_str()); + Assert::AreEqual("v4", pghs[1]["f4"].c_str()); + } + + TEST_METHOD(BinaryParagraph_serialize_min) + { + std::stringstream ss; + vcpkg::BinaryParagraph pgh({ + {"Package", "zlib"}, + {"Version", "1.2.8"}, + {"Architecture", "a"}, + {"Multi-Arch", "same"}, + }); + ss << pgh; + auto pghs = vcpkg::parse_paragraphs(ss.str()); + Assert::AreEqual(size_t(1), pghs.size()); + Assert::AreEqual(size_t(4), pghs[0].size()); + Assert::AreEqual("zlib", pghs[0]["Package"].c_str()); + Assert::AreEqual("1.2.8", pghs[0]["Version"].c_str()); + Assert::AreEqual("a", pghs[0]["Architecture"].c_str()); + Assert::AreEqual("same", pghs[0]["Multi-Arch"].c_str()); + } + + TEST_METHOD(BinaryParagraph_serialize_max) + { + std::stringstream ss; + vcpkg::BinaryParagraph pgh({ + {"Package", "zlib"}, + {"Version", "1.2.8"}, + {"Architecture", "a"}, + {"Description", "first line\n second line"}, + {"Maintainer", "abc "}, + {"Depends", "dep"}, + {"Multi-Arch", "same"}, + }); + ss << pgh; + auto pghs = vcpkg::parse_paragraphs(ss.str()); + Assert::AreEqual(size_t(1), pghs.size()); + Assert::AreEqual(size_t(7), pghs[0].size()); + Assert::AreEqual("zlib", pghs[0]["Package"].c_str()); + Assert::AreEqual("1.2.8", pghs[0]["Version"].c_str()); + Assert::AreEqual("a", pghs[0]["Architecture"].c_str()); + Assert::AreEqual("same", pghs[0]["Multi-Arch"].c_str()); + Assert::AreEqual("first line\n second line", pghs[0]["Description"].c_str()); + Assert::AreEqual("dep", pghs[0]["Depends"].c_str()); + } + + TEST_METHOD(BinaryParagraph_serialize_multiple_deps) + { + std::stringstream ss; + vcpkg::BinaryParagraph pgh({ + {"Package", "zlib"}, + {"Version", "1.2.8"}, + {"Architecture", "a"}, + {"Multi-Arch", "same"}, + {"Depends", "a, b, c"}, + }); + ss << pgh; + auto pghs = vcpkg::parse_paragraphs(ss.str()); + Assert::AreEqual(size_t(1), pghs.size()); + Assert::AreEqual("a, b, c", pghs[0]["Depends"].c_str()); + } + + TEST_METHOD(package_spec_parse) + { + vcpkg::expected spec = vcpkg::parse("zlib", vcpkg::triplet::X86_WINDOWS); + Assert::AreEqual(vcpkg::package_spec_parse_result::success, vcpkg::to_package_spec_parse_result(spec.error_code())); + Assert::AreEqual("zlib", spec.get()->name.c_str()); + Assert::AreEqual(vcpkg::triplet::X86_WINDOWS.value, spec.get()->target_triplet.value); + } + + TEST_METHOD(package_spec_parse_with_arch) + { + vcpkg::expected spec = vcpkg::parse("zlib:x64-uwp", vcpkg::triplet::X86_WINDOWS); + Assert::AreEqual(vcpkg::package_spec_parse_result::success, vcpkg::to_package_spec_parse_result(spec.error_code())); + Assert::AreEqual("zlib", spec.get()->name.c_str()); + Assert::AreEqual(vcpkg::triplet::X64_UWP.value, spec.get()->target_triplet.value); + } + + TEST_METHOD(package_spec_parse_with_multiple_colon) + { + auto ec = vcpkg::parse("zlib:x86-uwp:", vcpkg::triplet::X86_WINDOWS).error_code(); + Assert::AreEqual(vcpkg::package_spec_parse_result::too_many_colons, vcpkg::to_package_spec_parse_result(ec)); + } + + TEST_METHOD(utf8_to_utf16) + { + auto str = vcpkg::Strings::utf8_to_utf16("abc"); + Assert::AreEqual(L"abc", str.c_str()); + } + + TEST_METHOD(utf8_to_utf16_with_whitespace) + { + auto str = vcpkg::Strings::utf8_to_utf16("abc -x86-windows"); + Assert::AreEqual(L"abc -x86-windows", str.c_str()); + } + }; + + TEST_CLASS(Metrics) + { + }; +} diff --git a/toolsrc/src/triplet.cpp b/toolsrc/src/triplet.cpp new file mode 100644 index 00000000000000..9ad3d8847d6b36 --- /dev/null +++ b/toolsrc/src/triplet.cpp @@ -0,0 +1,59 @@ +#include "triplet.h" +#include "vcpkg_System.h" +#include "vcpkg_Checks.h" + +namespace vcpkg +{ + const triplet triplet::X86_WINDOWS = {"x86-windows"}; + const triplet triplet::X64_WINDOWS = {"x64-windows"}; + const triplet triplet::X86_UWP = {"x86-uwp"}; + const triplet triplet::X64_UWP = {"x64-uwp"}; + const triplet triplet::ARM_UWP = {"arm-uwp"}; + + std::string to_string(const triplet& t) + { + return t.value; + } + + std::string to_printf_arg(const triplet& t) + { + return to_string(t); + } + + bool operator==(const triplet& left, const triplet& right) + { + return left.value == right.value; + } + + bool operator!=(const triplet& left, const triplet& right) + { + return !(left == right); + } + + std::ostream& operator<<(std::ostream& os, const triplet& t) + { + return os << to_string(t); + } + + std::string triplet::architecture() const + { + if (*this == X86_WINDOWS || *this == X86_UWP) + return "x86"; + if (*this == X64_WINDOWS || *this == X64_UWP) + return "x64"; + if (*this == ARM_UWP) + return "arm"; + + Checks::exit_with_message("Unknown architecture: %s", value); + } + + std::string triplet::system() const + { + if (*this == X86_WINDOWS || *this == X64_WINDOWS) + return "windows"; + if (*this == X86_UWP || *this == X64_UWP || *this == ARM_UWP) + return "uwp"; + + Checks::exit_with_message("Unknown system: %s", value); + } +} diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp new file mode 100644 index 00000000000000..f705858cc2c37a --- /dev/null +++ b/toolsrc/src/vcpkg.cpp @@ -0,0 +1,178 @@ +#include "vcpkg.h" +#include +#include "vcpkg_Files.h" +#include "vcpkglib_helpers.h" + +namespace +{ + using namespace vcpkg; + + struct Parser + { + Parser(const char* c, const char* e) : cur(c), end(e) + { + } + + private: + const char* cur; + const char* const end; + + void peek(char& ch) const + { + if (cur == end) + ch = 0; + else + ch = *cur; + } + + void next(char& ch) + { + if (cur == end) + ch = 0; + else + { + ++cur; + peek(ch); + } + } + + void skip_spaces(char& ch) + { + while (ch == ' ' || ch == '\t') + next(ch); + } + + static bool is_alphanum(char ch) + { + return (ch >= 'A' && ch <= 'Z') + || (ch >= 'a' && ch <= 'z') + || (ch >= '0' && ch <= '9'); + } + + static bool is_lineend(char ch) + { + return ch == '\r' || ch == '\n' || ch == 0; + } + + void get_fieldvalue(char& ch, std::string& fieldvalue) + { + fieldvalue.clear(); + + auto beginning_of_line = cur; + do + { + // scan to end of current line (it is part of the field value) + while (!is_lineend(ch)) + next(ch); + + fieldvalue.append(beginning_of_line, cur); + + if (ch == '\r') + next(ch); + if (ch == '\n') + next(ch); + + if (is_alphanum(ch)) + { + // Line begins a new field. + return; + } + + beginning_of_line = cur; + + // Line may continue the current field with data or terminate the paragraph, + // depending on first nonspace character. + skip_spaces(ch); + + if (is_lineend(ch)) + { + // Line was whitespace or empty. + // This terminates the field and the paragraph. + // We leave the blank line's whitespace consumed, because it doesn't matter. + return; + } + + // First nonspace is not a newline. This continues the current field value. + // We forcibly convert all newlines into single '\n' for ease of text handling later on. + fieldvalue.push_back('\n'); + } + while (true); + } + + void get_fieldname(char& ch, std::string& fieldname) + { + auto begin_fieldname = cur; + while (is_alphanum(ch) || ch == '-') + next(ch); + Checks::check_throw(ch == ':', "Expected ':'"); + fieldname = std::string(begin_fieldname, cur); + + // skip ': ' + next(ch); + skip_spaces(ch); + } + + void get_paragraph(char& ch, std::unordered_map& fields) + { + fields.clear(); + std::string fieldname; + std::string fieldvalue; + do + { + get_fieldname(ch, fieldname); + + auto it = fields.find(fieldname); + Checks::check_throw(it == fields.end(), "Duplicate field"); + + get_fieldvalue(ch, fieldvalue); + + fields.emplace(fieldname, fieldvalue); + } + while (!is_lineend(ch)); + } + + public: + std::vector> get_paragraphs() + { + std::vector> paragraphs; + + char ch; + peek(ch); + + while (ch != 0) + { + if (ch == '\n' || ch == '\r' || ch == ' ' || ch == '\t') + { + next(ch); + continue; + } + + paragraphs.emplace_back(); + get_paragraph(ch, paragraphs.back()); + } + + return paragraphs; + } + }; +} + +namespace vcpkg +{ + std::string shorten_description(const std::string& desc) + { + auto simple_desc = std::regex_replace(desc.substr(0, 49), std::regex("\\n( |\\t)?"), ""); + if (desc.size() > 49) + simple_desc.append("..."); + return simple_desc; + } + + std::vector> get_paragraphs(const fs::path& control_path) + { + return parse_paragraphs(Files::get_contents(control_path).get_or_throw()); + } + + std::vector> parse_paragraphs(const std::string& str) + { + return Parser(str.c_str(), str.c_str() + str.size()).get_paragraphs(); + } +} diff --git a/toolsrc/src/vcpkg_Checks.cpp b/toolsrc/src/vcpkg_Checks.cpp new file mode 100644 index 00000000000000..d5433b1f5c3fb1 --- /dev/null +++ b/toolsrc/src/vcpkg_Checks.cpp @@ -0,0 +1,41 @@ +#include "vcpkg_Checks.h" + +#include +#include "vcpkg_System.h" + +namespace vcpkg {namespace Checks +{ + void unreachable() + { + System::println(System::color::error, "Error: Unreachable code was reached"); + exit(EXIT_FAILURE); + } + + void exit_with_message(const char* errorMessage) + { + System::println(System::color::error, errorMessage); + exit(EXIT_FAILURE); + } + + void throw_with_message(const char* errorMessage) + { + throw std::runtime_error(errorMessage); + } + + void check_throw(bool expression, const char* errorMessage) + { + if (!expression) + { + throw_with_message(errorMessage); + } + } + + void check_exit(bool expression, const char* errorMessage) + { + if (!expression) + { + System::println(System::color::error, errorMessage); + exit(EXIT_FAILURE); + } + } +}} diff --git a/toolsrc/src/vcpkg_Environment.cpp b/toolsrc/src/vcpkg_Environment.cpp new file mode 100644 index 00000000000000..f70f2b893a3cd3 --- /dev/null +++ b/toolsrc/src/vcpkg_Environment.cpp @@ -0,0 +1,87 @@ +#include +#include +#include "vcpkg_Environment.h" +#include "vcpkg_Commands.h" +#include "vcpkg.h" +#include "metrics.h" +#include "vcpkg_System.h" + +namespace vcpkg {namespace Environment +{ + static const fs::path default_cmake_installation_dir = "C:/Program Files/CMake/bin"; + static const fs::path default_cmake_installation_dir_x86 = "C:/Program Files (x86)/CMake/bin"; + static const fs::path default_git_installation_dir = "C:/Program Files/git/cmd"; + static const fs::path default_git_installation_dir_x86 = "C:/Program Files (x86)/git/cmd"; + + static void ensure_on_path(const std::array& version, const wchar_t* version_check_cmd, const wchar_t* install_cmd) + { + System::exit_code_and_output ec_data = System::cmd_execute_and_capture_output(version_check_cmd); + if (ec_data.exit_code == 0) + { + // version check + std::regex re(R"###((\d+)\.(\d+)\.(\d+))###"); + std::match_results match; + auto found = std::regex_search(ec_data.output, match, re); + if (found) + { + int d1 = atoi(match[1].str().c_str()); + int d2 = atoi(match[2].str().c_str()); + int d3 = atoi(match[3].str().c_str()); + if (d1 > version[0] || (d1 == version[0] && d2 > version[1]) || (d1 == version[0] && d2 == version[1] && d3 >= version[2])) + { + // satisfactory version found + return; + } + } + } + + auto rc = System::cmd_execute(install_cmd); + if (rc) + { + System::println(System::color::error, "Launching powershell failed or was denied"); + TrackProperty("error", "powershell install failed"); + TrackProperty("installcmd", install_cmd); + exit(rc); + } + } + + void ensure_git_on_path(const vcpkg_paths& paths) + { + const fs::path downloaded_git = paths.downloads / "PortableGit" / "cmd"; + const std::wstring path_buf = Strings::format(L"%s;%s;%s;%s", + downloaded_git.native(), + System::wdupenv_str(L"PATH"), + default_git_installation_dir.native(), + default_git_installation_dir_x86.native()); + _wputenv_s(L"PATH", path_buf.c_str()); + + static constexpr std::array git_version = {2,0,0}; + // TODO: switch out ExecutionPolicy Bypass with "Remove Mark Of The Web" code and restore RemoteSigned + ensure_on_path(git_version, L"git --version 2>&1", L"powershell -ExecutionPolicy Bypass scripts\\fetchDependency.ps1 -Dependency git"); + } + + void ensure_cmake_on_path(const vcpkg_paths& paths) + { + const fs::path downloaded_cmake = paths.downloads / "cmake-3.5.2-win32-x86" / "bin"; + const std::wstring path_buf = Strings::format(L"%s;%s;%s;%s", + downloaded_cmake.native(), + System::wdupenv_str(L"PATH"), + default_cmake_installation_dir.native(), + default_cmake_installation_dir_x86.native()); + _wputenv_s(L"PATH", path_buf.c_str()); + + static constexpr std::array cmake_version = {3,5,0}; + // TODO: switch out ExecutionPolicy Bypass with "Remove Mark Of The Web" code and restore RemoteSigned + ensure_on_path(cmake_version, L"cmake --version 2>&1", L"powershell -ExecutionPolicy Bypass scripts\\fetchDependency.ps1 -Dependency cmake"); + } + + void ensure_nuget_on_path(const vcpkg_paths& paths) + { + const std::wstring path_buf = Strings::format(L"%s;%s", paths.downloads.native(), System::wdupenv_str(L"PATH")); + _wputenv_s(L"PATH", path_buf.c_str()); + + static constexpr std::array nuget_version = {1,0,0}; + // TODO: switch out ExecutionPolicy Bypass with "Remove Mark Of The Web" code and restore RemoteSigned + ensure_on_path(nuget_version, L"nuget 2>&1", L"powershell -ExecutionPolicy Bypass scripts\\fetchDependency.ps1 -Dependency nuget"); + } +}} diff --git a/toolsrc/src/vcpkg_Files.cpp b/toolsrc/src/vcpkg_Files.cpp new file mode 100644 index 00000000000000..49a6611578a6dc --- /dev/null +++ b/toolsrc/src/vcpkg_Files.cpp @@ -0,0 +1,38 @@ +#include "vcpkg_Files.h" +#include +#include + +namespace fs = std::tr2::sys; + +namespace vcpkg {namespace Files +{ + void check_is_directory(const fs::path& dirpath) + { + Checks::check_throw(fs::is_directory(dirpath), "The path %s is not a directory", dirpath.string()); + } + + expected get_contents(const fs::path& file_path) noexcept + { + std::fstream file_stream(file_path, std::ios_base::in | std::ios_base::binary); + if (file_stream.fail()) + { + return std::errc::no_such_file_or_directory; + } + + file_stream.seekg(0, file_stream.end); + auto length = file_stream.tellg(); + file_stream.seekg(0, file_stream.beg); + + if (length > SIZE_MAX) + { + return std::errc::file_too_large; + } + + std::string output; + output.resize(static_cast(length)); + file_stream.read(&output[0], length); + file_stream.close(); + + return std::move(output); + } +}} diff --git a/toolsrc/src/vcpkg_Strings.cpp b/toolsrc/src/vcpkg_Strings.cpp new file mode 100644 index 00000000000000..b0312536a2711f --- /dev/null +++ b/toolsrc/src/vcpkg_Strings.cpp @@ -0,0 +1,60 @@ +#include "vcpkg_Strings.h" + +#include +#include +#include +#include + +namespace vcpkg {namespace Strings {namespace details +{ + std::string format_internal(const char* fmtstr, ...) + { + va_list lst; + va_start(lst, fmtstr); + + auto sz = _vscprintf(fmtstr, lst); + std::string output(sz, '\0'); + _vsnprintf_s(&output[0], output.size() + 1, output.size() + 1, fmtstr, lst); + va_end(lst); + + return output; + } + + std::wstring format_internal(const wchar_t* fmtstr, ...) + { + va_list lst; + va_start(lst, fmtstr); + + auto sz = _vscwprintf(fmtstr, lst); + std::wstring output(sz, '\0'); + _vsnwprintf_s(&output[0], output.size() + 1, output.size() + 1, fmtstr, lst); + va_end(lst); + + return output; + } +}}} + +namespace vcpkg {namespace Strings +{ + std::wstring utf8_to_utf16(const std::string& s) + { + std::wstring_convert, wchar_t> conversion; + return conversion.from_bytes(s); + } + + std::string utf16_to_utf8(const std::wstring& w) + { + std::wstring_convert, wchar_t> conversion; + return conversion.to_bytes(w); + } + + std::string::const_iterator case_insensitive_find(const std::string& s, const std::string& pattern) + { + std::string patter_as_lower_case; + std::transform(pattern.begin(), pattern.end(), back_inserter(patter_as_lower_case), tolower); + return search(s.begin(), s.end(), patter_as_lower_case.begin(), patter_as_lower_case.end(), [](const char a, const char b) + { + return (tolower(a) == b); + }); + } +}} diff --git a/toolsrc/src/vcpkg_System.cpp b/toolsrc/src/vcpkg_System.cpp new file mode 100644 index 00000000000000..71b4087d21aade --- /dev/null +++ b/toolsrc/src/vcpkg_System.cpp @@ -0,0 +1,111 @@ +#include "vcpkg_System.h" +#include +#include +#include + +namespace fs = std::tr2::sys; + +namespace vcpkg {namespace System +{ + fs::path get_exe_path_of_current_process() + { + wchar_t buf[_MAX_PATH ]; + int bytes = GetModuleFileNameW(nullptr, buf, _MAX_PATH); + if (bytes == 0) + std::abort(); + return fs::path(buf, buf + bytes); + } + + int cmd_execute(const wchar_t* cmd_line) + { + // Basically we are wrapping it in quotes + const std::wstring& actual_cmd_line = Strings::format(LR"###("%s")###", cmd_line); + int exit_code = _wsystem(actual_cmd_line.c_str()); + return exit_code; + } + + exit_code_and_output cmd_execute_and_capture_output(const wchar_t* cmd_line) + { + const std::wstring& actual_cmd_line = Strings::format(LR"###("%s")###", cmd_line); + + std::string output; + char buf[1024]; + auto pipe = _wpopen(actual_cmd_line.c_str(), L"r"); + if (pipe == nullptr) + { + return {1, output}; + } + while (fgets(buf, 1024, pipe)) + { + output.append(buf); + } + if (!feof(pipe)) + { + return {1, output}; + } + auto ec = _pclose(pipe); + return {ec, output}; + } + + void print(const char* message) + { + std::cout << message; + } + + void println(const char* message) + { + print(message); + std::cout << "\n"; + } + + void print(color c, const char* message) + { + HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + + CONSOLE_SCREEN_BUFFER_INFO consoleScreenBufferInfo{}; + GetConsoleScreenBufferInfo(hConsole, &consoleScreenBufferInfo); + auto original_color = consoleScreenBufferInfo.wAttributes; + + SetConsoleTextAttribute(hConsole, static_cast(c) | (original_color & 0xF0)); + std::cout << message; + SetConsoleTextAttribute(hConsole, original_color); + } + + void println(color c, const char* message) + { + print(c, message); + std::cout << "\n"; + } + + std::wstring wdupenv_str(const wchar_t* varname) noexcept + { + std::wstring ret; + wchar_t* buffer; + _wdupenv_s(&buffer, nullptr, varname); + if (buffer != nullptr) + { + ret = buffer; + free(buffer); + } + return ret; + } + + void Stopwatch::start() + { + static_assert(sizeof(start_time) == sizeof(LARGE_INTEGER), ""); + + QueryPerformanceCounter(reinterpret_cast(&start_time)); + } + + void Stopwatch::stop() + { + QueryPerformanceCounter(reinterpret_cast(&end_time)); + QueryPerformanceFrequency(reinterpret_cast(&freq)); + } + + double Stopwatch::microseconds() const + { + return (reinterpret_cast(&end_time)->QuadPart - + reinterpret_cast(&start_time)->QuadPart) * 1000000.0 / reinterpret_cast(&freq)->QuadPart; + } +}} diff --git a/toolsrc/src/vcpkg_cmd_arguments.cpp b/toolsrc/src/vcpkg_cmd_arguments.cpp new file mode 100644 index 00000000000000..4cfc127167db5f --- /dev/null +++ b/toolsrc/src/vcpkg_cmd_arguments.cpp @@ -0,0 +1,255 @@ +#define WIN32_LEAN_AND_MEAN +#include +#include "vcpkg_cmd_arguments.h" +#include "vcpkg_Commands.h" +#include "vcpkg_Graphs.h" +#include +#include "metrics.h" +#include "vcpkg.h" +#include "vcpkg_System.h" + +namespace vcpkg +{ + static void parse_value( + const std::string* arg_begin, + const std::string* arg_end, + const std::string& option_name, + std::unique_ptr& option_field) + { + if (arg_begin == arg_end) + { + System::println(System::color::error, "Error: expected value after %s", option_name); + TrackProperty("error", "error option name"); + print_usage(); + exit(EXIT_FAILURE); + } + + if (option_field != nullptr) + { + System::println(System::color::error, "Error: %s specified multiple times", option_name); + TrackProperty("error", "error option specified multiple times"); + print_usage(); + exit(EXIT_FAILURE); + } + + option_field = std::make_unique(*arg_begin); + } + + static void parse_switch( + opt_bool new_setting, + const std::string& option_name, + opt_bool& option_field) + { + if (option_field != opt_bool::unspecified && option_field != new_setting) + { + System::println(System::color::error, "Error: conflicting values specified for --%s", option_name); + TrackProperty("error", "error conflicting switches"); + print_usage(); + exit(EXIT_FAILURE); + } + option_field = new_setting; + } + + vcpkg_cmd_arguments vcpkg_cmd_arguments::create_from_command_line(const int argc, const wchar_t* const* const argv) + { + std::vector v; + for (int i = 1; i < argc; ++i) + { + v.push_back(Strings::utf16_to_utf8(argv[i])); + } + + return vcpkg_cmd_arguments::create_from_arg_sequence(v.data(), v.data() + v.size()); + } + + vcpkg_cmd_arguments vcpkg_cmd_arguments::create_from_arg_sequence(const std::string* arg_begin, const std::string* arg_end) + { + vcpkg_cmd_arguments args; + + for (; arg_begin != arg_end; ++arg_begin) + { + std::string arg = *arg_begin; + + if (arg.empty()) + { + continue; + } + + if (arg[0] == '-' && arg[1] != '-') + { + System::println(System::color::error, "Error: short options are not supported: %s", arg); + TrackProperty("error", "error short options are not supported"); + exit(EXIT_FAILURE); + } + + if (arg[0] == '-' && arg[1] == '-') + { + // command switch + if (arg == "--vcpkg-root") + { + ++arg_begin; + parse_value(arg_begin, arg_end, "--vcpkg-root", args.vcpkg_root_dir); + continue; + } + if (arg == "--triplet") + { + ++arg_begin; + parse_value(arg_begin, arg_end, "--triplet", args.target_triplet); + continue; + } + if (arg == "--debug") + { + parse_switch(opt_bool::enabled, "debug", args.debug); + continue; + } + if (arg == "--sendmetrics") + { + parse_switch(opt_bool::enabled, "sendmetrics", args.sendmetrics); + continue; + } + if (arg == "--printmetrics") + { + parse_switch(opt_bool::enabled, "printmetrics", args.printmetrics); + continue; + } + if (arg == "--no-sendmetrics") + { + parse_switch(opt_bool::disabled, "sendmetrics", args.sendmetrics); + continue; + } + if (arg == "--no-printmetrics") + { + parse_switch(opt_bool::disabled, "printmetrics", args.printmetrics); + continue; + } + + args.optional_command_arguments.insert(arg); + continue; + } + + if (args.command.empty()) + { + args.command = arg; + } + else + { + args.command_arguments.push_back(arg); + } + } + + return args; + } + + std::unordered_set vcpkg_cmd_arguments::check_and_get_optional_command_arguments(const std::vector& valid_options) const + { + std::unordered_set output; + auto options_copy = this->optional_command_arguments; + for (const std::string& option : valid_options) + { + auto it = options_copy.find(option); + if (it != options_copy.end()) + { + output.insert(option); + options_copy.erase(it); + } + } + + if (!options_copy.empty()) + { + System::println(System::color::error, "Unknown option(s) for command '%s':", this->command); + for (const std::string& option : options_copy) + { + System::println(option.c_str()); + } + exit(EXIT_FAILURE); + } + + return output; + } + + void vcpkg_cmd_arguments::check_max_args(size_t arg_count, const char* example_text) const + { + if (command_arguments.size() > arg_count) + { + System::println(System::color::error, "Error: too many arguments to command %s", command); + if (example_text != nullptr) + print_example(example_text); + else + print_usage(); + exit(EXIT_FAILURE); + } + } + + std::vector vcpkg_cmd_arguments::extract_package_specs_with_unmet_dependencies(const vcpkg_paths& paths, const triplet& default_target_triplet, const StatusParagraphs& status_db) const + { + std::vector specs = parse_all_arguments_as_package_specs(default_target_triplet); + std::unordered_set had_its_immediate_dependencies_added; + Graphs::Graph graph; + graph.add_vertices(specs); + + while (!specs.empty()) + { + package_spec spec = specs.back(); + specs.pop_back(); + + if (had_its_immediate_dependencies_added.find(spec) != had_its_immediate_dependencies_added.end()) + { + continue; + } + + std::vector dependencies_as_string = get_unmet_package_dependencies(paths, spec, status_db); + + for (const std::string& dep_as_string : dependencies_as_string) + { + package_spec current_dep = {dep_as_string, spec.target_triplet}; + auto it = status_db.find(current_dep.name, current_dep.target_triplet); + if (it != status_db.end() && (*it)->want == want_t::install) + { + continue; + } + + graph.add_edge(spec, current_dep); + if (had_its_immediate_dependencies_added.find(current_dep) == had_its_immediate_dependencies_added.end()) + { + specs.push_back(std::move(current_dep)); + } + } + + had_its_immediate_dependencies_added.insert(spec); + } + + return graph.find_topological_sort(); + } + + std::vector vcpkg_cmd_arguments::parse_all_arguments_as_package_specs(const triplet& default_target_triplet, const char* example_text) const + { + size_t arg_count = command_arguments.size(); + if (arg_count < 1) + { + System::println(System::color::error, "Error: %s requires one or more package specifiers", this->command); + if (example_text == nullptr) + print_example(Strings::format("%s zlib zlib:x64-windows curl boost", this->command).c_str()); + else + print_example(example_text); + exit(EXIT_FAILURE); + } + std::vector specs; + specs.reserve(arg_count); + + for (const std::string& command_argument : command_arguments) + { + expected current_spec = vcpkg::parse(command_argument, default_target_triplet); + if (auto spec = current_spec.get()) + { + specs.push_back(std::move(*spec)); + } + else + { + System::println(System::color::error, "Error: %s: %s", current_spec.error_code().message(), command_argument); + print_example(Strings::format("%s zlib:x64-windows", this->command).c_str()); + exit(EXIT_FAILURE); + } + } + + return specs; + } +} diff --git a/toolsrc/src/vcpkg_metrics_uploader.cpp b/toolsrc/src/vcpkg_metrics_uploader.cpp new file mode 100644 index 00000000000000..f1f4a52ed13b32 --- /dev/null +++ b/toolsrc/src/vcpkg_metrics_uploader.cpp @@ -0,0 +1,25 @@ +#include "metrics.h" +#include +#include "vcpkg_Checks.h" +#include "vcpkg_Files.h" +#include + +namespace fs = std::tr2::sys; +using namespace vcpkg; + +int WINAPI +WinMain( + _In_ HINSTANCE hInstance, + _In_opt_ HINSTANCE hPrevInstance, + _In_ LPSTR lpCmdLine, + _In_ int nShowCmd +) +{ + LPWSTR* szArgList; + int argCount; + + szArgList = CommandLineToArgvW(GetCommandLineW(), &argCount); + + Checks::check_exit(argCount == 2, "Requires exactly one argument, the path to the payload file"); + Upload(Files::get_contents(szArgList[1]).get_or_throw()); +} diff --git a/toolsrc/src/vcpkg_paths.cpp b/toolsrc/src/vcpkg_paths.cpp new file mode 100644 index 00000000000000..10b6d992af6d93 --- /dev/null +++ b/toolsrc/src/vcpkg_paths.cpp @@ -0,0 +1,48 @@ +#include +#include "expected.h" +#include "vcpkg_paths.h" +#include "metrics.h" +#include "vcpkg_System.h" + +namespace fs = std::tr2::sys; + +namespace vcpkg +{ + expected vcpkg_paths::create(const fs::path& vcpkg_root_dir) + { + std::error_code ec; + const fs::path canonical_vcpkg_root_dir = fs::canonical(vcpkg_root_dir, ec); + if (ec) + { + return ec; + } + + vcpkg_paths paths; + paths.root = canonical_vcpkg_root_dir; + + if (paths.root.empty()) + { + System::println(System::color::error, "Invalid vcpkg root directory: %s", paths.root.string()); + TrackProperty("error", "Invalid vcpkg root directory"); + exit(EXIT_FAILURE); + } + + paths.packages = paths.root / "packages"; + paths.buildtrees = paths.root / "buildtrees"; + paths.downloads = paths.root / "downloads"; + paths.ports = paths.root / "ports"; + paths.installed = paths.root / "installed"; + paths.triplets = paths.root / "triplets"; + + paths.buildsystems = paths.root / "scripts" / "buildsystems"; + paths.buildsystems_msbuild_targets = paths.buildsystems / "msbuild" / "vcpkg.targets"; + + paths.vcpkg_dir = paths.installed / "vcpkg"; + paths.vcpkg_dir_status_file = paths.vcpkg_dir / "status"; + paths.vcpkg_dir_info = paths.vcpkg_dir / "info"; + paths.vcpkg_dir_updates = paths.vcpkg_dir / "updates"; + + paths.ports_cmake = paths.root / "scripts" / "ports.cmake"; + return paths; + } +} diff --git a/toolsrc/src/vcpkg_version.cpp b/toolsrc/src/vcpkg_version.cpp new file mode 100644 index 00000000000000..da52b7cab1cfa1 --- /dev/null +++ b/toolsrc/src/vcpkg_version.cpp @@ -0,0 +1,25 @@ +#include "vcpkg.h" +#include "metrics.h" + +#define STRINGIFY(X) #X +#define MACRO_TO_STRING(X) STRINGIFY(X) + +#define VCPKG_VERSION_AS_STRING MACRO_TO_STRING(VCPKG_VERSION)"" // Double quotes needed at the end to prevent blank token + +const std::string& vcpkg::version() +{ + static const std::string s_version = +#include "../VERSION.txt" + + +#pragma warning( push ) +#pragma warning( disable : 4003) + // VCPKG_VERSION can be defined but have no value, which yields C4003. + + std::string(VCPKG_VERSION_AS_STRING) +#pragma warning( pop ) +#ifndef NDEBUG + + std::string("-debug") +#endif + + std::string(GetCompiledMetricsEnabled() ? "" : "-external"); + return s_version; +} diff --git a/toolsrc/src/vcpkglib_helpers.cpp b/toolsrc/src/vcpkglib_helpers.cpp new file mode 100644 index 00000000000000..e947dc647502ec --- /dev/null +++ b/toolsrc/src/vcpkglib_helpers.cpp @@ -0,0 +1,50 @@ +#include "vcpkg_Checks.h" +#include "vcpkglib_helpers.h" +#include + +namespace vcpkg {namespace details +{ + void optional_field(const std::unordered_map& fields, std::string& out, const std::string& fieldname) + { + auto it = fields.find(fieldname); + if (it == fields.end()) + { + out.clear(); + } + + else + { + out = it->second; + } + }; + + void required_field(const std::unordered_map& fields, std::string& out, const std::string& fieldname) + { + auto it = fields.find(fieldname); + vcpkg::Checks::check_throw(it != fields.end(), "Required field not present: %s", fieldname); + out = it->second; + }; + + void parse_depends(const std::string& depends_string, std::vector& out) + { + size_t cur = 0; + do + { + auto pos = depends_string.find(',', cur); + if (pos == std::string::npos) + { + out.push_back(depends_string.substr(cur)); + return; + } + out.push_back(depends_string.substr(cur, pos - cur)); + + // skip comma and space + ++pos; + if (depends_string[pos] == ' ') + ++pos; + + cur = pos; + } + while (cur != std::string::npos); + } +}} diff --git a/toolsrc/vcpkg.sln b/toolsrc/vcpkg.sln new file mode 100644 index 00000000000000..83051670a7fbd5 --- /dev/null +++ b/toolsrc/vcpkg.sln @@ -0,0 +1,78 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcpkg", "vcpkg\vcpkg.vcxproj", "{34671B80-54F9-46F5-8310-AC429C11D4FB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcpkgcommon", "vcpkgcommon\vcpkgcommon.vcxproj", "{7129F242-F20C-43E7-BBEC-4E15B71890B2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcpkglib", "vcpkglib\vcpkglib.vcxproj", "{B98C92B7-2874-4537-9D46-D14E5C237F04}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcpkgmetrics", "vcpkgmetrics\vcpkgmetrics.vcxproj", "{7226078C-1D2A-4123-9EF1-8DF2B722B8F1}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcpkgmetricsuploader", "vcpkgmetricsuploader\vcpkgmetricsuploader.vcxproj", "{7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vcpkgtest", "vcpkgtest\vcpkgtest.vcxproj", "{F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {34671B80-54F9-46F5-8310-AC429C11D4FB}.Debug|x64.ActiveCfg = Debug|x64 + {34671B80-54F9-46F5-8310-AC429C11D4FB}.Debug|x64.Build.0 = Debug|x64 + {34671B80-54F9-46F5-8310-AC429C11D4FB}.Debug|x86.ActiveCfg = Debug|Win32 + {34671B80-54F9-46F5-8310-AC429C11D4FB}.Debug|x86.Build.0 = Debug|Win32 + {34671B80-54F9-46F5-8310-AC429C11D4FB}.Release|x64.ActiveCfg = Release|x64 + {34671B80-54F9-46F5-8310-AC429C11D4FB}.Release|x64.Build.0 = Release|x64 + {34671B80-54F9-46F5-8310-AC429C11D4FB}.Release|x86.ActiveCfg = Release|Win32 + {34671B80-54F9-46F5-8310-AC429C11D4FB}.Release|x86.Build.0 = Release|Win32 + {7129F242-F20C-43E7-BBEC-4E15B71890B2}.Debug|x64.ActiveCfg = Debug|x64 + {7129F242-F20C-43E7-BBEC-4E15B71890B2}.Debug|x64.Build.0 = Debug|x64 + {7129F242-F20C-43E7-BBEC-4E15B71890B2}.Debug|x86.ActiveCfg = Debug|Win32 + {7129F242-F20C-43E7-BBEC-4E15B71890B2}.Debug|x86.Build.0 = Debug|Win32 + {7129F242-F20C-43E7-BBEC-4E15B71890B2}.Release|x64.ActiveCfg = Release|x64 + {7129F242-F20C-43E7-BBEC-4E15B71890B2}.Release|x64.Build.0 = Release|x64 + {7129F242-F20C-43E7-BBEC-4E15B71890B2}.Release|x86.ActiveCfg = Release|Win32 + {7129F242-F20C-43E7-BBEC-4E15B71890B2}.Release|x86.Build.0 = Release|Win32 + {B98C92B7-2874-4537-9D46-D14E5C237F04}.Debug|x64.ActiveCfg = Debug|x64 + {B98C92B7-2874-4537-9D46-D14E5C237F04}.Debug|x64.Build.0 = Debug|x64 + {B98C92B7-2874-4537-9D46-D14E5C237F04}.Debug|x86.ActiveCfg = Debug|Win32 + {B98C92B7-2874-4537-9D46-D14E5C237F04}.Debug|x86.Build.0 = Debug|Win32 + {B98C92B7-2874-4537-9D46-D14E5C237F04}.Release|x64.ActiveCfg = Release|x64 + {B98C92B7-2874-4537-9D46-D14E5C237F04}.Release|x64.Build.0 = Release|x64 + {B98C92B7-2874-4537-9D46-D14E5C237F04}.Release|x86.ActiveCfg = Release|Win32 + {B98C92B7-2874-4537-9D46-D14E5C237F04}.Release|x86.Build.0 = Release|Win32 + {7226078C-1D2A-4123-9EF1-8DF2B722B8F1}.Debug|x64.ActiveCfg = Debug|x64 + {7226078C-1D2A-4123-9EF1-8DF2B722B8F1}.Debug|x64.Build.0 = Debug|x64 + {7226078C-1D2A-4123-9EF1-8DF2B722B8F1}.Debug|x86.ActiveCfg = Debug|Win32 + {7226078C-1D2A-4123-9EF1-8DF2B722B8F1}.Debug|x86.Build.0 = Debug|Win32 + {7226078C-1D2A-4123-9EF1-8DF2B722B8F1}.Release|x64.ActiveCfg = Release|x64 + {7226078C-1D2A-4123-9EF1-8DF2B722B8F1}.Release|x64.Build.0 = Release|x64 + {7226078C-1D2A-4123-9EF1-8DF2B722B8F1}.Release|x86.ActiveCfg = Release|Win32 + {7226078C-1D2A-4123-9EF1-8DF2B722B8F1}.Release|x86.Build.0 = Release|Win32 + {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Debug|x64.ActiveCfg = Debug|x64 + {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Debug|x64.Build.0 = Debug|x64 + {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Debug|x86.ActiveCfg = Debug|Win32 + {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Debug|x86.Build.0 = Debug|Win32 + {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Release|x64.ActiveCfg = Release|x64 + {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Release|x64.Build.0 = Release|x64 + {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Release|x86.ActiveCfg = Release|Win32 + {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE}.Release|x86.Build.0 = Release|Win32 + {F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D}.Debug|x64.ActiveCfg = Debug|x64 + {F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D}.Debug|x64.Build.0 = Debug|x64 + {F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D}.Debug|x86.ActiveCfg = Debug|Win32 + {F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D}.Debug|x86.Build.0 = Debug|Win32 + {F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D}.Release|x64.ActiveCfg = Release|x64 + {F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D}.Release|x64.Build.0 = Release|x64 + {F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D}.Release|x86.ActiveCfg = Release|Win32 + {F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/toolsrc/vcpkg/vcpkg.vcxproj b/toolsrc/vcpkg/vcpkg.vcxproj new file mode 100644 index 00000000000000..15f5064d4a3ff0 --- /dev/null +++ b/toolsrc/vcpkg/vcpkg.vcxproj @@ -0,0 +1,161 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {34671B80-54F9-46F5-8310-AC429C11D4FB} + vcpkg + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level4 + Disabled + true + ..\include + /std:c++latest %(AdditionalOptions) + + + winhttp.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level4 + Disabled + true + ..\include + /std:c++latest %(AdditionalOptions) + + + winhttp.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + ..\include + _MBCS;NDEBUG;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + true + true + winhttp.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + ..\include + _MBCS;NDEBUG;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + true + true + winhttp.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + + + + + + + + + + + + + + + {7129f242-f20c-43e7-bbec-4e15b71890b2} + + + {b98c92b7-2874-4537-9d46-d14e5c237f04} + + + {7226078c-1d2a-4123-9ef1-8df2b722b8f1} + + + + + + \ No newline at end of file diff --git a/toolsrc/vcpkg/vcpkg.vcxproj.filters b/toolsrc/vcpkg/vcpkg.vcxproj.filters new file mode 100644 index 00000000000000..3ae3bf3a9f2999 --- /dev/null +++ b/toolsrc/vcpkg/vcpkg.vcxproj.filters @@ -0,0 +1,60 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj new file mode 100644 index 00000000000000..95cfd5764dc959 --- /dev/null +++ b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj @@ -0,0 +1,140 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {7129F242-F20C-43E7-BBEC-4E15B71890B2} + vcpkgcommon + 8.1 + + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + ..\include + /std:c++latest %(AdditionalOptions) + + + + + Level3 + Disabled + true + ..\include + /std:c++latest %(AdditionalOptions) + + + + + Level3 + MaxSpeed + true + true + true + ..\include + _MBCS;NDEBUG;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + ..\include + _MBCS;NDEBUG;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + true + true + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters new file mode 100644 index 00000000000000..a7e98c8537370d --- /dev/null +++ b/toolsrc/vcpkgcommon/vcpkgcommon.vcxproj.filters @@ -0,0 +1,54 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj b/toolsrc/vcpkglib/vcpkglib.vcxproj new file mode 100644 index 00000000000000..99e16e431a859c --- /dev/null +++ b/toolsrc/vcpkglib/vcpkglib.vcxproj @@ -0,0 +1,153 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {B98C92B7-2874-4537-9D46-D14E5C237F04} + vcpkglib + 8.1 + + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + ..\include + VCPKG_VERSION=$(VCPKG_VERSION);_MBCS;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + + + Level3 + Disabled + true + ..\include + VCPKG_VERSION=$(VCPKG_VERSION);_MBCS;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + + + Level3 + MaxSpeed + true + true + true + ..\include + VCPKG_VERSION=$(VCPKG_VERSION);_MBCS;NDEBUG;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + ..\include + VCPKG_VERSION=$(VCPKG_VERSION);_MBCS;NDEBUG;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters new file mode 100644 index 00000000000000..eec73a4459fda1 --- /dev/null +++ b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters @@ -0,0 +1,87 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/toolsrc/vcpkgmetrics/vcpkgmetrics.vcxproj b/toolsrc/vcpkgmetrics/vcpkgmetrics.vcxproj new file mode 100644 index 00000000000000..7b7fe89edd8ebd --- /dev/null +++ b/toolsrc/vcpkgmetrics/vcpkgmetrics.vcxproj @@ -0,0 +1,140 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {7226078C-1D2A-4123-9EF1-8DF2B722B8F1} + vcpkgmetrics + 8.1 + + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + StaticLibrary + true + v140 + MultiByte + + + StaticLibrary + false + v140 + true + MultiByte + + + 0 + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + ..\include + + + + + Level3 + Disabled + true + ..\include + + + + + Level3 + MaxSpeed + true + true + true + ..\include + DISABLE_METRICS=$(DISABLE_METRICS);_MBCS;NDEBUG;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + true + true + + + + + Level3 + MaxSpeed + true + true + true + ..\include + DISABLE_METRICS=$(DISABLE_METRICS);_MBCS;NDEBUG;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + true + true + + + + + DISABLE_METRICS=$(DISABLE_METRICS);_MBCS;%(PreprocessorDefinitions) + DISABLE_METRICS=$(DISABLE_METRICS);_MBCS;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + /std:c++latest %(AdditionalOptions) + + + + + + + + + + + + \ No newline at end of file diff --git a/toolsrc/vcpkgmetrics/vcpkgmetrics.vcxproj.filters b/toolsrc/vcpkgmetrics/vcpkgmetrics.vcxproj.filters new file mode 100644 index 00000000000000..7116a42474ed7c --- /dev/null +++ b/toolsrc/vcpkgmetrics/vcpkgmetrics.vcxproj.filters @@ -0,0 +1,27 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + + + Source Files + + + \ No newline at end of file diff --git a/toolsrc/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj b/toolsrc/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj new file mode 100644 index 00000000000000..1e2a8508777992 --- /dev/null +++ b/toolsrc/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj @@ -0,0 +1,144 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {7D6FDEEB-B299-4A23-85EE-F67C4DED47BE} + vcpkgmetricsuploader + 8.1 + + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + Application + true + v140 + MultiByte + + + Application + false + v140 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + ..\include + /std:c++latest %(AdditionalOptions) + + + winhttp.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + Disabled + true + ..\include + /std:c++latest %(AdditionalOptions) + + + winhttp.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + ..\include + _MBCS;NDEBUG;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + true + true + winhttp.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + Level3 + MaxSpeed + true + true + true + ..\include + _MBCS;NDEBUG;%(PreprocessorDefinitions) + /std:c++latest %(AdditionalOptions) + + + true + true + winhttp.lib;version.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) + + + + + + + + {7129f242-f20c-43e7-bbec-4e15b71890b2} + + + {7226078c-1d2a-4123-9ef1-8df2b722b8f1} + + + + + + \ No newline at end of file diff --git a/toolsrc/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj.filters b/toolsrc/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj.filters new file mode 100644 index 00000000000000..a50df725019895 --- /dev/null +++ b/toolsrc/vcpkgmetricsuploader/vcpkgmetricsuploader.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/toolsrc/vcpkgtest/vcpkgtest.vcxproj b/toolsrc/vcpkgtest/vcpkgtest.vcxproj new file mode 100644 index 00000000000000..3d95033748dbc9 --- /dev/null +++ b/toolsrc/vcpkgtest/vcpkgtest.vcxproj @@ -0,0 +1,173 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + + {7129f242-f20c-43e7-bbec-4e15b71890b2} + + + {b98c92b7-2874-4537-9d46-d14e5c237f04} + + + {7226078c-1d2a-4123-9ef1-8df2b722b8f1} + + + + {F27B8DB0-1279-4AF8-A2E3-1D49C4F0220D} + Win32Proj + vcpkgtest + 8.1 + + + + DynamicLibrary + true + v140 + Unicode + false + + + DynamicLibrary + false + v140 + true + Unicode + false + + + DynamicLibrary + true + v140 + Unicode + false + + + DynamicLibrary + false + v140 + true + Unicode + false + + + + + + + + + + + + + + + + + + + + + true + + + true + + + + + + NotUsing + Level3 + Disabled + ..\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;%(PreprocessorDefinitions) + true + + /std:c++latest %(AdditionalOptions) + + + Windows + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + NotUsing + Level3 + Disabled + ..\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + _DEBUG;%(PreprocessorDefinitions) + true + + /std:c++latest %(AdditionalOptions) + + + Windows + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + Level3 + NotUsing + MaxSpeed + true + true + ..\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;%(PreprocessorDefinitions) + true + + /std:c++latest %(AdditionalOptions) + + + Windows + true + true + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + Level3 + NotUsing + MaxSpeed + true + true + ..\include;$(VCInstallDir)UnitTest\include;%(AdditionalIncludeDirectories) + NDEBUG;%(PreprocessorDefinitions) + true + + /std:c++latest %(AdditionalOptions) + + + Windows + true + true + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories) + + + + + + \ No newline at end of file diff --git a/toolsrc/vcpkgtest/vcpkgtest.vcxproj.filters b/toolsrc/vcpkgtest/vcpkgtest.vcxproj.filters new file mode 100644 index 00000000000000..9db7e6ef8645cc --- /dev/null +++ b/toolsrc/vcpkgtest/vcpkgtest.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + \ No newline at end of file diff --git a/triplets/arm-uwp.cmake b/triplets/arm-uwp.cmake new file mode 100644 index 00000000000000..bf88711de49365 --- /dev/null +++ b/triplets/arm-uwp.cmake @@ -0,0 +1,6 @@ +set(CMAKE_SYSTEM_NAME WindowsStore) +set(CMAKE_SYSTEM_VERSION 10.0) + +if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 14 2015 ARM") + message(FATAL_ERROR "Visual Studio Generator must be used to target UWP") +endif() diff --git a/triplets/x64-uwp.cmake b/triplets/x64-uwp.cmake new file mode 100644 index 00000000000000..53c680bc837c8e --- /dev/null +++ b/triplets/x64-uwp.cmake @@ -0,0 +1,6 @@ +set(CMAKE_SYSTEM_NAME WindowsStore) +set(CMAKE_SYSTEM_VERSION 10.0) + +if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 14 2015 Win64") + message(FATAL_ERROR "Visual Studio Generator must be used to target UWP.") +endif() diff --git a/triplets/x64-windows.cmake b/triplets/x64-windows.cmake new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/triplets/x86-uwp.cmake b/triplets/x86-uwp.cmake new file mode 100644 index 00000000000000..a0c5601bbd9e1c --- /dev/null +++ b/triplets/x86-uwp.cmake @@ -0,0 +1,6 @@ +set(CMAKE_SYSTEM_NAME WindowsStore) +set(CMAKE_SYSTEM_VERSION 10.0) + +if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 14 2015") + message(FATAL_ERROR "Visual Studio Generator must be used to target UWP") +endif() diff --git a/triplets/x86-windows.cmake b/triplets/x86-windows.cmake new file mode 100644 index 00000000000000..e69de29bb2d1d6