mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Inject Blockly version into binaries (#2750)
* Inject the Blockly version in package.json into compressed Blockly builds.
This commit is contained in:
9
build.py
9
build.py
@@ -56,6 +56,9 @@ else:
|
||||
from urllib.parse import urlencode
|
||||
from importlib import reload
|
||||
|
||||
# Read package.json and extract the current Blockly version.
|
||||
blocklyVersion = json.loads(open('package.json', 'r').read())['version']
|
||||
|
||||
def import_path(fullpath):
|
||||
"""Import a file with full path specification.
|
||||
Allows one to import from any directory, something __import__ does not do.
|
||||
@@ -221,7 +224,11 @@ class Gen_compressed(threading.Thread):
|
||||
if filename.startswith(os.pardir + os.sep): # '../'
|
||||
continue
|
||||
f = codecs.open(filename, encoding="utf-8")
|
||||
params.append(("js_code", "".join(f.readlines()).encode("utf-8")))
|
||||
code = "".join(f.readlines()).encode("utf-8")
|
||||
# Inject the Blockly version.
|
||||
if filename == "core/blockly.js":
|
||||
code = code.replace("Blockly.VERSION = 'uncompiled';", "Blockly.VERSION = '" + blocklyVersion + "';")
|
||||
params.append(("js_code", code))
|
||||
f.close()
|
||||
|
||||
self.do_compile(params, target_filename, filenames, "")
|
||||
|
||||
@@ -65,6 +65,16 @@ goog.require('Blockly.Xml');
|
||||
var CLOSURE_DEFINES = {'goog.DEBUG': false};
|
||||
/* eslint-enable no-unused-vars */
|
||||
|
||||
/**
|
||||
* Blockly core version.
|
||||
* This constant is overriden by the build script (build.py) to the value of the version
|
||||
* in package.json. This is done during the gen_core build step.
|
||||
* For local builds, you can pass --define='Blockly.VERSION=X.Y.Z' to the compiler
|
||||
* to override this constant.
|
||||
* @define {string}
|
||||
*/
|
||||
Blockly.VERSION = 'uncompiled';
|
||||
|
||||
/**
|
||||
* The main workspace most recently used.
|
||||
* Set by Blockly.WorkspaceSvg.prototype.markFocused
|
||||
|
||||
Reference in New Issue
Block a user