Skip to content

Commit

Permalink
add development/contributing section
Browse files Browse the repository at this point in the history
  • Loading branch information
hrfee committed Jul 25, 2021
1 parent b7cb7e7 commit 0338529
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 8 deletions.
2 changes: 1 addition & 1 deletion content/docs/build/_index.md
Expand Up @@ -6,4 +6,4 @@ draft: false

# Building from source

See the sidebar for instructions for building a binary or a Docker container.
See the sidebar for instructions for building a binary or Docker container, as well as helpful information for those wishing to contribute.
10 changes: 3 additions & 7 deletions content/docs/build/binary.md
Expand Up @@ -26,22 +26,18 @@ The main dependencies of the program will be automatically downloaded on compila
```shell
$ git clone https://github.com/hrfee/jfa-go
$ cd jfa-go
$ make all # [DEBUG=on] [INTERNAL=off] [UPDATER=on/docker] [TRAY=on] [GOESBUILD=on] [RACE=on]
$ make all # [DEBUG=on] [INTERNAL=off] [UPDATER=on/docker] [TRAY=on] [GOESBUILD=on] [RACE=on] [...]
$ ls build/
jfa-go
```
A Makefile is provided, which requires the `make` command. Simply clone the repository and run `make all` to grab all necessary dependencies for go/python/node, compile everything and place the executable and app data inside `build/`. You can optionally compress the executable by running `make compress` after.
* You can add the following flags with `make all FLAGNAME=VALUE`:
* `DEBUG=on`: doesn't strip binaries and includes typescript sourcemaps.
* `INTERNAL=off`: Defaults to on, this disables embedding so assets are stored in the `data/` folder next to the binary. Useful for customizing after compilation.
* `UPDATER=on/off/docker`: Enables/disables the updater, which pings [build.hrfee.pw](https://builds.hrfee.pw) every 30 mins for new updates. New updates are shown with a download link to the user. When `INTERNAL=on`, updates are automatically downloaded, and installed upon request.
* `TRAY=on`: Enables a tray icon, which lets you start/stop/autostart on login. For linux, requires `libappindicator3-dev` for debian or the equivalent on other distributions.
* `RACE=on`: Compile with the go race detector included.

* If you get an error from npm regarding esbuild, this is because a precompiled binary for your system's architecture isn't available on npm. run `make all GOESBUILD=on` instead to have it compiled instead.

* You can optionally provide the path/name of the `go` executable manually with `make all GOBINARY=<path to go>`.

* More build-time variables exist, which are explained on the [contributing page](/docs/build/dev).

## Goreleaser
[goreleaser](https://github.com/goreleaser/goreleaser) is used to publish the packages seen in the release section. The `scripts/version.sh` wrapper generates the version and provides it to goreleaser with an environment variable.

Expand Down
44 changes: 44 additions & 0 deletions content/docs/build/dev.md
@@ -0,0 +1,44 @@
---
title: "Building/Contributing for developers"
date: 2021-07-25T00:33:36+01:00
draft: false
---
# Code
I use 4 spaces for indentation. Go should ideally be formatted with `goimports` and/or `gofmt`. I don't use a formatter on typescript, so don't worry about that.

Code in Go should ideally use `PascalCase` for exported values, and `camelCase` for non-exported, JSON for transferring data should use `snake_case`, and Typescript should use `camelCase`. Forgive me for my many inconsistencies in this, and feel free to fix them if you want.

Functions in Go that need to access `*appContext` should be generally be receivers, except when the behaviour could be seen as somewhat independent from it (`email.go` is the best example, its behaviour is broadly independent from the main app except from a couple config values).


# Compiling

The Makefile is more suited towards development than other build methods, and provides separate build stages to speed up compilation when only making changes to specific aspects of the project.

Prefix each of these with `make DEBUG=on `:
* `all` will download deps and build everything. The executable and data will be placed in `build`. This is only necessary the first time.
* `npm` will download all node.js build-time dependencies.
* `compile` will only compile go code into the `build/jfa-go` executable.
* `typescript` will compile typescript w/ sourcemaps into `build/data/web/js`.
* `bundle-css` will bundle CSS and place it in `build/data/web/css`.
* `inline` will inline the css and javascript used in the single-file crash report webpage.
* `configuration` will generate the `config-base.json` (used to render settings in the web ui) and `config-default.ini` and put them in `build/data`.
* `email` will compile email mjml, and copy the text versions in to `build/data`.
* `swagger`: generates swagger documentation for the API.
* `copy` will copy iconography, html, language files and static data into `build/data`.

## Environment variables

* `DEBUG=on/off`: If on, compiles with type-checking for typescript, sourcemaps, non-minified css and no symbol stripping.
* `INTERNAL=on/off`: Whether or not to embed file assets into the binary itself, or store them separately beside the binary.
* `UPDATER=on/off/docker`: Enable/Disable the updater, or set a special update type (currently only docker, which disables self-updating the binary).
* `TRAY=on/off`: Enable/disable the tray icon, which lets you start/stop/autostart on login. For linux, requires `libappindicator3-dev` for debian or the equivalent on other distributions.
* `GOESBUILD=on`: Use a locally installed `esbuild` binary. NPM doesn't provide builds for all os/architectures, so `npx esbuild` might not work for you, so the binary is compiled/installed with `go get`.
* `GOBINARY=<path to go>`: Alternative path to go executable. Useful for testing with unstable go releases.
* `VERSION=v<semver>`: Alternative verision number, useful to test update functionality.
* `COMMIT=<short commit>`: Self explanatory.
* `LDFLAGS=<ldflags>`: Passed to `go build -ldflags`.
* `E2EE=on/off`: Enable/disable end-to-end encryption support for Matrix, which is currently very broken. Must subsequently be enabled (with Advanced settings enabled) in Settings > Matrix.
* `TAGS=<tags>`: Passed to `go build -tags`.
* `OS=<os>`: Unrelated to GOOS, if set to `windows`, `-H=windowsgui` is passed to ldflags, which stops a windows terminal popping up when run.
* `RACE=on/off`: If on, compiles with the go race detector included.
1 change: 1 addition & 0 deletions content/menu/index.md
Expand Up @@ -14,6 +14,7 @@ headless = true
- [Build from source]({{< relref "/docs/build/" >}})
- [Binaries]({{< relref "/docs/build/binary" >}})
- [Docker]({{< relref "/docs/build/docker" >}})
- [Development]({{< relref "/docs/build/dev" >}})
- [Password Resets outside local network]({{< relref "/docs/password-resets" >}})
- [Reverse Proxying]({{< relref "/docs/reverse-proxy" >}})
- [TLS Setup]({{< relref "/docs/tls" >}})
Expand Down

0 comments on commit 0338529

Please sign in to comment.