Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Adding Win10 Universal Platform support
Browse files Browse the repository at this point in the history
ms\do_vsprojects14.bat will create a universal binary project as well as a universal test app.
Fixing up the vs project scripts to create a proper solution file
  • Loading branch information
Gilles Khouzam committed Apr 22, 2015
1 parent e370799 commit 3e8a22c
Show file tree
Hide file tree
Showing 43 changed files with 2,075 additions and 555 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Expand Up @@ -47,6 +47,10 @@

# Certificate symbolic links
*.0
# Include the Windows Test apps that end with .0
!*Phone*.0
!*Core*.0
!*Store*.0

# Links under apps
/apps/CA.pl
Expand Down
4 changes: 4 additions & 0 deletions Configure
Expand Up @@ -548,10 +548,13 @@ my %table=(
"VC-WINPHONE","cl:-W3 -Gs0 -GF -Gy -nologo -DWIN32_LEAN_AND_MEAN -DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DOPENSSL_WINAPP -FIsdkddkver.h -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
# 'perl Configure VC-WINSTORE
"VC-WINSTORE","cl:-W3 -Gs0 -GF -Gy -nologo -DWIN32_LEAN_AND_MEAN -DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP -DOPENSSL_WINAPP -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -FIsdkddkver.h -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
# 'perf Configure VC-WINONECORE
"VC-WINONECORE","cl:-W3 -Gs0 -GF -Gy -nologo -DWIN32_LEAN_AND_MEAN -DWINAPI_FAMILY=WINAPI_FAMILY_ONECORE_APP -DOPENSSL_WINAPP -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DOPENSSL_WINUCRT -FIsdkddkver.h -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
# Unified CE target
"debug-VC-WIN32","cl:-W3 -Gs0 -GF -Gy -Zi -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
"debug-VC-WINPHONE","cl:-W3 -Gs0 -GF -Gy -Zi -nologo -DWIN32_LEAN_AND_MEAN -DWINAPI_FAMILY=WINAPI_FAMILY_PHONE_APP -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -DOPENSSL_WINAPP -FIsdkddkver.h -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
"debug-VC-WINSTORE","cl:-W3 -Gs0 -GF -Gy -Zi -nologo -DWIN32_LEAN_AND_MEAN -DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP -DOPENSSL_WINAPP -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -FIsdkddkver.h -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
"debug-VC-WINONECORE","cl:-W3 -Gs0 -GF -Gy -Zi -nologo -DWIN32_LEAN_AND_MEAN -DWINAPI_FAMILY=WINAPI_FAMILY_ONECORE_APP -DOPENSSL_WINAPP -DOPENSSL_NO_ASM -DOPENSSL_NO_INLINE_ASM -FIsdkddkver.h -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_asm}:win32n:win32",
"VC-CE","cl::::WINCE::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${no_asm}:win32",

# Borland C++ 4.5
Expand Down Expand Up @@ -648,6 +651,7 @@ my @MK1MF_Builds=qw(VC-WIN64I VC-WIN64A
VC-NT VC-CE VC-WIN32 debug-VC-WIN32
VC-WINSTORE debug-VC-WINSTORE
VC-WINPHONE debug-VC-WINPHONE
VC-WINONECORE debug-VC-WINONECORE
BC-32
netware-clib netware-clib-bsdsock
netware-libc netware-libc-bsdsock);
Expand Down
123 changes: 123 additions & 0 deletions INSTALL.WINCORE
@@ -0,0 +1,123 @@

INSTALLATION ON WINDOWS 10 ONECORE PLATFORM
----------------------------------

[Instructions for building for Windows CE can be found in INSTALL.WCE]
[Instructions for building for Win64 can be found in INSTALL.W64]
[Instructions for building for Win32 can be found in INSTALL.W32]
[Instructions for building for Windows Phone 8.0/8.1 or Windows Store 8.1 can be found in INSTALL.WINAPP]


Requirments.
- You need Perl location for Win32 or Win64 in your PATH environmental variable.
- Visual Studio 2015
- Tools for Windows 10 [https://dev.windows.com/en-US/windows-10-developer-preview-tools]

QUICK MULTI-PLATFORM INSTALL
-----------------------------------------------------------------------

Execute the following script in the source root tree.
> ms\do_vsprojects14.bat

Open visual studio solution created
> vsout\openssl.sln


This file will generate a solution file that contains 4 projects.

2 OpenSSL Projects

OneCore 10.0 DLL (Win32|x64|arm) (Debug|Release)
OneCore 10.0 STATIC (Win32|x86|arm) (Debug|Release)

2 Test Apps which host the tests and run them

Run the test application to validate the libraries. It executes the same tests as the commandline
test suite.

Libraries are built on the following location

vsout\$(ProjectConfiguration)\$(Configuration)\$(Arch)\bin

Modify ms\do_vsprojects.bat for custom builds

You can build this solution file via the command line using devenv.exe, or MSBuild.exe, or via the UI

Once all configuration are build run

> ms\do_packwincore.bat

To pack the build output into vsout\package

SINGLE PLATFORM INSTALL
-----------------------------------------------------------------------
Firstly you should run Configure with platform VC-WINCORE

> perl Configure no-asm no-hw no-dso VC-WINCORE

Next you need to build the Makefiles:

> ms\do_wincore

Then from CMD.exe, the following environment variables must be set for nmake build.

INCLUDE
LIB
LIBPATH

In addition nmake.exe, link.exe and cl.exe must be available in the environmental variable %PATH%

Run ms\setVSvars.bat to set this environmental variables, and fix the path if needed, following flavours are supported, If your version is not supported by this batch you will need to manually set previous variables

ms\setVSvars onecore10.0arm
ms\setVSvars onecore10.0Win32
ms\setVSvars onecore10.01x64

Start nmake compilation with.

> nmake -f ms\nt.mak init
> nmake -f ms\nt.mak

Alternatively you can generate DLLs with the following command

> nmake -f ms\ntdll.mak

If all is well it should compile and you will have libs for openssl. on the directory out32 or out32dll if DLL build.


Tweaks:


Troubleshooting
---------------

Since the Win32 build is only occasionally tested it may not always compile
cleanly. If you get an error about functions not having numbers assigned
when you run ms\do_ms then this means the Win32 ordinal files are not up to
date. You can do:

> perl util\mkdef.pl crypto ssl update

then ms\do_XXX should not give a warning any more. However the numbers that
get assigned by this technique may not match those that eventually get
assigned in the Git tree: so anything linked against this version of the
library may need to be recompiled.

If you get errors about unresolved symbols there are several possible
causes.

If this happens when the DLL is being linked and you have disabled some
ciphers then it is possible the DEF file generator hasn't removed all
the disabled symbols: the easiest solution is to edit the DEF files manually
to delete them. The DEF files are ms\libeay32.def ms\ssleay32.def.

Another cause is if you missed or ignored the errors about missing numbers
mentioned above.


Linking your application
------------------------

If you link with static OpenSSL libraries [those built with ms/nt.mak],
then you're expected to additionally link your application with
WS2_32.LIB.
17 changes: 17 additions & 0 deletions crypto/bio/bss_file.c
Expand Up @@ -310,11 +310,28 @@ static long MS_CALLBACK file_ctrl(BIO *b, int cmd, long num, void *ptr)
#endif
#if defined(_IOB_ENTRIES)
/* Safety net to catch purely internal BIO_set_fp calls */

#if defined(OPENSSL_WINUCRT)
/* On Windows with the new Universal CRT, we only have
* 3 IOB entries. They are not in an array but require a
* function call to look up the value. This code compares
* each pointer with the IOB entries to see if we need to
* pass it through */
for (int i = 0; i < _IOB_ENTRIES; i++)
{
if (ptr == __acrt_iob_func(i))
{
BIO_clear_flags(b, BIO_FLAGS_UPLINK);
break;
}
}
#else
if ((size_t)ptr >= (size_t)stdin &&
(size_t)ptr < (size_t)(stdin+_IOB_ENTRIES))
BIO_clear_flags(b,BIO_FLAGS_UPLINK);
#endif
#endif
#endif
#ifdef UP_fsetmod
if (b->flags&BIO_FLAGS_UPLINK)
UP_fsetmod(b->ptr,(char)((num&BIO_FP_TEXT)?'t':'b'));
Expand Down
31 changes: 31 additions & 0 deletions ms/do_packwincore.bat
@@ -0,0 +1,31 @@
@echo off
if exist vsout\package rd /s /q vsout\package
mkdir vsout\package
mkdir vsout\package\include
mkdir vsout\package\lib
mkdir vsout\package\bin
xcopy inc32 vsout\package\include /h /k /r /e /i /y >nul

call :pack OneCore 10.0 Dll Unicode Debug Win32
call :pack OneCore 10.0 Dll Unicode Debug arm
call :pack OneCore 10.0 Dll Unicode Debug x64
call :pack OneCore 10.0 Dll Unicode Release Win32
call :pack OneCore 10.0 Dll Unicode Release arm
call :pack OneCore 10.0 Dll Unicode Release x64
call :pack OneCore 10.0 Static Unicode Debug Win32
call :pack OneCore 10.0 Static Unicode Debug arm
call :pack OneCore 10.0 Static Unicode Debug x64
call :pack OneCore 10.0 Static Unicode Release Win32
call :pack OneCore 10.0 Static Unicode Release arm
call :pack OneCore 10.0 Static Unicode Release x64

:pack
echo %1 %2 %3 %4 %5 %6
if not exist vsout\package\lib\%1\%2\%3\%4\%5\%6 mkdir vsout\package\lib\%1\%2\%3\%4\%5\%6 > nul
copy vsout\NT-%1-%2-%3-%4\%5\%6\bin\libeay32.lib vsout\package\lib\%1\%2\%3\%4\%5\%6\libeay32.lib
copy vsout\NT-%1-%2-%3-%4\%5\%6\bin\ssleay32.lib vsout\package\lib\%1\%2\%3\%4\%5\%6\ssleay32.lib
if "%3"=="Static" goto :eof
if not exist vsout\package\bin\%1\%2\%3\%4\%5\%6 mkdir vsout\package\bin\%1\%2\%3\%4\%5\%6 > nul
copy vsout\NT-%1-%2-%3-%4\%5\%6\bin\libeay32.dll vsout\package\bin\%1\%2\%3\%4\%5\%6\libeay32.dll
copy vsout\NT-%1-%2-%3-%4\%5\%6\bin\ssleay32.dll vsout\package\bin\%1\%2\%3\%4\%5\%6\ssleay32.dll
goto :eof
98 changes: 65 additions & 33 deletions ms/do_vsproject.pl
Expand Up @@ -3,10 +3,18 @@
my $guid = "$ARGV[4]";
my $testguid = "$ARGV[5]";
my $winrtguid = "$ARGV[6]";
my $PlatformToolset="v120" ;
my $PlatformToolset="v120";
my $ToolsVersion="12.0";
my $vstoolversion="";
if($ARGV[1]=="8.1")
my $winrt=1;
if($ARGV[1]=="10.0")
{
$ToolsVersion="14.0";
$PlatformToolset="v140";
$vstoolversion.="onecore10.0";
$winrt=0;
}
elsif($ARGV[1]=="8.1")
{
$ToolsVersion="12.0";
if($ARGV[0]=~/Phone/)
Expand Down Expand Up @@ -34,29 +42,11 @@
$vstoolversion.="ws8.0";
}
}
#add makefile project and test project to solution
open(my $solution, '>>', 'vsout\\openssl.sln') or die;

print $solution 'Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "'."$projectname".'", "'."$projectname\\$projectname.vcxproj".'", "{'."$guid".'}"
EndProject'."\r\n";

print $solution 'Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "'."$projectname".'-winrtcomponent", "'."$projectname-winrtcomponent\\$projectname-winrtcomponent.vcxproj".'", "{'."$winrtguid".'}"
'."\t".'ProjectSection(ProjectDependencies) = postProject
'."\t\t{$guid} = {$guid}".'
'."\t".'EndProjectSection
EndProject'."\r\n";

print $solution 'Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "'."$projectname".'-testapp", "'."$projectname-testapp\\$projectname-testapp.csproj".'", "{'."$testguid".'}"
'."\t".'ProjectSection(ProjectDependencies) = postProject
'."\t\t{$winrtguid} = {$winrtguid}".'
'."\t".'EndProjectSection
EndProject'."\r\n";

close %solution;

sub replaceInFile {
my($input,$output,%hash) =@_;
open INPUT, $input or die "Cant Open $input";

open INPUT, $input or die "Can\'t open $input";
my $inputFile="";
while (<INPUT>) { $inputFile .= $_ }
close INPUT;
Expand Down Expand Up @@ -106,8 +96,16 @@ sub replaceInFile {
#$replacement{"WindowsSDK_MetadataPath"}="WindowsSDK_WindowsMetadata";

}
replaceInFile("ms\\vstemplates\\OpenSSLTestApp$ARGV[0]$ARGV[1]\\OpenSSLTestApp.csproj","vsout\\$projectname-testapp\\$projectname-testapp.csproj", %replacement);
replaceInFile("ms\\vstemplates\\winrt$ARGV[0]$ARGV[1]\\winrt$ARGV[0]$ARGV[1].vcxproj","vsout\\$projectname-winrtcomponent\\$projectname-winrtcomponent.vcxproj", %replacement);
if ($winrt)
{
replaceInFile("ms\\vstemplates\\OpenSSLTestApp$ARGV[0]$ARGV[1]\\OpenSSLTestApp.csproj","vsout\\$projectname-testapp\\$projectname-testapp.csproj", %replacement);
replaceInFile("ms\\vstemplates\\winrt$ARGV[0]$ARGV[1]\\winrt$ARGV[0]$ARGV[1].vcxproj","vsout\\$projectname-winrtcomponent\\$projectname-winrtcomponent.vcxproj", %replacement);
}
else
{
replaceInFile("ms\\vstemplates\\OpenSSLTestApp$ARGV[0]$ARGV[1]\\OpenSSLTestApp.vcxproj","vsout\\$projectname-testapp\\$projectname-testapp.vcxproj", %replacement);
replaceInFile("ms\\vstemplates\\OpenSSLTestApp$ARGV[0]$ARGV[1]\\OpenSSLTestApp.vcxproj.filters","vsout\\$projectname-testapp\\$projectname-testapp.vcxproj.filters", %replacement);
}
replaceInFile("ms\\vstemplates\\Makefile$ARGV[0]\\Makefile$ARGV[0].vcxproj", "vsout\\$projectname\\$projectname.vcxproj", %replacement);
}

Expand Down Expand Up @@ -450,13 +448,20 @@ sub processBatch{
#generate VSProject
sub addToProject{
my ( $name ) = @_;
return"<Content Include=\"$name\" >\n<CopyToOutputDirectory>Always</CopyToOutputDirectory>\n</Content>\n";
if($winrt)
{
return"<Content Include=\"$name\" >\n\t<CopyToOutputDirectory>Always</CopyToOutputDirectory>\n</Content>\n";
}
else
{
return"<None Include=\"$name\">\n\t<DeploymentContent>true</DeploymentContent>\n</None>\n";
}
}

my @config=("Debug","Release");
my @arch=("Win32","arm");
my $rep="";
push(@arch, "x64") if($ARGV[0]=~/Store/);
push(@arch, "x64") if($ARGV[0]=~/Store|OneCore/);
for my $_config (@config) {
for my $_arch (@arch) {
my $suffix=$ARGV[2]=~/Dll/?"dll":"";
Expand Down Expand Up @@ -492,8 +497,10 @@ sub addToProject{
$rep.=addToProject("\$(SolutionDir)\\..\\apps\\server.pem");
$rep.=addToProject("\$(SolutionDir)\\..\\apps\\client.pem");
{
my $generated=<<'END_MESSAGE';
<Choose>
if($winrt)
{
my $generated=<<'END_MESSAGE';
<Choose>
<When Condition=" '$(Platform)'=='x86' ">
<PropertyGroup>
<BuildConfiguration>Win32</BuildConfiguration>
Expand All @@ -509,15 +516,40 @@ sub addToProject{
<BuildConfiguration>arm</BuildConfiguration>
</PropertyGroup>
</When>
</Choose>
</Choose>
END_MESSAGE

$generated.="<ItemGroup>$rep</ItemGroup>".
"<ItemGroup><ProjectReference Include=\"..\\$projectname-winrtcomponent\\$projectname-winrtcomponent.vcxproj\">\n".
$generated.="<ItemGroup>$rep</ItemGroup>".
"<ItemGroup><ProjectReference Include=\"..\\$projectname-winrtcomponent\\$projectname-winrtcomponent.vcxproj\">\n".
"<Project>{$winrtguid}</Project>\n".
"<Name>$projectname-winrtcomponent</Name>\n".
"</ProjectReference></ItemGroup>";

my (%replacement)=('<!--GeneratedData-->'=>$generated);
replaceInFile("vsout\\$projectname-testapp\\$projectname-testapp.csproj","vsout\\$projectname-testapp\\$projectname-testapp.csproj", %replacement);
my (%replacement)=('<!--GeneratedData-->'=>$generated);

replaceInFile("vsout\\$projectname-testapp\\$projectname-testapp.csproj","vsout\\$projectname-testapp\\$projectname-testapp.csproj", %replacement);
}
else
{
my $generated=<<'END_MESSAGE';
<PropertyGroup Condition="'$(Platform)'=='Win32'">
<BuildConfiguration>Win32</BuildConfiguration>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)'=='ARM'">
<BuildConfiguration>ARM</BuildConfiguration>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)'=='x64'">
<BuildConfiguration>x64</BuildConfiguration>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
END_MESSAGE

my (%replacement)=('<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />'=>$generated);
replaceInFile("vsout\\$projectname-testapp\\$projectname-testapp.vcxproj","vsout\\$projectname-testapp\\$projectname-testapp.vcxproj", %replacement);

$generated="</AppxManifest>".
"$rep";
(%replacement)=('</AppxManifest>'=>$generated);
replaceInFile("vsout\\$projectname-testapp\\$projectname-testapp.vcxproj","vsout\\$projectname-testapp\\$projectname-testapp.vcxproj", %replacement);
}
}

0 comments on commit 3e8a22c

Please sign in to comment.