Building

Building with go build

SCION can be built with go build without any other system prerequisites.

Please be aware that go build is not the recommended setup for development on SCION. Not all tests and checks can be run in this setup. We use Bazel to orchestrate all of this. Without running all checks locally, it is likely that there will be frustrating cycles with the CI system rejecting your changes. See Setting up the Development Environment for instructions on how to set up Bazel and the full development environment.

Prerequisites

  1. Clone the SCION repository into your workspace.

    git clone https://github.com/scionproto/scion
    cd scion
    
  2. Determine the go version used in the Bazel setup; the WORKSPACE file specifies this version in the go_register_toolchains clause.

    go_register_toolchains(
        nogo = "@//:nogo",
        version = "1.22.7",
    )
    

    Building with newer go versions usually works.

  3. Install go. Either follow the official instructions or check the Ubuntu specific installation options on the golang wiki.

Build

  • Build only “distributables”, without development and testing tools

    CGO_ENABLED=0 go build -o bin/ ./{router,control,dispatcher,daemon,scion,scion-pki,gateway}/cmd/...
    
  • Build all

    go build -o bin/ ./...
    

Options

  • sqlite implementations: two different sqlite implementations can be chosen at build time:

    • modernc/sqlite: default. A pure go implementation of sqlite (transpiled from C).

    • mattn/go-sqlite3: A CGO wrapper for the official sqlite implementation. It is well established but requires CGO; this makes it impossible to build static binaries and executables are dependent on a minimum glibc version.

    Specify build tag (go build -tags=<...>) either sqlite_modernc or sqlite_mattn.

Building with Bazel

Please be aware that the following instructions only result in a minimal build environment. Not all tests and checks can be run in this setup. See Setting up the Development Environment for instructions on how to set up Bazel and the full development environment.

Prerequisites

  1. Clone the SCION repository into your workspace.

    git clone https://github.com/scionproto/scion
    cd scion
    
  2. Install Bazel: either follow the official instructions at https://bazel.build/install, or run our helper script:

    tools/install_bazel
    
  3. Remove remote cache options from .bazelrc; the default setup is useful to limit Bazel’s cache size when contributing to SCION, but requires a running docker container acting as the “remote” cache service

    sed -e '/--remote_cache=/d' -i .bazelrc
    

    Alternatively, if you have docker installed, you can run ./scion.sh bazel-remote to start the cache service.

Build

  • Build only “distributables”, without development and testing tools

    make build                          # or, ...
    bazel build //:scion                # or, ...
    bazel build //control/cmd/control //router/cmd/router <...>
    
  • Build all

    make build-dev                      # or, ...
    make                                # or, ...
    bazel build //:scion //:scion-ci
    
  • Build packages for debian (all target architectures)

    make dist-deb                        # or, ...
    bazel build //dist:deb_all
    
  • Build packages for openwrt (x86_64 only, currently)

    make dist-openwrt                        # or, ...
    bazel build //dist:openwrt_all
    

Options

  • Bundling the management API documentation with the binaries.

    bazel build --//:mgmtapi_bundle_doc=true //:scion
    
  • sqlite implementations: specify a build tag, sqlite_modernc or sqlite_mattn.

    bazel build --define gotags=sqlite_mattn <...>