Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,8 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install m4
run: choco install gnuwin32-m4 --version=1.4.14 -y
- name: Build x86
run: |
$env:PATH += ";C:\Program Files (x86)\GnuWin32\bin"
cmake -G "Visual Studio 17 2022" -A "win32" -B build32 -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=ON
cmake --build build32 --target ALL_BUILD --config Debug
cmake --build build32 --target ALL_BUILD --config Release
Expand Down Expand Up @@ -111,7 +108,7 @@ jobs:
- uses: actions/checkout@v4
- name: Build
run: |
apk add cmake g++ ninja m4 linux-headers
apk add cmake g++ ninja linux-headers
mkdir build && cd build
cmake -G "Ninja" ../ -DCMAKE_VERBOSE_MAKEFILE=ON -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=ON -DCMAKE_EXE_LINKER_FLAGS=-static
cmake --build .
Expand All @@ -134,7 +131,7 @@ jobs:
-v ${{ github.workspace }}:/workspace \
-w /workspace \
i386/alpine:3.23.3 sh -c '
apk add cmake g++ ninja m4 linux-headers &&
apk add cmake g++ ninja linux-headers &&
mkdir build && cd build &&
cmake -G "Ninja" ../ -DCMAKE_VERBOSE_MAKEFILE=ON -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=ON -DCMAKE_EXE_LINKER_FLAGS=-static &&
cmake --build . &&
Expand Down Expand Up @@ -176,7 +173,7 @@ jobs:
-v ${{ github.workspace }}:/workspace \
-w /workspace \
i386/debian:bookworm sh -c '
apt-get update && apt-get install -y cmake ninja-build g++ m4 &&
apt-get update && apt-get install -y cmake ninja-build g++ &&
mkdir build && cd build &&
cmake -G "Ninja" ../ -DCMAKE_VERBOSE_MAKEFILE=ON -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=ON &&
cmake --build . &&
Expand Down Expand Up @@ -235,7 +232,7 @@ jobs:
- uses: actions/checkout@v4
- name: Build
run: |
apk add cmake mingw-w64-gcc ninja m4
apk add cmake mingw-w64-gcc ninja
mkdir build && cd build
cmake -G "Ninja" ../ -DCMAKE_TOOLCHAIN_FILE="../toolchain_mingw_x64_winblue.cmake" -DCMAKE_VERBOSE_MAKEFILE=ON -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=ON
cmake --build .
Expand All @@ -258,7 +255,7 @@ jobs:
-v ${{ github.workspace }}:/workspace \
-w /workspace \
i386/alpine:3.23.3 sh -c '
apk add cmake mingw-w64-gcc ninja m4 &&
apk add cmake mingw-w64-gcc ninja &&
mkdir build && cd build &&
cmake -G "Ninja" ../ -DCMAKE_TOOLCHAIN_FILE="../toolchain_mingw_x86_winblue.cmake" -DCMAKE_VERBOSE_MAKEFILE=ON -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=ON &&
cmake --build . &&
Expand Down Expand Up @@ -318,7 +315,7 @@ jobs:
with:
usesh: true
prepare: |
pkg install -y cmake ninja m4
pkg install -y cmake ninja
run: |
mkdir build && cd build
cmake -G "Ninja" ../ -DCMAKE_VERBOSE_MAKEFILE=ON -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=ON
Expand All @@ -341,7 +338,7 @@ jobs:
with:
usesh: true
prepare: |
pkg_add cmake ninja m4
pkg_add cmake ninja
run: |
mkdir build && cd build
cmake -G "Ninja" ../ -DCMAKE_VERBOSE_MAKEFILE=ON -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=ON
Expand Down Expand Up @@ -413,7 +410,7 @@ jobs:
- uses: actions/checkout@v4
- uses: egor-tensin/setup-cygwin@v4
with:
packages: cmake gcc-g++ ninja m4
packages: cmake gcc-g++ ninja
- name: Build
shell: C:\tools\cygwin\bin\bash.exe --login -eo pipefail -o igncr {0}
run: |
Expand Down
12 changes: 5 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,13 @@ add_custom_target(
)
set_target_properties(generate_version PROPERTIES FOLDER tinycsocket)

