Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
Fix build process and merge internal updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
insgadget committed May 31, 2018
1 parent 8bcc7be commit 2802317
Show file tree
Hide file tree
Showing 26 changed files with 347 additions and 141 deletions.
8 changes: 4 additions & 4 deletions client_side_only_impl/vsaq_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ vsaq.Qpage.prototype.updateStorage_ = function(data) {
var newStorageData = null;
var storageData = this.readStorage_();
if (storageData) {
storageData = JSON.parse(storageData);
storageData = /** @type {Object|null} */ (JSON.parse(storageData));
goog.object.extend(storageData, data);
newStorageData = goog.json.serialize(storageData);
} else {
Expand Down Expand Up @@ -259,7 +259,7 @@ vsaq.Qpage.prototype.loadExtensionThenQuestionnaire = function(
text = vsaq.utils.vsaqonToJson(text);
var extension = {};
try {
extension = JSON.parse(text);
extension = /** @type {Object|null} */ (JSON.parse(text));
} catch (err) {
alert('Loading the extension failed. It does not appear to be ' +
'valid json');
Expand Down Expand Up @@ -297,7 +297,7 @@ vsaq.Qpage.prototype.loadQuestionnaire = function(opt_path, opt_extension) {
text = vsaq.utils.vsaqonToJson(text);
var template = {};
try {
template = JSON.parse(text);
template = /** @type {Object|null} */ (JSON.parse(text));
} catch (err) {
alert('Loading the template failed. It does not appear to be ' +
'valid json');
Expand Down Expand Up @@ -328,7 +328,7 @@ vsaq.Qpage.prototype.loadQuestionnaire = function(opt_path, opt_extension) {

this.questionnaire.listen(
goog.events.EventType.CHANGE, goog.bind(function(e) {
goog.structs.forEach(e.changedValues, function(val, key) {
goog.object.forEach(e.changedValues, function(val, key) {
this.changes[key] = val;
}, this);
if (goog.structs.getCount(this.changes) > 0) {
Expand Down
4 changes: 1 addition & 3 deletions compiler.flags
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
--jscomp_error=checkVars
--jscomp_error=const
--jscomp_error=constantProperty
--jscomp_error=deprecated
--jscomp_warning=deprecated
--jscomp_error=duplicate
--jscomp_error=duplicateMessage
--jscomp_error=es5Strict
Expand All @@ -24,8 +24,6 @@
--jscomp_error=unknownDefines
--jscomp_error=uselessCode
--jscomp_error=visibility
--externs=third_party/closure-compiler/contrib/externs/chrome_extensions.js
--only_closure_dependencies
--manage_closure_dependencies
--js third_party/closure-library/closure/goog/deps.js
--js build/deps.js
32 changes: 19 additions & 13 deletions do.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#

PYTHON_CMD="python"
JSCOMPILE_CMD="java -jar third_party/closure-compiler/build/compiler.jar --flagfile=compiler.flags"
JSCOMPILE_CMD="java -jar third_party/closure-compiler/target/closure-compiler-1.0-SNAPSHOT.jar --flagfile=compiler.flags"
CKSUM_CMD="cksum" # chosen because it's available on most Linux/OS X installations
BUILD_DIR="build"
BUILD_TPL_DIR="$BUILD_DIR/templates"
Expand All @@ -35,10 +35,9 @@ vsaq_assert_dependencies() {
fi
# Check if required files are present.
files=(third_party/closure-library \
third_party/closure-templates-compiler \
third_party/closure-stylesheets/build/closure-stylesheets.jar \
third_party/closure-compiler/build/compiler.jar \
third_party/closure-compiler/contrib/externs/chrome_extensions.js \
third_party/closure-templates/target \
third_party/closure-stylesheets/target/closure-stylesheets-1.5.0-SNAPSHOT-jar-with-dependencies.jar \
third_party/closure-compiler/target/closure-compiler-1.0-SNAPSHOT.jar \
)
for var in "${files[@]}"
do
Expand All @@ -62,13 +61,16 @@ vsaq_build_templates() {
set -e
mkdir -p "$BUILD_TPL_DIR"
rm -rf "$BUILD_TPL_DIR/*"
mkdir "$BUILD_TPL_DIR/proto"
# Compile safe html type proto to JS
third_party/protoc/bin/protoc --js_out $BUILD_TPL_DIR/proto \
./third_party/safe-html-types/proto/src/main/protobuf/webutil/html/types/html.proto
# Compile soy templates
echo "Compiling Soy templates..."
rm -f "$BUILD_TPL_DIR/cksum"
vsaq_get_file_cksum '*.soy' > "$BUILD_TPL_DIR/cksum"
find "vsaq" -name '*.soy' -exec java -jar third_party/closure-templates-compiler/SoyToJsSrcCompiler.jar \
--shouldProvideRequireSoyNamespaces --shouldGenerateJsdoc --shouldDeclareTopLevelNamespaces --srcs {} \
--outputPathFormat "$BUILD_TPL_DIR/{INPUT_DIRECTORY}{INPUT_FILE_NAME}.js" \;
find "vsaq" -name '*.soy' -exec java -jar third_party/closure-templates/target/soy-2018-03-14-SoyToJsSrcCompiler.jar \
--srcs {} --outputPathFormat "$BUILD_TPL_DIR/{INPUT_DIRECTORY}{INPUT_FILE_NAME}.js" \;
echo "Done."
}

Expand Down Expand Up @@ -110,9 +112,10 @@ vsaq_build_closure_lib_() {
SRC_DIRS=( \
vsaq \
client_side_only_impl \
third_party/closure-templates/target \
third_party/closure-library/closure/goog \
third_party/closure-library/third_party/closure/goog \
third_party/closure-templates-compiler )
third_party/protoc/protobuf-3.5.1/js/binary )
if [ -d "$3" ]; then
SRC_DIRS+=("$3")
fi
Expand All @@ -122,13 +125,16 @@ vsaq_build_closure_lib_() {
jscompile_vsaq+=" --js='$var/**.js' --js='!$var/**_test.js' --js='!$var/**_perf.js'"
done
jscompile_vsaq+=" --js='!third_party/closure-library/closure/goog/demos/**.js'"
jscompile_vsaq+=" --js='!third_party/closure-templates/javascript/examples/**.js'"
if [ "$4" == "debug" ]; then
jscompile_vsaq+=" --debug --formatting=PRETTY_PRINT -O WHITESPACE_ONLY"
elif [ "$4" == "optimized" ]; then
jscompile_vsaq+=" -O ADVANCED"
fi
cmd="$jscompile_vsaq --closure_entry_point "$ENTRY_POINT" --js_output_file "$FNAME""
echo $cmd
echo -n "."
$jscompile_vsaq --closure_entry_point "$ENTRY_POINT" --js_output_file "$FNAME"
$cmd
}

vsaq_build_jsmodule() {
Expand Down Expand Up @@ -161,7 +167,7 @@ vsaq_build() {

BUILD_DIR_STATIC="$BUILD_DIR/static"
mkdir -p "$BUILD_DIR_STATIC"
csscompile_vsaq="java -jar third_party/closure-stylesheets/build/closure-stylesheets.jar --allowed-non-standard-function color-stop"
csscompile_vsaq="java -jar third_party/closure-stylesheets/target/closure-stylesheets-1.5.0-SNAPSHOT-jar-with-dependencies.jar --allowed-non-standard-function color-stop"
echo "Compiling CSS files..."
$csscompile_vsaq "vsaq/static/vsaq_base.css" "vsaq/static/vsaq.css" > "$BUILD_DIR_STATIC/vsaq.css"
echo "Copying remaining static files..."
Expand Down Expand Up @@ -203,7 +209,7 @@ vsaq_generate_jsdeps() {
$PYTHON_CMD third_party/closure-library/closure/bin/build/depswriter.py \
--root_with_prefix="build/templates/ build/templates/" \
--root_with_prefix="vsaq/ vsaq/" \
--root_with_prefix="third_party/closure-templates-compiler/ third_party/closure-templates-compiler/" \
--root_with_prefix="third_party/closure-templates/javascript third_party/closure-templates/javascript/" \
> "$BUILD_DIR/deps.js"
}

Expand All @@ -215,7 +221,7 @@ vsaq_run() {
$PYTHON_CMD third_party/closure-library/closure/bin/build/depswriter.py \
--root_with_prefix="build/templates/ ../../../build/templates/" \
--root_with_prefix="vsaq/ ../vsaq/" \
--root_with_prefix="third_party/closure-templates-compiler/ ../../../../third_party/closure-templates-compiler/" \
--root_with_prefix="third_party/closure-templates/javascript/ ../../../../third_party/closure-templates/javascript/" \
> "$BUILD_DIR/deps-runfiles.js"

rm -f "$BUILD_DIR/all_tests.js"
Expand Down
65 changes: 49 additions & 16 deletions download-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,24 @@
export JAVA_TOOL_OPTIONS=-Dfile.encoding=UTF8
THIRD_PARTY_DIRECTORY="third_party"



type unzip >/dev/null 2>&1 || {
echo >&2 "Unzip is required to build VSAQ dependencies."
exit 1
}
type wget >/dev/null 2>&1 || {
echo >&2 "Wget is required to build VSAQ dependencies."
exit 1
}
type ant >/dev/null 2>&1 || {
echo >&2 "Ant is required to build VSAQ dependencies."
exit 1
}
type mvn >/dev/null 2>&1 || {
echo >&2 "Apache Maven is required to build VSAQ dependencies."
exit 1
}
type javac >/dev/null 2>&1 || {
echo >&2 "Java compiler is required to build VSAQ dependencies."
exit 1
Expand Down Expand Up @@ -52,6 +66,7 @@ if [ ! -d .git ]; then
rm -rf $THIRD_PARTY_DIRECTORY/closure-library
rm -rf $THIRD_PARTY_DIRECTORY/closure-stylesheets
rm -rf $THIRD_PARTY_DIRECTORY/js-dossier
rm -rf $THIRD_PARTY_DIRECTORY/closure-templates
fi

if [ ! -d $THIRD_PARTY_DIRECTORY ]; then
Expand All @@ -62,54 +77,72 @@ cd $THIRD_PARTY_DIRECTORY
git submodule add -f https://github.com/google/closure-compiler closure-compiler
git submodule add -f https://github.com/google/closure-library closure-library
git submodule add -f https://github.com/google/closure-stylesheets closure-stylesheets
git submodule add -f https://github.com/google/closure-templates closure-templates
git submodule add -f https://github.com/jleyba/js-dossier js-dossier
git submodule add -f https://github.com/google/safe-html-types safe-html-types

git submodule init
git submodule update

# Pin submodules to particular commits
cd closure-compiler
git checkout -b 59b42c9fc8fc752b3ff3aabe04ad89a96f9a7bf7 59b42c9fc8fc752b3ff3aabe04ad89a96f9a7bf7
git checkout -b 0441c526dc7ed322034d4f708062c00802184e8f 0441c526dc7ed322034d4f708062c00802184e8f
cd ..
cd closure-library
git checkout -b dc369cde87d7ef6dfb46d3b873f872ebee7d07cd dc369cde87d7ef6dfb46d3b873f872ebee7d07cd
git checkout -b 26de3253e443d36f64c2ea380faee879dfcf1c54 26de3253e443d36f64c2ea380faee879dfcf1c54
cd ..
cd js-dossier
git checkout -b 6f2d09ee26925b7417f9f6bd1547dffe700ab60f 6f2d09ee26925b7417f9f6bd1547dffe700ab60f
git checkout -b e6e55806ea97a4fcf4157661ee809eb8b48fe848 e6e55806ea97a4fcf4157661ee809eb8b48fe848
cd ..
cd closure-templates
git checkout -b 17dad0f13db94ca43a2e4c436658682a0403ced1 17dad0f13db94ca43a2e4c436658682a0403ced1
cd ..
cd safe-html-types
git checkout -b 8507735457ea41a37dfa027fb176d49d5783c4ba 8507735457ea41a37dfa027fb176d49d5783c4ba
cd ..

# build closure compiler
if [ ! -f closure-compiler/build/compiler.jar ] && [ -d closure-compiler ]; then
cd closure-compiler
ant clean
ant jar
# ant clean
# ant jar
mvn -DskipTests -pl externs/pom.xml,pom-main.xml,pom-main-shaded.xml
cd ..
fi

# checkout closure templates compiler
if [ ! -d closure-templates-compiler ]; then
curl https://dl.google.com/closure-templates/closure-templates-for-javascript-latest.zip -O
unzip closure-templates-for-javascript-latest.zip -d closure-templates-compiler
rm closure-templates-for-javascript-latest.zip
# build closure templates compiler
if [ -d closure-templates ] && [ ! -d closure-templates/target ]; then
cd closure-templates
mvn -DskipTests package
cd ..
fi

# build css compiler
if [ ! -f closure-stylesheets/build/closure-stylesheets.jar ]; then
if [ ! -f closure-stylesheets/target/closure-stylesheets-1.5.0-SNAPSHOT-jar-with-dependencies.jar ]; then
cd closure-stylesheets
ant
mvn compile assembly:single
cd ..
fi

if [ -f chrome_extensions.js ]; then
rm -f chrome_extensions.js
fi

mkdir protoc; cd protoc
wget https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-linux-x86_64.zip
unzip protoc-3.5.1-linux-x86_64.zip
rm protoc-3.5.1-linux-x86_64.zip
wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-js-3.5.1.zip
unzip protobuf-js-3.5.1.zip
rm protobuf-js-3.5.1.zip
cd ..

# Temporary fix
# Soy file bundled with the compiler does not compile with strict settings:
# lib/closure-templates-compiler/soyutils_usegoog.js:1762: ERROR - element JS_STR_CHARS does not exist on this enum
cd closure-templates-compiler
echo $PWD
curl https://raw.githubusercontent.com/google/closure-templates/0cbc8543c34d3f7727dd83a2d1938672f16d5c20/javascript/soyutils_usegoog.js -O
cd ..
#cd closure-templates/javascript
#echo $PWD
#curl https://raw.githubusercontent.com/google/closure-templates/0cbc8543c34d3f7727dd83a2d1938672f16d5c20/javascript/soyutils_usegoog.js -O
#cd ../..

cd ..
15 changes: 0 additions & 15 deletions vsaq/static/qpage_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ goog.require('goog.events.EventType');
goog.require('goog.structs');
goog.require('goog.ui.Tooltip');
goog.require('vsaq.Questionnaire');
goog.require('vsaq.utils');



Expand All @@ -52,10 +51,6 @@ vsaq.QpageBase = function() {
goog.dom.createDom(goog.dom.TagName.SPAN);
this.questionnaire.setReadOnlyMode(this.isReadOnly);

vsaq.utils.initClickables({
'eh-edit': goog.bind(this.makeEditable, this)
});

goog.events.listen(window, [goog.events.EventType.BEFOREUNLOAD],
function() {
if (vsaq.qpageObject_ && vsaq.qpageObject_.unsavedChanges())
Expand Down Expand Up @@ -122,16 +117,6 @@ vsaq.QpageBase.prototype.isReadOnly;
vsaq.QpageBase.prototype.statusIndicator;


/**
* Make questionnaire editable.
*/
vsaq.QpageBase.prototype.makeEditable = function() {
this.isReadOnly = false;
this.questionnaire.setReadOnlyMode(this.isReadOnly);
this.questionnaire.render();
};


/**
* Attempts to keep track of updates that were done to the current
* questionnaire.
Expand Down
2 changes: 1 addition & 1 deletion vsaq/static/questionnaire/blockitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ goog.require('vsaq.questionnaire.templates');
* for the item to be visible to the user.
* @param {?string} caption The caption of the block.
* @param {?string=} opt_auth The needed authorization to get an item displayed.
* The auth param on {@code vsaq.questionnaire.items.BlockItem} only
* The auth param on `vsaq.questionnaire.items.BlockItem` only
* prevents that items are displayed to the user (hidden by display=none).
* @param {?string=} opt_className Name of a CSS class to add to the block.
* @extends {vsaq.questionnaire.items.ContainerItem}
Expand Down
10 changes: 6 additions & 4 deletions vsaq/static/questionnaire/boxitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ goog.require('vsaq.questionnaire.utils');
* @param {number=} opt_maxlength HTML maxlength attribute value for the input
* field. See {@link
* https://html.spec.whatwg.org/multipage/forms.html#attr-fe-maxlength}
* @param {string=} opt_auth If "readonly", this ValueItem cannot be modified.
* @extends {vsaq.questionnaire.items.ValueItem}
* @constructor
*/
vsaq.questionnaire.items.BoxItem = function(id, conditions, caption,
opt_placeholder, opt_inputPattern, opt_inputTitle, opt_isRequired,
opt_maxlength) {
opt_maxlength, opt_auth) {
goog.base(this, id, conditions, caption, opt_placeholder, opt_inputPattern,
opt_inputTitle, opt_isRequired, opt_maxlength);
opt_inputTitle, opt_isRequired, opt_maxlength, opt_auth);

/**
* The text area where the user can provide an answer.
Expand Down Expand Up @@ -122,13 +123,14 @@ vsaq.questionnaire.items.BoxItem.parse = function(questionStack) {

return new vsaq.questionnaire.items.BoxItem(item.id, item.cond, item.text,
item.placeholder, item.inputPattern, item.inputTitle, item.required,
item.maxlength);
item.maxlength, item.auth);
};


/** @inheritDoc */
vsaq.questionnaire.items.BoxItem.prototype.setReadOnly = function(readOnly) {
this.textArea_.readOnly = readOnly;
// if item marked readonly, always keep it readonly
this.textArea_.readOnly = this.auth == 'readonly' ? true : readOnly;
};


Expand Down
18 changes: 18 additions & 0 deletions vsaq/static/questionnaire/boxitem_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,22 @@ function testBoxItemParse() {
assertEquals('placeholder', box.placeholder);
assertTrue(box.required);
assertEquals(0, testStack.length);
assertTrue(box.auth != 'readonly');

testStack = [{
'type': 'box',
'text': CAPTION,
'id': ID,
'required' : true,
'placeholder': 'placeholder',
'auth': 'readonly'
}];
box = vsaq.questionnaire.items.BoxItem.parse(testStack);
assert(box instanceof vsaq.questionnaire.items.BoxItem);
assertEquals(ID, box.id);
assertEquals(CAPTION, box.text);
assertEquals('placeholder', box.placeholder);
assertTrue(box.required);
assertEquals(0, testStack.length);
assertEquals('readonly', box.auth);
}
Loading

3 comments on commit 2802317

@jeremiahRedacted
Copy link

@jeremiahRedacted jeremiahRedacted commented on 2802317 Jun 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@insgadget

I am now getting an error on ./do.sh install_deps

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.099 s
[INFO] Finished at: 2018-06-06T12:42:08-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/Users/USER/Documents/git/vsaq/third_party/closure-stylesheets). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException

@insgadget
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to check out closure-stylesheets. I pushed an update. Does it work now?

@jeremiahRedacted
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works now. Thanks for the update.

Please sign in to comment.