Skip to content

Commit

Permalink
Modify CI for CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
namazso committed Jun 24, 2023
1 parent dac4a67 commit 3abe557
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 59 deletions.
81 changes: 29 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,60 +48,37 @@ jobs:
Echo ("version_minor=" + $VersionMinor) >> $Env:GITHUB_OUTPUT;
Echo ("version_patch=" + $VersionPatch) >> $Env:GITHUB_OUTPUT;
- name: Set up MSBuild
uses: microsoft/setup-msbuild@v1

- name: Build Algorithms
run: |
cd ${{ github.workspace }}
.\build_algorithms.ps1
# - name: Build Solution (Win32)
# run: |
# msbuild "-property:Configuration=Release;Platform=x86;CI_VERSION=${{ steps.checktag.outputs.version }};CI_VERSION_MAJOR=${{ steps.checktag.outputs.version_major }};CI_VERSION_MINOR=${{ steps.checktag.outputs.version_minor }};CI_VERSION_PATCH=${{ steps.checktag.outputs.version_patch }}" OpenHashTab.sln
#
# - name: Build Solution (x64)
# run: |
# msbuild "-property:Configuration=Release;Platform=x64;CI_VERSION=${{ steps.checktag.outputs.version }};CI_VERSION_MAJOR=${{ steps.checktag.outputs.version_major }};CI_VERSION_MINOR=${{ steps.checktag.outputs.version_minor }};CI_VERSION_PATCH=${{ steps.checktag.outputs.version_patch }}" OpenHashTab.sln
#
# - name: Build Solution (ARM64)
# run: |
# msbuild "-property:Configuration=Release;Platform=ARM64;CI_VERSION=${{ steps.checktag.outputs.version }};CI_VERSION_MAJOR=${{ steps.checktag.outputs.version_major }};CI_VERSION_MINOR=${{ steps.checktag.outputs.version_minor }};CI_VERSION_PATCH=${{ steps.checktag.outputs.version_patch }}" OpenHashTab.sln
#
# - name: Build Installer
# run: |
# iscc .\installer.iss -DCI_VERSION="${{ steps.checktag.outputs.version }}" -DCI_VERSION_NUMERIC="${{ steps.checktag.outputs.version_major }}.${{ steps.checktag.outputs.version_minor }}.${{ steps.checktag.outputs.version_patch }}"
#
# - name: Pack artifacts
# run: |
# 7z a artifacts.7z .\bin\Release\
#
# - name: Upload setup
# uses: actions/upload-artifact@v3
# with:
# name: setup
# path: |
# .\OpenHashTab_setup.exe
#
# - name: Upload artifacts
# uses: actions/upload-artifact@v3
# with:
# name: artifacts
# path: |
# .\artifacts.7z
#
# - name: Pack release symbols
# if: ${{ steps.checktag.outputs.is_release == 'yes' }}
# run: |
# cd ${{ github.workspace }}
# 7z a symbols.7z .\bin\Release\*\*.pdb
#
# - name: Release
# uses: softprops/action-gh-release@v1
# if: ${{ steps.checktag.outputs.is_release == 'yes' }}
# with:
# files: |
# .\OpenHashTab_setup.exe
# asset_path: .\symbols.7z
# name: Release ${{ steps.checktag.outputs.version }}
# prerelease: true
- name: Build OpenHashTab
run: |
cd ${{ github.workspace }}
$Env:CI_VERSION = ${{ steps.checktag.outputs.version }};
$Env:CI_VERSION_MAJOR = ${{ steps.checktag.outputs.version_major }};
$Env:CI_VERSION_MINOR = ${{ steps.checktag.outputs.version_minor }};
$Env:CI_VERSION_PATCH = ${{ steps.checktag.outputs.version_patch }};
.\build_openhashtab.ps1
- name: Build Installer
run: |
iscc .\installer.iss -DCI_VERSION="${{ steps.checktag.outputs.version }}" -DCI_VERSION_NUMERIC="${{ steps.checktag.outputs.version_major }}.${{ steps.checktag.outputs.version_minor }}.${{ steps.checktag.outputs.version_patch }}"
- name: Upload Installer
uses: actions/upload-artifact@v3
with:
name: setup
path: |
.\OpenHashTab_setup.exe
- name: Release
uses: softprops/action-gh-release@v1
if: ${{ steps.checktag.outputs.is_release == 'yes' }}
with:
files: |
.\OpenHashTab_setup.exe
asset_path: .\symbols.7z
name: Release ${{ steps.checktag.outputs.version }}
prerelease: true
2 changes: 2 additions & 0 deletions AlgorithmsDlls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ foreach (FLAVOR ${FLAVORS})
PROPERTY IMPORTED_IMPLIB "${CMAKE_CURRENT_SOURCE_DIR}/AlgorithmsDll_${FLAVOR}.lib")
set_property(TARGET "AlgorithmsDll_${FLAVOR}"
PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/AlgorithmsDll_${FLAVOR}.dll")
set_property(TARGET "AlgorithmsDll_${FLAVOR}"
PROPERTY PDB_NAME "${CMAKE_CURRENT_SOURCE_DIR}/AlgorithmsDll_${FLAVOR}.pdb")
target_link_options("AlgorithmsDll_${FLAVOR}" INTERFACE "/DELAYLOAD:AlgorithmsDll_${FLAVOR}")

target_link_libraries(AlgorithmsDlls INTERFACE "AlgorithmsDll_${FLAVOR}")
Expand Down
13 changes: 9 additions & 4 deletions OpenHashTab/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,19 @@ target_compile_definitions(OpenHashTab PRIVATE
UNICODE
_UNICODE
_WINDLL
CI_VERSION=\"blah\"
CI_VERSION_MAJOR=1
CI_VERSION_MINOR=1
CI_VERSION_PATCH=1
"CI_VERSION=\"${CI_VERSION}\""
"CI_VERSION_MAJOR=${CI_VERSION_MAJOR}"
"CI_VERSION_MINOR=${CI_VERSION_MINOR}"
"CI_VERSION_PATCH=${CI_VERSION_PATCH}"
)

target_compile_options(OpenHashTab PRIVATE
/EHsc
)

target_precompile_headers(OpenHashTab PRIVATE stdafx.h)

add_custom_command(TARGET OpenHashTab POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_RUNTIME_DLLS:OpenHashTab> $<TARGET_FILE_DIR:OpenHashTab>
COMMAND_EXPAND_LISTS
)
58 changes: 58 additions & 0 deletions build_openhashtab.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
$VSRoot = (& vswhere -property installationPath);

function Invoke-CmdScript {
param(
[String] $scriptName
)
$cmdLine = """$scriptName"" $args & set"
& $Env:SystemRoot\system32\cmd.exe /c $cmdLine |
Select-String '^([^=]*)=(.*)$' | ForEach-Object {
$varName = $_.Matches[0].Groups[1].Value
$varValue = $_.Matches[0].Groups[2].Value
Set-Item Env:$varName $varValue
}
}

$Env:RC = "llvm-rc";

$Environment = (Get-ChildItem Env:);

Invoke-CmdScript "$VSRoot\VC\Auxiliary\Build\vcvars64.bat"

cmake `
-G Ninja `
-S . `
-B "cmake-openhashtab-x64" `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_C_COMPILER=clang-cl `
-DCMAKE_CXX_COMPILER=clang-cl `
"-DCI_VERSION=$Env:CI_VERSION" `
"-DCI_VERSION_MINOR=$Env:CI_VERSION_MINOR" `
"-DCI_VERSION_MAJOR=$Env:CI_VERSION_MAJOR" `
"-DCI_VERSION_PATCH=$Env:CI_VERSION_PATCH"
cmake --build "cmake-openhashtab-x64"

Remove-Item -Path Env:*
$Environment | % { Set-Item "env:$($_.Name)" $_.Value }

Invoke-CmdScript "$VSRoot\VC\Auxiliary\Build\vcvarsamd64_arm64.bat"
$ExtraFlags = "--target=arm64-pc-windows-msvc";

Set-Item Env:CFLAGS $ExtraFlags
Set-Item Env:CXXFLAGS $ExtraFlags

cmake `
-G Ninja `
-S . `
-B "cmake-openhashtab-ARM64" `
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_C_COMPILER=clang-cl `
-DCMAKE_CXX_COMPILER=clang-cl `
"-DCI_VERSION=$Env:CI_VERSION" `
"-DCI_VERSION_MINOR=$Env:CI_VERSION_MINOR" `
"-DCI_VERSION_MAJOR=$Env:CI_VERSION_MAJOR" `
"-DCI_VERSION_PATCH=$Env:CI_VERSION_PATCH"
cmake --build "cmake-openhashtab-ARM64"

Remove-Item -Path Env:*
$Environment | % { Set-Item "env:$($_.Name)" $_.Value }
15 changes: 12 additions & 3 deletions installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ VersionInfoProductTextVersion={#CI_VERSION}
VersionInfoVersion={#CI_VERSION_NUMERIC}
ChangesAssociations = yes
UninstallDisplayIcon={app}\OpenHashTab.dll,0
ArchitecturesAllowed=x64 arm64
ArchitecturesInstallIn64BitMode=x64 arm64

[Languages]
Name: "en"; MessagesFile: "compiler:Default.isl"
Expand Down Expand Up @@ -82,9 +84,16 @@ Name: "ChineseSimplified"; MessagesFile: "Localization\isl\ChineseSimplified.isl
Name: "ChineseTraditional"; MessagesFile: "Localization\isl\ChineseTraditional.isl"

[Files]
Source: "bin\Release\Win32\*.dll"; DestDir: "{app}"; Flags: ignoreversion solidbreak restartreplace 32bit; Check: InstallArch('x86')
Source: "bin\Release\x64\*.dll"; DestDir: "{app}"; Flags: ignoreversion solidbreak restartreplace 64bit; Check: InstallArch('x64')
Source: "bin\Release\ARM64\*.dll"; DestDir: "{app}"; Flags: ignoreversion solidbreak restartreplace 64bit; Check: InstallArch('arm64')
Source: "AlgorithmsDlls\*.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace;
Source: "AlgorithmsDlls\*.pdb"; DestDir: "{app}"; Flags: ignoreversion restartreplace;

Source: "cmake-openhashtab-x64\OpenHashTab.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace 64bit; Check: InstallArch('x64')
Source: "cmake-openhashtab-x64\StandaloneStub.exe"; DestDir: "{app}"; Flags: ignoreversion restartreplace 64bit; Check: InstallArch('x64')
Source: "cmake-openhashtab-x64\*.pdb"; DestDir: "{app}"; Flags: ignoreversion restartreplace 64bit; Check: InstallArch('x64')

Source: "cmake-openhashtab-ARM64\OpenHashTab.dll"; DestDir: "{app}"; Flags: ignoreversion restartreplace 64bit; Check: InstallArch('ARM64')
Source: "cmake-openhashtab-ARM64\StandaloneStub.exe"; DestDir: "{app}"; Flags: ignoreversion restartreplace 64bit; Check: InstallArch('ARM64')
Source: "cmake-openhashtab-ARM64\*.pdb"; DestDir: "{app}"; Flags: ignoreversion restartreplace 64bit; Check: InstallArch('ARM64')

[CustomMessages]
GroupDescription=Optional features:
Expand Down

0 comments on commit 3abe557

Please sign in to comment.