Skip to content

Commit

Permalink
Win
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Metsma <raul@metsma.ee>
  • Loading branch information
metsma committed Oct 22, 2024
1 parent f7070f4 commit c348f8a
Show file tree
Hide file tree
Showing 16 changed files with 266 additions and 213 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
103 changes: 103 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Windows

on:
pull_request:
paths:
- '**.c'
- '**.h'
- '**.sh'
- .github/workflows/windows.yml
- '**.am'
- doc/**
- configure.ac
push:

permissions:
contents: read # to fetch code (actions/checkout)

jobs:
build:
runs-on: ${{ matrix.image }}
strategy:
matrix:
platform: [x86, x64]
configuration: [Light, Release]
image: [windows-2022]
include:
- configuration: Release
nmake: "ZLIBSTATIC_DEF=/DENABLE_ZLIB_STATIC ZLIB_INCL_DIR=/I{0}\\installed\\{1}\\include ZLIB_LIB={0}\\installed\\{1}\\lib\\zlib.lib OPENSSL_DEF=/DENABLE_OPENSSL OPENSSL_DIR={0}\\installed\\{1} OPENSSL_LIB={0}\\installed\\{1}\\lib\\libcrypto.lib OPENSSL_EXTRA_CFLAGS=/DOPENSSL_SECURE_MALLOC_SIZE=65536"
env:
OPENPACE_VER: 1.1.3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Git describe
id: ghd
uses: proudust/gh-describe@v2
- name: Package name
shell: bash
run: |
echo PACKAGE_NAME=OpenSC-${{ steps.ghd.outputs.tag }} >> $GITHUB_ENV
echo ARTIFACT=OpenSC-${{ steps.ghd.outputs.tag }}_${{ matrix.platform == 'x86' && 'win32' || 'win64' }}${{ matrix.configuration == 'Light' && '-Light' || '' }} >> $GITHUB_ENV
- name: Install CPDK
run: choco install windows-cryptographic-provider-development-kit -y > $null
- name: Install autotools
uses: msys2/setup-msys2@v2
with:
update: true
install: autotools mingw-w64-x86_64-pkg-config
- name: Bootstrap
shell: msys2 {0}
run: ./bootstrap
- name: Configure
shell: bash
run: ./configure --disable-openssl --disable-readline --disable-zlib || cat config.log
- name: Setup dev env
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.platform }}
- name: Prepare vcpkg
if: matrix.configuration == 'Release'
uses: lukka/run-vcpkg@v7
with:
vcpkgArguments: zlib openssl
vcpkgGitCommitId: 18b028fe785e707265fa0e35590b7537ae1d12ea
vcpkgTriplet: ${{ matrix.platform }}-windows-static
- name: Build OpenPACE
if: matrix.configuration == 'Release'
run: |
Invoke-WebRequest "https://github.com/frankmorgner/openpace/archive/${env:OPENPACE_VER}.zip" -OutFile openpace.zip
tar xf openpace.zip
cd openpace-${env:OPENPACE_VER}\src
cl /nologo /W3 /GS /MT /I${env:RUNVCPKG_VCPKG_ROOT}\installed\${env:RUNVCPKG_VCPKG_TRIPLET}\include /I. `
/DX509DIR="\\\"/\\\"" /DCVCDIR="\\\"/\\\"" /D_CRT_SECURE_NO_DEPRECATE /DWIN32_LEAN_AND_MEAN `
/DHAVE_ASN1_STRING_GET0_DATA=1 /DHAVE_DECL_OPENSSL_ZALLOC=1 /DHAVE_DH_GET0_KEY=1 /DHAVE_DH_GET0_PQG=1 `
/DHAVE_DH_SET0_KEY=1 /DHAVE_DH_SET0_PQG=1 /DHAVE_ECDSA_SIG_GET0=1 /DHAVE_ECDSA_SIG_SET0=1 `
/DHAVE_EC_KEY_METHOD=1 /DHAVE_RSA_GET0_KEY=1 /DHAVE_RSA_SET0_KEY=1 /DHAVE_EC_POINT_GET_AFFINE_COORDINATES=1 `
/DHAVE_EC_POINT_SET_AFFINE_COORDINATES=1 /c `
ca_lib.c cv_cert.c cvc_lookup.c x509_lookup.c eac_asn1.c eac.c eac_ca.c eac_dh.c `
eac_ecdh.c eac_kdf.c eac_lib.c eac_print.c eac_util.c misc.c pace.c pace_lib.c `
pace_mappings.c ri.c ri_lib.c ta.c ta_lib.c objects.c ssl_compat.c
lib /nologo /out:libeac.lib `
ca_lib.obj cv_cert.obj cvc_lookup.obj x509_lookup.obj eac_asn1.obj eac.obj eac_ca.obj eac_dh.obj `
eac_ecdh.obj eac_kdf.obj eac_lib.obj eac_print.obj eac_util.obj misc.obj pace.obj pace_lib.obj `
pace_mappings.obj ri.obj ri_lib.obj ta.obj ta_lib.obj objects.obj ssl_compat.obj
- name: Build OpenSC
run: nmake /f Makefile.mak ${{ format(matrix.nmake, env.RUNVCPKG_VCPKG_ROOT, env.RUNVCPKG_VCPKG_TRIPLET) }}
- name: Build Installer
run: |
cd win32 && nmake /nologo /f Makefile.mak ${{ format(matrix.nmake, env.RUNVCPKG_VCPKG_ROOT, env.RUNVCPKG_VCPKG_TRIPLET) }} OpenSC.msi
move OpenSC.msi "..\\OpenSC-${{ env.ARTIFACT }}.msi"
- name: Debug symbols
run: |
md ${env:ARTIFACT}-Debug
Get-ChildItem -recurse . -exclude vc*.pdb *.pdb | % {
7z a -tzip ${env:ARTIFACT}-Debug.zip $_.FullName
}
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: msi_${{ matrix.platform }}_${{ matrix.configuration }}
path: |
./*.msi
./*-Debug.zip
10 changes: 0 additions & 10 deletions Makefile.mak
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@ SUBDIRS = etc win32 src

default: all

32:
CALL "C:\Program Files\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86
$(MAKE) /f Makefile.mak opensc.msi PLATFORM=x86 OPENPACE_DIR=C:\openpace-Win32_1.0.2
MOVE win32\OpenSC.msi OpenSC_win32.msi

64:
CALL "C:\Program Files\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
$(MAKE) /f Makefile.mak opensc.msi OPENPACE_DIR=C:\openpace-Win64_1.0.2
MOVE win32\OpenSC.msi OpenSC_win64.msi

opensc.msi:
$(MAKE) /f Makefile.mak all OPENSSL_DEF=/DENABLE_OPENSSL OPENPACE_DEF=/DENABLE_OPENPACE"
@cmd /c "cd win32 && $(MAKE) /nologo /f Makefile.mak opensc.msi OPENSSL_DEF=/DENABLE_OPENSSL OPENPACE_DEF=/DENABLE_OPENPACE"
Expand Down
83 changes: 21 additions & 62 deletions win32/Make.rules.mak
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,9 @@ OPENSC_FEATURES = pcsc
#Include support for minidriver
MINIDRIVER_DEF = /DENABLE_MINIDRIVER

#Build MSI with the Windows Installer XML (WIX) toolkit, requires WIX >= 3.9
!IF "$(WIX)" == ""
# at least WiX 3.11 sets the WIX environment variable to its path
WIX = C:\Program Files\WiX Toolset v3.10
!ENDIF
!IF "$(DEVENVDIR)" == "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\" || "$(DEVENVDIR)" == "C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\"
WIXVSVER = VS2010
!ENDIF
!IF "$(VISUALSTUDIOVERSION)" == "12.0"
WIXVSVER = VS2013
!ENDIF
!IF "$(VISUALSTUDIOVERSION)" == "14.0"
WIXVSVER = VS2015
!ENDIF
!IF "$(VISUALSTUDIOVERSION)" == "15.0"
WIXVSVER = VS2017
!ENDIF
!IF "$(VISUALSTUDIOVERSION)" == "16.0"
WIXVSVER = VS2019
!ENDIF
WIX_INCL_DIR = "/I$(WIX)\SDK\$(WIXVSVER)\inc"
WIX_LIBS = "$(WIX)\SDK\$(WIXVSVER)\lib\$(PLATFORM)\dutil.lib" "$(WIX)\SDK\$(WIXVSVER)\lib\$(PLATFORM)\wcautil.lib"
#Build MSI with the Windows Installer XML (WIX) toolkit, requires WIX >= 3.14
WIX_INCL_DIR = "/I$(WIX)\SDK\VS2017\inc"
WIX_LIBS = "$(WIX)\SDK\VS2017\lib\$(PLATFORM)\dutil.lib" "$(WIX)\SDK\VS2017\lib\$(PLATFORM)\wcautil.lib"

# We do not build tests on windows
#TESTS_DEF = /DENABLE_TESTS
Expand Down Expand Up @@ -54,31 +35,22 @@ OPENSSL_INCL_DIR = /I$(OPENSSL_DIR)\include
#define OPENSSL_STATIC if you have visual studio compatible with OpenSSL's static binaries
OPENSSL_STATIC_DIR = static

!IF "$(OPENSSL_LIB)" == ""
!IF "$(DEBUG_DEF)" == "/DDEBUG"
!IF "$(PLATFORM)" == "x86"
# OpenSSL 1.0.2
#OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libeay32MTd.lib user32.lib advapi32.lib crypt32.lib ws2_32.lib
# OpenSSL 1.1.0
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libcrypto32MTd.lib user32.lib advapi32.lib crypt32.lib ws2_32.lib
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libcrypto32MTd.lib
!ELSE
# OpenSSL 1.0.2
#OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libeay32MTd.lib user32.lib advapi32.lib crypt32.lib ws2_32.lib
# OpenSSL 1.1.0
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libcrypto64MTd.lib user32.lib advapi32.lib crypt32.lib ws2_32.lib
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libcrypto64MTd.lib
!ENDIF
!ELSE
!IF "$(PLATFORM)" == "x86"
# OpenSSL 1.0.2
#OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libeay32MT.lib user32.lib advapi32.lib crypt32.lib ws2_32.lib
# OpenSSL 1.1.0
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libcrypto32MT.lib user32.lib advapi32.lib crypt32.lib ws2_32.lib
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libcrypto32MT.lib
!ELSE
# OpenSSL 1.0.2
#OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libeay32MT.lib user32.lib advapi32.lib crypt32.lib ws2_32.lib
# OpenSSL 1.1.0
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libcrypto64MT.lib user32.lib advapi32.lib crypt32.lib ws2_32.lib
OPENSSL_LIB = $(OPENSSL_DIR)\lib\VC\$(OPENSSL_STATIC_DIR)\libcrypto64MT.lib
!ENDIF
!ENDIF
!ENDIF
OPENSSL_LIB = $(OPENSSL_LIB) user32.lib advapi32.lib crypt32.lib ws2_32.lib

PROGRAMS_OPENSSL = cryptoflex-tool.exe pkcs15-init.exe netkey-tool.exe piv-tool.exe \
westcos-tool.exe sc-hsm-tool.exe dnie-tool.exe gids-tool.exe
Expand Down Expand Up @@ -135,38 +107,25 @@ CANDLEFLAGS = -dOpenPACE="$(OPENPACE_DIR)" $(CANDLEFLAGS)


# Used for MiniDriver
CNGSDK_INCL_DIR = "/IC:\Program Files (x86)\Microsoft CNG Development Kit\Include"
CPDK_INCL_DIR = "/IC:\Program Files (x86)\Windows Kits\10\Cryptographic Provider Development Kit\Include"
!IF "$(PROCESSOR_ARCHITECTURE)" == "x86" && "$(PROCESSOR_ARCHITEW6432)" == ""
CNGSDK_INCL_DIR = "/IC:\Program Files\Microsoft CNG Development Kit\Include"
CPDK_INCL_DIR = "/IC:\Program Files\Windows Kits\10\Cryptographic Provider Development Kit\Include"
!ENDIF
# Mandatory path to 'ISO C9x compliant stdint.h and inttypes.h for Microsoft Visual Studio'
# http://msinttypes.googlecode.com/files/msinttypes-r26.zip
# INTTYPES_INCL_DIR = /IC:\opensc\dependencies\msys\local
CPDK_INCL_DIR = "/IC:\Program Files (x86)\Windows Kits\10\Cryptographic Provider Development Kit\Include"

# Code optimisation
# O1 - minimal code size
CODE_OPTIMIZATION = /O1

ALL_INCLUDES = /I$(TOPDIR)\win32 /I$(TOPDIR)\src $(OPENPACE_INCL_DIR) $(OPENSSL_INCL_DIR) $(OPENSSL_EXTRA_CFLAGS) $(ZLIB_INCL_DIR) $(LIBLTDL_INCL) $(INTTYPES_INCL_DIR) $(CPDK_INCL_DIR) $(CNGSDK_INCL_DIR) $(WIX_INCL_DIR)
COPTS = /nologo /GS /W3 /WX /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_WARNINGS /DHAVE_CONFIG_H /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\""
COPTS = $(COPTS) $(OPENPACE_DEF) $(OPENSSL_DEF) $(ZLIB_DEF) $(MINIDRIVER_DEF) $(SM_DEF) $(TESTS_DEF) $(OPENSSL_EXTRA_CFLAGS)
COPTS = $(COPTS) /I$(TOPDIR)\win32 /I$(TOPDIR)\src $(OPENPACE_INCL_DIR) $(OPENSSL_INCL_DIR) $(ZLIB_INCL_DIR) $(LIBLTDL_INCL) $(CPDK_INCL_DIR) $(WIX_INCL_DIR)
LINKFLAGS = /NOLOGO /INCREMENTAL:NO /MACHINE:$(PLATFORM) /NXCOMPAT /DYNAMICBASE /DEBUG /NODEFAULTLIB:MSVCRT /NODEFAULTLIB:MSVCRTD
LIBFLAGS = /nologo /machine:$(PLATFORM)
CANDLEFLAGS = -arch $(PLATFORM) $(CANDLEFLAGS)

!IF "$(DEBUG_DEF)" == "/DDEBUG"
LINKDEBUGFLAGS = /NODEFAULTLIB:LIBCMT /DEBUG
LINKFLAGS = $(LINKFLAGS) /NODEFAULTLIB:LIBCMT
CODE_OPTIMIZATION =
COPTS = /GS /W3 /WX /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_WARNINGS /MTd /nologo /DHAVE_CONFIG_H $(ALL_INCLUDES) /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN $(OPENPACE_DEF) $(OPENSSL_DEF) $(ZLIB_DEF) $(MINIDRIVER_DEF) $(SM_DEF) $(TESTS_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\"" /DDEBUG /Zi /Od
!ELSE
LINKDEBUGFLAGS = /NODEFAULTLIB:LIBCMTD /DEBUG /OPT:REF /OPT:ICF
COPTS = /GS /W3 /WX /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_WARNINGS /MT /nologo /DHAVE_CONFIG_H $(ALL_INCLUDES) /DWINVER=0x0601 /D_WIN32_WINNT=0x0601 /DWIN32_LEAN_AND_MEAN $(OPENPACE_DEF) $(OPENSSL_DEF) $(ZLIB_DEF) $(MINIDRIVER_DEF) $(SM_DEF) $(TESTS_DEF) /DOPENSC_FEATURES="\"$(OPENSC_FEATURES)\"" /Zi
!ENDIF


LINKFLAGS = /NOLOGO /INCREMENTAL:NO /MACHINE:$(PLATFORM) /NODEFAULTLIB:MSVCRTD /NODEFAULTLIB:MSVCRT /NXCOMPAT /DYNAMICBASE $(LINKDEBUGFLAGS)
LIBFLAGS = /nologo /machine:$(PLATFORM)
!IF "$(PLATFORM)" == "x86"
CANDLEFLAGS = -dPlatform=x86 $(CANDLEFLAGS)
COPTS = $(COPTS) /MTd /DDEBUG /Zi /Od
!ELSE
CANDLEFLAGS = -dPlatform=x64 $(CANDLEFLAGS)
LINKFLAGS = $(LINKFLAGS) /NODEFAULTLIB:LIBCMTD /OPT:REF /OPT:ICF
COPTS = $(COPTS) /MT /Zi
!ENDIF

.c.obj::
Expand Down
2 changes: 1 addition & 1 deletion win32/Makefile.mak
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ customactions.dll: versioninfo-customactions.res customactions.obj
link /dll $(LINKFLAGS) /def:$*.def /out:customactions.dll versioninfo-customactions.res customactions.obj msi.lib $(WIX_LIBS) Advapi32.lib User32.lib Version.lib Shell32.lib

OpenSC.msi: OpenSC.wixobj
"$(WIX)\bin\light.exe" -sh -ext WixUIExtension -ext WiXUtilExtension $?
"$(WIX)\bin\light.exe" -ext WixUIExtension -ext WiXUtilExtension $?

OpenSC.wixobj: OpenSC.wxs customactions.dll
"$(WIX)\bin\candle.exe" -ext WiXUtilExtension -dSOURCE_DIR=$(TOPDIR) $(CANDLEFLAGS) OpenSC.wxs
Expand Down
Loading

0 comments on commit c348f8a

Please sign in to comment.