55from typing import Literal , Optional
66
77import spy .libspy
8- from spy .build .build_info import BuildTarget , BuildType
8+ from spy .build .build_info import BuildTarget , BuildType , OutputKind
99from spy .build .flags import get_cc , get_cflags , get_ldflags , get_libdir
10+ from spy .errors import WIP
1011
11- OutputKind = Literal ["exe" , "lib" , "py-cffi" ]
1212GCOption = Literal ["none" , "bdwgc" ]
1313
1414
@@ -22,6 +22,12 @@ class BuildConfig:
2222 gc : GCOption = "none"
2323 static : bool = False
2424
25+ def __post_init__ (self ) -> None :
26+ if self .kind == "testlib" and self .target not in ("wasi" , "emscripten" ):
27+ raise WIP (
28+ "--output-kind=testlib works only for wasi and emscripten targets"
29+ )
30+
2531
2632# ======= CFLAGS and LDFLAGS logic =======
2733
@@ -61,8 +67,8 @@ def __init__(self, config: BuildConfig):
6167 self .ldflags += get_ldflags (flags_target , config .build_type )
6268
6369 libdir = get_libdir (flags_target , config .build_type )
64- if config .target == "wasi" and config .kind == "lib " :
65- # WASM libs are mostly used by tests: in this case we want to make sure to
70+ if config .target == "wasi" and config .kind == "testlib " :
71+ # WASM testlibs are used by tests: in this case we want to make sure to
6672 # include the whole libspy.a, so that helper functions such as spy_str_alloc
6773 # are always available.
6874 #
@@ -89,7 +95,7 @@ def __init__(self, config: BuildConfig):
8995
9096 elif config .target == "wasi" :
9197 self .ext = ".wasm"
92- if config .kind == "lib " :
98+ if config .kind == "testlib " :
9399 self .ldflags += ["-mexec-model=reactor" ]
94100
95101 elif config .target == "emscripten" :
0 commit comments