aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cb15g11@soton.ac.uk>2015-05-02 10:36:03 +0100
committerChristopher Baines <cb15g11@soton.ac.uk>2015-05-02 11:58:01 +0100
commite7e1494e3384cc5904fb79a7f6c0f5a8776f1718 (patch)
treec07af64606c0148878c92f34dcc77afe6671de73
parentc0da98f318a637a91df6655b1c63385adb41e5ab (diff)
downloadmaps.southampton.ac.uk-e7e1494e3384cc5904fb79a7f6c0f5a8776f1718.tar
maps.southampton.ac.uk-e7e1494e3384cc5904fb79a7f6c0f5a8776f1718.tar.gz
Change build system to make
This is shorter, simpler, and works without random hacky javascript. The Makefile also now incorporates the download-libraries script, and will either use the system versions of leaflet and jquery if available, or attempt to download them from the web. The following web pages were helpful: http://aeflash.com/2014-10/make.html http://vmrob.com/colorized-makefiles/
-rw-r--r--Gruntfile.js116
-rwxr-xr-xMakefile122
-rw-r--r--README4
-rwxr-xr-xbuild-without-grunt.sh37
-rwxr-xr-xdownload-libraries.sh7
-rw-r--r--package.json12
6 files changed, 124 insertions, 174 deletions
diff --git a/Gruntfile.js b/Gruntfile.js
deleted file mode 100644
index 7e2f8b3..0000000
--- a/Gruntfile.js
+++ /dev/null
@@ -1,116 +0,0 @@
-module.exports = function(grunt) {
-
- grunt.initConfig({
- pkg: grunt.file.readJSON('package.json'),
- concat: {
- js: {
- options: {
- separator: ';'
- },
- src: [
- 'libraries/jquery/dist/jquery.js',
- 'libraries/bootstrap/dist/js/bootstrap.js',
- 'libraries/typeahead.js/dist/typeahead.bundle.js',
- 'libraries/list.js/dist/list.js',
- 'libraries/leaflet-soton/resources/leaflet/dist/leaflet.js',
- 'libraries/leaflet-soton/resources/leaflet-markercluster/dist/leaflet.markercluster.js',
- 'libraries/leaflet-soton/resources/leaflet-locatecontrol/src/L.Control.Locate.js',
- 'libraries/leaflet-soton/resources/leaflet-hash/leaflet-hash.js',
- 'libraries/leaflet-soton/resources/leaflet-indoor/leaflet-indoor.js',
- 'libraries/leaflet-soton/resources/leaflet-route/leaflet-route.js',
- 'libraries/leaflet-soton/resources/leaflet-textpath/leaflet.textpath.js',
- 'libraries/leaflet-soton/resources/uos-live.js/uos-live.js',
- 'libraries/leaflet-soton/resources/uos-live.js/libraries/pollymer/pollymer.js',
- 'libraries/leaflet-soton/src/leaflet-soton.js',
- 'scripts.js'
- ],
- dest: 'dist/scripts.js',
- nonull: true
- },
- css: {
- src: [
- 'libraries/bootstrap/dist/css/bootstrap.css',
- 'libraries/leaflet-soton/resources/leaflet/dist/leaflet.css',
- 'libraries/leaflet-soton/resources/leaflet-markercluster/dist/MarkerCluster.css',
- 'libraries/leaflet-soton/resources/leaflet-locatecontrol/src/L.Control.Locate.css',
- 'libraries/leaflet-soton/src/leaflet-soton.css',
- 'style.css'
- ],
- dest: 'dist/css/style.css',
- nonull: true
- }
- },
- uglify: {
- options: {
- banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
- },
- dist: {
- files: {
- 'dist/scripts.js': ['<%= concat.js.dest %>']
- }
- }
- },
- cssmin: {
- add_banner: {
- options: {
- banner: '/* My minified css file */'
- },
- files: {
- 'dist/css/style.css': ['<%= concat.css.dest %>']
- }
- }
- },
- clean: {
- build: ['dist']
- },
- copy: {
- index: {
- src: 'index.html',
- dest: 'dist/index.html',
- nonull: true
- },
- data: {
- src: 'libraries/leaflet-soton/data.json',
- dest: 'dist/data.json',
- nonull: true
- },
- fonts: {
- src: 'libraries/bootstrap/dist/fonts/*',
- dest: 'dist/fonts/',
- expand: 'false',
- flatten: true,
- nonull: true
- },
- images: {
- src: 'libraries/leaflet-soton/resources/images/*',
- dest: 'dist/images/',
- flatten: true,
- expand: 'false',
- nonull: true
- },
- logos: {
- src: 'libraries/leaflet-soton/resources/images/logos/*',
- dest: 'dist/images/logos/',
- flatten: true,
- expand: 'false',
- nonull: true
- },
- locateimage: {
- src: 'libraries/leaflet-soton/resources/leaflet-locatecontrol/src/images/*',
- dest: 'dist/css/images/',
- flatten: true,
- expand: 'false',
- nonull: true
- }
- }
- });
-
- grunt.loadNpmTasks('grunt-contrib-uglify');
- grunt.loadNpmTasks('grunt-contrib-cssmin');
- grunt.loadNpmTasks('grunt-contrib-concat');
- grunt.loadNpmTasks('grunt-contrib-clean');
- grunt.loadNpmTasks('grunt-contrib-copy');
-
- grunt.registerTask('default', ['clean:build', 'concat', 'copy']);
- grunt.registerTask('release', ['clean:build', 'concat', 'uglify', 'cssmin', 'copy']);
-};
diff --git a/Makefile b/Makefile
new file mode 100755
index 0000000..aead42b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,122 @@
+
+NO_COLOR=\033[0m
+OK_COLOR=\033[32;01m
+#ERROR_COLOR=\033[31;01m
+#WARN_COLOR=\033[33;01m
+
+OK_STRING=$(OK_COLOR)[OK]$(NO_COLOR)
+#ERROR_STRING=$(ERROR_COLOR)[ERRORS]$(NO_COLOR)
+#WARN_STRING=$(WARN_COLOR)[WARNINGS]$(NO_COLOR)
+
+AWK_CMD = awk '{ printf "%-30s %-10s\n",$$1, $$2; }'
+#PRINT_ERROR = printf "$@ $(ERROR_STRING)\n" | $(AWK_CMD) && printf "$(CMD)\n$$LOG\n" && false
+#PRINT_WARNING = printf "$@ $(WARN_STRING)\n" | $(AWK_CMD) && printf "$(CMD)\n$$LOG\n"
+PRINT_OK = printf "$@ $(OK_STRING)\n" | $(AWK_CMD)
+#BUILD_CMD = LOG=$$($(CMD) 2>&1) ; if [ $$? -eq 1 ]; then $(PRINT_ERROR); elif [ "$$LOG" != "" ] ; then $(PRINT_WARNING); else $(PRINT_OK); fi;
+
+build: clean dist/scripts.js dist/css/style.css dist/index.html dist/fonts dist/images dist/images/logos dist/css/images dist/data.json
+ @$(PRINT_OK)
+
+release: clean build uglify cssmin
+ @$(PRINT_OK)
+
+clean:
+ @rm -fr dist
+ @mkdir dist
+ @rm -f libraries/jquery/dist/jquery.js
+ @rm -f libraries/leaflet-soton/resources/leaflet/dist/leaflet.js
+ @$(PRINT_OK)
+
+stats:
+ ls -lh dist
+
+.PHONY: all clean stats release debug
+
+SYSTEM_JQUERY=/usr/share/javascript/jquery/jquery.js
+
+libraries/jquery/dist/jquery.js:
+ifneq ("$(wildcard $(SYSTEM_JQUERY))","")
+ @echo "Using system version of jquery"
+ cp $(SYSTEM_JQUERY) libraries/jquery/dist/jquery.js;
+ @$(PRINT_OK)
+else
+ @echo "System version of jquery does not exist, downloading...\n"
+ @mkdir -p libraries/jquery/dist/
+ wget http://code.jquery.com/jquery-2.1.1.js -O libraries/jquery/dist/jquery.js
+ @$(PRINT_OK)
+endif
+
+SYSTEM_LEAFLET=/usr/share/javascript/leaflet/leaflet-src.js
+
+libraries/leaflet-soton/resources/leaflet/dist/leaflet.js:
+ifneq ("$(wildcard $(SYSTEM_LEAFLET))","")
+ @echo "Using system version of leaflet"
+ cp $(SYSTEM_LEAFLET) libraries/leaflet-soton/resources/leaflet/dist/leaflet.js;
+else
+ @echo "System version of leaflet does not exist, downloading...\n"
+ wget http://leaflet-cdn.s3.amazonaws.com/build/leaflet-0.7.3.zip -O libraries/leaflet-0.7.3.zip
+ unzip -o libraries/leaflet-0.7.3.zip -d libraries/leaflet-soton/resources/leaflet/dist
+ @$(PRINT_OK)
+endif
+
+dist/scripts.js: libraries/jquery/dist/jquery.js libraries/leaflet-soton/resources/leaflet/dist/leaflet.js
+ @cat libraries/jquery/dist/jquery.js \
+ libraries/bootstrap/dist/js/bootstrap.js \
+ libraries/typeahead.js/dist/typeahead.bundle.js libraries/list.js/dist/list.js \
+ libraries/leaflet-soton/resources/leaflet/dist/leaflet.js \
+ libraries/leaflet-soton/resources/leaflet-markercluster/dist/leaflet.markercluster.js \
+ libraries/leaflet-soton/resources/leaflet-locatecontrol/src/L.Control.Locate.js \
+ libraries/leaflet-soton/resources/leaflet-hash/leaflet-hash.js \
+ libraries/leaflet-soton/resources/leaflet-indoor/leaflet-indoor.js \
+ libraries/leaflet-soton/resources/leaflet-route/leaflet-route.js \
+ libraries/leaflet-soton/resources/leaflet-textpath/leaflet.textpath.js \
+ libraries/leaflet-soton/resources/uos-live.js/uos-live.js \
+ libraries/leaflet-soton/resources/uos-live.js/libraries/pollymer/pollymer.js \
+ libraries/leaflet-soton/src/leaflet-soton.js \
+ scripts.js > dist/scripts.js
+ @$(PRINT_OK)
+
+uglify: dist/scripts.js
+ @uglifyjs dist/scripts.js --mangle toplevel --compress > dist/scripts.min.js
+ @mv dist/scripts.min.js dist/scripts.js
+ @$(PRINT_OK)
+
+cssmin: dist/css/style.css
+ @cssmin --wrap 1000 < dist/css/style.css > dist/css/style.min.css
+ @mv dist/css/style.min.css dist/css/style.css
+ @$(PRINT_OK)
+
+dist/css/style.css:
+ @mkdir dist/css
+ @cat libraries/bootstrap/dist/css/bootstrap.css \
+ libraries/leaflet-soton/resources/leaflet/dist/leaflet.css \
+ libraries/leaflet-soton/resources/leaflet-markercluster/dist/MarkerCluster.css \
+ libraries/leaflet-soton/resources/leaflet-locatecontrol/src/L.Control.Locate.css \
+ libraries/leaflet-soton/src/leaflet-soton.css \
+ style.css > dist/css/style.css
+ @$(PRINT_OK)
+
+dist/index.html:
+ @cp index.html dist/index.html
+ @$(PRINT_OK)
+
+dist/fonts:
+ @cp -r libraries/bootstrap/dist/fonts dist/fonts
+ @$(PRINT_OK)
+
+dist/images:
+ @cp -r libraries/leaflet-soton/resources/images dist/images
+ @$(PRINT_OK)
+
+dist/images/logos:
+ @cp -r libraries/leaflet-soton/resources/images/logos dist/images/logos
+ @$(PRINT_OK)
+
+dist/css/images:
+ @cp -r libraries/leaflet-soton/resources/leaflet-locatecontrol/src/images dist/css/images
+ @$(PRINT_OK)
+
+dist/data.json:
+ @cp libraries/leaflet-soton/data.json dist/data.json
+ @$(PRINT_OK)
+
diff --git a/README b/README
index f80b486..dfd0a93 100644
--- a/README
+++ b/README
@@ -21,11 +21,11 @@ After this, you will need to fetch or build the data.json file. Either running:
Then run:
- grunt
+ make
Or, to build for release (with smaller js and css files):
- grunt release
+ make release
# Building the libraries
diff --git a/build-without-grunt.sh b/build-without-grunt.sh
deleted file mode 100755
index b5956eb..0000000
--- a/build-without-grunt.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash -x
-
-rm -fr dist
-mkdir dist
-
-cat libraries/jquery/dist/jquery.js \
-libraries/bootstrap/dist/js/bootstrap.js \
-libraries/typeahead.js/dist/typeahead.bundle.js libraries/list.js/dist/list.js \
-libraries/leaflet-soton/resources/leaflet/dist/leaflet.js \
-libraries/leaflet-soton/resources/leaflet-markercluster/dist/leaflet.markercluster.js \
-libraries/leaflet-soton/resources/leaflet-locatecontrol/src/L.Control.Locate.js \
-libraries/leaflet-soton/resources/leaflet-hash/leaflet-hash.js \
-libraries/leaflet-soton/resources/leaflet-indoor/leaflet-indoor.js \
-libraries/leaflet-soton/resources/leaflet-route/leaflet-route.js \
-libraries/leaflet-soton/src/leaflet-soton.js \
-scripts.js > dist/scripts.js
-
-mkdir dist/css
-
-cat libraries/bootstrap/dist/css/bootstrap.css \
-libraries/leaflet-soton/resources/leaflet/dist/leaflet.css \
-libraries/leaflet-soton/resources/leaflet-markercluster/dist/MarkerCluster.css \
-libraries/leaflet-soton/resources/leaflet-locatecontrol/src/L.Control.Locate.css \
-libraries/leaflet-soton/src/leaflet-soton.css \
-style.css > dist/css/style.css
-
-cp index.html dist/index.html
-
-cp -r libraries/bootstrap/dist/fonts dist/fonts
-
-cp -r libraries/leaflet-soton/resources/images dist/images
-
-cp -r libraries/leaflet-soton/resources/images/logos dist/images/logos
-
-cp -r libraries/leaflet-soton/resources/leaflet-locatecontrol/src/images dist/css/images
-
-cp libraries/leaflet-soton/data.json dist/data.json
diff --git a/download-libraries.sh b/download-libraries.sh
deleted file mode 100755
index f01a64f..0000000
--- a/download-libraries.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash -x
-
-mkdir -p libraries/jquery/dist/
-wget http://code.jquery.com/jquery-2.1.1.js -O libraries/jquery/dist/jquery.js
-
-wget http://leaflet-cdn.s3.amazonaws.com/build/leaflet-0.7.3.zip -O libraries/leaflet-0.7.3.zip
-unzip -o libraries/leaflet-0.7.3.zip -d libraries/leaflet-soton/resources/leaflet/dist
diff --git a/package.json b/package.json
deleted file mode 100644
index c987bec..0000000
--- a/package.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "name": "maps.southampton.ac.uk",
- "version": "0.1.0",
- "devDependencies": {
- "grunt": "~0.4.5",
- "grunt-contrib-concat": "~0.5.0",
- "grunt-contrib-uglify": "~0.5.0",
- "grunt-contrib-cssmin": "~0.10.0",
- "grunt-contrib-copy": "~0.5.0",
- "grunt-contrib-clean": "~0.6.0"
- }
-}