docs/DEVELOPMENT.md
Environment Variables buttonPath. Edit and add C:\MinGW\bin (replace with the correct path to where you extracted MingW64).NOTE: The make command in Windows will be mingw32-make with MinGW. For example, make pre-ui will be mingw32-make pre-ui.
brew install go git gcc make node ffmpegsudo pacman -S go git gcc make nodejs ffmpeg --neededsudo apt-get install golang git gcc nodejs ffmpeg -ydoas pkg_add gmake go git node cmake ffmpegmake build-release with gmake flags-release stash, to avoid the PIE buildmode.NOTE: The make command in OpenBSD will be gmake. For example, make pre-ui will be gmake pre-ui.
make pre-ui - Installs the UI dependencies. This only needs to be run once after cloning the repository, or if the dependencies are updated.make generate - Generates Go and UI GraphQL files. Requires make pre-ui to have been run.make generate-stash-box-client - Generate Go files for the Stash-box client code.make ui - Builds the UI. Requires make pre-ui to have been run.make stash - Builds the stash binary (make sure to build the UI as well... see below)make stash-macapp - Builds the Stash.app macOS app (only works when on macOS, for cross-compilation see below)make phasher - Builds the phasher binarymake build - Builds both the stash and phasher binaries, alias for make stash phashermake build-release - Builds release versions (debug information removed) of both the stash and phasher binaries, alias for make flags-release flags-pie buildmake docker-build - Locally builds and tags a complete 'stash/build' docker imagemake docker-cuda-build - Locally builds and tags a complete 'stash/cuda-build' docker imagemake validate - Runs all of the tests and checks required to submit a PRmake lint - Runs golangci-lint on the backendmake it - Runs all unit and integration testsmake fmt - Formats the Go source codemake fmt-ui - Formats the UI source codemake validate-ui - Runs tests and checks for the UI onlymake fmt-ui-quick - (experimental) Formats only changed UI source codemake validate-ui-quick - (experimental) Runs tests and checks of changed UI codemake server-start - Runs a development stash server in the .local directorymake server-clean - Removes the .local directory and all of its contentsmake ui-start - Runs the UI in development mode. Requires a running Stash server to connect to - the server URL can be changed from the default of http://localhost:9999 using the environment variable VITE_APP_PLATFORM_URL, but keep in mind that authentication cannot be used since the session authorization cookie cannot be sent cross-origin. The UI runs on port 3000 or the next available port.When building, you can optionally prepend flags-* targets to the target list in your make command to use different build flags:
flags-release (e.g. make flags-release stash) - Remove debug information from the binary.flags-pie (e.g. make flags-pie build) - Build a PIE (Position Independent Executable) binary. This provides increased security, but it is unsupported on some systems (notably 32-bit ARM and OpenBSD).flags-static (e.g. make flags-static phasher) - Build a statically linked binary (the default is a dynamically linked binary).flags-static-pie (e.g. make flags-static-pie stash) - Build a statically linked PIE binary (using flags-static and flags-pie separately will not work).flags-static-windows (e.g. make flags-static-windows build) - Identical to flags-static-pie, but does not enable the netgo build tag, which is not needed for static builds on Windows.make pre-ui to install UI dependenciesmake generate to create generated filesmake server-start to run the server codemake ui-start to run the UI in development modehttp://localhost:3000/Changes to the UI code can be seen by reloading the browser page.
Changes to the backend code require a server restart (CTRL-C in the server terminal, followed by make server-start again) to be seen.
On first launch:
To start fresh with new configuration:
CTRL-C in the server terminal)make server-clean to clear all config, database, and generated files (under .local)make server-start to restart the serverSimply run make or make release, or equivalently:
make pre-ui to install UI dependenciesmake generate to create generated filesmake ui to build the frontendmake build-release to build a release executable for your current platformThis project uses a modification of the CI-GoReleaser Docker container for cross-compilation, defined in docker/compiler/Dockerfile.
To cross-compile the app yourself:
make pre-ui, make generate and make ui outside the container, to generate files and build the UI.docker pull ghcr.io/stashapp/compilerdocker run --rm --mount type=bind,source="$(pwd)",target=/stash -w /stash -it ghcr.io/stashapp/compiler /bin/bash to open a shell inside the container.make build-cc-all to build for all platforms, or run make build-cc-{platform} to build for a specific platform (have a look at the Makefile for the list of targets).dist/.NOTE: Since the container is run as UID 0 (root), the resulting binaries (and the dist/ folder itself, if it had to be created) will be owned by root.
Stash can be profiled using the --cpuprofile <output profile filename> command line flag.
The resulting file can then be used with pprof as follows:
go tool pprof <path to binary> <path to profile filename>
With graphviz installed and in the path, a call graph can be generated with:
go tool pprof -svg <path to binary> <path to profile filename> > <output svg file>