Skip to content

Commit

Permalink
WEBAPP WebView new cmake via git
Browse files Browse the repository at this point in the history
  • Loading branch information
pannous committed Sep 14, 2024
1 parent 492a8df commit c1bfd4a
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 16 deletions.
25 changes: 19 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# REMOVE CMakeCache.txt after switching between mac and linux / " Cannot generate into … " errors

cmake_minimum_required(VERSION 3.10)
project(wasp)

include(FetchContent) # external projects like webview

set(CMAKE_VERBOSE_MAKEFILE OFF) # DEBUG CMAKE

#set(CROSSCOMPILE x86) # needs more work / just use different docker images
Expand Down Expand Up @@ -42,7 +43,7 @@ if (X86_64)
if (LINUX)
LINK_DIRECTORIES(bin/linux/lib.x86)
else ()
LINK_DIRECTORIES(bin/mac/lib.x86)
LINK_DIRECTORIES(bin/mac/lib.x86)
endif ()
else ()
LINK_DIRECTORIES(lib/)
Expand All @@ -66,10 +67,10 @@ if (NOT WASM)
# TO EXECUTE wasm provide _run_wasm :
# https://github.com/WebAssembly/wasm-c-api implemented by V8 Wabt Wasmtime Wasmer
# as of 2022-10 wasm-c-api encompasses multiple return values and reference types, but not yet threads.
SET(WASMEDGE 1) # fastest, easiest, bestest. todo smart multi-value returns
# SET(WASMEDGE 1) # fastest, easiest, bestest. todo smart multi-value returns
# SET(WASMEDGE 0)
# SET(WASMTIME 1) # FASTEST but unstable / elusive bugs "object used with the wrong store" etc
# set(WEBAPP 1) # FAST!! WebView for electron like standalone apps.
set(WEBAPP 1) # FAST!! WebView for electron like standalone apps.
# set(WASM3 1) # GOOD (backtrace…) wasm_runner_wasm3.cpp BEST API but dying to Russia :( 2022-12: last release on Jun 2, 2021
# set(MICRO 1) # WAMR 2023-02 still NOT M1 READY! wasm-micro-runtime => wasm_runner_micro.cpp TODO: use AOT/JIT mode!?
# SET(V8 1) # 2024-04 Exception: EXC_BAD_ACCESS (code=1, address=0x0) :( and VERY SLOW !?
Expand Down Expand Up @@ -695,13 +696,25 @@ elseif (WASMTIME)
target_link_libraries(wasp PRIVATE wasm)
target_link_libraries(wasp PRIVATE wasmtime)
elseif (WEBAPP)
message(WEBAPP)
ADD_DEFINITIONS(-DWEBAPP)
# on Windows 11, developers and end-users must have the WebView2 runtime installed!
# for standalone for Windows version check choc_WebView.h (1 MB)
include(source/WebView.cmake)
# include(source/WebView.cmake)
set(SOURCE_FILES ${SOURCE_FILES} source/WebApp.cpp source/WebServer.cpp)
add_executable(wasp-app ${SOURCE_FILES})
target_link_libraries(wasp-app PUBLIC webview)

FetchContent_Declare(webview GIT_REPOSITORY https://github.com/webview/webview.git)
FetchContent_MakeAvailable(webview)
find_library(WEBVIEW webview HINTS ${webview_SOURCE_DIR}/core)
target_link_libraries(wasp-app PUBLIC ${WEBVIEW})
target_include_directories(wasp-app PUBLIC ${webview_SOURCE_DIR}/core/include)
FIND_LIBRARY(OBJC_LIBRARY objc)
TARGET_LINK_LIBRARIES(wasp-app PRIVATE ${OBJC_LIBRARY})

# target_link_libraries(wasp-app PUBLIC webview)
# target_include_directories(wasp-app PUBLIC ${webview_SOURCE_DIR}/core/include)

if (CURL)
target_link_libraries(wasp-app PUBLIC ${CURL_LIBRARIES})
target_link_libraries(wasp-app PUBLIC -lcurl)
Expand Down
6 changes: 6 additions & 0 deletions source/Angle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1925,6 +1925,12 @@ Node &groupWhile(Node &n, Function &context) {

Node &groupOperatorCall(Node &node, Function &function);

/*
* ☢️ ⚛ Nuclear Core ⚠️ 🚧
* turning some knobs might yield some great powers
* touching anything can result in disaster
* should be replaced with elegant modular solar panels
*/
Node &analyze(Node &node, Function &function) {
String &context = function.name;
if (context != "global" and !functions.has(context)) {
Expand Down
2 changes: 1 addition & 1 deletion source/DwarfEmitter.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//#include "DwarfEmitter.h"
#include "dwarf.h"
#include "Code.h"
#include "asserts.h"
//#include "asserts.h"

// wasm-tools addr2line main.wasm 0x50

Expand Down
2 changes: 1 addition & 1 deletion source/ErrorHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static void signal_segv(int signum, siginfo_t *info, void *ptr) {
//istead of _Unwind_Backtrace(tracer, &state);

static void handler(int sig, siginfo_t *si, void *context) {
printf("Got SIGSEGV at address: 0x%lx\n", (int64) si->si_addr);
printf("Got SIGSEGV at address: 0x%lx\n", (unsigned long) si->si_addr);
printf("Implements the handler only\n");
// Backtrace();
}
Expand Down
4 changes: 3 additions & 1 deletion source/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ typedef byte *bytes;
#include "String.h" // AFTER defines!
#include "smart_types.h"

// [[noreturn]]
//#if …// sometimes needed sometimes not !?
[[noreturn]]
//#endif
extern void error1(chars message, chars file = 0, int line = 0);

extern void info(chars);
Expand Down
1 change: 1 addition & 0 deletions source/WebApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,5 @@ int64 open_webview(String url = "") {

extern "C" int64 init_graphics() {
open_webview();
return 0;// returns data offset OUTSIDE wasm: pointer to RGBA surface
}
9 changes: 4 additions & 5 deletions source/wasm_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ int isalnum0(int c) {
}

// todo put to util
#if not WEBAPP

//#if not WEBAPP
[[noreturn]]
#endif
//#endif
void error1(chars message, chars file, int line) {
#ifdef _Backtrace_
// Backtrace(2);// later, in raise
Expand All @@ -90,10 +89,10 @@ void error1(chars message, chars file, int line) {
if (file)printf("\n%s:%d\n", file, line);
raise(message);
#endif
#if not WEBAPP
//#if not WEBAPP
// if (throwing)
throw message; // [[noreturn]] should not return
#endif
//#endif
}


Expand Down
4 changes: 2 additions & 2 deletions source/wasm_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ typedef char32_t codepoint;// 'letter' ☃ is a single code point but 3 UTF-8 co
typedef const char *chars;
typedef unsigned char *bytes;

#if not WEBAPP
//#if not WEBAPP
[[noreturn]]
#endif
//#endif
extern void error1(chars message, chars file, int line);

// there are two aspects of wasm memory: the internal memory starting at 0 and the external c-pointer *wasm_memory if the VM provides it
Expand Down

0 comments on commit c1bfd4a

Please sign in to comment.