# Header generation (requires GNU m4 for undivert with filename)
find_program(M4_EXECUTABLE gm4 m4 REQUIRED)
# Header generation (concatenates source files into single-header via cmake)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/tinycsocket.h
COMMAND
${M4_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/tinycsocket.h.m4 >
${CMAKE_CURRENT_SOURCE_DIR}/include/tinycsocket.h
DEPENDS ${TINYCSOCKET_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/src/tinycsocket.h.m4
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src
COMMAND ${CMAKE_COMMAND} -DSRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/GenerateHeader.cmake
DEPENDS ${TINYCSOCKET_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/src/tinycsocket.h.in
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(
generate_header
Expand Down
11 changes: 11 additions & 0 deletions cmake/GenerateHeader.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
file(READ "${SRC_DIR}/src/tinycsocket_internal.h" TINYCSOCKET_INTERNAL_H)
file(READ "${SRC_DIR}/src/tinydatastructures.h" TINYDATASTRUCTURES_H)
file(READ "${SRC_DIR}/src/tinycsocket_posix.c" TINYCSOCKET_POSIX_C)
file(READ "${SRC_DIR}/src/tinycsocket_win32.c" TINYCSOCKET_WIN32_C)
file(READ "${SRC_DIR}/src/tinycsocket_common.c" TINYCSOCKET_COMMON_C)

if(NOT OUTPUT)
set(OUTPUT "${SRC_DIR}/include/tinycsocket.h")
endif()

configure_file("${SRC_DIR}/src/tinycsocket.h.in" "${OUTPUT}" @ONLY)
2 changes: 1 addition & 1 deletion include/tinycsocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#ifndef TINYCSOCKET_INTERNAL_H_
#define TINYCSOCKET_INTERNAL_H_

static const char* const TCS_VERSION_TXT = "v0.3.60";
static const char* const TCS_VERSION_TXT = "v0.3.61";
static const char* const TCS_LICENSE_TXT =
"Copyright 2018 Markus Lindelöw\n"
"\n"
Expand Down
11 changes: 5 additions & 6 deletions src/tinycsocket.h.m4 → src/tinycsocket.h.in
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
dnl generate with m4 program `m4 tinycsocket.h.m4 > ../include/tinycsocket.h`
/* Warning! This file is generated by the tinycsocket project. */
#ifndef TINYCSOCKET_HEADER_H_
#define TINYCSOCKET_HEADER_H_
/**********************************/
/********* tinycsocket.h **********/
/**********************************/
undivert(tinycsocket_internal.h)
@TINYCSOCKET_INTERNAL_H@
#ifdef TINYCSOCKET_IMPLEMENTATION
/**********************************/
/****** tinydatastructures.h ******/
/**********************************/
undivert(tinydatastructures.h)
@TINYDATASTRUCTURES_H@
/**********************************/
/****** tinycsocket_posix.h *******/
/**********************************/
undivert(tinycsocket_posix.c)
@TINYCSOCKET_POSIX_C@
/**********************************/
/****** tinycsocket_win32.h *******/
/**********************************/
undivert(tinycsocket_win32.c)
@TINYCSOCKET_WIN32_C@
/**********************************/
/****** tinycsocket_common.h ******/
/**********************************/
undivert(tinycsocket_common.c)
@TINYCSOCKET_COMMON_C@
#endif
#endif
2 changes: 1 addition & 1 deletion src/tinycsocket_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#ifndef TINYCSOCKET_INTERNAL_H_
#define TINYCSOCKET_INTERNAL_H_

static const char* const TCS_VERSION_TXT = "v0.3.60";
static const char* const TCS_VERSION_TXT = "v0.3.61";
static const char* const TCS_LICENSE_TXT =
"Copyright 2018 Markus Lindelöw\n"
"\n"
Expand Down
31 changes: 15 additions & 16 deletions tools/build_msvc.bat
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
choco feature enable -n allowGlobalConfirmation
choco install cmake
choco install gnuwin32-m4 --version=1.4.14
call RefreshEnv.cmd
set PATH=%PATH%;C:\Program Files\CMake\bin\
mkdir build32
cd build32
cmake.exe -G "Visual Studio 17 2022" -A "win32" ../ -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=OFF
cmake.exe --build . --target ALL_BUILD --config Debug
cmake.exe --build . --target ALL_BUILD --config Release
cd ..
mkdir build64
cd build64
cmake.exe -G "Visual Studio 17 2022" -A "x64" ../ -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=OFF
cmake.exe --build . --target ALL_BUILD --config Debug
cmake.exe --build . --target ALL_BUILD --config Release
choco feature enable -n allowGlobalConfirmation
choco install cmake
call RefreshEnv.cmd
set PATH=%PATH%;C:\Program Files\CMake\bin\
mkdir build32
cd build32
cmake.exe -G "Visual Studio 17 2022" -A "win32" ../ -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=OFF
cmake.exe --build . --target ALL_BUILD --config Debug
cmake.exe --build . --target ALL_BUILD --config Release
cd ..
mkdir build64
cd build64
cmake.exe -G "Visual Studio 17 2022" -A "x64" ../ -DTCS_ENABLE_TESTS=ON -DTCS_ENABLE_EXAMPLES=ON -DTCS_WARNINGS_AS_ERRORS=OFF
cmake.exe --build . --target ALL_BUILD --config Debug
cmake.exe --build . --target ALL_BUILD --config Release
10 changes: 7 additions & 3 deletions tools/is_header_up_to_date.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/sh
# Returns 0 if up to date
# Returns 0 if the committed header matches what would be generated
PROJPATH="$(dirname "$(readlink -f "$0")")"/..
cd $PROJPATH/src
m4 tinycsocket.h.m4 | diff $PROJPATH/include/tinycsocket.h -
TMPFILE=$(mktemp)
trap "rm -f $TMPFILE" EXIT

# Generate to temp file
cmake -DSRC_DIR=$PROJPATH -DOUTPUT=$TMPFILE -P $PROJPATH/cmake/GenerateHeader.cmake
diff $PROJPATH/include/tinycsocket.h $TMPFILE
Loading