Skip to content

Commit

Permalink
chore: Rework the shared-builtins target to produce a single static a…
Browse files Browse the repository at this point in the history
…rchive (#646)
  • Loading branch information
elliottt authored Sep 5, 2023
1 parent 8328add commit 2b8c6b1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
1 change: 0 additions & 1 deletion runtime/js-compute-runtime/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
!/host_interface/component/fastly_world.o
/js-compute-runtime*.wasm
/build
/shared
29 changes: 19 additions & 10 deletions runtime/js-compute-runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -338,19 +338,28 @@ $(OBJ_DIR)/js-compute-runtime-component.wasm: $(OBJ_DIR)/host_interface/componen

# Shared builtins build ########################################################

shared-builtins: shared/builtins.a shared/librust_url.a shared/librust_encoding.a
.PHONY: shared-builtins
shared-builtins: shared.a

shared/builtins.a: $(OBJ_DIR)/builtins/shared/*.o
shared/builtins.a: $(OBJ_DIR)/builtin.o
shared/builtins.a: $(OBJ_DIR)/core/encode.o
shared/builtins.a: | shared
$(call cmd,wasi_ar,$^)

shared/librust_url.a: $(RUST_URL_LIB) | shared
.PHONY: shared.a
shared.a: $(OBJ_DIR)/shared.a
$(call cmd,cp,$@)

shared/librust_encoding.a: $(RUST_ENCODING_LIB) | shared
$(call cmd,cp,$@)
extract_lib = $(call cmd_format,WASI_AR [x],$2) $(WASI_AR) -x --output $1 $2

$(OBJ_DIR)/shared: $(OBJ_DIR)/builtins.a $(RUST_URL_LIB) $(RUST_ENCODING_LIB)
$(call cmd,mkdir,$@)
$(call extract_lib,$(OBJ_DIR)/shared,$(OBJ_DIR)/builtins.a)
$(call extract_lib,$(OBJ_DIR)/shared,$(RUST_URL_LIB))
$(call extract_lib,$(OBJ_DIR)/shared,$(RUST_ENCODING_LIB))

$(OBJ_DIR)/shared.a: | $(OBJ_DIR)/shared
$(call cmd,wasi_ar,$(wildcard $(OBJ_DIR)/shared/*.o))

$(OBJ_DIR)/builtins.a: $(filter $(OBJ_DIR)/builtins/shared/%.o,$(FSM_OBJ))
$(OBJ_DIR)/builtins.a: $(OBJ_DIR)/builtin.o
$(OBJ_DIR)/builtins.a: $(OBJ_DIR)/core/encode.o
$(call cmd,wasi_ar,$^)

# These two rules copy the built artifacts into the $(FSM_SRC) directory, and
# are both marked phony as we need to do the right thing when running the
Expand Down
4 changes: 2 additions & 2 deletions runtime/js-compute-runtime/mk/commands.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Q := @
quiet_flag = $1

# Convenience macro for calling known commands with a nicer output format.
cmd = $(call cmd_format,$(cmd_$1_name),$2)$(call cmd_$1,$2)
cmd = $(call cmd_format,$(cmd_$1_name),$@)$(call cmd_$1,$2)

# Strip off the js-compute-runtime root from a path.
without_root = $(subst $(FSM_SRC)/,,$1)
Expand Down Expand Up @@ -39,7 +39,7 @@ cmd_wget_name := WGET
cmd_wget = wget $(URL) $(call quiet_flag,--quiet) -O $1

cmd_wasi_ar_name := WASI_AR
cmd_wasi_ar = $(WASI_AR) rcs $@ $^
cmd_wasi_ar = $(WASI_AR) rcs $@ $1

cmd_wasi_cxx_name := WASI_CXX
cmd_wasi_cxx = $(WASI_CXX) $(CXX_FLAGS) $(OPT_FLAGS) $(INCLUDES) $(DEFINES) -MMD -MP -c -o $1 $<
Expand Down

0 comments on commit 2b8c6b1

Please sign in to comment.