Skip to content

Commit cd4f2fc

Browse files
authored
Merge pull request #18 from cen1/feature/refresh
Tooling refresh and CI improvements
2 parents 6e09fdf + d727968 commit cd4f2fc

File tree

7 files changed

+295
-123
lines changed

7 files changed

+295
-123
lines changed

.github/workflows/cmake.yml

Lines changed: 103 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,114 @@ name: CMake
33
on: [push]
44

55
env:
6-
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
76
BUILD_TYPE: Release
87

98
jobs:
10-
build:
11-
# The CMake configure and build commands are platform agnostic and should work equally
12-
# well on Windows or Mac. You can convert this to a matrix build if you need
13-
# cross-platform coverage.
14-
# See: https://docs.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow#configuring-a-build-matrix
9+
build-debian-system-reproducible:
10+
if: true
1511
runs-on: ubuntu-latest
12+
container:
13+
image: debian:bookworm
1614

1715
steps:
18-
- uses: actions/checkout@v2
19-
20-
- name: Create Build Environment
21-
# Some projects don't allow in-source building, so create a separate build directory
22-
# We'll use this as our working directory for all subsequent commands
23-
run: cmake -E make_directory ${{runner.workspace}}/build
24-
25-
- name: Configure CMake
26-
# Use a bash shell so we can use the same syntax for environment variable
27-
# access regardless of the host operating system
28-
shell: bash
29-
working-directory: ${{runner.workspace}}/build
30-
# Note the current convention is to use the -S and -B options here to specify source
31-
# and build directories, but this is only available with CMake 3.13 and higher.
32-
# The CMake binaries on the Github Actions machines are (as of this writing) 3.12
33-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
16+
- uses: actions/checkout@v4
17+
18+
- name: Install dependencies
19+
run: apt-get -y update && apt-get install -y libgmp-dev build-essential cmake
20+
21+
- name: Cmake pass 1
22+
run: cmake -G "Unix Makefiles" -B./build1 -DCMAKE_BUILD_TYPE=$BUILD_TYPE
23+
24+
- name: Build pass 1
25+
run: cmake --build ./build1
26+
27+
- name: Cmake pass 2
28+
run: cmake -G "Unix Makefiles" -B./build2 -DCMAKE_BUILD_TYPE=$BUILD_TYPE
29+
30+
- name: Build pass 2
31+
run: cmake --build ./build2
32+
33+
- name: Check hashes
34+
run: |
35+
ls -la build1
36+
hash1=$(sha256sum build1/libbncsutil.so | cut -d ' ' -f 1)
37+
hash2=$(sha256sum build2/libbncsutil.so | cut -d ' ' -f 1)
38+
echo "Hash 1: $hash1\n"
39+
echo "Hash 2: $hash2\n"
40+
[ "$hash1" = "$hash2" ] && exit 0 || exit 1
41+
42+
build-debian-conan:
43+
if: true
44+
runs-on: ubuntu-latest
45+
container:
46+
image: debian:bookworm
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Install dependencies
52+
run: apt-get -y update && apt-get install -y python3 python3-pip build-essential cmake
53+
54+
- name: Install conan
55+
run: pip install conan --break-system-packages
56+
57+
- name: Init conan
58+
run: conan profile detect
59+
60+
- name: Install deps with conan
61+
run: conan install . -of ./build -s build_type=Release --build=missing
62+
63+
- name: Cmake
64+
working-directory: ./build
65+
run: bash conanbuild.sh && cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSE_SYSTEM_LIBS=0
3466

3567
- name: Build
36-
working-directory: ${{runner.workspace}}/build
37-
shell: bash
38-
# Execute the build. You can specify a specific target with "--target <NAME>"
39-
run: cmake --build . --config $BUILD_TYPE
40-
41-
- name: Test
42-
working-directory: ${{runner.workspace}}/build
43-
shell: bash
44-
# Execute tests defined by the CMake configuration.
45-
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
46-
run: ctest -C $BUILD_TYPE
68+
working-directory: ./build
69+
run: cmake --build .
70+
71+
build-fedora-system:
72+
if: true
73+
runs-on: ubuntu-latest
74+
container:
75+
image: fedora:latest
76+
77+
steps:
78+
- uses: actions/checkout@v4
79+
80+
- name: Install dependencies
81+
run: dnf -y install gmp-devel make automake clang cmake
82+
83+
- name: Cmake
84+
run: cmake -G "Unix Makefiles" -B./build -DCMAKE_BUILD_TYPE=$BUILD_TYPE
85+
86+
- name: Build
87+
run: cmake --build ./build
88+
89+
build-windows-conan:
90+
if: true
91+
runs-on: windows-latest
92+
93+
steps:
94+
- uses: actions/checkout@v4
95+
96+
- uses: TheMrMilchmann/setup-msvc-dev@v3
97+
with:
98+
arch: x64
99+
100+
- name: Install Conan
101+
id: conan
102+
uses: turtlebrowser/get-conan@main
103+
104+
- name: Init conan
105+
run: conan profile detect
106+
107+
- name: Install dependencies
108+
shell: cmd
109+
run: conan install . -of build -s build_type=Release -o *:shared=False --build=missing
110+
111+
- name: Build
112+
shell: cmd
113+
working-directory: ./build
114+
run: .\conanbuild.bat && cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DBUILD_SHARED_LIBS=1 && cmake --build . --config Release
115+
116+

