-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed build problem. Added CI with github workflows. It can now start…
… without a config file.
- Loading branch information
Showing
25 changed files
with
1,420 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
schedule: | ||
- cron: '0 0 1 * *' # This line schedules the workflow to run at 00:00 on the first day of every month | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
compiler: gcc | ||
- os: ubuntu-latest | ||
compiler: clang | ||
- os: windows-latest | ||
compiler: msvc | ||
- os: macos-latest | ||
compiler: clang | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
|
||
- name: Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/vcpkg | ||
./build/vcpkg_installed | ||
${{ env.HOME }}/.cache/vcpkg/archives | ||
${{ env.XDG_CACHE_HOME }}/vcpkg/archives | ||
${{ env.LOCALAPPDATA }}\vcpkg\archives | ||
${{ env.APPDATA }}\vcpkg\archives | ||
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ env.BUILD_TYPE }}-${{ hashFiles('**/CMakeLists.txt') }}-${{ hashFiles('./vcpkg.json')}} | ||
restore-keys: | | ||
${{ runner.os }}-${{ env.BUILD_TYPE }}- | ||
- name: Setup Cpp | ||
uses: aminya/setup-cpp@v1 | ||
with: | ||
compiler: ${{ matrix.compiler }} | ||
vcvarsall: ${{ contains(matrix.os, 'windows') }} | ||
cmake: true | ||
ninja: true | ||
vcpkg: true | ||
cppcheck: false | ||
|
||
- name: Prepare the PATH | ||
run: | | ||
if [[ "${{ runner.os }}" == "Windows" ]]; then | ||
echo "$env:USERPROFILE\vcpkg" >> $GITHUB_PATH | ||
echo "$env:USERPROFILE\ninja" >> $GITHUB_PATH | ||
else | ||
echo "$HOME/vcpkg" >> $GITHUB_PATH | ||
echo "$HOME/ninja" >> $GITHUB_PATH | ||
fi | ||
shell: bash | ||
|
||
- name: Install dependencies | ||
run: | | ||
vcpkg install | ||
- name: Build project | ||
shell: bash | ||
run: | | ||
if [ -d build ]; then | ||
echo "Build dir exists" | ||
ls -la build | ||
else | ||
mkdir build | ||
#rm -rf build/* | ||
fi | ||
pushd build | ||
cmake .. -DCMAKE_BUILD_TYPE=Release -G "Ninja" -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake | ||
cmake --build . | ||
popd | ||
- name: Install curl | ||
run: | | ||
if [[ "${{ runner.os }}" == "Windows" ]]; then | ||
choco install curl | ||
elif [[ "${{ runner.os }}" == "macOS" ]]; then | ||
brew install curl | ||
else | ||
sudo apt-get install -y curl | ||
fi | ||
shell: bash | ||
|
||
- name: Test shinysocks | ||
run: | | ||
# Start shinysocks in the background | ||
./build/bin/shinysocks -c "" -l debug & | ||
# Save its PID | ||
SHINYSOCKS_PID=$! | ||
# Give shinysocks some time to start | ||
sleep 5 | ||
# Run curl command to verify that shinysocks works | ||
curl -L --socks5-hostname socks5://localhost:1080 https://raw.githubusercontent.com/jgaa/shinysocks/master/ci/test.txt | ||
# Check the exit code of the curl command | ||
if [ $? -ne 0 ]; then | ||
# If the curl command failed, fail the workflow | ||
echo "Curl command failed" | ||
exit 1 | ||
fi | ||
# Kill the shinysocks program | ||
kill $SHINYSOCKS_PID | ||
shell: bash | ||
|
||
- name: Prepare artifacts | ||
run: | | ||
mkdir -p artifacts | ||
cp build/bin/* artifacts/ | ||
cp shinysocks.conf artifacts/ | ||
- name: Archive artifacts | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: shinysocks-${{ matrix.os }}-${{ matrix.compiler }} | ||
path: artifacts/* | ||
retention-days: 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
|
||
.vs/ | ||
out/ | ||
*.user | ||
build/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,55 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
project(shinysocks) | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
project (shinysocks VERSION 1.3.1 LANGUAGES CXX) | ||
|
||
option(BOOST_ERROR_CODE_HEADER_ONLY "Work-around for another boost issue" ON) | ||
if (BOOST_ERROR_CODE_HEADER_ONLY) | ||
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY=1) | ||
if(WIN32) | ||
set (WINVER "0x0601" CACHE STRING "Value for _WIN32_WINNT") | ||
add_definitions(-D_WIN32_WINNT=${WINVER}) | ||
endif() | ||
|
||
project(shinysocks | ||
DESCRIPTION "Socks Proxy server" | ||
HOMEPAGE_URL https://github.com/jgaa/shinysocks | ||
VERSION 1.3.2 | ||
LANGUAGES CXX | ||
) | ||
|
||
add_definitions(-DSHINYSOCKS_VERSION=\"${CMAKE_PROJECT_VERSION}\") | ||
|
||
include(cmake/external-projects.cmake) | ||
include(cmake/3rdparty.cmake) | ||
|
||
find_package(Threads REQUIRED) | ||
|
||
if(NOT DEFINED USE_BOOST_VERSION) | ||
set(USE_BOOST_VERSION 1.65) | ||
set(USE_BOOST_VERSION 1.69) | ||
endif() | ||
|
||
set(Boost_USE_MULTITHREADED ON) | ||
if (UNIX) | ||
find_package(Boost REQUIRED COMPONENTS | ||
find_package(Boost ${USE_BOOST_VERSION} REQUIRED COMPONENTS | ||
system | ||
program_options | ||
serialization | ||
filesystem | ||
date_time | ||
iostreams | ||
regex | ||
context | ||
coroutine | ||
chrono | ||
thread | ||
) | ||
endif() | ||
|
||
if (WIN32) | ||
include_directories(${BOOST_ROOT}) | ||
message(STATUS "Boost root: ${BOOST_ROOT}") | ||
link_directories(${BOOST_LIBRARYDIR}) | ||
add_definitions(-D_WIN32_WINNT=0x0600) | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") | ||
# Msvc and possible some other Windows-compilers will link | ||
# to the correct libraries trough #pragma directives in boost headers. | ||
#SET(BOOST_UNIT_TEST_FRAMEWORK libboost_test_exec_monitor-vc140-mt-sgd-1_57) | ||
else () | ||
set(LIB_BOOST_PROGRAM_OPTIONS boost_program_options) | ||
set(LIB_BOOST_SERIALIZATION boost_serialization) | ||
set(LIB_BOOST_FILESYSTEM boost_filesystem) | ||
set(LIB_BOOST_DATE_TIME boost_date_time) | ||
set(LIB_BOOST_IOSTREAMS boost_iostreams) | ||
set(LIB_BOOST_SYSTEM boost_system) | ||
set(LIB_BOOST_REGEX boost_regex) | ||
set(LIB_BOOST_CONTEXT boost_context) | ||
set(LIB_BOOST_COROUTINE boost_coroutine) | ||
set(LIB_BOOST_CHRONO boost_chrono) | ||
set(LIB_BOOST_THREAD boost_thread) | ||
set(LIB_BOOST_LOG boost_log boost_log_setup) | ||
SET(BOOST_UNIT_TEST_FRAMEWORK boost_unit_test_framework) | ||
endif () | ||
|
||
if (UNIX) | ||
set (BOOST_LIBRARIES | ||
${LIB_BOOST_SYSTEM} | ||
${LIB_BOOST_PROGRAM_OPTIONS} | ||
${LIB_BOOST_SERIALIZATION} | ||
${LIB_BOOST_FILESYSTEM} | ||
${LIB_BOOST_DATE_TIME} | ||
${LIB_BOOST_IOSTREAMS} | ||
${LIB_BOOST_REGEX} | ||
${LIB_BOOST_CONTEXT} | ||
${LIB_BOOST_COROUTINE} | ||
${LIB_BOOST_CHRONO} | ||
${LIB_BOOST_LOG} | ||
${LIB_BOOST_THREAD} | ||
context | ||
) | ||
endif() | ||
|
||
if (UNIX) | ||
set(THREADLIBS pthread) | ||
endif() | ||
|
||
if (UNIX) | ||
# For now, assume we use g++/clang++ | ||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG=1 -o3 ") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1 -D_DEBUG=1 -o0 -g ") | ||
add_definitions(-D__USE_LARGEFILE64=1 -D__USE_FILE_OFFSET64=1 -D BOOST_LOG_DYN_LINK -Wall -fPIC -std=c++1y -pthread) | ||
endif() | ||
add_executable(${PROJECT_NAME} Manager.cpp Listener.cpp Proxy.cpp main.cpp shinysocks.h logging.h) | ||
add_dependencies(${PROJECT_NAME} logfault) | ||
|
||
include_directories(${Boost_INCLUDE_DIR}) | ||
|
||
add_executable(shinysocks Manager.cpp Listener.cpp Proxy.cpp main.cpp shinysocks.h logging.h) | ||
add_dependencies(shinysocks externalLogfault) | ||
## Boost libraries tend to use boost depricated stuff and create lots of drama in the compile output | ||
target_compile_definitions(shinysocks PUBLIC -DBOOST_COROUTINE_NO_DEPRECATION_WARNING=1 -DBOOST_ALLOW_DEPRECATED_HEADERS=1 -DBOOST_COROUTINES_NO_DEPRECATION_WARNING=1) | ||
target_link_libraries(shinysocks ${BOOST_LIBRARIES} ${THREADLIBS}) | ||
set_target_properties(${PROJECT_NAME} | ||
PROPERTIES | ||
CXX_STANDARD 17 | ||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" | ||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" | ||
) | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
PRIVATE | ||
${Boost_LIBRARIES} | ||
$<BUILD_INTERFACE:${stdc++fs}> | ||
$<BUILD_INTERFACE:Threads::Threads> | ||
) | ||
|
||
install(TARGETS shinysocks RUNTIME DESTINATION bin) | ||
|
||
message ("VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.