Got things running for Linux

This commit is contained in:
2026-07-22 22:28:05 +03:00
parent 5e7ed489af
commit 767eeb6b39
12 changed files with 78 additions and 13 deletions

View File

@@ -2,6 +2,9 @@ project('scuffedcraft', 'c')
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
vendor_dir_abs = meson.current_source_dir() + '/vendor/' vendor_dir_abs = meson.current_source_dir() + '/vendor/'
message(vendor_dir_abs)
pltf_src = []
cargs = [ cargs = [
'-std=c99', '-std=c99',
@@ -18,19 +21,40 @@ link_args = []
test_link_args = [ '-static' ] test_link_args = [ '-static' ]
include_dirs = [ include_dirs = [
'vendor/', # 'vendor/',
'src/' 'src/'
] ]
test_include_dirs = [ test_include_dirs = [
'src/', 'src/',
'vendor/' 'vendor/cmocka-2.0.2/'
] ]
if host_machine.system() == 'linux' if host_machine.system() == 'linux'
pltf_src = [
'src/pltf/linux/gl_funcs.c'
]
dependencies += [ dependencies += [
dependency('libglvnd') dependency('libglvnd')
] ]
libcmocka = cc.find_library(
'libcmocka',
dirs: [ vendor_dir_abs + 'cmocka-2.0.2/linux/' ]
)
elif host_machine.system() == 'windows' elif host_machine.system() == 'windows'
pltf_src = [
'src/pltf/win32/gl_funcs.c',
'src/pltf/win32/internal.c',
'src/pltf/win32/pltf.c',
'src/pltf/win32/win_proc.c',
]
libcmocka = cc.find_library(
'libcmocka',
dirs: [ vendor_dir_abs + 'cmocka-2.0.2/win/' ]
)
link_args += [ link_args += [
'-lopengl32' '-lopengl32'
] ]
@@ -53,22 +77,18 @@ endif
executable( executable(
'scuffedcraft', 'scuffedcraft',
'src/pltf/win32/gl_funcs.c',
'src/pltf/win32/internal.c',
'src/pltf/win32/pltf.c',
'src/pltf/win32/win_proc.c',
'src/DynArray.c', 'src/DynArray.c',
'src/DynString.c', 'src/DynString.c',
'src/log.c', 'src/log.c',
'src/main.c', 'src/main.c',
'src/shader.c', 'src/shader.c',
pltf_src,
c_args: cargs, c_args: cargs,
dependencies: dependencies, dependencies: dependencies,
link_args: link_args, link_args: link_args,
include_directories: include_directories(include_dirs), include_directories: include_directories(include_dirs),
) )
executable( executable(
'tests', 'tests',
'tests/main.c', 'tests/main.c',
@@ -78,9 +98,6 @@ executable(
include_directories: include_directories(test_include_dirs), include_directories: include_directories(test_include_dirs),
link_args: test_link_args, link_args: test_link_args,
dependencies: [ dependencies: [
cc.find_library( libcmocka
'libcmocka',
dirs: [ vendor_dir_abs + 'cmocka/' ]
)
] ]
) )

View File

@@ -1,3 +1,5 @@
#ifdef _WIN32
#include <assert.h> #include <assert.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
@@ -107,3 +109,16 @@ int main() {
return 0; return 0;
} }
#endif // _WIN32
#ifdef __linux__
#include <stdio.h>
int main() {
printf("Hello linux\n");
return 0;
}
#endif // __linux__

13
src/pltf/linux/gl_funcs.c Normal file
View File

@@ -0,0 +1,13 @@
#ifdef __linux__
#include <stddef.h>
#include "../gl_funcs.h"
#define X(type, name) \
type name = NULL
PLTF_GL_FUNCS(X)
#undef X
#endif // __linux__

View File

@@ -1,3 +1,5 @@
#ifdef _WIN32
#include "../gl_funcs.h" #include "../gl_funcs.h"
#include "log.h" #include "log.h"
#include "internal.h" #include "internal.h"
@@ -31,3 +33,4 @@ void pltf_gl_funcs_load() {
PLTF_GL_FUNCS(X) PLTF_GL_FUNCS(X)
} }
#endif // _WIN32

View File

@@ -1,3 +1,5 @@
#ifdef _WIN32
#include <windows.h> #include <windows.h>
#include "internal.h" #include "internal.h"
@@ -43,3 +45,5 @@ unsigned int vk_to_pltf_key(WPARAM key) {
return PLTF_KEY_NONE; return PLTF_KEY_NONE;
} }
} }
#endif // _WIN32

View File

@@ -1,3 +1,5 @@
#ifdef _WIN32
#include <GL/glcorearb.h> #include <GL/glcorearb.h>
#include <GL/wglext.h> #include <GL/wglext.h>
#include <assert.h> #include <assert.h>
@@ -285,3 +287,5 @@ void pltf_key_callback_set(
} }
#undef PLTF_KEYS_X #undef PLTF_KEYS_X
#endif // _WIN32

View File

@@ -1,3 +1,5 @@
#ifdef _WIN32
#include <windows.h> #include <windows.h>
#include "internal.h" #include "internal.h"
@@ -68,3 +70,5 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
} }
return DefWindowProc(hwnd, uMsg, wParam, lParam); return DefWindowProc(hwnd, uMsg, wParam, lParam);
} }
#endif // _WIN32

View File

@@ -1,3 +1,6 @@
// Disabling on linux until opengl function
// #ifdef _WIN32
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
@@ -86,3 +89,5 @@ unsigned int shader_create(
return shader_program; return shader_program;
} }
// #endif // _WIN32

View File

@@ -1,7 +1,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "cmocka/cmocka.h" #include "cmocka.h"
#include "DynString.h" #include "DynString.h"
void test_DynString_alloc(void** state) { void test_DynString_alloc(void** state) {

BIN
vendor/cmocka-2.0.2/linux/libcmocka.a vendored Normal file

Binary file not shown.