Skip to content

Commit

Permalink
Fixed WASM build.
Browse files Browse the repository at this point in the history
  • Loading branch information
indigoparadox committed Oct 22, 2022
1 parent 1023cad commit 5542a8b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
19 changes: 5 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,6 @@ define RESEXT_H_RULE
$(MD) $$(dir $$@)
cp $$< $$@

$(GENDIR)/$(platform)/%.wasm: %.wasm | \
$(GENDIR)/$(platform)/$(STAMPFILE)
$(MD) $$(dir $$@)
cp $$< $$@

$(GENDIR)/$(platform)/%.js: %.js | \
$(GENDIR)/$(platform)/$(STAMPFILE)
$(MD) $$(dir $$@)
cp $$< $$@

# Preprocess JSON maps/tilesets for depth path.
$(GENDIR)/$(platform)/$(ASSETDIR)/t2_%.json: $(ASSETDIR)/t2_%.json \
| $(GENDIR)/$(platform)/$(STAMPFILE)
Expand Down Expand Up @@ -425,27 +415,28 @@ define PKG_RULE
$(MD) $$(dir $$@)
cp $$< $$@

# Copy binary (strip if release).
ifeq ($(BUILD),RELEASE)
$$(PKGBUILD)/$$(notdir $(pkg_bin)): $(pkg_bin)
$(MD) $$(dir $$@)
cp $$^ $$@
cp $$^ $$(PKGBUILD)
$(pkg_strip) $$@
else
$$(PKGBUILD)/$$(notdir $(pkg_bin)): $(pkg_bin)
$(MD) $$(dir $$@)
cp $$^ $$@
cp $$^ $$(PKGBUILD)
endif

$(ROOT)/$(PKGDIR)/$(pkg_name)$(PKG_OUT_FLAGS).tar.gz: \
$$(addprefix $$(PKGBUILD)/,$(pkg_reqs)) \
$$(PKGBUILD)/$(notdir $(pkg_bin)) \
$$(addprefix $$(PKGBUILD)/,$(notdir $(pkg_bin))) \
$$(PKGBUILD)/README.md \
| $(PKGDIR)/$(STAMPFILE)
cd pkgbuild && $(TAR) -cvf - $(pkg_name)$(PKG_OUT_FLAGS) | $(GZIP) > $$@

$(ROOT)/$(PKGDIR)/$(pkg_name)$(PKG_OUT_FLAGS).zip: \
$$(addprefix $$(PKGBUILD)/,$(pkg_reqs)) \
$$(PKGBUILD)/$(notdir $(pkg_bin)) \
$$(addprefix $$(PKGBUILD)/,$(notdir $(pkg_bin))) \
$$(PKGBUILD)/README.md \
| $(PKGDIR)/$(STAMPFILE)
cd pkgbuild && $(ZIP) -r $$@ $(pkg_name)$(PKG_OUT_FLAGS)
Expand Down
14 changes: 9 additions & 5 deletions Makefile.wasm
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,28 @@ endif

# 5. Targets

# 5a. Packages

platform := wasm
res_gfx := $(DSEKAI_ASSETS_BITMAPS)
res_maps := $(DSEKAI_ASSETS_MAPS_JSON)
$(eval $(RESEXT_H_RULE))

pkg_bin := $(BIN_WASM)
pkg_strip := echo
pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH)
pkg_reqs := \
pkg_bin := $(BIN_WASM) \
$(BINDIR)/$(DSEKAI).wasm \
$(BINDIR)/$(DSEKAI).js
pkg_strip := echo
pkg_name := $(DSEKAI)-$(platform)-$(GIT_HASH)
pkg_reqs :=
$(eval $(PKG_RULE))


# 5b. Binaries

$(BIN_WASM) $(BINDIR)/$(DSEKAI).wasm $(BINDIR)/$(DSEKAI).js: \
$(DSEKAI_O_FILES_WASM) | $(BINDIR)/$(STAMPFILE)
$(LD_WASM) -o $(BIN_WASM) $^ $(LDFLAGS_WASM)


$(OBJDIR_WASM)/%.o: %.c $(RESEXT_H) | $(DSEKAI_ASSETS_MAPS_JSON)
$(MD) $(dir $@)
$(CC_WASM) $(CFLAGS_WASM) -c -o $@ $(<:%.o=%)
Expand Down
2 changes: 2 additions & 0 deletions pkgs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ do_run() {
build_xlib
fi
cd pkgbuild/dsekai-xlib-*-cga-*-json && ./dsekaix
elif [ "$PLAT_SPEC" = "wasm" ]; then
cd pkgbuild/dsekai-wasm-*-vga-* && python -m http.server
fi
}

Expand Down

0 comments on commit 5542a8b

Please sign in to comment.