Prerequisites
Before building Viction from source, ensure you have the following installed:- Go: Version 1.18 or later (Download Go)
- C Compiler: Required on all platforms (Linux, Windows, macOS)
- Git: For cloning the repository
Clone the Repository
First, clone the Viction blockchain repository:Build Methods
Standard Build
The standard build process uses the custom build script to compile the Viction node:- Build all packages and executables
- Place binaries in
build/bin/directory - Build the main
tomoexecutable along with utility tools
Building Specific Components
Build Main Node Only
build/bin/tomo.
Build Bootnode
build/bin/bootnode
Build GC (Garbage Collection Tool)
build/bin/gc
Build Puppeth (Network Wizard)
build/bin/puppeth
Build All Tools
Cross-Compilation
Viction supports cross-compilation for multiple platforms usingxgo.
Cross-Compile for All Platforms
- Windows (amd64)
- macOS (darwin amd64)
- Linux (386, amd64, mips64, mips64le)
Platform-Specific Builds
Linux Builds
macOS Builds
Windows Build
Custom Go Version for Cross-Compilation
You can specify a custom Go version:Docker Build
Alternatively, build using Docker:Build Configuration
Build Flags
The build system automatically includes:- Git commit hash in the binary
- Optimized flags for macOS (
-slinker flag) - Custom
GOBINpath pointing tobuild/bin
Environment Variables
GOBIN: Set to$(pwd)/build/binGO: Go version for cross-compilation (default: 1.18.10)CC: C compiler for cross-compilationGOARCH: Target architectureCGO_ENABLED: Enabled for cross-compilation
Testing the Build
Run Tests
Run Tests with Coverage
coverage.txt file with code coverage information.
Code Quality
Run Linters
vet: Go vet for potential issuesgofmt: Code formatting checkmisspell: Spelling errorsgoconst: Repeated constantsunconvert: Unnecessary conversionsgosimple: Simplification suggestions
Format Code
Cleaning Build Artifacts
Remove all built binaries and build artifacts:build/_workspace/pkg/- All binaries in
build/bin/
Troubleshooting
Go Version Issues
Viction requires Go 1.9 or later. If you encounter build errors, check your Go version:Missing Dependencies
If you encounter missing dependencies, ensure you’re running from the repository root:Cross-Compilation Errors
For cross-compilation issues, ensurexgo is installed: