Skip to content

Commit

Permalink
Reduce compiled Javascript size
Browse files Browse the repository at this point in the history
  • Loading branch information
ddohler committed Nov 16, 2017
1 parent 2f4d24d commit b5bb247
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
17 changes: 12 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ EMMAKE ?= emmake
EMCC ?= emcc
EMCONFIGURE ?= emconfigure
EMCONFIGURE_JS ?= 0
EMCC_CFLAGS := -msse
GDAL_EMCC_CFLAGS := -msse -Oz
PROJ_EMCC_CFLAGS := -msse -Oz
EXPORTED_FUNCTIONS = "[\
'_GDALAllRegister',\
'_GDALOpen',\
Expand All @@ -16,22 +17,23 @@ EXPORTED_FUNCTIONS = "[\
]"

export EMCONFIGURE_JS
export EMCC_CFLAGS

include gdal-configure.opt

.PHONY: clean

########
# GDAL #
########
gdal: gdal.js

gdal.js: gdal-lib
$(EMCC) $(GDAL)/libgdal.a -o gdal.js -O3 -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS)
EMCC_CFLAGS="$(GDAL_EMCC_CFLAGS)" $(EMCC) $(GDAL)/libgdal.a -o gdal.js -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS)

gdal-lib: $(GDAL)/libgdal.a

$(GDAL)/libgdal.a: $(GDAL)/config.status proj4
cd $(GDAL) && $(EMMAKE) make lib-target
cd $(GDAL) && EMCC_CFLAGS="$(GDAL_EMCC_CFLAGS)" $(EMMAKE) make lib-target

# TODO: Pass the configure params more elegantly so that this uses the
# EMCONFIGURE variable
Expand All @@ -48,7 +50,7 @@ reset-proj4:
proj4: reset-proj4
cd $(PROJ4) && ./autogen.sh
cd $(PROJ4) && $(EMCONFIGURE) ./configure
cd $(PROJ4) && $(EMMAKE) make
cd $(PROJ4) && EMCC_CFLAGS="$(PROJ_EMCC_CFLAGS)" $(EMMAKE) make

# We need to make proj4-native a separate prerequisite even though it's nearly
# the same thing because make will only run each prerequisite once per
Expand All @@ -66,3 +68,8 @@ proj4-native: reset-proj4-native
cd $(PROJ4) && ./autogen.sh
cd $(PROJ4) && ./configure
cd $(PROJ4) && make

clean:
cd $(GDAL) && make clean
cd $(PROJ4) && make clean
rm -f gdal.js gdal.js.mem
6 changes: 3 additions & 3 deletions gdal-configure.opt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A = --enable-static
A += --enable-pdf-plugin=no
A += --without-libtool
A += --without-ld-shared
A += --with-threads=yes
A += --with-threads=no
A += --with-libz=internal
A += --without-libiconv-prefix
A += --without-liblzma
Expand All @@ -13,13 +13,13 @@ A += --without-grass
A += --without-libgrass
A += --without-cfitsio
A += --without-pcraster
A += --with-png=internal
A += --without-png
A += --without-mrf
A += --without-dds
A += --without-gta
A += --with-libtiff=internal
A += --with-geotiff=internal
A += --with-jpeg=internal
A += --without-jpeg
A += --without-jpeg12
A += --without-gif
A += --without-ogdi
Expand Down

0 comments on commit b5bb247

Please sign in to comment.