Skip to content

Commit

Permalink
first draft of windows ci (#393)
Browse files Browse the repository at this point in the history
* first draft of windows ci

* fix

* fix manifest

* fixes

* fix

* manifest in root

* keep trying

* remove -GNinja for now

* changes

* Add a new way to get ninja

* remove ninja

* more fixes

* .

* remove cache for now

* rev vcpkg

* fix package name

* changes

* try calling ninja directly

* try again

* more changes

* typo

* more fixes

* windows only

* windows only v2

* More fixes and upload exe

* fix debug on windows.  more ci stuff

* try to support unix/mac

* remove linux os update.  add .a extension

* more linux fixes

* only use vcpkg curl on windows
  • Loading branch information
MisterTea authored Feb 14, 2021
1 parent faf2e6f commit 3942bea
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 22 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/linux_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y apt-get install -y libssl-dev libcurl4-openssl-dev libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
sudo DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y apt-get -y upgrade
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git submodule update --init --force --recursive
Expand All @@ -44,7 +43,6 @@ jobs:
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y apt-get install -y libssl-dev libcurl4-openssl-dev libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
sudo DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y apt-get -y upgrade
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git submodule update --init --force --recursive
Expand All @@ -71,7 +69,6 @@ jobs:
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y apt-get install -y libssl-dev libcurl4-openssl-dev libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
sudo DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y apt-get -y upgrade
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git submodule update --init --force --recursive
Expand All @@ -98,7 +95,6 @@ jobs:
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y apt-get install -y libssl-dev libcurl4-openssl-dev libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
sudo DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y apt-get -y upgrade
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git submodule update --init --force --recursive
Expand All @@ -125,7 +121,6 @@ jobs:
echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y apt-get install -y libssl-dev libcurl4-openssl-dev libunwind-dev git cmake gdb protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++ lcov
sudo DEBIAN_FRONTEND=noninteractive ACCEPT_EULA=Y apt-get -y upgrade
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git submodule update --init --force --recursive
Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/vcpkg_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Vcpkg Build
on:
push:
pull_request:

jobs:
build_vcpkg:
name: build-vcpkg-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: windows-latest
triplet: x64-windows-static-md
extension: .exe
zlib: zlib.lib
zlib_debug: zlibd.lib
- os: ubuntu-latest
triplet: x64-linux
extension:
zlib: libz.a
zlib_debug: libz.a
- os: macos-latest
triplet: x64-osx
extension:
zlib: libz.a
zlib_debug: libz.a
env:
# Indicates the CMake build directory where project files and binaries are being produced.
CMAKE_BUILD_DIR: ${{ github.workspace }}/build
# Indicates the location of the vcpkg as a Git submodule of the project repository.
VCPKG_ROOT: ${{ github.workspace }}/external/vcpkg

steps:
- name: Install Dependencies (Linux)
run: sudo apt-get update && sudo apt-get install ninja-build libutempter-dev libunwind-dev libcurl4-openssl-dev
if: matrix.os == 'ubuntu-latest'
- name: Install Dependencies (Windows)
run: choco install ninja
if: matrix.os == 'windows-latest'
- name: Install Dependencies (macOS)
run: brew install ninja
if: matrix.os == 'macos-latest'

- uses: actions/checkout@v2
with:
submodules: recursive

# Setup the build machine with the most recent versions of CMake and Ninja. Both are cached if not already: on subsequent runs both will be quickly restored from GitHub cache service.
- uses: lukka/get-cmake@latest

# Restore both vcpkg and its artifacts from the GitHub cache service.
- name: Restore vcpkg and its artifacts.
uses: actions/cache@v2
with:
# The first path is where vcpkg generates artifacts while consuming the vcpkg.json manifest file.
# The second path is the location of vcpkg (it contains the vcpkg executable and data files).
# The other paths starting with '!' are exclusions: they contain termporary files generated during the build of the installed packages.
path: |
${{ env.CMAKE_BUILD_DIR }}/vcpkg_installed/
${{ env.VCPKG_ROOT }}
!${{ env.VCPKG_ROOT }}/buildtrees
!${{ env.VCPKG_ROOT }}/packages
!${{ env.VCPKG_ROOT }}/downloads
# The key is composed in a way that it gets properly invalidated: this must happen whenever vcpkg's Git commit id changes, or the list of packages changes. In this case a cache miss must happen and a new entry with a new key with be pushed to GitHub the cache service.
# The key includes: hash of the vcpkg.json file, the hash of the vcpkg Git commit id, and the used vcpkg's triplet. The vcpkg's commit id would suffice, but computing an hash out it does not harm.
# Note: given a key, the cache content is immutable. If a cache entry has been created improperly, in order the recreate the right content the key must be changed as well, and it must be brand new (i.e. not existing already).
key: |
${{ hashFiles( 'vcpkg.json' ) }}-${{ hashFiles( '.git/modules/external/vcpkg/HEAD' )}}-${{ matrix.triplet }}-invalidate
- name: Show content of workspace after cache has been restored
run: find $RUNNER_WORKSPACE
shell: bash

# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
- uses: ilammy/msvc-dev-cmd@v1
# Run CMake to generate Ninja project files, using the vcpkg's toolchain file to resolve and install the dependencies as specified in vcpkg.json.
- name: Install dependencies and generate project files
run: |
cmake -S "${{ github.workspace }}" -B "${{ env.CMAKE_BUILD_DIR }}" -GNinja -DVCPKG_TARGET_TRIPLET="${{ matrix.triplet }}" -DCMAKE_TOOLCHAIN_FILE="${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake" -DProtobuf_PROTOC_EXECUTABLE="${{ env.VCPKG_ROOT }}/packages/protobuf_${{ matrix.triplet }}/tools/protobuf/protoc${{matrix.extension}}" -DZLIB_LIBRARY_RELEASE="${{ env.CMAKE_BUILD_DIR }}/vcpkg_installed/${{ matrix.triplet }}/lib/${{ matrix.zlib }}" -DZLIB_LIBRARY_DEBUG="${{ env.CMAKE_BUILD_DIR }}/vcpkg_installed/${{ matrix.triplet }}/debug/lib/${{matrix.zlib_debug}}"
# Build the whole project with Ninja (which is spawn by CMake).
- name: Build
run: |
cmake --build "${{ env.CMAKE_BUILD_DIR }}"
- uses: actions/upload-artifact@v2
with:
name: et-client-${{matrix.os}}
path: ${{ env.CMAKE_BUILD_DIR }}/et${{matrix.extension}}
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
cmake_minimum_required (VERSION 3.0.2)

IF(WIN32)
set(VCPKG_TARGET_TRIPLET "x64-windows-static-md" CACHE STRING "")
ENDIF()

project (EternalTCP VERSION 6.0.13)

include(CMakeFindDependencyMacro)
Expand Down
2 changes: 1 addition & 1 deletion external/vcpkg
Submodule vcpkg updated 5722 files
6 changes: 3 additions & 3 deletions src/base/Headers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <sys/socket.h>
#elif __NetBSD__ // do not need pty.h on NetBSD
#include <util.h>
#elif WIN32
#elif defined(_MSC_VER)
#include <WinSock2.h>
#include <Ws2tcpip.h>
#include <afunix.h>
Expand Down Expand Up @@ -100,7 +100,7 @@ inline int close(int fd) { return ::closesocket(fd); }

#include "sentry.h"

#if WIN32
#if defined(_MSC_VER)
#define popen _popen
#define pclose _pclose

Expand All @@ -109,7 +109,7 @@ inline int close(int fd) { return ::closesocket(fd); }
#if defined(_WIN64)
typedef signed __int64 ssize_t;
#else
typedef signed long ssize_t;
typedef int ssize_t;
#endif
#endif /* !ssize_t */

Expand Down
24 changes: 20 additions & 4 deletions src/base/PipeSocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ int PipeSocketHandler::connect(const SocketEndpoint& endpoint) {
#else
::shutdown(sockFd, SHUT_RDWR);
#endif
::close(sockFd);
#ifdef _MSC_VER
FATAL_FAIL(::closesocket(sockFd));
#else
FATAL_FAIL(::close(sockFd));
#endif
sockFd = -1;
errno = localErrno;
return sockFd;
Expand Down Expand Up @@ -60,14 +64,22 @@ int PipeSocketHandler::connect(const SocketEndpoint& endpoint) {
} else {
LOG(INFO) << "Error connecting to " << endpoint << ": " << so_error << " "
<< strerror(so_error);
::close(sockFd);
#ifdef _MSC_VER
FATAL_FAIL(::closesocket(sockFd));
#else
FATAL_FAIL(::close(sockFd));
#endif
sockFd = -1;
}
} else {
auto localErrno = errno;
LOG(INFO) << "Error connecting to " << endpoint << ": " << localErrno << " "
<< strerror(localErrno);
::close(sockFd);
#ifdef _MSC_VER
FATAL_FAIL(::closesocket(sockFd));
#else
FATAL_FAIL(::close(sockFd));
#endif
sockFd = -1;
}

Expand Down Expand Up @@ -126,6 +138,10 @@ void PipeSocketHandler::stopListening(const SocketEndpoint& endpoint) {
<< pipePath;
}
int sockFd = *(it->second.begin());
::close(sockFd);
#ifdef _MSC_VER
FATAL_FAIL(::closesocket(sockFd));
#else
FATAL_FAIL(::close(sockFd));
#endif
}
} // namespace et
30 changes: 25 additions & 5 deletions src/base/TcpSocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ int TcpSocketHandler::connect(const SocketEndpoint &endpoint) {
LOG(INFO) << "Error connecting: " << localErrno << " "
<< strerror(localErrno);
}
::close(sockFd);
#ifdef _MSC_VER
FATAL_FAIL(::closesocket(sockFd));
#else
FATAL_FAIL(::close(sockFd));
#endif
sockFd = -1;
continue;
}
Expand Down Expand Up @@ -118,7 +122,11 @@ int TcpSocketHandler::connect(const SocketEndpoint &endpoint) {
LOG(INFO) << "Error connecting to " << endpoint << ": " << so_error
<< " " << strerror(so_error);
}
::close(sockFd);
#ifdef _MSC_VER
FATAL_FAIL(::closesocket(sockFd));
#else
FATAL_FAIL(::close(sockFd));
#endif
sockFd = -1;
continue;
}
Expand All @@ -131,7 +139,11 @@ int TcpSocketHandler::connect(const SocketEndpoint &endpoint) {
LOG(INFO) << "Error connecting to " << endpoint << ": " << localErrno
<< " " << strerror(localErrno);
}
::close(sockFd);
#ifdef _MSC_VER
FATAL_FAIL(::closesocket(sockFd));
#else
FATAL_FAIL(::close(sockFd));
#endif
sockFd = -1;
continue;
}
Expand Down Expand Up @@ -206,7 +218,11 @@ set<int> TcpSocketHandler::listen(const SocketEndpoint &endpoint) {
oss << "Error binding port " << port << ": " << localErrno << " "
<< strerror(localErrno);
string s = oss.str();
close(sockFd);
#ifdef _MSC_VER
FATAL_FAIL(::closesocket(sockFd));
#else
FATAL_FAIL(::close(sockFd));
#endif
throw std::runtime_error(s.c_str());
}

Expand Down Expand Up @@ -250,7 +266,11 @@ void TcpSocketHandler::stopListening(const SocketEndpoint &endpoint) {
}
auto &serverSockets = it->second;
for (int sockFd : serverSockets) {
::close(sockFd);
#ifdef _MSC_VER
FATAL_FAIL(::closesocket(sockFd));
#else
FATAL_FAIL(::close(sockFd));
#endif
}
portServerSockets.erase(it);
}
Expand Down
4 changes: 4 additions & 0 deletions src/base/UnixSocketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,11 @@ void UnixSocketHandler::close(int fd) {
auto m = it->second;
lock_guard<std::recursive_mutex> guard(*m);
VLOG(1) << "Closing connection: " << fd;
#ifdef _MSC_VER
FATAL_FAIL(::closesocket(fd));
#else
FATAL_FAIL(::close(fd));
#endif
activeSocketMutexes.erase(it);
}

Expand Down
14 changes: 14 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "eternal-terminal",
"version-string": "6.0.13",
"dependencies": [
"zlib",
"openssl",
"protobuf",
"libsodium",
{
"name": "curl",
"platform": "windows"
}
]
}

0 comments on commit 3942bea

Please sign in to comment.