[win32, build] first iteration on build script for win32

This commit is contained in:
martinfouilleul 2023-06-16 19:46:58 +02:00
parent 37ab5ca5e4
commit ea4a19b074
3 changed files with 134 additions and 125 deletions

55
build.bat Normal file
View File

@ -0,0 +1,55 @@
@echo off
set target=%1%
if "%~1%" == "" set target=orca
if not exist bin mkdir bin
if not exist bin\obj mkdir bin\obj
if %target% == wasm3 (
echo building wasm3
set wasm3_includes=/I .\ext\wasm3\source
set wasm3_sources=/I .\ext\wasm3\source\*.c
for %%f in ( .\ext\wasm3\source\*.c ) do (
cl /nologo /Zi /Zc:preprocessor /c /Fo:bin\obj\%%~nf.obj %wasm3_includes% %%f
)
lib /nologo /out:bin\wasm3.lib bin\obj\*.obj
)
if %target% == milepost (
echo building milepost
cd milepost
build.bat
cd ..
)
if %target% == orca (
echo building orca
::copy libraries
copy milepost\bin\milepost.dll bin
copy milepost\bin\milepost.dll.lib bin
::generate wasm3 api bindings
python3 scripts\bindgen.py core src
python3 scripts\bindgen.py gles src
python3 scripts\bindgen2.py canvas src\canvas_api.json^
--guest-stubs sdk\orca_surface.c^
--guest-include graphics.h^
--wasm3-bindings src\canvas_api_bind_gen.c
python3 scripts\bindgen2.py io^
src\io_api.json^
--guest-stubs sdk\io_stubs.c^
--wasm3-bindings src\io_api_bind_gen.c
::compile orca
set INCLUDES=/I src /I sdk /I ext\wasm3\source /I milepost\src /I milepost\ext /I ..\vcpkg\packages\pthreads_x64-windows\include
set LIBS=/LIBPATH:bin /LIBPATH:..\vcpkg\packages\pthreads_x64-windows\lib milepost.dll.lib wasm3.lib pthreadVC3.lib
cl /Zi /Zc:preprocessor /std:c11 %INCLUDES% src\main.c /link %LIBS% /out:bin\orca.exe
)

@ -1 +1 @@
Subproject commit b2d2d2a587f3c8a0b7dae5521f3202b92f57ae08
Subproject commit debcffce2a2dccab3c3abf8972d0adb11052a515

View File

