Skip to content

Commit ed6885e

Browse files
committed
- update to conan v2
- update readme - remove old obsolete repos from readme, use github actions to create releases and packages - reproducible build job - build tests for 3 different variants - small lint warn fix. Will do more linting and analyzing on code soon without touching any functionality.
1 parent 6e09fdf commit ed6885e

7 files changed

Lines changed: 237 additions & 107 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,82 @@ 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:
1510
runs-on: ubuntu-latest
11+
container:
12+
image: debian:bookworm
1613

1714
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
15+
- uses: actions/checkout@v4
16+
17+
- name: Install dependencies
18+
run: apt-get -y update && apt-get install -y libgmp-dev build-essential cmake
19+
20+
- name: Cmake pass 1
21+
run: cmake -G "Unix Makefiles" -B./build1 -DCMAKE_BUILD_TYPE=$BUILD_TYPE
22+
23+
- name: Build pass 1
24+
run: cmake --build ./build1
25+
26+
- name: Cmake pass 2
27+
run: cmake -G "Unix Makefiles" -B./build2 -DCMAKE_BUILD_TYPE=$BUILD_TYPE
28+
29+
- name: Build pass 2
30+
run: cmake --build ./build2
31+
32+
- name: Check hashes
33+
run: |
34+
ls -la build1
35+
hash1=$(sha256sum build1/libbncsutil.so | cut -d ' ' -f 1)
36+
hash2=$(sha256sum build2/libbncsutil.so | cut -d ' ' -f 1)
37+
echo "Hash 1: $hash1\n"
38+
echo "Hash 2: $hash2\n"
39+
[ "$hash1" = "$hash2" ] && exit 0 || exit 1
40+
41+
build-debian-conan:
42+
runs-on: ubuntu-latest
43+
container:
44+
image: debian:bookworm
45+
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- name: Install dependencies
50+
run: apt-get -y update && apt-get install -y python3 python3-pip build-essential cmake
51+
52+
- name: Install conan
53+
run: pip install conan --break-system-packages
54+
55+
- name: Init conan
56+
run: conan profile detect
57+
58+
- name: Install deps with conan
59+
run: conan install . -of ./build -s build_type=Release --build=missing
60+
61+
- name: Cmake
62+
working-directory: ./build
63+
run: bash conanbuild.sh && cmake .. -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DUSE_SYSTEM_LIBS=0
64+
65+
- name: Build
66+
working-directory: ./build
67+
run: cmake --build .
68+
69+
build-fedora-system:
70+
runs-on: ubuntu-latest
71+
container:
72+
image: fedora:latest
73+
74+
steps:
75+
- uses: actions/checkout@v4
76+
77+
- name: Install dependencies
78+
run: dnf -y install gmp-devel make automake clang cmake
79+
80+
- name: Cmake
81+
run: cmake -G "Unix Makefiles" -B./build -DCMAKE_BUILD_TYPE=$BUILD_TYPE
3482

3583
- 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
84+
run: cmake --build ./build

