Skip to content

Commit f6f8dc5

Browse files
authored
Added cmake build and project cleanup (#13)
* Moved sources under src directory. Removed obsolete VS projects * Fixed meson build binaries. Plus further cleanup of directories * Added cmake build files * Fine tuned the cmake projects based on the meson build * Added proper flags for x86 builds * Further cleaning up
1 parent 57a77f0 commit f6f8dc5

File tree

208 files changed

+331
-1098
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+331
-1098
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: build all targets with meson+ninja
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
target: [linux-amd64, linux-i686, linux-armhf, linux-aarch64, windows-x64, windows-x86]
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
- name: Prepare Build Environemnt
14+
run: |
15+
sudo apt-get update
16+
sudo apt-get -y install build-essential python3-virtualenv python3-dev python3-pip ninja-build cmake gcc-i686-linux-gnu
17+
sudo apt-get -y install gcc-arm-linux-gnueabihf pkg-config-arm-linux-gnueabihf libc6-dev-armhf-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross
18+
sudo apt-get -y install gcc-mingw-w64-x86-64 gcc-mingw-w64-i686
19+
virtualenv .venv --python=python3
20+
. .venv/bin/activate
21+
pip3 install --upgrade pip
22+
pip3 install -r requirements.txt
23+
- name: Build
24+
run: |
25+
./.venv/bin/meson build-${{ matrix.target }} --buildtype=release --cross-file tools/cross-compilation/${{ matrix.target }}.txt
26+
ninja -v -C build-${{ matrix.target }}
27+
- name: Upload artifacts
28+
uses: actions/upload-artifact@v2
29+
with:
30+
name: ${{ matrix.target }}
31+
path: |
32+
build-${{ matrix.target }}/qtv
33+
build-${{ matrix.target }}/qtv.exe
34+
if-no-files-found: ignore
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: build all targets with cmake
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
target: [linux-amd64, linux-i686, linux-armhf, linux-aarch64, windows-x64, windows-x86]
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
- name: Prepare Build Environemnt
14+
run: |
15+
sudo apt-get update
16+
sudo apt-get -y install build-essential cmake gcc-i686-linux-gnu
17+
sudo apt-get -y install gcc-arm-linux-gnueabihf pkg-config-arm-linux-gnueabihf libc6-dev-armhf-cross gcc-aarch64-linux-gnu libc6-dev-arm64-cross
18+
sudo apt-get -y install gcc-mingw-w64-x86-64 gcc-mingw-w64-i686
19+
- name: Build
20+
run: |
21+
./build_cmake.sh ${{ matrix.target }}
22+
- name: Upload artifacts
23+
uses: actions/upload-artifact@v2
24+
with:
25+
name: ${{ matrix.target }}
26+
path: |
27+
build/${{ matrix.target }}/qtv
28+
build/${{ matrix.target }}/qtv.exe
29+
if-no-files-found: ignore

.travis.yml

Lines changed: 0 additions & 111 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
cmake_minimum_required(VERSION 3.4.0)
2+
3+
set(CMAKE_VERBOSE_MAKEFILE ON)
4+
5+
# Set project name and languge.
6+
project(qtv C)
7+
8+
9+
######################################################################################################
10+
11+
# Set where sources located.
12+
set(DIR_SRC "src")
13+
14+
# Add sources
15+
set(SRC_COMMON
16+
"${DIR_SRC}/ban.c"
17+
"${DIR_SRC}/build.c"
18+
"${DIR_SRC}/cl_cmds.c"
19+
"${DIR_SRC}/cmd.c"
20+
"${DIR_SRC}/crc.c"
21+
"${DIR_SRC}/cvar.c"
22+
"${DIR_SRC}/forward.c"
23+
"${DIR_SRC}/forward_pending.c"
24+
"${DIR_SRC}/fs.c"
25+
"${DIR_SRC}/httpsv.c"
26+
"${DIR_SRC}/httpsv_generate.c"
27+
"${DIR_SRC}/info.c"
28+
"${DIR_SRC}/main.c"
29+
"${DIR_SRC}/mdfour.c"
30+
"${DIR_SRC}/msg.c"
31+
"${DIR_SRC}/net_utils.c"
32+
"${DIR_SRC}/parse.c"
33+
"${DIR_SRC}/qw.c"
34+
"${DIR_SRC}/source.c"
35+
"${DIR_SRC}/source_cmds.c"
36+
"${DIR_SRC}/sys.c"
37+
"${DIR_SRC}/token.c"
38+
"${DIR_SRC}/sha3.c"
39+
"${DIR_SRC}/udp.c"
40+
)
41+
42+
43+
######################################################################################################
44+
45+
# Set base compiler flags
46+
set(CFLAGS -Wall)
47+
set(LFLAGS)
48+
49+
50+
######################################################################################################
51+
52+
# Set target
53+
add_executable(${PROJECT_NAME} ${SRC_COMMON})
54+
set_target_properties(${PROJECT_NAME}
55+
PROPERTIES #PREFIX "" # Strip lib prefix.
56+
C_VISIBILITY_PRESET hidden # Hide all symbols unless excplicitly marked to export.
57+
)
58+
59+
60+
######################################################################################################
61+
62+
# Set include directories
63+
target_include_directories(${PROJECT_NAME} PRIVATE)
64+
65+
66+
######################################################################################################
67+
68+
# Check build target, and included sources and libs
69+
if(UNIX)
70+
else()
71+
target_link_libraries(${PROJECT_NAME} ws2_32)
72+
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc")
73+
endif()
74+
75+
76+
######################################################################################################
77+
78+
# Assign compiler flags
79+
target_compile_options(${PROJECT_NAME} PRIVATE ${CFLAGS})
80+
81+
82+
######################################################################################################

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ endif
1111

1212
STRIPFLAGS=--strip-unneeded --remove-section=.comment
1313

14-
OBJS = cmd.o crc.o cvar.o forward.o forward_pending.o info.o main.o mdfour.o \
15-
msg.o net_utils.o parse.o qw.o source.o source_cmds.o sys.o build.o token.o httpsv.o httpsv_generate.o \
16-
cl_cmds.o fs.o ban.o udp.o sha3.o
14+
OBJS = src/cmd.o src/crc.o src/cvar.o src/forward.o src/forward_pending.o src/info.o src/main.o src/mdfour.o \
15+
src/msg.o src/net_utils.o src/parse.o src/qw.o src/source.o src/source_cmds.o src/sys.o src/build.o src/token.o src/httpsv.o src/httpsv_generate.o \
16+
src/cl_cmds.o src/fs.o src/ban.o src/udp.o src/sha3.o
1717

18-
qtv: $(OBJS) qtv.h qconst.h
18+
qtv: $(OBJS) src/qtv.h src/qconst.h
1919
$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o $@.db -lm
2020
$(STRIP) $(STRIPFLAGS) $@.db -o $@.bin
2121

build_cmake.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
# Useful if you willing to stop on first error, also prints what is executed.
4+
#set -ex
5+
6+
BUILDIR="${BUILDIR:-build}" # Default build dir.
7+
8+
# Define target platforms, feel free to comment out if you does not require some of it,
9+
# or you can call this script with plaforms list you willing to build on the command line.
10+
DEFAULT_PLATFORMS=(
11+
linux-amd64
12+
linux-aarch64
13+
linux-armhf
14+
linux-i686
15+
windows-x64
16+
windows-x86
17+
)
18+
PLATFORMS=("${@:-${DEFAULT_PLATFORMS[@]}}")
19+
20+
21+
# If V variable is not empty then provide -v argument to cmake --build command (verbose output).
22+
V="${V:-}"
23+
[ ! -z ${V} ] && V="-v"
24+
25+
# Overwrite build type with B variable.
26+
B="${B:-Release}"
27+
[ ! -z ${B} ] && BUILD="-DCMAKE_BUILD_TYPE=${B}"
28+
29+
# The maximum number of concurrent processes to use when building.
30+
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-8}"
31+
32+
# Use specified (with G variable) CMake generator or use default generator (most of the time its make) or ninja if found.
33+
G="${G:-}"
34+
[ -z "${G}" ] && hash ninja >/dev/null 2>&1 && G="Ninja"
35+
[ ! -z "${G}" ] && export CMAKE_GENERATOR="${G}"
36+
37+
rm -rf ${BUILDIR}
38+
mkdir -p ${BUILDIR}
39+
40+
# Build platforms one by one.
41+
for name in "${PLATFORMS[@]}"; do
42+
P="${BUILDIR}/$name"
43+
mkdir -p "${P}"
44+
case "${name}" in
45+
* ) # Build native library.
46+
cmake -B "${P}" -S . ${BUILD} -DCMAKE_TOOLCHAIN_FILE="tools/cross-cmake/${name}.cmake"
47+
cmake --build "${P}" ${V}
48+
;;
49+
esac
50+
done

dotnet2005/qtvprox.sln

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)