Skip to content

Commit

Permalink
fixed build on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Aug 26, 2024
1 parent da471bd commit eb0c808
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 46 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ if (TARGET_WEBOS)
pkg_check_modules(PBNJSON_C REQUIRED pbnjson_c)
pkg_check_modules(PMLOG REQUIRED PmLogLib)
pkg_check_modules(WEBOSI18N REQUIRED webosi18n)
elseif (OS_WINDOWS)
set(BUILD_SHARED_CORE_LIBS OFF)
else ()

set(BUILD_SHARED_CORE_LIBS ON)
endif ()

Expand Down
3 changes: 3 additions & 0 deletions core/libgamestream/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ target_link_libraries(gamestream PRIVATE ${MBEDCRYPTO_LIBRARY} ${MBEDX509_LIBRAR
target_link_libraries(gamestream PUBLIC commons-logging commons-uuidstr)
target_include_directories(gamestream SYSTEM PRIVATE ${MBEDTLS_INCLUDE_DIRS})
target_link_libraries(gamestream PRIVATE ${CURL_LIBRARIES} ${EXPAT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
if (WIN32)
target_link_libraries(gamestream PUBLIC ws2_32)
endif()
if (BUILD_SHARED_LIBS)
install(TARGETS gamestream LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
Expand Down
11 changes: 11 additions & 0 deletions core/libgamestream/src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,17 @@ static bool construct_url(GS_CLIENT hnd, char *url, size_t ulen, bool secure, co
return true;
}

#if __WIN32__
static char *stpncpy(char *dest, const char *src, size_t n) {
size_t i;
for (i = 0; i < n && src[i] != '\0'; i++) {
dest[i] = src[i];
}
dest[i] = '\0';
return dest + i;
}
#endif

static bool append_param(char *url, size_t ulen, const char *param, const char *value_fmt, ...) {
char value[256];
va_list ap;
Expand Down
1 change: 1 addition & 0 deletions core/libgamestream/src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#if __WIN32

#include <windows.h>
#include <dirent.h>

#define PATH_SEPARATOR '\\'
#define MKDIR(path) mkdir(path)
Expand Down
11 changes: 7 additions & 4 deletions core/libgamestream/src/mkcert.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ static const int NUM_YEARS = 10;
static int mkcert_generate_impl(mbedtls_pk_context *key, mbedtls_x509write_cert *crt, mbedtls_ctr_drbg_context *rng) {
int ret;

mbedtls_mpi serial;

mbedtls_mpi_init(&serial);

char buf[512];

Expand All @@ -61,8 +58,15 @@ static int mkcert_generate_impl(mbedtls_pk_context *key, mbedtls_x509write_cert
mbedtls_x509write_crt_set_subject_name(crt, "CN=NVIDIA GameStream Client");
mbedtls_x509write_crt_set_issuer_name(crt, "CN=NVIDIA GameStream Client");

#if MBEDTLS_VERSION_NUMBER >= 0x03040000
mbedtls_x509write_crt_set_serial_raw(crt, (unsigned char *) "1", 1);
#else
mbedtls_mpi serial;
mbedtls_mpi_init(&serial);
mbedtls_mpi_read_string(&serial, 10, "1");
mbedtls_x509write_crt_set_serial(crt, &serial);
mbedtls_mpi_free(&serial);
#endif

mbedtls_x509write_crt_set_version(crt, MBEDTLS_X509_CRT_VERSION_2);
mbedtls_x509write_crt_set_md_alg(crt, MBEDTLS_MD_SHA256);
Expand All @@ -87,7 +91,6 @@ static int mkcert_generate_impl(mbedtls_pk_context *key, mbedtls_x509write_cert
}

finally:
mbedtls_mpi_free(&serial);
return ret;
}

Expand Down
6 changes: 3 additions & 3 deletions src/app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ bool app_decoder_or_embedded_present(app_t *app) {

static void libs_init(app_t *app, int argc, char *argv[]) {
SS4S_SetLoggingFunction(commons_ss4s_logf);
int errno;
if ((errno = SS4S_ModulesList(&app->ss4s.modules, &app->os_info)) != 0) {
commons_log_error("SS4S", "Can't load modules list: %s", strerror(errno));
int ret;
if ((ret = SS4S_ModulesList(&app->ss4s.modules, &app->os_info)) != 0) {
commons_log_error("SS4S", "Can't load modules list: %s", strerror(ret));
}
SS4S_ModulePreferences module_preferences = {
.audio_module = app_configuration->audio_backend,
Expand Down
46 changes: 10 additions & 36 deletions src/app/stream/input/vk.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#ifndef __WIN32__
enum {
VK_LBUTTON = 0x01,/*Left mouse button*/
VK_RBUTTON = 0x02,/*Right mouse button*/
Expand Down Expand Up @@ -46,42 +47,6 @@ enum {
VK_INSERT = 0x2D,/*INS key*/
VK_DELETE = 0x2E,/*DEL key*/
VK_HELP = 0x2F,/*HELP key*/
VK_0 = 0x30,/*0 key*/
VK_1 = 0x31,/*1 key*/
VK_2 = 0x32,/*2 key*/
VK_3 = 0x33,/*3 key*/
VK_4 = 0x34,/*4 key*/
VK_5 = 0x35,/*5 key*/
VK_6 = 0x36,/*6 key*/
VK_7 = 0x37,/*7 key*/
VK_8 = 0x38,/*8 key*/
VK_9 = 0x39,/*9 key*/
VK_A = 0x41,/*A key*/
VK_B = 0x42,/*B key*/
VK_C = 0x43,/*C key*/
VK_D = 0x44,/*D key*/
VK_E = 0x45,/*E key*/
VK_F = 0x46,/*F key*/
VK_G = 0x47,/*G key*/
VK_H = 0x48,/*H key*/
VK_I = 0x49,/*I key*/
VK_J = 0x4A,/*J key*/
VK_K = 0x4B,/*K key*/
VK_L = 0x4C,/*L key*/
VK_M = 0x4D,/*M key*/
VK_N = 0x4E,/*N key*/
VK_O = 0x4F,/*O key*/
VK_P = 0x50,/*P key*/
VK_Q = 0x51,/*Q key*/
VK_R = 0x52,/*R key*/
VK_S = 0x53,/*S key*/
VK_T = 0x54,/*T key*/
VK_U = 0x55,/*U key*/
VK_V = 0x56,/*V key*/
VK_W = 0x57,/*W key*/
VK_X = 0x58,/*X key*/
VK_Y = 0x59,/*Y key*/
VK_Z = 0x5A,/*Z key*/
VK_LWIN = 0x5B,/*Left Windows key (Natural keyboard)*/
VK_RWIN = 0x5C,/*Right Windows key (Natural keyboard)*/
VK_APPS = 0x5D,/*Applications key (Natural keyboard)*/
Expand Down Expand Up @@ -176,4 +141,13 @@ enum {
VK_NONAME = 0xFC,/*Reserved*/
VK_PA1 = 0xFD,/*PA1 key*/
VK_OEM_CLEAR = 0xFE,/*Clear key*/
};
#else

#include "winuser.h"

#endif
enum {
VK_0 = '0',
VK_A = 'A',
};

0 comments on commit eb0c808

Please sign in to comment.