Skip to content

Commit 291b6a4

Browse files
committed
Update github workflow
1 parent f1e54c7 commit 291b6a4

9 files changed

Lines changed: 161 additions & 62 deletions

File tree

.github/workflows/multi-os-build.yml

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -9,62 +9,71 @@ on:
99

1010
jobs:
1111
build-linux:
12-
1312
runs-on: ubuntu-latest
14-
13+
strategy:
14+
matrix:
15+
shared: [true, false]
1516
steps:
16-
1717
- name: Install packages
1818
uses: delgurth/get-package@v6
1919
with:
2020
# Space-separated list of packages to install using apt-get. Will only run if on ubuntu.
21-
apt-get: libssl-dev
22-
21+
apt-get: libssl-dev cmake binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686
2322
- name: Checkout with submodules
24-
uses: actions/checkout@v3
25-
with:
26-
submodules: 'true'
27-
23+
uses: actions/checkout@v4
24+
- name: config shared=${{ matrix.shared }}
25+
run: >-
26+
cmake
27+
-Bbuild
28+
-DBUILD_SHARED_LIBS=${{ matrix.shared }}
2829
- name: Compile
29-
run: make
30-
31-
32-
build-osx:
30+
run: cmake --build build
31+
- name: test
32+
run: ctest --test-dir build -V
3333

34+
build-osx:
3435
runs-on: macos-latest
35-
3636
steps:
37-
3837
- name: Checkout with submodules
39-
uses: actions/checkout@v3
40-
with:
41-
submodules: 'true'
42-
38+
uses: actions/checkout@v4
39+
- name: config
40+
run: >-
41+
cmake
42+
-Bbuild
43+
-DENABLE_TESTS=Off
4344
- name: Compile
44-
run: CFLAGS="-I$(brew --prefix openssl@1.1)/include/" LDFLAGS="-L$(brew --prefix openssl@1.1)/lib/" make
45+
run: cmake --build build
46+
# - name: Compile
47+
# run: CFLAGS="-I$(brew --prefix openssl@1.1)/include/" LDFLAGS="-L$(brew --prefix openssl@1.1)/lib/" make
4548

4649
build-win64:
47-
4850
runs-on: windows-latest
49-
5051
steps:
51-
5252
- name: Install Cygwin
5353
# You may pin to the exact commit or the version.
5454
# uses: egor-tensin/setup-cygwin@4f96f9fecb8c952fa32ff791b0a77d93d5191bb4
55-
uses: egor-tensin/setup-cygwin@v3
55+
uses: egor-tensin/setup-cygwin@v4
5656
with:
5757
platform: x64 # optional, default is x64
5858
install-dir: c:\tools\cygwin # optional, default is C:\tools\cygwin
59-
packages: gcc-core binutils make zip libssl-devel # optional
60-
59+
packages: gcc-core gcc-g++ binutils make zip libssl-devel cmake # optional
6160
- name: Checkout with submodules
62-
uses: actions/checkout@v3
63-
with:
64-
submodules: 'true'
65-
61+
uses: actions/checkout@v4
62+
shell: C:\tools\cygwin\bin\bash.exe --login '{0}'
63+
- name: config
64+
run: >-
65+
cmake
66+
-Bbuild
67+
-DENABLE_TESTS=Off
68+
shell: C:\tools\cygwin\bin\bash.exe --login '{0}'
6669
- name: Compile
67-
run: make
68-
69-
- name: Compile Windows-only tools and create a ZIP package
70-
run: make zip
70+
run: cmake --build build
71+
shell: C:\tools\cygwin\bin\bash.exe --login '{0}'
72+
- name: pack
73+
run: cd build cpack -G CYGWIN_BINARY
74+
shell: C:\tools\cygwin\bin\bash.exe --login '{0}'
75+
# - name: Compile
76+
# run: make
77+
# - name: Compile Windows-only tools and create a ZIP package
78+
# run: make zip
79+

CMakeLists.txt

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
cmake_minimum_required(VERSION 3.30)
1+
cmake_minimum_required(VERSION 3.20.0)
22
project(readpe)
33

44
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
55

66
option(BUILD_DISASSEMBLER "Build with basic disassembler support (deprecated)" OFF)
7-
option(BUILD_STATIC "Build static executable" Off)
7+
option(BUILD_LEGACY "Build support for legacy executables by link name" ON)
88
option(BUILD_STANDALONE "Build separate executables" OFF)
9+
option(BUILD_STATIC "Build static executable" Off)
910
option(ENABLE_TESTS "Enable testing" On)
1011

