-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit with the build on windows
- Loading branch information
Showing
11 changed files
with
313 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
[submodule "third_party/prometheus-cpp"] | ||
path = third_party/prometheus-cpp | ||
url = https://github.com/jupp0r/prometheus-cpp.git | ||
[submodule "tools/vcpkg"] | ||
path = tools/vcpkg | ||
url = https://github.com/Microsoft/vcpkg | ||
[submodule "third_party/benchmark"] | ||
path = third_party/benchmark | ||
url = https://github.com/google/benchmark |
Submodule prometheus-cpp
added at
6a5b37
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@echo off | ||
set VS_TOOLS_VERSION=vs2019 | ||
set CMAKE_GEN="Visual Studio 16 2019" | ||
echo Building Google Benchmark (test only dependency)... | ||
@setlocal ENABLEEXTENSIONS | ||
|
||
echo Auto-detecting Visual Studio version... | ||
call "%~dp0\vcvars.cmd" | ||
|
||
pushd "%~dp0\.." | ||
set "ROOT=%CD%" | ||
|
||
set MAXCPUCOUNT=%NUMBER_OF_PROCESSORS% | ||
set platform= | ||
|
||
if not exist "%ROOT%\third_party\benchmark\" ( | ||
echo "Google Benchmark library is not available, skipping benchmark build." | ||
call skip_the_build | ||
) | ||
|
||
cd "%ROOT%\third_party\benchmark\" | ||
set "GOOGLETEST_PATH=%ROOT%\third_party\googletest" | ||
if not exist "build" ( | ||
mkdir build | ||
) | ||
cd build | ||
|
||
REM By default we generate the project for the older Visual Studio 2017 even if we have newer version installed | ||
cmake ../ -G %CMAKE_GEN% -Ax64 -DBENCHMARK_ENABLE_TESTING=OFF | ||
set SOLUTION=%ROOT%\third_party\benchmark\build\benchmark.sln | ||
msbuild %SOLUTION% /maxcpucount:%MAXCPUCOUNT% /p:Configuration=Debug /p:Platform=x64 | ||
msbuild %SOLUTION% /maxcpucount:%MAXCPUCOUNT% /p:Configuration=Release /p:Platform=x64 | ||
popd | ||
|
||
:skip_the_build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
set "VS_TOOLS_VERSION=vs2019" | ||
set "CMAKE_GEN=Visual Studio 16 2019" | ||
cd %~dp0 | ||
call setup-buildtools.cmd | ||
call build.cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
@echo off | ||
REM Currently we require Visual Studio 2019 for C++20 build targeting Release/x64. | ||
REM | ||
REM TODO: allow specifying compiler version as argument. | ||
REM | ||
REM Supported versions for nostd build: | ||
REM - vs2015 (C++11) | ||
REM - vs2017 (C++14) | ||
REM - vs2019 (C++20) | ||
REM | ||
REM Supported versions for STL build: | ||
REM - vs2017 (C++14) | ||
REM - vs2019 (C++20) | ||
REM | ||
|
||
if "%VS_TOOLS_VERSION%" == "" set "VS_TOOLS_VERSION=vs2019" | ||
if "%CMAKE_GEN%" == "" set "CMAKE_GEN=Visual Studio 16 2019" | ||
|
||
pushd %~dp0 | ||
setlocal enableextensions | ||
setlocal enabledelayedexpansion | ||
set "ROOT=%~dp0\.." | ||
|
||
REM Use preinstalled vcpkg if installed or use our local | ||
if "%VCPKG_INSTALLATION_ROOT%" neq "" ( | ||
set "VCPKG_CMAKE=%VCPKG_INSTALLATION_ROOT%\scripts\buildsystems\vcpkg.cmake" | ||
) else ( | ||
set "VCPKG_CMAKE=%CD%\vcpkg\scripts\buildsystems\vcpkg.cmake" | ||
) | ||
|
||
REM ******************************************************************** | ||
REM Setup compiler environment | ||
REM ******************************************************************** | ||
call "%~dp0\vcvars.cmd" | ||
|
||
|
||
REM ******************************************************************** | ||
REM Use cmake | ||
REM ******************************************************************** | ||
set "PATH=%PATH%;C:\Program Files\CMake\bin\" | ||
|
||
REM ******************************************************************** | ||
REM Build with nostd implementation | ||
REM ******************************************************************** | ||
set CONFIG=-DWITH_STL:BOOL=OFF %* | ||
set "OUTDIR=%ROOT%\out\%VS_TOOLS_VERSION%\nostd" | ||
call :build_config | ||
|
||
REM ******************************************************************** | ||
REM Build with STL implementation - only for vs2017+ | ||
REM ******************************************************************** | ||
if "%VS_TOOLS_VERSION%" neq "vs2015" ( | ||
set CONFIG=-DWITH_STL:BOOL=ON | ||
set "OUTDIR=%ROOT%\out\%VS_TOOLS_VERSION%\stl" | ||
call :build_config | ||
) | ||
|
||
popd | ||
REM ******************************************************************** | ||
|
||
|
||
REM ******************************************************************** | ||
REM Function that allows to build given build configuration | ||
REM ******************************************************************** | ||
:build_config | ||
REM TODO: consider rmdir for clean builds | ||
if not exist "%OUTDIR%" mkdir "%OUTDIR%" | ||
cd "%OUTDIR%" | ||
REM Optional platform specification parameter below: -Ax64 | ||
cmake %ROOT% -G "%CMAKE_GEN%" -DCMAKE_TOOLCHAIN_FILE="%VCPKG_CMAKE%" %CONFIG% | ||
set "SOLUTION=%OUTDIR%\opentelemetry-cpp.sln" | ||
REM TODO: allow building [Release|Debug]x[Win32|x64|ARM|ARM64] | ||
msbuild "%SOLUTION%" /p:Configuration=Release /p:Platform=x64 /p:VcpkgEnabled=true | ||
exit /b 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Source: benchmark | ||
Version: 1.5.1 | ||
Homepage: https://github.com/google/benchmark | ||
Description: A library to support the benchmarking of functions, similar to unit-tests. | ||
Supports: !uwp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") | ||
message(FATAL_ERROR "${PORT} does not currently support UWP") | ||
endif() | ||
|
||
if (VCPKG_PLATFORM_TOOLSET STREQUAL "v140") | ||
# set(CMAKE_C_COMPILER_WORKS 1) | ||
# set(CMAKE_CXX_COMPILER_WORKS 1) | ||
set(CMAKE_C_COMPILER cl.exe) | ||
set(CMAKE_CXX_COMPILER cl.exe) | ||
set(MSVC_TOOLSET_VERSION 140) | ||
# set(VCPKG_VISUAL_STUDIO_PATH "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0") | ||
# set(VCPKG_PLATFORM_TOOLSET v140) | ||
else() | ||
# Make sure vs2019 compiled binaries are compat with vs2017 | ||
set(VCPKG_CXX_FLAGS "/Zc:__cplusplus /d2FH4-") | ||
set(VCPKG_C_FLAGS "/Zc:__cplusplus /d2FH4-") | ||
set(PREFER PREFER_NINJA) | ||
endif() | ||
|
||
include(vcpkg_common_functions) | ||
|
||
vcpkg_check_linkage(ONLY_STATIC_LIBRARY) | ||
|
||
vcpkg_from_github( | ||
OUT_SOURCE_PATH SOURCE_PATH | ||
REPO google/benchmark | ||
HEAD_REF master | ||
) | ||
|
||
vcpkg_configure_cmake( | ||
SOURCE_PATH ${SOURCE_PATH} | ||
${PREFER} | ||
OPTIONS | ||
-DBENCHMARK_ENABLE_TESTING=OFF | ||
-DCMAKE_DEBUG_POSTFIX=d | ||
) | ||
|
||
vcpkg_install_cmake() | ||
|
||
vcpkg_copy_pdbs() | ||
|
||
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/benchmark) | ||
|
||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) | ||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) | ||
|
||
# Handle copyright | ||
file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/benchmark) | ||
file(RENAME ${CURRENT_PACKAGES_DIR}/share/benchmark/LICENSE ${CURRENT_PACKAGES_DIR}/share/benchmark/copyright) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
@echo off | ||
set "PATH=%PATH%;%~dp0;%~dp0\vcpkg" | ||
pushd %~dp0 | ||
|
||
REM Fail if chocolatey is not installed | ||
where /Q choco | ||
if ERRORLEVEL 1 ( | ||
echo This script requires chocolatey. Installation instructions: https://chocolatey.org/docs/installation | ||
exit -1 | ||
) | ||
|
||
REM Print current Visual Studio installations detected | ||
where /Q vswhere | ||
if ERRORLEVEL 0 ( | ||
echo Visual Studio installations detected: | ||
vswhere -property installationPath | ||
) | ||
|
||
REM Install tools needed for building stuff | ||
choco install -y cmake | ||
choco install -y svn | ||
choco install -y git | ||
choco install -y llvm | ||
choco install -y zip | ||
|
||
REM Try to autodetect Visual Studio | ||
call "%~dp0\vcvars.cmd" | ||
if "%TOOLS_VS_NOTFOUND%" == "1" ( | ||
REM Cannot detect MSBuild path | ||
REM TODO: no command line tools.. | ||
REM TODO: use MSBuild from vswhere? | ||
) | ||
|
||
where /Q vcpkg.exe | ||
if ERRORLEVEL 1 ( | ||
REM Build our own vcpkg from source | ||
pushd .\vcpkg | ||
call bootstrap-vcpkg.bat | ||
popd | ||
) | ||
|
||
REM Install it | ||
vcpkg install gtest:x64-windows | ||
vcpkg install --head --overlay-ports=%~dp0\ports benchmark:x64-windows | ||
vcpkg install ms-gsl:x64-windows | ||
vcpkg install nlohmann-json:x64-windows | ||
vcpkg install abseil:x64-windows | ||
vcpkg integrate install | ||
popd | ||
exit /b 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
@echo off | ||
REM | ||
REM Make sure to enable the 'Visual C++ ATL' components for all platforms during the setup. | ||
REM | ||
REM This build script auto-detects and configures Visual Studio in the following order: | ||
REM 1. Visual Studio 2017 Enterprise | ||
REM 2. Visual Studio 2017 BuildTools | ||
REM 3. Visual Studio 2019 Enterprise | ||
REM 4. Visual Studio 2019 Community | ||
REM 5. Visual Studio 2019 BuildTools | ||
REM | ||
|
||
REM 1st parameter - Visual Studio version | ||
if "%1" neq "" ( | ||
goto %1 | ||
) | ||
|
||
if "%VS_TOOLS_VERSION%" neq "" ( | ||
goto %VS_TOOLS_VERSION% | ||
) | ||
|
||
REM vs2017 Enterprise | ||
:vs2017 | ||
:vs2017_enterprise | ||
set TOOLS_VS2017_ENTERPRISE="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\Common7\Tools\VsDevCmd.bat" | ||
if exist %TOOLS_VS2017_ENTERPRISE% ( | ||
echo Building with vs2017 Enterprise... | ||
call %TOOLS_VS2017_ENTERPRISE% | ||
goto tools_configured | ||
) | ||
|
||
REM vs2017 BuildTools | ||
:vs2017_buildtools | ||
set TOOLS_VS2017="%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsDevCmd.bat" | ||
if exist %TOOLS_VS2017% ( | ||
echo Building with vs2017 BuildTools... | ||
call %TOOLS_VS2017% | ||
goto tools_configured | ||
) | ||
|
||
REM vs2019 Enterprise | ||
:vs2019 | ||
:vs2019_enterprise | ||
set TOOLS_VS2019_ENTERPRISE="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" | ||
if exist %TOOLS_VS2019_ENTERPRISE% ( | ||
echo Building with vs2019 Enterprise... | ||
call %TOOLS_VS2019_ENTERPRISE% | ||
goto tools_configured | ||
) | ||
|
||
REM vs2019 Community | ||
:vs2019_community | ||
set TOOLS_VS2019_COMMUNITY="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat" | ||
if exist %TOOLS_VS2019_COMMUNITY% ( | ||
echo Building with vs2019 Community... | ||
call %TOOLS_VS2019_COMMUNITY% | ||
goto tools_configured | ||
) | ||
|
||
REM vs2019 BuildTools | ||
:vs2019_buildtools | ||
set TOOLS_VS2019="%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat" | ||
if exist %TOOLS_VS2019% ( | ||
echo Building with vs2019 BuildTools... | ||
call %TOOLS_VS2019% | ||
goto tools_configured | ||
) | ||
|
||
REM vs2015 | ||
:vs2015 | ||
set TOOLS_VS2015="%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat" | ||
if exist %TOOLS_VS2015% ( | ||
echo Building with vs2015 BuildTools... | ||
call %TOOLS_VS2015% | ||
set "VCPKG_VISUAL_STUDIO_PATH=C:\Program Files (x86)\Microsoft Visual Studio 14.0" | ||
set VCPKG_PLATFORM_TOOLSET=v140 | ||
goto tools_configured | ||
) | ||
|
||
echo WARNING:********************************************* | ||
echo WARNING: cannot auto-detect Visual Studio version !!! | ||
echo WARNING:********************************************* | ||
set TOOLS_VS_NOTFOUND=1 | ||
exit /b 0 | ||
|
||
:tools_configured |