[archived] Building Syncthing

Content moved to Github:

I moved 4 posts to a new topic: Does not build after upgrading Go from 1.2 to 1.3

How can we debug syncthing?

I tried compiling with

  •   godep go build $* -ldflags "$ldflags" -gcflags '-N -l' ./cmd/syncthing
    

but running it under GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7 doesn’t seem to provide any go debug symbols

Indeed. The build script builds with -w to minimize the size of the resulting binary. For a regular, no frills, all debug symbols build, the easiest is actually to skip the build script and just run godep go build ./cmd/syncthing.

How can we clean? I’m doing it with git but it’s nuking my project file, should we add some clean to build.sh? I don’t know what’s the best way to do this in go or if there’s a recommended build system for go programs which handles this (godep?), I’m still trying to figure out all the golang tooling.

I clean with git clean -fxd, but I don’t have any files that I need left alife in .gitignore. Lacking that, what you need to do is get rid of the built artefacts, which for syncthing are in the bin and Godep/_workspace/pkg directories. Rm-rf:ing those should give you a clean rebuild.

If not building with godep, the relevant pkg directory is at $GOPATH/pkg.

Edit: Actually, the main syncthing packages (as opposed to the dependencies) seem to be placed there always, so nuke that too. A ./build.sh clean wouldn’t hurt.

Requirements changed: now requires Go 1.3 or higher.

Updated to reflect the new build.go “script”, which ought to work better on Windows.

I’m new to both go and git; the build.go script runs fine here, but when I change eg gui/index.html, the newly-built syncthing.exe still shows the old gui.

Is there a way to make the compilation show more details of what’s happening?

Ah, I have to rebuild assets if I change the GUI, now it works. Is/could there be a single command to build everything? It’s not like it takes much time anyway :).

As you discovered. You can also set the environment variable STGUIASSETS to point at the directory that contains the gui stuff (i.e. the gui folder in the source). Syncthing will then use the assets from there instead of the built in ones, so a regular “reload” in the browser reloads from disk.

Hi

I have problems building the deps, any ideas?

piotr@cubito:0:~/devel/syncthing (master)+$ git clean -f -d piotr@cubito:0:~/devel/syncthing (master)+$ ./build.sh deps go get -v code.google.com/p/go.tools/cmd/cover code.google.com/p/go.tools (download) code.google.com/p/go.tools/cover code.google.com/p/go.tools/cmd/cover go get -v code.google.com/p/go.tools/cmd/vet code.google.com/p/go.tools/cmd/vet/whitelist code.google.com/p/go.tools/go/exact code.google.com/p/go.tools/go/types code.google.com/p/go.tools/go/gcimporter code.google.com/p/go.tools/cmd/vet go get -v code.google.com/p/go.net/html code.google.com/p/go.net (download) code.google.com/p/go.net/html/atom code.google.com/p/go.net/html go get -v github.com/tools/godep github.com/tools/godep (download) github.com/kr/fs (download) code.google.com/p/go.tools/go/vcs github.com/kr/fs github.com/tools/godep rm -r Godeps godep save ./cmd/… godep: directory “/home/piotr/devel/syncthing/cmd/stevents” is outside source root "src" godep: directory “/home/piotr/devel/syncthing/cmd/stindex” is outside source root "src" godep: directory “/home/piotr/devel/syncthing/cmd/syncthing” is outside source root "src" godep: error loading packages exit status 1 exit status 1 piotr@cubito:1:~/devel/syncthing (master)+$ echo $GOROOT /home/piotr/devel/go piotr@cubito:0:~/devel/syncthing (master)+$ echo $GOPATH /home/piotr/devel/gopath/

piotr@cubito:2:~/devel/syncthing (master)+$ go version go version go1.3.1 linux/amd64

You didn’t follow the build instructions. :wink:

# Go is particular about file locations; use this path unless you know very
# well what you're doing.
$ mkdir -p ~/src/github.com/syncthing
$ cd ~/src/github.com/syncthing
$ git clone https://github.com/syncthing/syncthing

The complaints you are getting is because the source is not under GOPATH. The path to the checked out source should be exactly $GOPATH/src/github.com/syncthing/syncthing.

1 Like

Thanks. It was all working before with go 1.2 and I thought it was the right way.

Possibly godep has become more strict in a later update. The build.go script currently tries to do some magic so things will work even if GOPATH is not set, but that won’t help godep and does nothing if GOPATH is set but not set correctly.

It’s a bit of a love-it-or-hate-it situation, I’m personally not that impressed by the whole GOPATH thing, although when set up exactly as the tools expect it it works very well.

I created a Dockerfile and script that will automatically build the syncthing binary for you from source. . Just run ./build.sh and the binary will be created in that directory. The only prerequisite is a working Docker environment. Wasn’t sure if there was someplace else in the docs to put this :smile:

Scott

Edit: advantage for this – you don’t need a Go environment installed on your machine. It’s all containerized.

1 Like

What’s the reason why you have to set the directories in such a way to build? It’s the first program that I see that needs to be in a particular directory to be build…

Because Go.