Adding a fully compiled demo draft (still simple optimizations).

This commit is contained in:
Tom
2017-08-03 16:56:24 +02:00
parent fbb71b996a
commit dec6910b67
4 changed files with 2026 additions and 4 deletions

View File

@@ -60,9 +60,10 @@ for arg in sys.argv[1:len(sys.argv)]:
if (arg != 'core' and
arg != 'accessible' and
arg != 'generators' and
arg != 'langfiles'):
arg != 'langfiles' and
arg != 'demo'):
raise Exception("Invalid argument: \"" + arg + "\". Usage: build.py <0 or more of accessible," +
" core, generators, langfiles>")
" core, generators, langfiles, demo>")
import errno, glob, httplib, json, os, re, subprocess, threading, urllib
@@ -214,6 +215,37 @@ class Gen_compressed(threading.Thread):
self.gen_generator("dart")
self.gen_generator("lua")
if ('demo' in self.bundles):
self.gen_together()
def gen_together(self):
target_filename = os.path.join("demos", "fixed-advanced", "main_compressed.js")
# Define the parameters for the POST request.
params = [
# TODO switch to advanced
("compilation_level", "SIMPLE_OPTIMIZATIONS"),
("use_closure_library", "true"),
("output_format", "json"),
("output_info", "compiled_code"),
("output_info", "warnings"),
("output_info", "errors"),
("output_info", "statistics"),
]
# Read in all the source files.
filenames = calcdeps.CalculateDependencies(self.search_paths,
[os.path.join("demos", "fixed-advanced", "main.js")])
filenames.sort() # Deterministic build.
for filename in filenames:
# Filter out the Closure files (the compiler will add them).
if filename.startswith(os.pardir + os.sep): # '../'
continue
f = open(filename)
params.append(("js_code", "".join(f.readlines())))
f.close()
self.do_compile(params, target_filename, filenames, "")
def gen_core(self):
target_filename = "blockly_compressed.js"
# Define the parameters for the POST request.
@@ -544,8 +576,15 @@ developers.google.com/blockly/guides/modify/web/closure""")
if ('accessible' in args):
Gen_uncompressed(full_search_paths, 'blockly_accessible_uncompressed.js').start()
# Compressed is limited by network and server speed.
Gen_compressed(full_search_paths, args).start()
if ('demo' in args):
all_search_paths = calcdeps.ExpandDirectories(
["accessible", "core", "blocks", os.path.join("demos", "fixed-advanced"), os.path.join("msg", "js"), os.path.join(os.path.pardir, "closure-library")])
all_search_paths.sort() # Deterministic build.
Gen_compressed(all_search_paths, args).start()
else:
# Compressed is limited by network and server speed.
Gen_compressed(full_search_paths, args).start()
# This is run locally in a separate thread
# defaultlangfiles checks for changes in the msg files, while manually asking

View File

@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Blockly Demo: Fixed Blockly</title>
<script src="main_compressed.js"></script>
<style>
body {
background-color: #fff;
font-family: sans-serif;
}
h1 {
font-weight: normal;
font-size: 140%;
}
</style>
</head>
<body>
<h1><a href="https://developers.google.com/blockly/">Blockly</a> &gt;
<a href="../index.html">Demos</a> &gt; Fixed Blockly</h1>
<p>This is a simple demo of injecting Blockly into a fixed-sized 'div' element.</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/guides/configure-blockly/web/fixed-size">injecting fixed-sized Blockly</a>&hellip;</p>
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
<xml id="toolbox" style="display: none">
<block type="controls_if"></block>
<block type="logic_compare"></block>
<block type="controls_repeat_ext"></block>
<block type="math_number"></block>
<block type="math_arithmetic"></block>
<block type="text"></block>
<block type="text_print"></block>
</xml>
</body>
</html>

View File

@@ -0,0 +1,31 @@
/**
* @fileoverview Main file (entry point) for the advanced compilation demo.
*/
'use strict';
goog.provide('Demo');
// core
goog.require('Blockly');
// blocks
goog.require('Blockly.Constants.Colour');
goog.require('Blockly.Constants.Lists');
goog.require('Blockly.Constants.Logic');
goog.require('Blockly.Constants.Loops');
goog.require('Blockly.Constants.Math');
goog.require('Blockly.Blocks.procedures');
goog.require('Blockly.Constants.Text');
goog.require('Blockly.Constants.Variables');
// messages (in some language)
goog.require('Blockly.Msg.en');
Demo.init = function() {
Blockly.inject('blocklyDiv', {
media: '../../media/',
toolbox: document.getElementById('toolbox')
});
}
window.addEventListener('load', Demo.init);

File diff suppressed because it is too large Load Diff