Skip to content
Snippets Groups Projects
Commit 8551cb31 authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'stack' into 'pregmod-master'

add stacktrace to SC2

Closes #1487

See merge request pregmodfan/fc-pregmod!6291
parents 4c9c3318 884d246a
No related branches found
No related tags found
1 merge request!6291add stacktrace to SC2
This brief how-to guides through patching and building sugarcube (https://bitbucket.org/tmedwards/sugarcube) This brief how-to guides through patching and building sugarcube (https://github.com/tmedwards/sugarcube-2)
for the Free Cities. Sugarcube sources can be obtained locally either by cloning its Mercurial for the Free Cities. Sugarcube sources can be obtained locally by cloning its Git repository.
repository or downloading source archive from bitbucket (https://bitbucket.org/tmedwards/sugarcube/downloads/).
Prerequisites (listed NOT in the installation order, please read the list to the end first): Prerequisites (listed NOT in the installation order, please read the list to the end first):
1. Node.js with npm (https://nodejs.org). 1. Node.js with npm (https://nodejs.org).
2. Mercurial (https://www.mercurial-scm.org/) if you want to clone the sugarcube repository (so it is 2. To build some packages, Node.js requires python and a C/C++ compiler. On Windows you may want to
optional). Please note that when downloading Windows version, the Mercurial web site lists source
download first (and linked it to the main page), while we need binaries.
3. To build some packages, Node.js requires python and a C/C++ compiler. On Windows you may want to
install Visual Studio (or just the build tools) and Python 2.7 first. As of now, SugarCube does not install Visual Studio (or just the build tools) and Python 2.7 first. As of now, SugarCube does not
depend on any of such packages. depend on any of such packages.
...@@ -16,20 +12,9 @@ Windows: please choose to make the tools accessible from anywhere by allowing in ...@@ -16,20 +12,9 @@ Windows: please choose to make the tools accessible from anywhere by allowing in
the PATH environment variable. the PATH environment variable.
Retrieving SugarCube sources and preparing build environment for it. Retrieving SugarCube sources and preparing build environment for it.
1a. If you opted to use Mercurial, open a terminal window where you want to clone the repository, and 1. Open a terminal window where you want to clone the repository, and run the following command:
run the following command: git clone https://github.com/tmedwards/sugarcube-2.git
hg clone https://bitbucket.org/tmedwards/sugarcube
Change working directory into the cloned repository. Change working directory into the cloned repository.
Now choose the branch. Let's suppose we want the latest officially released version 2. The branch name
is "v2-release" then:
hg checkout v2-release
Please note that branch switching in Mercurial requires a clean local tree (without modifications).
To achieve that, run:
hg update --clean
1b. If you decided not to use Mercurial, you can download a snapshot of a branch or a tag from the
"Downloads" tab of the bitbucket repository page. Unpack it and open a terminal in the directory
with the source files.
2. The last step we need is downloading required JavaScript libraries that are used during the build. 2. The last step we need is downloading required JavaScript libraries that are used during the build.
Run the node package manager (npm) in the repository: Run the node package manager (npm) in the repository:
...@@ -40,28 +25,29 @@ commit to commit and it differs between branches! Make sure to install correct d ...@@ -40,28 +25,29 @@ commit to commit and it differs between branches! Make sure to install correct d
Patching and building SugarCube. Patching and building SugarCube.
3a. If you opted to use Mercurial, use it to apply the patch: 3. Apply the patch:
hg patch --no-commit <full path to sugarcube-fc-changes.patch> git apply <full path to sugarcube-fc-changes.patch>
3b. If you do not use Mercurial:
patch -p1 < <full path to sugarcube-fc-changes.patch>
Building Building
Run the build.js script. If you use Git bash, you can run the build.js file directly, otherwise run Run the build.js script. If you use Git bash, you can run the build.js file directly, otherwise run
it as "node build.js". See "build.js -h" for options, but reasonable sets are the following. it as "node build.js". See "build.js -h" for options, but reasonable sets are the following.
For release version: For release version:
./build.js -b 2 node ./build.js -b 2
and for the debug version: and for the debug version:
./build.js -b 2 -u -d node ./build.js -b 2 -u -d
Find result files in the dist directory. Find result files in the dist directory.
Patching
create a new patch with
git diff HEAD > <full path to sugarcube-fc-changes.patch>
Make sure to stage new files first as otherwise they are lost.
APPENDIX Lists required steps very briefly. APPENDIX Lists required steps very briefly.
1. Clone Sugarcube repo: hg clone https://bitbucket.org/tmedwards/sugarcube 1. Clone Sugarcube repo: git clone https://github.com/tmedwards/sugarcube-2.git
2. Change active directory into the directory of the sugarcube clone. 2. Change active directory into the directory of the sugarcube clone.
3. Set active branch to "v2-release": hg checkout v2-release 3. Set active branch to "master": git checkout master
4. Run npm install in the repo dir. 4. Run npm install in the repo dir.
CAUTION: Requited dependencies change during the project lifetime and vary from branch to branch; CAUTION: Requited dependencies change during the project lifetime and vary from branch to branch;
...@@ -71,9 +57,9 @@ case of strange build errors. ...@@ -71,9 +57,9 @@ case of strange build errors.
The next is done in the directory where SC repo was cloned. Loop over required SugarCube versions: The next is done in the directory where SC repo was cloned. Loop over required SugarCube versions:
1. hg update --clean to clean any local changes 1. git reset --hard to clean any local changes
2. hg checkout v2.28.2 (any tag or head here, of course) 2. (Optionally) git checkout v2.30.1 (any tag or head here, of course)
3. hg patch --no-commit ~/games/fc-pregmod/devNotes/sugarcube\ stuff/sugarcube-fc-changes.patch 3. git apply ~/games/fc-pregmod/devNotes/sugarcube\ stuff/sugarcube-fc-changes.patch
4. node build.js -b 2 to build release version 4. node build.js -b 2 to build release version
5. cp dist/twine2/sugarcube-2/format.js <whenever you want> 5. cp dist/twine2/sugarcube-2/format.js <whenever you want>
6. node build.js -b 2 -u -d to build debug version 6. node build.js -b 2 -u -d to build debug version
......
diff -r 3892fa22d6fa -r c5e783614ccf build.js diff --git a/build.js b/build.js
--- a/build.js Thu Jun 27 16:10:07 2019 -0500 index 7a17935..565faa3 100644
+++ b/build.js Sun Aug 18 19:09:49 2019 -0700 --- a/build.js
@@ -29,6 +29,7 @@ +++ b/build.js
@@ -29,6 +29,7 @@ const CONFIG = {
'src/lib/jquery-plugins.js', 'src/lib/jquery-plugins.js',
'src/lib/util.js', 'src/lib/util.js',
'src/lib/simplestore/simplestore.js', 'src/lib/simplestore/simplestore.js',
...@@ -9,9 +10,38 @@ diff -r 3892fa22d6fa -r c5e783614ccf build.js ...@@ -9,9 +10,38 @@ diff -r 3892fa22d6fa -r c5e783614ccf build.js
'src/lib/simplestore/adapters/webstorage.js', 'src/lib/simplestore/adapters/webstorage.js',
'src/lib/simplestore/adapters/cookie.js', 'src/lib/simplestore/adapters/cookie.js',
'src/lib/debugview.js', 'src/lib/debugview.js',
diff -r 3892fa22d6fa -r c5e783614ccf src/lib/jquery-plugins.js diff --git a/src/lib/helpers.js b/src/lib/helpers.js
--- a/src/lib/jquery-plugins.js Thu Jun 27 16:10:07 2019 -0500 index 2c0157e..0448427 100644
+++ b/src/lib/jquery-plugins.js Sun Aug 18 19:09:49 2019 -0700 --- a/src/lib/helpers.js
+++ b/src/lib/helpers.js
@@ -248,7 +248,7 @@ var { // eslint-disable-line no-var
/*
Appends an error view to the passed DOM element.
*/
- function throwError(place, message, source) {
+ function throwError(place, message, source, stack) {
const $wrapper = jQuery(document.createElement('div'));
const $toggle = jQuery(document.createElement('button'));
const $source = jQuery(document.createElement('pre'));
@@ -286,6 +286,14 @@ var { // eslint-disable-line no-var
hidden : 'hidden'
})
.appendTo($wrapper);
+ if (stack) {
+ const lines = stack.split('\n');
+ for (const ll of lines) {
+ const div = document.createElement('div');
+ div.append(ll.replace(/file:.*\//, '<path>/'));
+ $source.append(div);
+ }
+ }
$wrapper
.addClass('error-view')
.appendTo(place);
diff --git a/src/lib/jquery-plugins.js b/src/lib/jquery-plugins.js
index a5b4050..aae9a47 100644
--- a/src/lib/jquery-plugins.js
+++ b/src/lib/jquery-plugins.js
@@ -43,14 +43,9 @@ @@ -43,14 +43,9 @@
return function () { return function () {
const $this = jQuery(this); const $this = jQuery(this);
...@@ -42,9 +72,11 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/lib/jquery-plugins.js ...@@ -42,9 +72,11 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/lib/jquery-plugins.js
}; };
} }
diff -r 3892fa22d6fa -r c5e783614ccf src/lib/simplestore/adapters/FCHost.Storage.js diff --git a/src/lib/simplestore/adapters/FCHost.Storage.js b/src/lib/simplestore/adapters/FCHost.Storage.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 new file mode 100644
+++ b/src/lib/simplestore/adapters/FCHost.Storage.js Sun Aug 18 19:09:49 2019 -0700 index 0000000..34581b1
--- /dev/null
+++ b/src/lib/simplestore/adapters/FCHost.Storage.js
@@ -0,0 +1,171 @@ @@ -0,0 +1,171 @@
+/*********************************************************************************************************************** +/***********************************************************************************************************************
+ +
...@@ -217,10 +249,11 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/lib/simplestore/adapters/FCHost.Storage ...@@ -217,10 +249,11 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/lib/simplestore/adapters/FCHost.Storage
+ create : { value : adapterCreate } + create : { value : adapterCreate }
+ })); + }));
+})()); +})());
diff -r 3892fa22d6fa -r c5e783614ccf src/lib/simplestore/adapters/webstorage.js diff --git a/src/lib/simplestore/adapters/webstorage.js b/src/lib/simplestore/adapters/webstorage.js
--- a/src/lib/simplestore/adapters/webstorage.js Thu Jun 27 16:10:07 2019 -0500 index a486bc0..243def3 100644
+++ b/src/lib/simplestore/adapters/webstorage.js Sun Aug 18 19:09:49 2019 -0700 --- a/src/lib/simplestore/adapters/webstorage.js
@@ -189,11 +189,11 @@ +++ b/src/lib/simplestore/adapters/webstorage.js
@@ -189,11 +189,11 @@ SimpleStore.adapters.push((() => {
} }
static _serialize(obj) { static _serialize(obj) {
...@@ -234,10 +267,57 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/lib/simplestore/adapters/webstorage.js ...@@ -234,10 +267,57 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/lib/simplestore/adapters/webstorage.js
} }
} }
diff -r 3892fa22d6fa -r c5e783614ccf src/markup/wikifier.js diff --git a/src/macros/macrocontext.js b/src/macros/macrocontext.js
--- a/src/markup/wikifier.js Thu Jun 27 16:10:07 2019 -0500 index d179d9c..265ce5d 100644
+++ b/src/markup/wikifier.js Sun Aug 18 19:09:49 2019 -0700 --- a/src/macros/macrocontext.js
@@ -212,7 +212,7 @@ +++ b/src/macros/macrocontext.js
@@ -272,8 +272,8 @@ var MacroContext = (() => { // eslint-disable-line no-unused-vars, no-var
this._debugViewEnabled = false;
}
- error(message, source) {
- return throwError(this._output, `<<${this.name}>>: ${message}`, source ? source : this.source);
+ error(message, source, stack) {
+ return throwError(this._output, `<<${this.name}>>: ${message}`, source ? source : this.source, stack);
}
}
diff --git a/src/macros/macrolib.js b/src/macros/macrolib.js
index e9500f4..6108297 100644
--- a/src/macros/macrolib.js
+++ b/src/macros/macrolib.js
@@ -89,7 +89,7 @@
Scripting.evalJavaScript(this.args.full);
}
catch (ex) {
- return this.error(`bad evaluation: ${typeof ex === 'object' ? ex.message : ex}`);
+ return this.error(`bad evaluation: ${typeof ex === 'object' ? `${ex.name}: ${ex.message}` : ex}`, null, ex.stack);
}
// Custom debug view setup.
@@ -350,7 +350,7 @@
}
}
catch (ex) {
- return this.error(`bad evaluation: ${typeof ex === 'object' ? ex.message : ex}`);
+ return this.error(`bad evaluation: ${typeof ex === 'object' ? `${ex.name}: ${ex.message}` : ex}`, null, ex.stack);
}
}
});
@@ -493,7 +493,7 @@
}
}
catch (ex) {
- return this.error(`bad conditional expression in <<${i === 0 ? 'if' : 'elseif'}>> clause${i > 0 ? ' (#' + i + ')' : ''}: ${typeof ex === 'object' ? ex.message : ex}`); // eslint-disable-line prefer-template
+ return this.error(`bad conditional expression in <<${i === 0 ? 'if' : 'elseif'}>> clause${i > 0 ? ' (#' + i + ')' : ''}: ${typeof ex === 'object' ? `${ex.name}: ${ex.message}` : ex}`, null, ex.stack); // eslint-disable-line prefer-template
}
}
});
diff --git a/src/markup/wikifier.js b/src/markup/wikifier.js
index e206f96..61381f0 100644
--- a/src/markup/wikifier.js
+++ b/src/markup/wikifier.js
@@ -212,7 +212,7 @@ var Wikifier = (() => { // eslint-disable-line no-unused-vars, no-var
} }
outputText(destination, startPos, endPos) { outputText(destination, startPos, endPos) {
...@@ -246,10 +326,11 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/markup/wikifier.js ...@@ -246,10 +326,11 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/markup/wikifier.js
} }
/* /*
diff -r 3892fa22d6fa -r c5e783614ccf src/passage.js diff --git a/src/passage.js b/src/passage.js
--- a/src/passage.js Thu Jun 27 16:10:07 2019 -0500 index 0cb17a4..bdc072d 100644
+++ b/src/passage.js Sun Aug 18 19:09:49 2019 -0700 --- a/src/passage.js
@@ -266,8 +266,10 @@ +++ b/src/passage.js
@@ -275,8 +275,10 @@ var Passage = (() => { // eslint-disable-line no-unused-vars, no-var
} }
}); });
...@@ -262,10 +343,11 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/passage.js ...@@ -262,10 +343,11 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/passage.js
return passageEl; return passageEl;
} }
diff -r 3892fa22d6fa -r c5e783614ccf src/state.js diff --git a/src/state.js b/src/state.js
--- a/src/state.js Thu Jun 27 16:10:07 2019 -0500 index 9f18cb2..7564f49 100644
+++ b/src/state.js Sun Aug 18 19:09:49 2019 -0700 --- a/src/state.js
@@ -104,7 +104,7 @@ +++ b/src/state.js
@@ -104,7 +104,7 @@ var State = (() => { // eslint-disable-line no-unused-vars, no-var
} }
if (_expired.length > 0) { if (_expired.length > 0) {
...@@ -274,10 +356,11 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/state.js ...@@ -274,10 +356,11 @@ diff -r 3892fa22d6fa -r c5e783614ccf src/state.js
} }
if (_prng !== null) { if (_prng !== null) {
diff -r 3892fa22d6fa -r c5e783614ccf src/ui.js diff --git a/src/ui.js b/src/ui.js
--- a/src/ui.js Thu Jun 27 16:10:07 2019 -0500 index d53ed07..9212415 100644
+++ b/src/ui.js Sun Aug 18 19:09:49 2019 -0700 --- a/src/ui.js
@@ -334,6 +334,7 @@ +++ b/src/ui.js
@@ -334,6 +334,7 @@ var UI = (() => { // eslint-disable-line no-unused-vars, no-var
if (saves.slots[i]) { if (saves.slots[i]) {
// Add the load button. // Add the load button.
$tdLoad.append( $tdLoad.append(
......
Copyright (c) 2013-2019, Thomas Michael Edwards <thomasmedwards@gmail.com>.
Copyright (c) 2013-2018 Thomas Michael Edwards <thomasmedwards@gmail.com>.
All rights reserved. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment