Skip to content

Commit

Permalink
chore: reorganize + wip
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Sep 21, 2023
1 parent c2e4dbb commit c7350db
Show file tree
Hide file tree
Showing 13 changed files with 220 additions and 205 deletions.
18 changes: 17 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ package(default_visibility = ["//visibility:public"])

filegroup(
name = "headers",
srcs = ["ecsact/wasm.h", "ecsact/wasm.hh"],
srcs = [
"ecsact/wasm.h",
"ecsact/wasm.hh",
],
)

filegroup(
Expand All @@ -17,6 +20,19 @@ filegroup(
]),
)

cc_library(
name = "ecsact_si_wasm",
copts = copts,
defines = ["ECSACTSI_WASM_API="],
hdrs = [":headers"],
srcs = [":sources"],
deps = [
"@wasmer",
"@ecsact_runtime//:common",
"@ecsact_runtime//:dynamic",
],
)

cc_library(
name = "minst",
copts = copts,
Expand Down
6 changes: 0 additions & 6 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@ecsact_si_wasm//:wasmer.bzl", "wasmer_repo")

wasmer_repo(
name = "wasmer",
wasmer_version = "3.3.0",
)

http_archive(
name = "com_grail_bazel_toolchain",
Expand Down
4 changes: 4 additions & 0 deletions bazel/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config_setting(
name = "compiler_emscripten",
flag_values = {"@bazel_tools//tools/cpp:compiler": "emscripten"},
)
3 changes: 3 additions & 0 deletions bazel/copts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ load("@bazel_skylib//lib:selects.bzl", "selects")

# Ecsact repositories currently only support clang and cl
copts = selects.with_or({
(Label("//bazel:compiler_emscripten")): [
"-std=c++20",
],
("@rules_cc//cc/compiler:clang"): [
"-std=c++2b",
"-fexperimental-library",
Expand Down
14 changes: 7 additions & 7 deletions ecsact/wasm.hh
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ struct system_load_options {
};

inline auto load_file(
std::filesystem::path wasm_file_path,
std::span<system_load_options> systems
std::filesystem::path wasm_file_path,
std::span<const system_load_options> systems
) -> ecsactsi_wasm_error {
auto system_ids = std::vector<ecsact_system_like_id>{};
auto wasm_exports = std::vector<std::string>{};
Expand All @@ -50,7 +50,7 @@ inline auto load_file(
wasm_file_path.string().c_str(),
static_cast<std::int32_t>(systems.size()),
system_ids.data(),
wasm_exports.data()
wasm_exports_c.data()
);
}

Expand All @@ -75,11 +75,11 @@ inline auto load(
}

return ecsactsi_wasm_load(
static_cast<char*>(wasm_data.data()),
reinterpret_cast<char*>(wasm_data.data()),
static_cast<std::int32_t>(wasm_data.size()),
static_cast<std::int32_t>(systems.size()),
system_ids.data(),
wasm_exports.data()
wasm_exports_c.data()
);
}

Expand Down Expand Up @@ -116,8 +116,8 @@ auto consume_logs(log_consumer auto&& f) -> void {
std::int32_t message_length,
void* user_data
) {
static_cast<decltype(&f)>(user_data)(
reinterpret_cast<log_level>(level),
(*static_cast<decltype(&f)>(user_data))(
static_cast<log_level>(level),
std::string_view{message, static_cast<std::size_t>(message_length)}
);
},
Expand Down
1 change: 0 additions & 1 deletion ecsact/wasm/detail/wasm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include <array>
#include <cstddef>
#include "ecsact/runtime/dynamic.h"
#include "ecsact/runtime/meta.h"
#include "ecsact/wasm/detail/minst/minst.hh"
#include "ecsact/wasm/detail/logger.hh"
#include "ecsact/wasm/detail/wasi_fs.hh"
Expand Down
184 changes: 0 additions & 184 deletions example/BUILD.bazel

This file was deleted.

Loading

0 comments on commit c7350db

Please sign in to comment.