-
Notifications
You must be signed in to change notification settings - Fork 4
Building
Learn how to compile the go-module and it's components
There are prerequisites for building the module. You can find them here.
- Go >= 1.21.0
- mingw-w64 (for Windows users)
- MSVC >= 17 (for Windows users)
- GCC >= 9.3.0 (for Linux or macOS users)
- CMake >= 3.16
- Make >= 4.3 (optional)
Make sure you have installed all requirements.
At first clone this repository:
git clone --recurse-submodules https://github.com/timo972/altv-go.gitEither follow the automatic build (make) or the manuall build guides.
requires make
To build the runtime and the c-api run the following command:
makeIf you do not have make installed, you can run the following commands manually:
./scripts/build-runtime.shYou can find the built runtime library in the folder ./runtime/bin/libruntime.so (linux) or ./runtime/bin/Release/go-module.dll (windows).
See how to use your local build for more information.
./scripts/build-capi.shYou can find the built c-api library in the folder ./internal/c-api/lib/linux/libcapi.a (linux) or ./internal/c-api/lib/win32/libcapi.a (windows). However usually you do not need to touch the built c-api library.
Run go tests:
go test -vIf this command succeeds everything is compatible and built correctly and you can start using your local version of altv-go.
To use your local version of the altv-go package, you need to add the following line to the go.mod file of your resource:
replace github.com/timo972/altv-go => ../relative/path/to/your/altv-go
This tells go to use the local version of the package instead of the one hosted on github.
Building the runtime is as easy as running the following command:
cd ./runtime
# create build and output folder
mkdir build
mkdir bin
cd build
# start build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++ ..
cmake --build . --config Release
See more about runtime build here.
Building the c-api constists of two parts:
- Generation of the c-api header & source file
- Actual build of the c-api using cmake
Generate the c-api header & source files using cmd/gencapi:
go run cmd/gencapi/*.go -cout=./internal/c-api/build/out/capi.c -hout=./internal/c-api/build/out/capi.h -hout=./internal/c-api/lib/capi.h ./runtime/src/capiThis will generate the c-api header & source file in the folder ./internal/c-api/build/out/ and copy the header file to ./internal/c-api/lib/capi.h.
Build the c-api using cmake:
cd ./internal/c-api
# create build and output folder
mkdir build
mkdir bin
cd build
# start build
cmake ..
cmake --build .See how to test the build below.
To check if the build was successful, you can run the following command:
go test -v
This will run all tests in the root go package and errors in case the capi is not built correctly or incompatible with the go api.
You encountered a problem ๐ฅ? Check out the Troubleshooting Guide!
If you can't find a solution there file a new issue in this repository or contact me on Discord.