Skip to content

Commit 36ad08e

Browse files
authored
chore: Move fastly.wit into host_interface/wit and extract fastly interfaces (#611)
1 parent 048131c commit 36ad08e

File tree

14 files changed

+40
-37
lines changed

14 files changed

+40
-37
lines changed

ci/clang-format.ignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
runtime/js-compute-runtime/third_party/wizer.h
22
runtime/js-compute-runtime/rust-url/rust-url.h
33
runtime/js-compute-runtime/rust-encoding/rust-encoding.h
4-
runtime/js-compute-runtime/fastly-world/fastly_world.h
4+
runtime/js-compute-runtime/host_interface/component/fastly_world.h

runtime/js-compute-runtime/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/compile_commands.json
33
/.cache
44

5-
!/fastly-world/*.o
5+
!/host_interface/component/fastly_world.o
66
/js-compute-runtime*.wasm
77
/build
88
/shared

runtime/js-compute-runtime/Makefile

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ $(BUILD):
151151
$(OBJ_DIR):
152152
$(call cmd,mkdir,$@)
153153

154-
$(OBJ_DIR)/fastly-world:
155-
$(call cmd,mkdir,$@)
156-
157154
$(OBJ_DIR)/impl:
158155
$(call cmd,mkdir,$@)
159156

@@ -169,6 +166,9 @@ $(OBJ_DIR)/core:
169166
$(OBJ_DIR)/host_interface:
170167
$(call cmd,mkdir,$@)
171168

169+
$(OBJ_DIR)/host_interface/component:
170+
$(call cmd,mkdir,$@)
171+
172172
shared:
173173
$(call cmd,mkdir,$@)
174174

@@ -277,7 +277,10 @@ regenerate-world:
277277
@exit 1
278278
else
279279
regenerate-world:
280-
$(WIT_BINDGEN) c fastly.wit --no-helpers --out-dir fastly-world
280+
$(WIT_BINDGEN) c --no-helpers \
281+
--out-dir host_interface/component \
282+
--world fastly-world \
283+
host_interface/wit
281284
endif
282285

283286

@@ -295,7 +298,8 @@ $(foreach source,$(FSM_CPP),$(eval $(call compile_cxx,$(source))))
295298

296299
# Compute runtime build ########################################################
297300

298-
$(eval $(call compile_cxx,$(FSM_SRC)/fastly-world/fastly_world_adapter.cpp))
301+
$(eval $(call compile_cxx,$(FSM_SRC)/host_interface/component/fastly_world_adapter.cpp))
302+
$(eval $(call compile_cxx,$(FSM_SRC)/impl/main.cpp))
299303

300304
# This version of the runtime uses the world adapter in place of the world
301305
# generated by wit-bindgen, adapting to the currently available host calls on
@@ -306,17 +310,16 @@ $(eval $(call compile_cxx,$(FSM_SRC)/fastly-world/fastly_world_adapter.cpp))
306310
# that script for more information about why we do this.
307311
$(OBJ_DIR)/js-compute-runtime.wasm: $(FSM_OBJ) $(SM_OBJ) $(RUST_URL_LIB) $(RUST_ENCODING_LIB)
308312
$(OBJ_DIR)/js-compute-runtime.wasm: $(OBJ_DIR)/impl/main.o
309-
$(OBJ_DIR)/js-compute-runtime.wasm: $(OBJ_DIR)/fastly-world/fastly_world_adapter.o
313+
$(OBJ_DIR)/js-compute-runtime.wasm: $(OBJ_DIR)/host_interface/component/fastly_world_adapter.o
310314
$(call cmd_format,WASI_LD,$@) PATH="$(FSM_SRC)/scripts:$$PATH" \
311315
$(WASI_CXX) $(LD_FLAGS) $(OPENSSL_LIBS) -o $@ $^
312316
$(call cmd_format,WASM_STRIP,$@) $(call WASM_STRIP,$@)
313317
$(call cmd_format,WASM_METADATA,$@) $(call WASM_METADATA,$@)
314318

315-
$(eval $(call compile_cxx,$(FSM_SRC)/impl/main.cpp))
316-
317319
# Compute runtime component build ##############################################
318320

319-
$(eval $(call compile_c,$(FSM_SRC)/fastly-world/fastly_world.c))
321+
$(eval $(call compile_c,$(FSM_SRC)/host_interface/component/fastly_world.c))
322+
$(eval $(call compile_cxx,$(FSM_SRC)/impl/main_component.cpp))
320323

321324
# This version of the runtime uses the code generated by wit-bindgen, to
322325
# ultimately be run as a component on c@e.
@@ -326,15 +329,13 @@ $(eval $(call compile_c,$(FSM_SRC)/fastly-world/fastly_world.c))
326329
# that script for more information about why we do this.
327330
$(OBJ_DIR)/js-compute-runtime-component.wasm: $(FSM_OBJ) $(SM_OBJ) $(RUST_URL_LIB) $(RUST_ENCODING_LIB)
328331
$(OBJ_DIR)/js-compute-runtime-component.wasm: $(OBJ_DIR)/impl/main_component.o
329-
$(OBJ_DIR)/js-compute-runtime-component.wasm: $(FSM_SRC)/fastly-world/fastly_world_component_type.o
330-
$(OBJ_DIR)/js-compute-runtime-component.wasm: $(OBJ_DIR)/fastly-world/fastly_world.o
332+
$(OBJ_DIR)/js-compute-runtime-component.wasm: $(FSM_SRC)/host_interface/component/fastly_world_component_type.o
333+
$(OBJ_DIR)/js-compute-runtime-component.wasm: $(OBJ_DIR)/host_interface/component/fastly_world.o
331334
$(call cmd_format,WASI_LD,$@) PATH="$(FSM_SRC)/scripts:$$PATH" \
332335
$(WASI_CXX) $(LD_FLAGS) $(OPENSSL_LIBS) -o $@ $^
333336
$(call cmd_format,WASM_STRIP,$@) $(call WASM_STRIP,$@)
334337
$(call cmd_format,WASM_METADATA,$@) $(call WASM_METADATA,$@)
335338

336-
$(eval $(call compile_cxx,$(FSM_SRC)/impl/main_component.cpp))
337-
338339
# Shared builtins build ########################################################
339340

340341
shared-builtins: shared/builtins.a shared/librust_url.a shared/librust_encoding.a
Binary file not shown.
Binary file not shown.

runtime/js-compute-runtime/host_interface/fastly.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
extern "C" {
55
#endif
66

7-
#include "fastly-world/fastly_world.h"
87
#include <stdbool.h>
98
#include <stddef.h>
109
#include <stdint.h>
1110

11+
#include "host_interface/component/fastly_world.h"
12+
1213
namespace fastly {
1314

1415
#define WASM_IMPORT(module, name) __attribute__((import_module(module), import_name(name)))

runtime/js-compute-runtime/host_interface/host_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "builtins/cache-override.h"
55
#include "core/allocator.h"
6-
#include "fastly-world/fastly_world.h"
6+
#include "host_interface/component/fastly_world.h"
77
#include "host_interface/fastly.h"
88
#include "host_interface/host_api.h"
99
#include "js-compute-builtins.h"

0 commit comments

Comments
 (0)