8
8
9
9
10
10
@task (default = True )
11
- def build (ctx , clean = False ):
11
+ def build (ctx , clean = False , native = False ):
12
12
"""
13
13
Compile rabe library (in Rust) and C++ bindings into a WASM library
14
14
"""
@@ -18,18 +18,29 @@ def build(ctx, clean=False):
18
18
rmtree (join (rabe_dir , "target" ))
19
19
20
20
# 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
+
22
25
run (cargo_cmd , shell = True , check = True , cwd = rabe_dir )
23
26
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 )
29
36
30
37
# Build the CPP bindings library, and cross-compile it to WASM
31
38
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" )
33
44
34
45
if clean and exists (build_dir ):
35
46
rmtree (build_dir )
@@ -52,19 +63,22 @@ def build(ctx, clean=False):
52
63
run (cmake_cmd , shell = True , check = True , cwd = build_dir , env = work_env )
53
64
run ("ninja" , shell = True , check = True , cwd = build_dir )
54
65
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