Skip to content

Commit

Permalink
Replace bespoke openssl build script with vcpkg, and integrate with p…
Browse files Browse the repository at this point in the history
…remake
  • Loading branch information
gorlak committed Jun 5, 2021
1 parent d701c94 commit 9601d98
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 128 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- name: Build Debug
run: |
MSBuild.exe Build\P4Win.sln -p:Configuration=Debug
MSBuild.exe Build\P4Win.sln -p:Configuration=Debug /p:Platform=x64
build-release:
name: Release
Expand Down Expand Up @@ -66,4 +66,4 @@ jobs:

- name: Build Release
run: |
MSBuild.exe Build\P4Win.sln -p:Configuration=Release
MSBuild.exe Build\P4Win.sln -p:Configuration=Release /p:Platform=x64
9 changes: 3 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
[submodule "Dependencies/p4"]
path = Dependencies/p4
url = https://github.com/gorlak/P4.git
[submodule "Dependencies/openssl"]
path = Dependencies/openssl
url = https://github.com/gorlak/openssl.git
[submodule "Dependencies/StrawberryPerl"]
path = Dependencies/StrawberryPerl
url = https://github.com/HeliumProject/StrawberryPerl.git
[submodule "Dependencies/InnoSetup"]
path = Dependencies/InnoSetup
url = https://github.com/HeliumProject/InnoSetup.git
[submodule "Dependencies/vcpkg"]
path = Dependencies/vcpkg
url = https://github.com/microsoft/vcpkg
2 changes: 1 addition & 1 deletion Dependencies/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
openssl-*/
vcpkg-installed/
1 change: 0 additions & 1 deletion Dependencies/StrawberryPerl
Submodule StrawberryPerl deleted from a69bd0
1 change: 0 additions & 1 deletion Dependencies/openssl
Submodule openssl deleted from 0039a4
72 changes: 0 additions & 72 deletions Dependencies/openssl-build.bat

This file was deleted.

2 changes: 1 addition & 1 deletion Dependencies/p4
2 changes: 1 addition & 1 deletion Dependencies/premake
Submodule premake updated 1416 files
1 change: 1 addition & 0 deletions Dependencies/vcpkg
Submodule vcpkg added at 5568f1
4 changes: 4 additions & 0 deletions Dependencies/vcpkg-overlay/overlay-x64-windows-vs2019.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_PLATFORM_TOOLSET v142)
4 changes: 4 additions & 0 deletions Dependencies/vcpkg-overlay/overlay-x86-windows-vs2019.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_PLATFORM_TOOLSET v142)
10 changes: 10 additions & 0 deletions Dependencies/vcpkg.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@echo off

:: -disableMetrics in important to avoid Malwarebytes quarantine the vcpkg file.
call %~dp0vcpkg\bootstrap-vcpkg.bat -disableMetrics

:: build for each triplet
for %%x in (overlay-x64-windows overlay-x86-windows) do (
%~dp0vcpkg\vcpkg.exe install --x-install-root=%~dp0vcpkg-installed --overlay-ports=%~dp0/vcpkg-overlay --overlay-triplets=%~dp0/vcpkg-overlay --triplet=%%x-%1 openssl
if ERRORLEVEL 1 exit /b 1
)
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,7 @@ First, grab our source tree from git and ensure that you fetch all the submodule

git submodule update --init

Now, build dependent libs. Open a visual studio command prompt for _the architecture you want to use, Win32 or x64_. Then:

cd Dependencies
openssl-build.bat

Now, generate the main solution:
Now, build dependencies and generate the main solution:

premake vs2019
start Build\P4Win.sln
Expand Down
101 changes: 64 additions & 37 deletions premake5.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
action = _ACTION

if (action == nil) then
action = "none"
end

newoption
{
trigger = "client",
Expand All @@ -10,17 +16,8 @@ newoption
description = "Bundle japanese resources",
}

newoption
{
trigger = "architecture",
description = "Specify architecture (see premake 'architecture' action for choices)",
default = (function() if os.is64bit() then return 'x86_64' else return 'x86' end end)(),
}

-- global options

architecture( _OPTIONS[ "architecture" ] )

flags
{
"FatalWarnings",
Expand Down Expand Up @@ -68,20 +65,40 @@ configurations
"Release",
}

platforms
{
"x86",
"x64",
}

