Permalink
Browse files

Updated build script to build Chrome app. Added icons and manifest.

  • Loading branch information...
BKcore committed Mar 1, 2013
1 parent f3dde45 commit 93f2874d9d962578f4cd0fc727aba4c2c5a87d54
View
@@ -5,7 +5,8 @@ var uglify = require("uglify-js");
var execSync = require('exec-sync');
var spawn = require('child_process').spawn;
-var base = "../sources/";
+var root = "../";
+var base = root+"sources/";
var coffeedir = base+"shdr/";
var minifiedlibs = [
base+"libs/ace/ace.js",
@@ -27,13 +28,77 @@ var files = [
base+"shdr/Validator.js",
base+"shdr/Viewer.js"
];
+var chrome_output = "shdr-chrome.crx";
+var chrome_dir = "shdr-chrome";
+var chrome_iconspath = root+"icons/";
+var chrome_icons = [
+ "icon_016.png",
+ "icon_032.png",
+ "icon_048.png",
+ "icon_128.png",
+ "icon_256.png",
+ "icon_512.png"
+];
+var chrome_shdrdir = "build";
+var chrome_dirs = [
+ "css",
+ "fonts",
+ "fonts/font-awesome",
+ "fonts/ubuntu-mono",
+ "img",
+ "models"
+];
+var chrome_files = [ // ignore shdr.js && nobase
+ "index.html",
+ "manifest.json",
+ "css/main.css",
+ "fonts/font-awesome/FontAwesome.otf",
+ "fonts/font-awesome/font-awesome.min.css",
+ "fonts/font-awesome/fontawesome-webfont.eot",
+ "fonts/font-awesome/fontawesome-webfont.svg",
+ "fonts/font-awesome/fontawesome-webfont.ttf",
+ "fonts/font-awesome/fontawesome-webfont.woff",
+ "fonts/ubuntu-mono/bold.woff",
+ "fonts/ubuntu-mono/bolditalic.woff",
+ "fonts/ubuntu-mono/font.css",
+ "fonts/ubuntu-mono/italic.woff",
+ "fonts/ubuntu-mono/normal.woff",
+ "img/loader.gif",
+ "models/cube.js",
+ "models/dragon.js",
+ "models/hexmkii.js",
+ "models/sphere.js",
+ "models/suzanne_high.js",
+ "models/suzanne_low.js",
+ "models/torus.js"
+];
+
+function recrmdirSync(dirPath) {
+ try { var files = fs.readdirSync(dirPath); }
+ catch(e) { return; }
+ if (files.length > 0)
+ for (var i = 0; i < files.length; i++) {
+ var filePath = dirPath + '/' + files[i];
+ if (fs.statSync(filePath).isFile())
+ fs.unlinkSync(filePath);
+ else
+ recrmdirSync(filePath);
+ }
+ fs.rmdirSync(dirPath);
+}
+
+function copySync(srcFile, destFile) {
+ var content = fs.readFileSync(srcFile);
+ fs.writeFileSync(destFile, content);
+}
function main() {
"use strict";
var parser = new argparse.ArgumentParser();
parser.addArgument(['--minify'], { action: 'storeTrue', defaultValue: false });
+ parser.addArgument(['--chromeapp'], { action: 'storeTrue', defaultValue: false });
parser.addArgument(['--output'], { defaultValue: 'shdr.js' });
var args = parser.parseArgs();
@@ -42,8 +107,11 @@ function main() {
console.log(' * Building ' + output);
console.log(' * Compiling coffeescript classes from '+coffeedir);
- var comp = execSync('coffee -c '+coffeedir);
- console.log(comp);
+ try {
+ var comp = execSync('coffee -c '+coffeedir);
+ }catch(e){
+ console.log(e);
+ }
var buffer = [];
var sources = [];
@@ -56,22 +124,20 @@ function main() {
}
console.log(' * Concating .js files');
-
- console.log(files);
-
- if(!args.minify)
+ if(!args.minify && !args.chromeapp)
{
for(var j = 0; j < files.length; j++)
{
var file = files[j];
+ console.log(" - "+file);
sources.push(file);
buffer.push(fs.readFileSync(file, 'utf8'));
}
var temp = buffer.join('');
fs.writeFileSync(output, minlibs+temp, 'utf8');
- }
- else
+ }
+ else
{
console.log(' * Minifying...');
@@ -80,6 +146,65 @@ function main() {
}
console.log(' * Shdr was built to '+output);
+
+ if(args.chromeapp)
+ {
+ console.log(' * Building Chrome App into '+chrome_dir);
+
+ recrmdirSync(chrome_dir);
+ fs.mkdirSync(chrome_dir);
+
+ var targetpath = chrome_dir+'/';
+
+ console.log(' * Creating directories');
+ for(var j=0; j < chrome_dirs.length; j++)
+ {
+ var d = targetpath+chrome_dirs[j];
+ console.log(' - '+d);
+ fs.mkdirSync(d);
+ }
+
+ console.log(' * Copying core files');
+ for(var k=0; k < chrome_files.length; k++)
+ {
+ var file = chrome_files[k];
+ var o = base+file;
+ var t = targetpath+file;
+ console.log(' - '+o+' -> '+t);
+ copySync(o,t);
+ }
+
+ console.log(' * Copying icons');
+ for(var l=0; l < chrome_icons.length; l++)
+ {
+ var file = chrome_icons[l];
+ var o = chrome_iconspath+file;
+ var t = targetpath+file;
+ console.log(' - '+o+' -> '+t);
+ copySync(o,t);
+ }
+
+ console.log(' * Copying '+output+' to '+chrome_shdrdir+'/');
+ var dir = targetpath+chrome_shdrdir;
+ fs.mkdirSync(dir);
+ var o = output;
+ var t = dir+'/shdr.js';
+ console.log(' - '+o+' -> '+t);
+ copySync(o,t);
+
+ console.log(' * Zipping '+chrome_dir+'...');
+ try {
+ var zip = execSync('zip -r '+chrome_output+' '+chrome_dir);
+ }catch(e){
+ console.log(e);
+ }
+
+ console.log(' * Cleaning up...');
+ recrmdirSync(chrome_dir);
+
+ console.log(' * Chrome app built to '+chrome_output);
+
+ }
}
main();
View
Binary file not shown.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Shdr Editor</title>
- <meta name="description" content="Shdr is an online ESSL (GLSL) shader editor, viewer and validator powered by WebGL and built by Thibaut Despoulain (BKcore).">
+ <meta name="description" content="Shdr is a live ESSL (GLSL) shader editor, viewer and validator powered by WebGL and built by Thibaut Despoulain (BKcore).">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="fonts/font-awesome/font-awesome.min.css">
View
@@ -0,0 +1,141 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <title>Shdr Editor</title>
+ <meta name="description" content="Shdr is a live ESSL (GLSL) shader editor, viewer and validator powered by WebGL and built by Thibaut Despoulain (BKcore).">
+ <meta name="viewport" content="width=device-width">
+ <meta name="google-site-verification" content="9aMzbIqnVsSKifyPR9OdN8HoKfTbsE3W8lSQ9M66zwk">
+ <link rel="icon" href="/favicon.png" type="image/png">
+ <link rel="shortcut icon" href="/favicon.png" type="image/png">
+ <link rel="stylesheet" type="text/css" href="css/main.css">
+ <link rel="stylesheet" type="text/css" href="fonts/font-awesome/font-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="fonts/ubuntu-mono/font.css">
+</head>
+<body onload="init();">
+
+<!-- inline preloader -->
+<div id="main-loader" style="position: absolute; z-index: 10000; top: 0; bottom: 0; left: 0; right: 0; background: #000; color: #000; font-family: Arial, 'Ubuntu sans', sans-serif; font-size: 32px; font-weight: bold;">
+ <div style="position: absolute; z-index: 10001; top: 50%; left: 0; width: 100%; background: #191919; text-align: center; line-height: 60px; margin-top: -30px; border-top: 1px solid #333; border-bottom: 1px solid #333;">
+ <img src="img/loader.gif" height="32" width="32" alt="Loading..." style="margin-bottom: -4px"> Fetching stuff.
+ </div>
+</div>
+
+<!-- app structure -->
+<div id="panel-top">
+ <div class="menu" id="menu-mode" data-action="mode">
+ <button type="button" class="menu-trigger"><i class="icon-pencil"></i><span>Fragment</span></button>
+ <div class="menu-list">
+ <button type="button" class="menu-item" data-index="0">Fragment</button>
+ <button type="button" class="menu-item" data-index="1">Vertex</button>
+ </div>
+ </div>
+ <div class="menu" id="menu-update" data-action="update">
+ <button type="button" class="menu-trigger"><i class="icon-circle"></i>Auto update</button>
+ <div class="menu-list">
+ <button type="button" class="menu-item" data-index="0"><i class="icon-circle"></i>Auto Update</button>
+ <button type="button" class="menu-item" data-index="1"><i class="icon-adjust"></i>ENTER Update</button>
+ <button type="button" class="menu-item" data-index="2"><i class="icon-circle-blank"></i>Ctrl+S Update</button>
+ </div>
+ </div>
+ <div class="menu" id="menu-snippets" data-action="snippets">
+ <button type="button" class="menu-trigger"><i class="icon-plus"></i>Snippets</button>
+ <div class="menu-list"></div>
+ </div>
+ <div class="menu" id="menu-download" data-action="download">
+ <button type="button" class="menu-button"><i class="icon-download-alt"></i>Download</button>
+ </div>
+ <div class="menu" id="menu-share" data-action="share">
+ <button type="button" class="menu-button"><i class="icon-share-alt"></i>Share</button>
+ </div>
+ <!-- LEFT/RIGHT -->
+ <div class="menu menu-right" id="menu-models" data-action="models">
+ <button type="button" class="menu-trigger"><i class="icon-reorder"></i><span>Suzanne (high)</span></button>
+ <div class="menu-list"></div>
+ </div>
+ <div class="menu menu-right" id="menu-rotate" data-action="rotate">
+ <button type="button" class="menu-button menu-toggle menu-icon-only" data-current="0" data-off="1" data-on="0">
+ <i class="icon-pause" data-on="icon-pause" data-off="icon-play"></i>
+ </button>
+ </div>
+</div>
+
+<div id="panel-main">
+ <div id="panel-left">
+ <div id="editor"></div>
+ </div>
+ <div id="panel-right">
+ <div id="viewer"></div>
+ <div id="shdr">Shdr</div>
+ <div id="model-loader">
+ <img src="img/loader.gif" height="32" width="32" alt="Loading model...">
+ </div>
+ </div>
+</div>
+
+<div id="panel-bottom">
+ <div id="status">
+ <span class="status-success"><i class="icon-ok-sign"></i><b>Ready</b></span>
+ </div>
+ <div id="footer">
+ <div class="menu menu-right menu-status" id="menu-about" data-action="about">
+ <button type="button" class="menu-button"><i class="icon-info-sign"></i>About Shdr</button>
+ </div>
+ <div class="menu menu-right menu-status" id="menu-help" data-action="help">
+ <button type="button" class="menu-button"><i class="icon-question-sign"></i>Help</button>
+ </div>
+ </div>
+</div>
+
+<div id="box-share" class="box">
+ <h1 class="title">Share URL</h1>
+ <div class="content">
+ <input type="text" value="" id="box-share-url" readonly><button id="box-share-shorten" class="menu-button">Shorten</button>
+ </div>
+ <button type="button" class="close">
+ <i class="icon-remove"></i>
+ </button>
+</div>
+
+<div id="box-about" class="box">
+ <h1 class="title">About Shdr</h1>
+ <div class="content">
+ <p>
+ Shdr is an online ESSL (GLSL) shader editor, viewer and validator powered by WebGL.
+ </p>
+ <p>
+ <b>Author:</b> <a href="bkcore.com" target="_blank">Thibaut Despoulain</a>
+ <br><b>Version:</b> 0.1.130228
+ </p>
+ <p>
+ Inspired by MrDoob's live HTML editor.
+ <br>Powered by Three.js, Ace.js, RawDeflate.js and jQuery.
+ <br>Icons by FontAwesome, Suzanne from Blender, HexMKII from HexGL.
+ </p>
+ <p>
+ Issues, feature requests, contributions:
+ <a href="https://github.com/BKcore/Shdr" target="_blank">Fork me on GitHub!</a>
+ </p>
+ </div>
+ <button type="button" class="close">
+ <i class="icon-remove"></i>
+ </button>
+</div>
+
+<div id="mid-separator"></div>
+<div id="top-separator"></div>
+<div id="bottom-separator"></div>
+
+<script src="build/shdr.js" type="text/javascript" charset="utf-8"></script>
+
+<script>
+
+ function init() {
+ var app = new shdr.App("editor", "viewer");
+ window.app = app;
+ }
+
+</script>
+
+</body>
+</html>
View
@@ -0,0 +1,24 @@
+{
+ "name": "Shdr",
+ "description": "Shdr is a live ESSL (GLSL) shader editor, viewer and validator powered by WebGL and built by Thibaut Despoulain (BKcore).",
+ "version": "0.1.130228",
+
+ "app": {
+ "launch": {
+ "local_path": "index.html"
+ }
+ },
+
+ "icons": {
+ "16": "icon_016.png",
+ "32": "icon_032.png",
+ "48": "icon_048.png",
+ "128": "icon_128.png",
+ "256": "icon_256.png",
+ "512": "icon_512.png",
+ },
+
+ "permissions": [
+ "unlimited_storage"
+ ]
+}

0 comments on commit 93f2874

Please sign in to comment.