Skip to content

Building kjudge manually

Natsu Kagami edited this page Mar 31, 2020 · 2 revisions

So you are one of the bravely ones, who wishes to jump into master branch and try out the latest commits. Or maybe you are a friendly developer who wishes to try out your fork to make sure it works?

Fear not, here goes all the requirements to build and run kjudge manually!

Requirements

For building

A quick list:

cc:      anything that compiles SQLite 3
go:      >= 1.13
node.js: >= 9
yarn:    >= 1

In depth:

  • kjudge is built mainly in Go, so a Go compiler is of course required. We require good module support, so at least 1.13 is desirable.
  • Aside from Go, a C compiler is needed to compile the sqlite component of kjudge. We recommend:
    • On Linux and OSX, either gcc or clang would be okay, although gcc is preferred by cgo. Try running either of the command to see if you have it.
    • On Windows, a gcc toolchain like mingw64 is required. Please install and make sure gcc is callable from the command line.
  • kjudge relies on some Javascript tools that require Node.js, and the Yarn package manager, to build the front-end assets.

Rather than giving installation commands for these tools, I encourage you to try and find the appropriate way to have them installed on your own system. Once you have done it, you can verify the existence and versions of each by

gcc --version # Or clang --version
go version
node --version
yarn --version

For running

  • isolate: The recommended sandbox. This is actually optional, however the only alternate sandbox implementation available (as of now) is the raw sandbox, which DOES NOT PROVIDE ANY GUARDS AGAINST FOREIGN CODE (which makes it okay to run when you are the only user). isolate is available on Linux systems only.

If you cannot or do not want to use isolate, run kjudge with -sandbox raw.

Preparation steps

First you need some Go tools. These can be installed simply by running

scripts/install_tools.sh

For Windows users: Sorry, but a script doesn't exist yet. You can manually install the tools by running

go get -v [tool-url-here]

for each import URL listed in tools.go.

Build instructions

There are two options:

  • A production version: Runs fast, no debugging messages.
  • A development version: Much slower, comes with profiling and debugging, live reload of templates etc.

Depending on the goal of running kjudge, pick your flavor.

Production version

Building a production, for Linux users, is as simple as

scripts/production_build.sh

For Windows users: Read the Bash scripts for more information... But in short, you need to:

  • Build a production template with yarn build inside the frontend folder.
  • Disable debugging mode in fileb0x.yml.
  • Run go generate to create model implementations and the filebox archive.
  • Run go build -tags production -o kjudge cmd/kjudge/main.go to compile the main binary.

Development version

First, open up a terminal, get to the frontend folder and start the development environment:

yarn dev

Now open another terminal, run

go generate

to generate the model implementations and the filebox system. Now you can run kjudge with

go run cmd/kjudge/main.go