@ -1,124 +1,78 @@
/************************************************************//**
*
* @file: orca_runtime.h
* @author: Martin Fouilleul
* @date: 17/04/2023
*
*****************************************************************/
#ifndef __ORCA_RUNTIME_H_
#define __ORCA_RUNTIME_H_
#include"platform/platform_io_internal.h"
#include"wasm3.h"
#include"m3_env.h"
#include"m3_compile.h"
#define G_EVENTS(X) \
X(G_EVENT_START, "OnInit", "", "") \
X(G_EVENT_MOUSE_DOWN, "OnMouseDown", "", "i") \
X(G_EVENT_MOUSE_UP, "OnMouseUp", "", "i") \
X(G_EVENT_MOUSE_ENTER, "OnMouseEnter", "", "") \
X(G_EVENT_MOUSE_LEAVE, "OnMouseLeave", "", "") \
X(G_EVENT_MOUSE_MOVE, "OnMouseMove", "", "ffff") \
X(G_EVENT_MOUSE_WHEEL, "OnMouseWheel", "", "ff") \
X(G_EVENT_KEY_DOWN, "OnKeyDown", "", "i") \
X(G_EVENT_KEY_UP, "OnKeyUp", "", "i") \
X(G_EVENT_FRAME_REFRESH, "OnFrameRefresh", "", "") \
X(G_EVENT_FRAME_RESIZE, "OnFrameResize", "", "ii")
typedef enum {
#define G_EVENT_KIND(kind, ...) kind,
G_EVENTS(G_EVENT_KIND)
G_EVENT_COUNT
} guest_event_kind;
typedef struct g_event_handler_desc
{
str8 name;
str8 retTags;
str8 argTags;
} g_event_handler_desc;
const g_event_handler_desc G_EVENT_HANDLER_DESC[] = {
#define G_EVENT_HANDLER_DESC_ENTRY(kind, name, rets, args) {STR8(name), STR8(rets), STR8(args)},
G_EVENTS(G_EVENT_HANDLER_DESC_ENTRY)
};
typedef struct wasm_memory
{
char* ptr;
u64 reserved;
u64 committed;
} wasm_memory;
typedef struct orca_runtime
{
str8 wasmBytecode;
wasm_memory wasmMemory;
// wasm3 data
IM3Environment m3Env;
IM3Runtime m3Runtime;
IM3Module m3Module;
IM3Function eventHandlers[G_EVENT_COUNT];
} orca_runtime;
typedef struct log_entry
{
list_elt listElt;
u64 cap;
log_level level;
str8 file;
str8 function;
int line;
str8 msg;
u64 recordIndex;
} log_entry;
typedef struct orca_debug_overlay
{
bool show;
mg_surface surface;
mg_canvas canvas;
mg_font fontReg;
mg_font fontBold;
ui_context ui;
mem_arena logArena;
list_info logEntries;
list_info logFreeList;
u32 entryCount;
u32 maxEntries;
u64 logEntryTotalCount;
bool logScrollToLast;
} orca_debug_overlay;
typedef struct orca_app
{
mp_window window;
mg_surface surface;
mg_canvas canvas;
file_table fileTable;
file_handle rootDir;
orca_runtime runtime;
orca_debug_overlay debugOverlay;
} orca_app;
orca_app* orca_app_get();
orca_runtime* orca_runtime_get();
#endif //__ORCA_RUNTIME_H_
/************************************************************//**
*
* @file: orca_runtime.h
* @author: Martin Fouilleul
* @date: 17/04/2023
*
*****************************************************************/
#ifndef __ORCA_RUNTIME_H_
#define __ORCA_RUNTIME_H_
#include"wasm3.h"
#include"m3_env.h"
#include"m3_compile.h"
#define G_EVENTS(X) \
X(G_EVENT_START, "OnInit", "", "") \
X(G_EVENT_MOUSE_DOWN, "OnMouseDown", "", "i") \
X(G_EVENT_MOUSE_UP, "OnMouseUp", "", "i") \
X(G_EVENT_MOUSE_ENTER, "OnMouseEnter", "", "") \
X(G_EVENT_MOUSE_LEAVE, "OnMouseLeave", "", "") \
X(G_EVENT_MOUSE_MOVE, "OnMouseMove", "", "ffff") \
X(G_EVENT_MOUSE_WHEEL, "OnMouseWheel", "", "ff") \
X(G_EVENT_KEY_DOWN, "OnKeyDown", "", "i") \
X(G_EVENT_KEY_UP, "OnKeyUp", "", "i") \
X(G_EVENT_FRAME_REFRESH, "OnFrameRefresh", "", "") \
X(G_EVENT_FRAME_RESIZE, "OnFrameResize", "", "ii")
typedef enum {
#define G_EVENT_KIND(kind, ...) kind,
G_EVENTS(G_EVENT_KIND)
G_EVENT_COUNT
} guest_event_kind;
typedef struct g_event_handler_desc
{
str8 name;
str8 retTags;
str8 argTags;
} g_event_handler_desc;
const g_event_handler_desc G_EVENT_HANDLER_DESC[] = {
#define STR8LIT(s) {sizeof(s), s} //NOTE: msvc doesn't accept STR8(s) as compile-time constant...
#define G_EVENT_HANDLER_DESC_ENTRY(kind, name, rets, args) {STR8LIT(name), STR8LIT(rets), STR8LIT(args)},
G_EVENTS(G_EVENT_HANDLER_DESC_ENTRY)
#undef G_EVENT_HANDLER_DESC_ENTRY
#undef STR8LIT
};
typedef struct wasm_memory
{
char* ptr;
u64 reserved;
u64 committed;
} wasm_memory;
typedef struct orca_runtime
{
str8 wasmBytecode;
wasm_memory wasmMemory;
// wasm3 data
IM3Environment m3Env;
IM3Runtime m3Runtime;
IM3Module m3Module;
IM3Function eventHandlers[G_EVENT_COUNT];
} orca_runtime;
orca_runtime* orca_runtime_get();
#endif //__ORCA_RUNTIME_H_