1112
if(BUILD_DISASSEMBLER)
@@ -20,3 +21,28 @@ if(ENABLE_TESTS)
2021
include("${CMAKE_SOURCE_DIR}/cmake/tests.cmake")
2122
endif()
2223

24+
set(
25+
CPACK_PACKAGE_NAME ${PROJECT_NAME}
26+
CACHE STRING "The resulting package name"
27+
)
28+
29+
30+
set(CPACK_STRIP_FILES YES)
31+
32+
33+
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
34+
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
35+
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
36+
37+
38+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
39+
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
40+
41+
42+
include(CPack)
43+
configure_file ("${PROJECT_SOURCE_DIR}/cmake/cpackopt.cmake.in"
44+
"${PROJECT_BINARY_DIR}/cpackopt.cmake"
45+
@ONLY)
46+
set (CPACK_PROJECT_CONFIG_FILE
47+
"${PROJECT_BINARY_DIR}/cpackopt.cmake")
48+

cmake/TC-mingw64.cmake

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,20 @@ set(CMAKE_SYSTEM_NAME Windows)
55
# enable_language(C,CXX)
66

77
# which compilers to use for C and C++
8-
set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
9-
set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
8+
find_program(GNUCCi686W86Mingw32 NAMES
9+
i686-w64-mingw32-gcc
10+
i686-w64-mingw32-gcc-win32
11+
i686-w64-mingw32-gcc-posix
12+
REQUIRED
13+
)
14+
find_program(GNUPlusPlusi686W86Mingw32 NAMES
15+
i686-w64-mingw32-g++
16+
i686-w64-mingw32-g++-win32
17+
i686-w64-mingw32-g++-posix
18+
REQUIRED
19+
)
20+
set(CMAKE_C_COMPILER ${GNUCCi686W86Mingw32})
21+
set(CMAKE_CXX_COMPILER ${GNUPlusPlusi686W86Mingw32})
1022

1123
# where is the target environment located
1224
set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)

cmake/cpackopt.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@_CPACK_OTHER_VARIABLES_@
2+

lib/libpe/CMakeLists.txt

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,17 @@ set(SOURCES
4040
utils.c
4141
)
4242

43-
add_library(pe STATIC ${HEADERS} ${SOURCES})
44-
target_include_directories(pe PRIVATE "include")
43+
find_package(OpenSSL REQUIRED)
44+
45+
if(BUILD_STATIC)
46+
add_library(pe STATIC ${HEADERS} ${SOURCES})
47+
else()
48+
add_library(pe SHARED ${HEADERS} ${SOURCES})
49+
endif()
50+
51+
target_link_libraries(pe PRIVATE OpenSSL::Crypto OpenSSL::SSL )
52+
53+
target_include_directories(pe PRIVATE "include" ${OPENSSL_INCLUDE_DIR} )
4554
if(MSVC)
4655
target_compile_options(pe PRIVATE /W4 /WX)
4756
else()
@@ -58,3 +67,11 @@ else()
5867
)
5968
endif()
6069

70+
install(TARGETS pe
71+
EXPORT peTargets
72+
LIBRARY DESTINATION lib
73+
ARCHIVE DESTINATION lib
74+
RUNTIME DESTINATION bin
75+
INCLUDES DESTINATION include/libpe
76+
)
77+

src/CMakeLists.txt

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ set(HEADERS
1414
../include/stack.h
1515

1616
dylib.h
17-
legacy.h
1817
)
1918

