Skip to content

Commit

Permalink
build setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Marsch committed Apr 1, 2016
1 parent 9b91313 commit 5937b25
Show file tree
Hide file tree
Showing 7 changed files with 1,249 additions and 571 deletions.
182 changes: 20 additions & 162 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,196 +1,54 @@

var fs = require('fs');

module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),

concat: {
glx: {
options: {
separator: "\n",
banner: "(function(global) {",
footer: "}(this));",
sourceMap: true
},
src: [
"src/glx/index.js",
"src/glx/prefix.js",
"src/glx/util.js",
"src/glx/Buffer.js",
"src/glx/Framebuffer.js",
"src/glx/Shader.js",
"src/glx/Matrix.js",
"src/glx/Texture.js",
"src/glx/texture/index.js",
"src/glx/texture/Image.js",
"src/glx/texture/Data.js",
"src/glx/mesh/index.js",
"src/glx/mesh/Triangle.js",
"src/glx/mesh/Plane.js",
"src/glx/mesh/Cube.js",
"src/glx/suffix.js"
],
dest: 'lib/GLX.debug.js'
jshint: {
options: {
globals: {}
},
all: 'src/Triangulate.js'
},

'osmb-basemap': {
concat: {
default: {
options: {
separator: "\n",
banner: "(function(global) {",
footer: "}(this));",
sourceMap: true
footer: "}(this));"
},
src: [
'src/engines/Basemap/index.js',
'src/engines/Basemap/Pointer.js',
'src/engines/Basemap/Layers.js',
grunt.file.readJSON('config.json').lib,
grunt.file.readJSON('config.json').src
"node_modules/earcut/dist/earcut.dev.js",
"node_modules/Color/dist/Color.debug.js",
"src/Triangulate.js"
],
dest: 'dist/OSMBuildings/<%=pkg.name%>.debug.js'
}
},

copy: {
'assets': {
src: 'src/skydome.jpg',
dest: 'dist/OSMBuildings/skydome.jpg'
},
'css': {
src: 'src/engines/Basemap/style.css',
dest: 'dist/OSMBuildings/<%=pkg.name%>.css'
dest: 'dist/<%=pkg.name%>.debug.js'
}
},

uglify: {
'osmb-basemap': {
options: {
sourceMap: true
},
src: 'dist/OSMBuildings/<%=pkg.name%>.debug.js',
dest: 'dist/OSMBuildings/<%=pkg.name%>.js'
}
},

shaders: {
dist: {
src: 'src/shader',
dest: 'src/Shaders.min.js',
names: grunt.file.readJSON('config.json').shaders
}
},

version: {
dist: {
src: './dist/OSMBuildings/<%=pkg.name%>.debug.js',
mapping: {
'{{VERSION}}': '<%=pkg.version%>'
}
}
},

clean: {
dist: ['./dist/OSMBuildings/<%=pkg.name%>.pack.js']
},

jshint: {
options: {
globals: {}
},
all: grunt.file.readJSON('config.json').src
},

compress: {
main: {
options: {
level: 5,
archive: 'dist/<%=pkg.name%>-<%=pkg.version%>.zip'
},
files: [
{ expand: true, cwd: 'dist/', src: ['<%=pkg.name%>/*', 'index.html'] }
]
}
},

// just testing, whether wepack *would* work
webpack: {
test: {
entry: './dist/OSMBuildings/<%=pkg.name%>.debug.js',
output: {
path: './dist/OSMBuildings',
filename: '<%=pkg.name%>.pack.js',
},
stats: false, // the stats output
progress: false, // show progress
failOnError: true, // don't report error to grunt if webpack find errors
watch: false,
keepalive: true // don't finish the grunt task
default: {
options: {},
src: 'dist/<%=pkg.name%>.debug.js',
dest: 'dist/<%=pkg.name%>.js'
}
}
});

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-webpack');

grunt.registerMultiTask('version', 'Set version number', function() {
var config = this.data;

var content = '' + fs.readFileSync(config.src);

for (var tag in config.mapping) {
content = content.replace(tag, config.mapping[tag]);
}

fs.writeFileSync(config.src, content);
});

grunt.registerMultiTask('shaders', 'Build shaders', function() {
// grunt.log.writeln(JSON.stringify(this.data));
var config = this.data;

var src, name, Shaders = {};
for (var i = 0; i < config.names.length; i++) {
name = config.names[i];
Shaders[name] = {};

src = fs.readFileSync(config.src + '/' + name + '.vs', 'ascii');
Shaders[name].vertex = src.replace(/'/g, "\'").replace(/[\r\n]+/g, '\n');

src = fs.readFileSync(config.src + '/' + name + '.fs', 'ascii');
Shaders[name].fragment = src.replace(/'/g, "\'").replace(/[\r\n]+/g, '\n');
}

fs.writeFileSync(config.dest, 'var Shaders = '+ JSON.stringify(Shaders) +';\n');
});
grunt.loadNpmTasks('grunt-contrib-uglify');

grunt.registerTask('default', 'Development build', function() {
grunt.log.writeln('\033[1;36m'+ grunt.template.date(new Date(), 'yyyy-mm-dd HH:MM:ss') +'\033[0m');
grunt.task.run('shaders');
grunt.task.run('concat:osmb-basemap');
grunt.task.run('version');
grunt.task.run('concat');
grunt.task.run('uglify');
});

grunt.registerTask('release', 'Release', function() {
grunt.log.writeln('\033[1;36m'+ grunt.template.date(new Date(), 'yyyy-mm-dd HH:MM:ss') +'\033[0m');

grunt.task.run('jshint');

grunt.task.run('concat:glx');
grunt.task.run('shaders');
grunt.task.run('concat:osmb-basemap');
grunt.task.run('version');
grunt.task.run('uglify:osmb-basemap');

grunt.task.run('copy:assets');
grunt.task.run('copy:css');

grunt.task.run('compress');
grunt.task.run('webpack');
grunt.task.run('default');
});
};
79 changes: 2 additions & 77 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

OSM Buildings
https://github.com/OSMBuildings/OSMBuildings
Triangulate
https://github.com/OSMBuildings/Triangulates
Copyright (c) 2016, Jan Marsch, OSM Buildings

Color.js
Expand Down Expand Up @@ -48,78 +48,3 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

===============================================================================

Suncalc
https://github.com/mourner/suncalc/
Copyright (c) 2014, Vladimir Agafonkin

Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

===============================================================================

Clockwise winding check
https://github.com/Turfjs/turf-rewind
Abel Vázquez

Uses Shoelace Formula (http://en.wikipedia.org/wiki/Shoelace_formula)

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

===============================================================================

several code fragments from osmstreetview
https://github.com/rbuch703/osmstreetview/
Robert Buchholz

Copyright 2014, Robert Buchholz <[email protected]>.

It is licensed under the GNU General Public License version 3.

===============================================================================

Skydome image
<unknown>

Taken from http://blenderartists.org/forum/showthread.php?24038-Free-high-res-skymaps-%28Massive-07-update!%29

"There are no restrictions on using these textures, you can use these for
commercial work, and you don't have to name me if you don't want to. the only
restriction is that you can't sell them. that's all."
Loading

0 comments on commit 5937b25

Please sign in to comment.