Skip to content

Commit

Permalink
Merge pull request microsoft#467 from Madhusudhan-MSFT/user/masudars/…
Browse files Browse the repository at this point in the history
…Component_governance_fixes_for_Openssl_lib_subtree

User/masudars/component governance fixes for openssl lib subtree
  • Loading branch information
msftrubengu committed Aug 10, 2021
2 parents 7442244 + 43a9e21 commit 5f977a7
Show file tree
Hide file tree
Showing 19,294 changed files with 802,968 additions and 428,218 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ more of the following dependencies may be statically linked into the binary:

* [ZLib Tag v1.2.11 Commit cacf7f1d4e3d44d871b605da3b647f07d718623f](https://github.com/madler/zlib/releases/tag/v1.2.11)
* [Xerces-C Tag v3.2.1 Commit 9ac2984508eff312585b86b2a89850a439b5650b](https://github.com/apache/xerces-c/releases/tag/v3.2.1)
* [OpenSSL Tag OpenSSL_1_0_2q Commit 5707219a6aae8052cb98aa361d115be01b8fd894](https://github.com/openssl/openssl/releases/tag/OpenSSL_1_0_2q)
* [OpenSSL Tag OpenSSL_1_1_1j Commit 52c587d60be67c337364b830dd3fdc15404a2f04](https://github.com/openssl/openssl/releases/tag/OpenSSL_1_1_1j)
* [Android NDK](https://developer.android.com/ndk)

For convinience, Zlib, Xerces-C and OpenSSL are git-subtrees that are mapped in under the lib folder of this project. Edits on top of these subtrees for build related optimizations are tracked within this repository.
Expand Down
67 changes: 60 additions & 7 deletions cmake/crypto.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ set( TARGET_SOURCES "" )

# Because OpenSSL does silly things we have to create a proper include dir to build everything
file( COPY ${OpenSSL_SOURCE_PATH}/e_os.h DESTINATION ${OpenSLL_INCLUDE_PATH}/ )
file( COPY ${OpenSSL_SOURCE_PATH}/e_os2.h DESTINATION ${OpenSLL_INCLUDE_PATH}/openssl/ )
file( COPY ${OpenSSL_SOURCE_PATH}/include/openssl/e_os2.h DESTINATION ${OpenSLL_INCLUDE_PATH}/openssl/ )

# we hold the sources (.c) under XSRC and headers (.h) under XINC
# we do this as we need to copy headers else the lib will not build.
Expand All @@ -29,9 +29,11 @@ set( XSRC_SHARED "")
# OpenSSL Has a lot of source files so we separated it.
include( crypto_sources )

file( COPY ${XINC} DESTINATION ${OpenSLL_INCLUDE_PATH}/openssl FILES_MATCHING REGEX "\.h$" )
file( COPY ${TARGET_SOURCE_DIR_TRUE}/opensslconf.h.in DESTINATION ${OpenSLL_INCLUDE_PATH}/openssl )

file( COPY ${OpenSSL_SOURCE_PATH}/include/openssl/opensslconf.h.in DESTINATION ${OpenSLL_INCLUDE_PATH}/openssl )
file( COPY ${OpenSSL_SOURCE_PATH}/include/internal DESTINATION ${OpenSLL_INCLUDE_PATH}/openssl/ )
file( COPY ${OpenSSL_SOURCE_PATH}/include/crypto DESTINATION ${OpenSLL_INCLUDE_PATH}/openssl/ )
file( COPY ${OpenSSL_SOURCE_PATH}/include/openssl DESTINATION ${OpenSLL_INCLUDE_PATH}/openssl/ )

if(WIN32)
# TODO: Replicate build flags for cl
# Flags taken from OpenSSL Configure file for VC-WIN64A target. More care may be required for other targets.
Expand All @@ -41,7 +43,47 @@ else()
-fno-math-errno -fno-unroll-loops -fmerge-all-constants)
endif()

file( READ "${OpenSLL_INCLUDE_PATH}/openssl/opensslconf.h.in" CONF )
if( MSVC )
include( MSVCRuntime )
# configure_msvc_runtime()
set( OPENSSLDIR "C:/ssl" )
set( ENGINESDIR "C:/engines-1.1" )
else()
set( OPENSSLDIR "/usr/local/ssl" )
set( ENGINESDIR "/usr/local/engines-1.1" )
endif()
add_definitions( "-DOPENSSLDIR=\"${OPENSSLDIR}\"" )
add_definitions( "-DENGINESDIR=\"${ENGINESDIR}\"" )

# This was a default option during OpenSSL 1.0.2u and is the option that MSIX SDK
# uses although it compiles set of DSO source code. With the latest version
# of OpenSSL 1.1.1j we need this to be set explicitly (it appears we don't have default)
set( DSO_NONE ON )

if( APPLE )
set( DSO_EXTENSION ".dylib" )
elseif( WIN32 AND NOT CYGWIN )
set( DSO_EXTENSION ".dll" )
elseif( CYGWIN )
set( DSO_EXTENSION ".dll" )
else()
set( DSO_EXTENSION ".so" )
endif()

include( CheckTypeSize )
check_type_size( "long" LONG_INT )
check_type_size( "long long" LONG_LONG_INT )
check_type_size( "int" INT )
if( HAVE_LONG_INT AND (${LONG_INT} EQUAL 8) )
set( SIXTY_FOUR_BIT_LONG ON )
elseif( HAVE_LONG_LONG_INT AND (${LONG_LONG_INT} EQUAL 8) )
set( SIXTY_FOUR_BIT ON )
else()
set( THIRTY_TWO_BIT ON )
endif()

# Begin configure public headers
file( READ "${MSIX_PROJECT_ROOT}/cmake/openssl/opensslconf.h.cmake" CONF )
set( CONF "
#define OPENSSL_NO_GMP
#define OPENSSL_NO_JPAKE
Expand Down Expand Up @@ -80,17 +122,28 @@ set( CONF "
#define OPENSSL_NO_BF
#define OPENSSL_NO_MD4
#define OPENSSL_NO_CMS
#define OPENSSL_NO_OCSP
#define OPENSSL_NO_SRP
#define OPENSSL_NO_SM2
${CONF}" )
file( WRITE "${OpenSLL_INCLUDE_PATH}/openssl/opensslconf.h" "${CONF}" )
file( WRITE "${OpenSLL_INCLUDE_PATH}/openssl/opensslconf.h.cmake" "${CONF}" )

configure_file( "${OpenSLL_INCLUDE_PATH}/openssl/opensslconf.h.cmake"
"${OpenSLL_INCLUDE_PATH}/openssl/opensslconf.h" )

configure_file( "${MSIX_PROJECT_ROOT}/cmake/openssl/crypto/bn_conf.h.cmake"
"${OpenSLL_INCLUDE_PATH}/openssl/crypto/bn_conf.h" )

configure_file( "${MSIX_PROJECT_ROOT}/cmake/openssl/crypto/dso_conf.h.cmake"
"${OpenSLL_INCLUDE_PATH}/openssl/crypto/dso_conf.h" )
# End configure public headers

set( BuildInfH "
#ifndef MK1MF_BUILD
/* Generated by crypto.cmake - does it break anything? */
#define CFLAGS \"\"
#define PLATFORM \"${CMAKE_SYSTEM_NAME}\"
#define DATE \"\"
static const char *compiler_flags = CFLAGS;
#endif
" )
file( WRITE ${OpenSLL_INCLUDE_PATH}/buildinf.h "${BuildInfH}" )
Expand Down
Loading

0 comments on commit 5f977a7

Please sign in to comment.