2019
set(SOURCES
@@ -41,20 +40,28 @@ set(SOURCES
4140
certificates.c
4241
scan.c
4342

44-
legacy/pehash.c
45-
legacy/peldd.c
46-
legacy/pepack.c
47-
legacy/peres.c
48-
legacy/pescan.c
49-
legacy/pesec.c
50-
legacy/pestr.c
51-
legacy/readpe.c
52-
legacy/ofs2rva.c
53-
legacy/rva2ofs.c
5443
)
5544

56-
if(BUILD_DISASSEMBLER)
57-
list(APPEND SOURCES legacy/pedis.c )
45+
if(BUILD_LEGACY)
46+
if(BUILD_DISASSEMBLER)
47+
list(APPEND SOURCES legacy/pedis.c )
48+
endif()
49+
50+
list(APPEND HEADERS
51+
legacy.h
52+
)
53+
list(APPEND SOURCES
54+
legacy/pehash.c
55+
legacy/peldd.c
56+
legacy/pepack.c
57+
legacy/peres.c
58+
legacy/pescan.c
59+
legacy/pesec.c
60+
legacy/pestr.c
61+
legacy/readpe.c
62+
legacy/ofs2rva.c
63+
legacy/rva2ofs.c
64+
)
5865
endif()
5966

6067
if(BUILD_STATIC)
@@ -82,8 +89,6 @@ add_compile_definitions(
8289
PLUGINSDIR="src/plugins"
8390
)
8491

85-
86-
8792
find_package(OpenSSL)
8893

8994
add_executable(readpe ${HEADERS} ${SOURCES})
@@ -95,10 +100,17 @@ target_include_directories(readpe PRIVATE
95100

96101
target_link_libraries(readpe PRIVATE pe OpenSSL::Crypto m)
97102

98-
if(BUILD_DISASSEMBLER)
99-
target_link_libraries(readpe PRIVATE udis86)
100-
target_compile_definitions(readpe
101-
READPE_DISASSEMBLER=1
103+
104+
if(BUILD_LEGACY)
105+
if(BUILD_DISASSEMBLER)
106+
target_link_libraries(readpe PRIVATE udis86)
107+
target_compile_definitions(readpe PRIVATE
108+
READPE_DISASSEMBLER=1
109+
)
110+
endif()
111+
112+
target_compile_definitions(readpe PRIVATE
113+
READPE_LEGACY=1
102114
)
103115
endif()
104116

@@ -119,3 +131,10 @@ else()
119131
)
120132
endif()
121133

134+
install(TARGETS readpe
135+
LIBRARY DESTINATION lib
136+
ARCHIVE DESTINATION lib
137+
RUNTIME DESTINATION bin
138+
INCLUDES DESTINATION include
139+
)
140+

src/main.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@
3636

3737
#include "common.h"
3838
#include "config.h"
39-
#include "legacy.h"
4039
#include "modes.h"
4140
#include "output.h"
4241
#include "readpe.h"
4342

43+
#ifdef READPE_LEGACY
44+
#include "legacy.h"
45+
#endif
46+
4447
#include <getopt.h>
4548
#include <libpe/context.h>
4649
#include <libpe/error.h>
@@ -302,6 +305,7 @@ static const struct mode_option base_mode[] = {
302305

303306
// ------------------------------------------------------------------------- //
304307

308+
#ifdef READPE_LEGACY
305309
static void legacy(int argc, char *argv[])
306310
{
307311
const char *bin_name = strrchr(argv[0], '/');
@@ -332,7 +336,7 @@ static void legacy(int argc, char *argv[])
332336
else if (bin_name[2] == 'd' && bin_name[3] == 'i') {
333337
exit(pedis(argc, argv));
334338
}
335-
#endif
339+
#endif // READPE_DISASSEMBLER
336340
} else if (bin_name[2] == 'l' && bin_name[3] == 'd'
337341
&& bin_name[4] == 'd') {
338342
exit(peldd(argc, argv));
@@ -350,6 +354,7 @@ static void legacy(int argc, char *argv[])
350354
// }
351355
// }
352356
}
357+
#endif // READPE_LEGACY
353358

354359
// -------------------------------------------------------------------------
355360

@@ -723,7 +728,9 @@ static const char *parse_options(int argc, char *argv[])
723728

724729
int main(int argc, char *argv[])
725730
{
731+
#ifdef READPE_LEGACY
726732
legacy(argc, argv);
733+
#endif // READPE_LEGACY
727734

728735
// Print help when no arguments are given
729736
if (argc < 2) {

src/plugins/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,10 @@ add_library(html SHARED output/html.c)
55
add_library(json SHARED output/json.c)
66
add_library(xml SHARED output/xml.c)
77

8+
install(TARGETS csv html json xml
9+
LIBRARY DESTINATION share/readpe/plugins
10+
ARCHIVE DESTINATION share/readpe/plugins
11+
RUNTIME DESTINATION bin
12+
INCLUDES DESTINATION include/readpe
13+
)
14+

t/texe/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.30)
1+
cmake_minimum_required(VERSION 3.20)
22
project(texe)
33

44
# Test EXEcutable

0 commit comments

Comments
 (0)