From b5bb247f1bd43a9acc158cd207ce3d49e8b8ce3b Mon Sep 17 00:00:00 2001 From: Derek Dohler Date: Thu, 16 Nov 2017 10:31:43 -0500 Subject: [PATCH] Reduce compiled Javascript size --- Makefile | 17 ++++++++++++----- gdal-configure.opt | 6 +++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 4f7d337498d8..9ab88db55aed 100644 --- a/Makefile +++ b/Makefile @@ -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',\ @@ -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 @@ -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 @@ -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 diff --git a/gdal-configure.opt b/gdal-configure.opt index b80af273dfb8..d31b1aab9f6d 100644 --- a/gdal-configure.opt +++ b/gdal-configure.opt @@ -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 @@ -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