Skip to content

Commit 67b55df

Browse files
committed
rabe: add native build
1 parent 112fa63 commit 67b55df

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed

tasks/rabe.py

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
@task(default=True)
11-
def build(ctx, clean=False):
11+
def build(ctx, clean=False, native=False):
1212
"""
1313
Compile rabe library (in Rust) and C++ bindings into a WASM library
1414
"""
@@ -18,18 +18,29 @@ def build(ctx, clean=False):
1818
rmtree(join(rabe_dir, "target"))
1919

2020
# First, cross-compile the rust library to WASM
21-
cargo_cmd = "cargo build --release --target=wasm32-wasip1"
21+
cargo_cmd = "cargo build --release"
22+
if not native:
23+
cargo_cmd += "--target=wasm32-wasip1"
24+
2225
run(cargo_cmd, shell=True, check=True, cwd=rabe_dir)
2326

24-
# Install it in the WASM sysroot
25-
build_env = get_faasm_build_env_dict()
26-
src_lib = join(rabe_dir, "target", "wasm32-wasip1", "release", "librabe.a")
27-
dst_lib = join(build_env["FAASM_WASM_LIB_INSTALL_DIR"], "librabe.a")
28-
copy(src_lib, dst_lib)
27+
if not native:
28+
# Install it in the WASM sysroot
29+
build_env = get_faasm_build_env_dict()
30+
31+
src_lib = join(rabe_dir, "target", "wasm32-wasip1", "release", "librabe.a")
32+
dst_lib = join(build_env["FAASM_WASM_LIB_INSTALL_DIR"], "librabe.a")
33+
34+
# TODO: move down
35+
copy(src_lib, dst_lib)
2936

3037
# Build the CPP bindings library, and cross-compile it to WASM
3138
rabe_cpp_dir = join(rabe_dir, "cpp-bindings")
32-
build_dir = join(rabe_cpp_dir, "build")
39+
40+
if native:
41+
build_dir = join(rabe_cpp_dir, "build-native")
42+
else:
43+
build_dir = join(rabe_cpp_dir, "build-wasm")
3344

3445
if clean and exists(build_dir):
3546
rmtree(build_dir)
@@ -52,19 +63,22 @@ def build(ctx, clean=False):
5263
run(cmake_cmd, shell=True, check=True, cwd=build_dir, env=work_env)
5364
run("ninja", shell=True, check=True, cwd=build_dir)
5465

55-
# Install the library in the WASM sysroot
56-
src_lib = join(build_dir, "librabe-cpp.a")
57-
dst_lib = join(build_env["FAASM_WASM_LIB_INSTALL_DIR"], "librabe-cpp.a")
58-
copy(src_lib, dst_lib)
59-
60-
# Install the header in the WASM sysroot too
61-
src_header = join(rabe_cpp_dir, "rabe_bindings.hpp")
62-
dst_header = join(
63-
build_env["FAASM_WASM_HEADER_INSTALL_DIR"], "tless_abe.h"
64-
)
65-
copy(src_header, dst_header)
66-
src_header = join(rabe_cpp_dir, "tless_aes.h")
67-
dst_header = join(
68-
build_env["FAASM_WASM_HEADER_INSTALL_DIR"], "tless_aes.h"
69-
)
70-
copy(src_header, dst_header)
66+
if not native:
67+
build_env = get_faasm_build_env_dict()
68+
69+
# Install the library in the WASM sysroot
70+
src_lib = join(build_dir, "librabe-cpp.a")
71+
dst_lib = join(build_env["FAASM_WASM_LIB_INSTALL_DIR"], "librabe-cpp.a")
72+
copy(src_lib, dst_lib)
73+
74+
# Install the header in the WASM sysroot too
75+
src_header = join(rabe_cpp_dir, "rabe_bindings.hpp")
76+
dst_header = join(
77+
build_env["FAASM_WASM_HEADER_INSTALL_DIR"], "tless_abe.h"
78+
)
79+
copy(src_header, dst_header)
80+
src_header = join(rabe_cpp_dir, "tless_aes.h")
81+
dst_header = join(
82+
build_env["FAASM_WASM_HEADER_INSTALL_DIR"], "tless_aes.h"
83+
)
84+
copy(src_header, dst_header)

0 commit comments

Comments
 (0)