location "Build"
objdir "Build"

-- global configurations

configuration "Debug"
filter { "platforms:x86" }
architecture "x86"

filter { "platforms:x64" }
architecture "x86_64"

filter { "configurations:Debug", "platforms:x86" }
targetdir( "Bin/Debug (x86)/" )
libdirs { "Bin/Debug (x86)/" }

filter { "configurations:Release", "platforms:x86" }
targetdir( "Bin/Release (x86)/" )
libdirs { "Bin/Release (x86)/" }

filter { "configurations:Debug", "platforms:x64" }
targetdir( "Bin/Debug/" )
libdirs { "Bin/Debug/" }

configuration "Release"
filter { "configurations:Release", "platforms:x64" }
targetdir( "Bin/Release/" )
libdirs { "Bin/Release/" }

configuration "Debug"
filter { "configurations:Debug" }
defines
{
"_DEBUG",
Expand All @@ -92,7 +109,7 @@ configuration "Debug"
"/Ob0",
}

configuration "Release"
filter { "configurations:Release" }
defines
{
"NDEBUG",
Expand All @@ -107,47 +124,43 @@ configuration "Release"
"/Oi",
}

configuration {"Debug", "x86"}
filter { "platforms:x86" }
includedirs
{
"Dependencies/openssl-Win32-mdd/include",
"Dependencies/vcpkg-installed/overlay-x86-windows-" .. action .. "/include",
}

filter { "configurations:Debug", "platforms:x86" }
libdirs
{
"Dependencies/openssl-Win32-mdd/lib"
"Dependencies/vcpkg-installed/overlay-x86-windows-" .. action .. "/debug/lib",
}

configuration {"not Debug", "x86"}
includedirs
{
"Dependencies/openssl-Win32-md/include",
}
filter { "configurations:not Debug", "platforms:x86" }
libdirs
{
"Dependencies/openssl-Win32-md/lib"
"Dependencies/vcpkg-installed/overlay-x86-windows-" .. action .. "/lib",
}

configuration {"Debug", "x86_64"}
filter { "platforms:x64" }
includedirs
{
"Dependencies/openssl-x64-mdd/include",
"Dependencies/vcpkg-installed/overlay-x64-windows-" .. action .. "/include",
}

filter { "configurations:Debug", "platforms:x64" }
libdirs
{
"Dependencies/openssl-x64-mdd/lib"
"Dependencies/vcpkg-installed/overlay-x64-windows-" .. action .. "/debug/lib",
}

configuration {"not Debug", "x86_64"}
includedirs
{
"Dependencies/openssl-x64-md/include",
}
filter { "configurations:not Debug", "platforms:x64" }
libdirs
{
"Dependencies/openssl-x64-md/lib"
"Dependencies/vcpkg-installed/overlay-x64-windows-" .. action .. "/lib",
}

configuration {}
filter {}

-- workspace

Expand Down Expand Up @@ -288,6 +301,11 @@ project "libscript-curl"
characterset "MBCS"
-- staticruntime "On"

disablewarnings
{
"4090", -- 'function': different 'const' qualifiers
}

defines
{
"CURL_STATICLIB",
Expand Down Expand Up @@ -447,7 +465,6 @@ project "p4"

includedirs
{
"Dependencies/openssl-install/include",
"Dependencies/p4/client",
"Dependencies/p4/diff",
"Dependencies/p4/i18n",
Expand Down Expand Up @@ -475,10 +492,11 @@ project "p4"
"libscript-curl",
"libscript-sqlite",
"libclient",
"ssleay32",
"libeay32",
"libssl",
"libcrypto",
"dbghelp",
"ws2_32",
"crypt32",
"wininet",
"setargv.obj",
}
Expand Down Expand Up @@ -557,10 +575,19 @@ project "P4Win"
"libscript-curl",
"libscript-sqlite",
"libclient",
"ssleay32",
"libeay32",
"libssl",
"libcrypto",
"dbghelp",
"ws2_32",
"crypt32",
"wininet",
"winmm",
}

if action:match("^vs*") then
local success, termination, result = os.execute( "cmd.exe /c Dependencies\\vcpkg.bat " .. action )
if ( result ~= 0 ) then
premake.error( "vcpkg failed!" )
os.exit( 1 )
end
end

0 comments on commit 9601d98

Please sign in to comment.