.github/workflows/release.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
env:
9+
BUILD_TYPE: Release
10+
11+
jobs:
12+
deb:
13+
runs-on: ubuntu-latest
14+
container:
15+
image: debian:bookworm
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install dependencies
21+
run: apt-get -y update && apt-get install -y libgmp-dev build-essential cmake
22+
23+
- name: Cmake
24+
run: cmake -G "Unix Makefiles" -B./build -DCMAKE_BUILD_TYPE=$BUILD_TYPE
25+
26+
- name: Build
27+
run: cmake --build ./build
28+
29+
- name: Package
30+
id: package
31+
working-directory: build
32+
run: |
33+
cpack -G "DEB" -D CPACK_PACKAGE_FILE_NAME=libbncsutil-${{ github.ref_name }}-devel
34+
35+
- uses: actions/upload-artifact@v4
36+
with:
37+
retention-days: 1
38+
overwrite: true
39+
name: libbncsutil-${{ github.ref_name }}-devel.deb
40+
path: build/libbncsutil-${{ github.ref_name }}-devel.deb
41+
42+
rpm:
43+
runs-on: ubuntu-latest
44+
container:
45+
image: fedora:latest
46+
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: Install dependencies
51+
run: dnf -y install gmp-devel make automake clang cmake rpm-build
52+
53+
- name: Cmake
54+
run: cmake -G "Unix Makefiles" -B./build -DCMAKE_BUILD_TYPE=$BUILD_TYPE
55+
56+
- name: Build
57+
run: cmake --build ./build
58+
59+
- name: Package
60+
working-directory: build
61+
run: cpack -G "RPM" -D CPACK_PACKAGE_FILE_NAME=libbncsutil-${{ github.ref_name }}-devel
62+
63+
- uses: actions/upload-artifact@v4
64+
with:
65+
retention-days: 1
66+
overwrite: true
67+
name: libbncsutil-${{ github.ref_name }}-devel.rpm
68+
path: build/libbncsutil-${{ github.ref_name }}-devel.rpm
69+
70+
release:
71+
needs: [deb, rpm]
72+
runs-on: ubuntu-latest
73+
74+
steps:
75+
- name: Download deb
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: libbncsutil-${{ github.ref_name }}-devel.deb
79+
80+
- name: Download rpm
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: libbncsutil-${{ github.ref_name }}-devel.rpm
84+
85+
- name: Create GitHub Release
86+
uses: softprops/action-gh-release@v1
87+
with:
88+
files: |
89+
libbncsutil-${{ github.ref_name }}-devel.deb
90+
libbncsutil-${{ github.ref_name }}-devel.rpm
91+
tag_name: ${{ github.ref_name }}
92+
env:
93+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ conan.lock
4040
conanbuildinfo.txt
4141
conaninfo.txt
4242
graph_info.json
43+
CMakeUserPresets.json

CMakeLists.txt

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,62 @@
1+
cmake_minimum_required(VERSION 3.25)
12
project(bncsutil)
2-
cmake_minimum_required(VERSION 3.2)
33

44
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} "${PROJECT_SOURCE_DIR}/CMake/Modules")
55
message(${CMAKE_BINARY_DIR})
66

