Provide better flexibility for passing OS and ARCH

This commit is contained in:
Arnaud 2025-10-15 06:54:58 +02:00
parent 7a09d02768
commit 2dfd2a8faa
No known key found for this signature in database
GPG Key ID: 20E40A5D3110766F
2 changed files with 12 additions and 9 deletions

View File

@ -6,9 +6,9 @@ CGO_CFLAGS := -I$(LIBS_DIR)
CGO_LDFLAGS := -L$(LIBS_DIR) -Wl,-rpath,$(LIBS_DIR)
# Configuration for fetching the right binary
OS := "linux"
ARCH := "amd64"
VERSION := "v0.0.15"
OS ?= "linux"
ARCH ?= "amd64"
VERSION ?= "v0.0.15"
LATEST_URL := "https://github.com/codex-storage/codex-go-bindings/releases/latest/download/codex-${OS}-${ARCH}.zip"
VERSIONED_URL := "https://github.com/codex-storage/codex-go-bindings/releases/download/$(VERSION)/codex-${OS}-${ARCH}.zip"
@ -20,7 +20,7 @@ all: run
fetch:
@echo "Fetching libcodex from GitHub Actions: ${LATEST_URL}"
@curl -fSL --create-dirs -o $(LIBS_DIR)/codex-${OS}-${ARCH}.zip ${LATEST_URL}
@unzip $(LIBS_DIR)/codex-${OS}-${ARCH}.zip -d $(LIBS_DIR)
@unzip $(LIBS_DIR)/codex-${OS}-${ARCH}.zip -d -qq $(LIBS_DIR)
@rm -f $(LIBS_DIR)/*.zip
build:

View File

@ -15,14 +15,17 @@ go get
### Fetch the artifacts
```sh
# Adapt for your OS
OS := "linux" # can be linux, macos or windows
ARCH := "amd64" # can amd64 or arm64
make fetch
```
By default, the last release will be downloaded and extracted to libs folder. You can change the `Makefile`
to specify another folder or download a specific version.
The default `OS` is `linux` and the default `ARCH` is `amd64`.
You can update them like this:
```sh
OS="macos" ARCH="arm64" make fetch
```
By default, the last release will be downloaded and extracted to libs folder.
### Build