|
| 1 | +var gulp = require('gulp') |
| 2 | + , uglify = require('gulp-uglify') |
| 3 | + , concat = require('gulp-concat-util') |
| 4 | + , wrap = require('gulp-wrap') |
| 5 | + , tap = require('gulp-tap') |
| 6 | + , header = require('gulp-header') |
| 7 | + , path = require('path') |
| 8 | + , version |
| 9 | + , glowscript_libraries; |
| 10 | + |
| 11 | +version = '1.1'; |
| 12 | + |
| 13 | +glowscript_libraries = { |
| 14 | + "glow": [ |
| 15 | + "lib/jquery/jquery.mousewheel.js", |
| 16 | + "lib/flot/jquery.flot.min.js", |
| 17 | + "lib/flot/jquery.flot.crosshair_GS.js", |
| 18 | + "lib/glMatrix.js", |
| 19 | + "lib/webgl-utils.js", |
| 20 | + "lib/glow/property.js", |
| 21 | + "lib/glow/vectors.js", |
| 22 | + "lib/glow/mesh.js", |
| 23 | + "lib/glow/canvas.js", |
| 24 | + "lib/glow/orbital_camera.js", |
| 25 | + "lib/glow/autoscale.js", |
| 26 | + "lib/glow/WebGLRenderer.js", |
| 27 | + "lib/glow/graph.js", |
| 28 | + "lib/glow/color.js", |
| 29 | + "lib/glow/primitives.js", |
| 30 | + "lib/glow/api_misc.js", |
| 31 | + "lib/glow/shaders.gen.js" |
| 32 | + ], |
| 33 | + "compiler": [ |
| 34 | + "lib/narcissus/lib/jsdefs.js", |
| 35 | + "lib/narcissus/lib/jslex.js", |
| 36 | + "lib/narcissus/lib/jsparse.js", |
| 37 | + "lib/narcissus/lib/jsdecomp.js", |
| 38 | + "lib/streamline/compiler/format.js", |
| 39 | + "lib/streamline/compiler/transform.js", |
| 40 | + "lib/compiler.js", |
| 41 | + "lib/coffee-script.js" |
| 42 | + ], |
| 43 | + "RSrun": [ |
| 44 | + "lib/rapydscript/stdlib.js" |
| 45 | + ], |
| 46 | + "RScompiler": [ |
| 47 | + "lib/narcissus/lib/jsdefs.js", |
| 48 | + "lib/narcissus/lib/jslex.js", |
| 49 | + "lib/narcissus/lib/jsparse.js", |
| 50 | + "lib/narcissus/lib/jsdecomp.js", |
| 51 | + "lib/streamline/compiler/format.js", |
| 52 | + "lib/streamline/compiler/transform.js", |
| 53 | + "lib/compiler.js", |
| 54 | + "lib/rapydscript/utils.js", |
| 55 | + "lib/rapydscript/ast.js", |
| 56 | + "lib/rapydscript/output.js", |
| 57 | + "lib/rapydscript/parse.js", |
| 58 | + "lib/rapydscript/baselib.js", |
| 59 | + "lib/rapydscript/stdlib.js" |
| 60 | + ], |
| 61 | +}; |
| 62 | + |
| 63 | +gulp.task('default', function() { |
| 64 | + var shaders = [] |
| 65 | + , shader_key; |
| 66 | + |
| 67 | + gulp.src('./shaders/*.shader') |
| 68 | + .pipe(tap(function(file) { |
| 69 | + shader_key = path.basename(file.path, '.shader'); |
| 70 | + file.contents = new Buffer('"' + shader_key + '":' + JSON.stringify(file.contents.toString())); |
| 71 | + return file; |
| 72 | + })) |
| 73 | + .pipe(concat('shaders.gen.js', { sep : ',\n' })) |
| 74 | + .pipe(wrap('Export({ shaders: {\n<%= contents %>\n}});')) |
| 75 | + .pipe(gulp.dest('./lib/glow/')); |
| 76 | + |
| 77 | + Object.keys(glowscript_libraries).forEach(function(lib) { |
| 78 | + gulp.src(glowscript_libraries[lib]) |
| 79 | + .pipe(uglify()) |
| 80 | + .pipe(concat(lib + '.' + version + '.min.js')) |
| 81 | + .pipe(header("/*This is a combined, compressed file. Look at https://github.com/BruceSherwood/glowscript for source code and copyright information.*/")) |
| 82 | + .pipe(gulp.dest('./package/')); |
| 83 | + }); |
| 84 | +}); |
0 commit comments