Obtaining and building SugarCube for FC
Intro
This brief how-to guides through patching and building SugarCube for the Free Cities. SugarCube sources can be obtained locally by cloning its Git repository.
Prerequisites (listed NOT in the installation order, please read the list to the end first):
- Node.js with npm.
- 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 depend on any of such packages.
Windows: please choose to make the tools accessible from anywhere by allowing installers to modify the PATH environment variable.
Retrieving SugarCube sources and preparing build environment for it
The SC2 sources are a git submodule.
-
Get the sources: If it's the first time:
git submodule update --init --recursive
, afterwardsgit submodule update
is enough. -
Download required JavaScript libraries that are used during the build. Run the node package manager (npm) in the repository:
npm install
ornpm update
.- You need to navigate into
submodules/sugarcube-2
first.
- You need to navigate into
Building
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.
- for release version:
node build.js -n -b 2
- for debug version:
node build.js -n -b 2 -u -d
Find result files in the build
directory. After each build you have to copy the release format.js
to
devTools/tweeGo/storyFormats/sugarcube-2
. Do not forget to git add
the file.
Linux: If you have make installed, make sugarcube
automatically builds and copies format.js
to
devTools/tweeGo/storyFormats/sugarcube-2
for easy testing.
Contributing
- Fork the SC2 repo
- Navigate into submodules/sugarcube-2
- Tip: Use two terminals, one in the main repo and one in the submodule.
- You are now in the root of the submodule. Git works here (almost) the same as in the root of a standalone repo.
- Add your fork as remote
-
git submodule update
leaves you in a detached head state, so checkout fc and pull recent changes - Branch, modify, commit, push as usual.
- Build and replace
devTools/tweeGo/storyFormats/sugarcube-2/format.js
- Create a new patch
git diff master <your branch> > sugarcube-fc-changes.patch
and move it todevNotes/sugarcube stuff/
. - Commit and push in the main repo.
- Open an MR in the SC2 repo AND in the main repo. Mark the MR in the main repo as WIP.
- Once the MR in the SC2 repo is accepted do:
- In the submodule
git checkout fc
git pull
- In the main repo
git add submodules/sugarcube-2
git commit --amend --no-edit
git push -f
- Remove WIP flag from main repo.
Repeat steps 4 - 11.
(OLD) Retrieving SugarCube sources and preparing build environment for it
Note: This is NOT recommended. Everything below is for documentation purposes only.
-
Open a terminal window where you want to clone the repository, and run the following command:
git clone https://github.com/tmedwards/sugarcube-2.git
. Change working directory into the cloned repository. -
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:
npm install
ornpm update