Skip to content
Snippets Groups Projects
building SugarCube.md 7.99 KiB

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):

  1. Node.js with npm.
  2. 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.

  1. Get the sources: If it's the first time: git submodule update --init --recursive, afterwards git submodule update is enough.

  2. Download required JavaScript libraries that are used during the build. Run the node package manager (npm) in the repository: npm install or npm update.

    • You need to navigate into submodules/sugarcube-2 first.

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

  1. Fork the SC2 repo
  2. 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.
  3. Add your fork as remote
  4. git submodule update leaves you in a detached head state, so checkout fc and pull recent changes
  5. Branch, modify, commit, push as usual.
  6. Build and replace devTools/tweeGo/storyFormats/sugarcube-2/format.js
  7. Create a new patch git diff master <your branch> > sugarcube-fc-changes.patch and move it to devNotes/sugarcube stuff/.
  8. Commit and push in the main repo.
  9. Open an MR in the SC2 repo AND in the main repo. Mark the MR in the main repo as WIP.
  10. Once the MR in the SC2 repo is accepted do:
    • In the submodule
    1. git checkout fc
    2. git pull
    • In the main repo
    1. git add submodules/sugarcube-2
    2. git commit --amend --no-edit
    3. git push -f
  11. 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.

  1. 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.

  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: npm install or npm update