77
SET(VERSION_MAJOR "1")
88
SET(VERSION_MINOR "4")
9-
SET(VERSION_PATCH "1")
10-
11-
file(GLOB SOURCE
12-
"src/bncsutil/*.cpp"
13-
"src/bncsutil/*.c"
9+
SET(VERSION_PATCH "2")
10+
11+
add_library(bncsutil SHARED)
12+
13+
set(HEADERS
14+
"src/bncsutil/bncsutil.h"
15+
"src/bncsutil/bsha1.h"
16+
"src/bncsutil/buffer.h"
17+
"src/bncsutil/cdkeydecoder.h"
18+
"src/bncsutil/checkrevision.h"
19+
"src/bncsutil/decodekey.h"
20+
"src/bncsutil/file.h"
21+
"src/bncsutil/keytables.h"
22+
"src/bncsutil/libinfo.h"
23+
"src/bncsutil/ms_stdint.h"
24+
"src/bncsutil/mutil.h"
25+
"src/bncsutil/mutil_types.h"
26+
"src/bncsutil/nls.h"
27+
"src/bncsutil/oldauth.h"
28+
"src/bncsutil/pe.h"
29+
"src/bncsutil/sha1.h"
30+
"src/bncsutil/stack.h"
1431
)
15-
file(GLOB HEADERS
16-
"src/bncsutil/*.h"
32+
33+
set(SOURCES
34+
"src/bncsutil/bsha1.cpp"
35+
"src/bncsutil/cdkeydecoder.cpp"
36+
"src/bncsutil/checkrevision.cpp"
37+
"src/bncsutil/decodekey.cpp"
38+
"src/bncsutil/file.cpp"
39+
"src/bncsutil/libinfo.cpp"
40+
"src/bncsutil/oldauth.cpp"
41+
"src/bncsutil/sha1.c"
1742
)
1843

19-
add_library(${PROJECT_NAME} ${SOURCE} ${HEADERS})
44+
target_sources(bncsutil PRIVATE ${SOURCES} ${HEADERS})
2045

2146
if (WIN32)
22-
set(USE_GMP 0)
47+
set(USE_SYSTEM_LIBS 0)
48+
else()
49+
set(USE_SYSTEM_LIBS 1)
2350
endif()
2451

2552
if (CMAKE_GENERATOR_PLATFORM EQUAL "x86")
26-
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
53+
set_target_properties(bncsutil PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
2754
MESSAGE(STATUS "Excluding 64bit library paths from search.")
2855
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS OFF)
2956
set(ARCH_DEB i386)
3057
set(ARCH_RPM i686)
3158
elseif (CMAKE_GENERATOR_PLATFORM EQUAL "x64")
32-
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m64" LINK_FLAGS "-m64")
59+
set_target_properties(bncsutil PROPERTIES COMPILE_FLAGS "-m64" LINK_FLAGS "-m64")
3360
set(ARCH_DEB amd64)
3461
set(ARCH_RPM x86_64)
3562
else()
@@ -38,27 +65,22 @@ else()
3865
endif()
3966

4067
if (USE_SYSTEM_LIBS)
68+
message("Using system dependencies")
4169
find_package(GMP REQUIRED)
42-
include_directories(src ${GMP_INCLUDE_DIR})
43-
target_link_libraries(${PROJECT_NAME} ${GMP_LIBRARIES})
70+
target_include_directories(bncsutil PRIVATE src ${GMP_INCLUDE_DIR})
71+
target_link_libraries(bncsutil ${GMP_LIBRARIES})
4472
else()
45-
if (USE_GMP)
46-
find_package(gmp REQUIRED)
47-
target_include_directories(${PROJECT_NAME} PRIVATE src gmp:gmp)
48-
target_link_libraries(${PROJECT_NAME} PRIVATE gmp:gmp)
49-
else()
50-
find_package(mpir REQUIRED)
51-
target_include_directories(${PROJECT_NAME} PRIVATE src mpir::mpir)
52-
target_link_libraries(${PROJECT_NAME} PRIVATE mpir::mpir)
53-
add_definitions(-DUSE_MPIR=1)
54-
endif()
73+
message("Using conan dependencies")
74+
find_package(gmp REQUIRED)
75+
target_include_directories(bncsutil PRIVATE src gmp::gmp)
76+
target_link_libraries(bncsutil PRIVATE gmp::gmp)
5577
endif()
5678

57-
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME bncsutil)
79+
set_target_properties(bncsutil PROPERTIES OUTPUT_NAME bncsutil)
5880

5981
if(UNIX)
60-
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
61-
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION 1)
82+
set_target_properties(bncsutil PROPERTIES VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
83+
set_target_properties(bncsutil PROPERTIES SOVERSION 1)
6284

6385
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3 -Wno-multichar -fPIC")
6486
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -Wno-multichar -fPIC")
@@ -77,7 +99,7 @@ install(FILES ${HEADERS} DESTINATION include/bncsutil)
7799

78100
#CPack configurtion
79101
SET(CPACK_GENERATOR "DEB" "RPM")
80-
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
102+
SET(CPACK_PACKAGE_NAME "bncsutil")
81103
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Battle.Net Chat Service Utility")
82104
SET(CPACK_PACKAGE_VENDOR "bncsutil")
83105
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
@@ -96,7 +118,7 @@ SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libgmp10")
96118
#RPM configuration
97119
SET(CPACK_RPM_PACKAGE_RELEASE 1)
98120
SET(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
99-
SET(CPACK_RPM_PACKAGE_GROUP "${PROJECT_NAME}")
121+
SET(CPACK_RPM_PACKAGE_GROUP "bncsutil")
100122
SET(CPACK_RPM_PACKAGE_URL "https://github.com/BNETDocs/bncsutil")
101123
SET(CPACK_RPM_PACKAGE_REQUIRES "gmp")
102124
SET(CPACK_RPM_PACKAGE_ARCHITECTURE ${ARCH_RPM})

0 commit comments

Comments
 (0)