.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: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,57 @@ 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.c"
30+
"src/bncsutil/sha1.h"
31+
"src/bncsutil/stack.h"
1432
)
15-
file(GLOB HEADERS
16-
"src/bncsutil/*.h"
33+
34+
set(SOURCES
35+
"src/bncsutil/bsha1.cpp"
36+
"src/bncsutil/cdkeydecoder.cpp"
37+
"src/bncsutil/checkrevision.cpp"
38+
"src/bncsutil/decodekey.cpp"
39+
"src/bncsutil/file.cpp"
40+
"src/bncsutil/libinfo.cpp"
41+
"src/bncsutil/oldauth.cpp"
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()
@@ -39,22 +66,15 @@ endif()
3966

4067
if (USE_SYSTEM_LIBS)
4168
find_package(GMP REQUIRED)
42-
include_directories(src ${GMP_INCLUDE_DIR})
43-
target_link_libraries(${PROJECT_NAME} ${GMP_LIBRARIES})
69+
target_include_directories(bncsutil PRIVATE src ${GMP_INCLUDE_DIR})
70+
target_link_libraries(bncsutil ${GMP_LIBRARIES})
4471
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()
72+
find_package(gmp REQUIRED)
73+
target_include_directories(bncsutil PRIVATE src gmp:gmp)
74+
target_link_libraries(bncsutil PRIVATE gmp:gmp)
5575
endif()
5676

57-
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME bncsutil)
77+
set_target_properties(bncsutil PROPERTIES OUTPUT_NAME bncsutil)
5878

5979
if(UNIX)
6080
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

README.md

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ been maintained over the course of several years by the open source Battle.net c
1616
## Usage
1717
Add `bncsutil.h` to your include directory and link against `bncsutil.lib` or `libbncsutil.so`.
1818

19-
## Building with conan and CMake
20-
Conan will automatically install mpir on Windows and gmp on non-Windows platforms.
19+
## Building
2120

2221
To force a specific build (32bit or 64bit) add `-DCMAKE_GENERATOR_PLATFORM=x86` or `-DCMAKE_GENERATOR_PLATFORM=x64` to CMake flags.
2322

@@ -35,58 +34,31 @@ cmake -G "Visual Studio 16 2019" -B./build -DBUILD_SHARED_LIBS=1 -DCMAKE_GENERAT
3534
```
3635

3736
### Linux
37+
38+
#### Using system dependencies
39+
Instead of using conan you can link against system provided gmp. Install `libgmp-dev` on deb distros or `gmp-devel` on rpm distros. For 32bit builds, CMake will not warn you if you are missing 32bit glibc and GMP, you must install them manually first (CentOS/Fedora: `glibc-devel.i686` and `gmp-devel.i686`).
40+
3841
```
39-
conan install . -if ./build
4042
cmake -G "Unix Makefiles" -B./build
4143
cd build && make && make install
4244
```
4345

44-
## Building using system dependencies
45-
Instead of using conan you can link against system provided gmp. Install `libgmp-dev` on deb distros or `gmp-devel` on rpm distros. For 32bit builds, CMake will not warn you if you are missing 32bit glibc and GMP, you must install them manually first (CentOS/Fedora: `glibc-devel.i686` and `gmp-devel.i686`).
46+
#### Using conan
47+
If you are using pyenv or building python3 from source, make sure you have the following packages installed first:
48+
```
49+
sudo apt-get install libbz2-dev liblzma-dev
50+
```
4651

4752
```
48-
cmake -G "Unix Makefiles" -B./build -DUSE_SYSTEM_LIBS=1
53+
conan install . -of build -s build_type=Release --build=missing
54+
cmake -G "Unix Makefiles" -B./build -DUSE_SYSTEM_LIBS=0
4955
cd build && make && make install
5056
```
5157

5258
## Building .deb and .rpm packages
5359
After invoking CMake, cd to build folder and generate them with `cpack -G "DEB"` and `cpack -G "RPM"`.
5460
You can then use `gdebi` to do a local install of .deb with automatic dependency resolution or `yum localinstall` on rpm distros. For dnf it's `dnf install <name>.rpm`.
5561

56-
## Hosted Linux repositories
57-
DEB and RPM repositories are maintained with best effort.
58-
59-
### Debian 8 and 9 (amd64)
60-
1. To `/etc/apt/sources.list` add:
61-
62-
#### 9
63-
```
64-
#apt.xpam.pl
65-
deb http://apt.xpam.pl/debian9/ bnetdocs-stretch main
66-
```
67-
#### 8
68-
```
69-
#apt.xpam.pl
70-
deb http://apt.xpam.pl/debian8/ bnetdocs-jessie main
71-
```
72-
73-
2. Add GPG key: `wget -qO - https://apt.xpam.pl/xpam.pl-pubkey.asc | sudo apt-key add -`
74-
3. Update and install: `sudo apt-get update && sudo apt-get install bncsutil`
75-
62+
Note that this is a "devel" package which also includes header files.
7663

77-
### Centos 7
78-
```
79-
yum -y install yum-utils
80-
yum-config-manager --add-repo https://centos7.rpm.xpam.pl
81-
yum-config-manager --enable https://centos7.rpm.xpam.pl
82-
rpm --import https://centos7.rpm.xpam.pl/xpam.pl-pubkey.asc
83-
yum -y install bncsutil
84-
```
85-
### Centos 6
86-
```
87-
yum -y install yum-utils
88-
yum-config-manager --add-repo https://centos6.rpm.xpam.pl
89-
yum-config-manager --enable https://centos6.rpm.xpam.pl
90-
rpm --import https://centos6.rpm.xpam.pl/xpam.pl-pubkey.asc
91-
yum -y install bncsutil
92-
```
64+
Library installs go to `/usr/lib`, include files in `/usr/include/bncsutil`.

0 commit comments

Comments
 (0)