diff options
author | editfund-founder <61936162+editfund-founder@users.noreply.github.com> | 2023-06-13 10:53:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-13 10:53:51 +0800 |
commit | 139704f4994f8a960351cd19f66b262e53cc9f6d (patch) | |
tree | 8ee2e4b3debf8958a00ecc08952f5f18d1a7fb98 /docs | |
parent | 6da19d76bff9924a30e054e9e57f54d3ca515764 (diff) | |
download | gitea-139704f4994f8a960351cd19f66b262e53cc9f6d.tar.gz gitea-139704f4994f8a960351cd19f66b262e53cc9f6d.zip |
Update `from-source.zh-cn.md` & `from-source.en-us.md` - Cross Compile Using Zig (#25194)
## Compile & Cross Compile Gitea With CGO Dependencies Using Zig
---------
Co-authored-by: Jason Song <i@wolfogre.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/content/doc/installation/from-source.en-us.md | 58 | ||||
-rw-r--r-- | docs/content/doc/installation/from-source.zh-cn.md | 58 |
2 files changed, 116 insertions, 0 deletions
diff --git a/docs/content/doc/installation/from-source.en-us.md b/docs/content/doc/installation/from-source.en-us.md index dfded3d9fd..98179dd55e 100644 --- a/docs/content/doc/installation/from-source.en-us.md +++ b/docs/content/doc/installation/from-source.en-us.md @@ -206,3 +206,61 @@ Similarly, a script for zsh-completion can be found at [`contrib/autocompletion/ `.zshrc`. YMMV and these scripts may need further improvement. + +## Compile or cross-compile using Linux with Zig + +Follow [Getting Started of Zig](https://ziglang.org/learn/getting-started/#installing-zig) to install zig. + +- Compile (Linux ➝ Linux) + +```sh +CC="zig cc -target x86_64-linux-gnu" \ +CGO_ENABLED=1 \ +CGO_CFLAGS="-O2 -g -pthread" \ +CGO_LDFLAGS="-linkmode=external -v" +GOOS=linux \ +GOARCH=amd64 \ +TAGS="bindata sqlite sqlite_unlock_notify" \ +make build +``` + +- Cross-compile (Linux ➝ Windows) + +```sh +CC="zig cc -target x86_64-windows-gnu" \ +CGO_ENABLED=1 \ +CGO_CFLAGS="-O2 -g -pthread" \ +GOOS=windows \ +GOARCH=amd64 \ +TAGS="bindata sqlite sqlite_unlock_notify" \ +make build +``` + +## Compile or cross-compile with Zig using Windows + +Compile with `GIT BASH`. + +- Compile (Windows ➝ Windows) + +```sh +CC="zig cc -target x86_64-windows-gnu" \ +CGO_ENABLED=1 \ +CGO_CFLAGS="-O2 -g -pthread" \ +GOOS=windows \ +GOARCH=amd64 \ +TAGS="bindata sqlite sqlite_unlock_notify" \ +make build +``` + +- Cross-compile (Windows ➝ Linux) + +```sh +CC="zig cc -target x86_64-linux-gnu" \ +CGO_ENABLED=1 \ +CGO_CFLAGS="-O2 -g -pthread" \ +CGO_LDFLAGS="-linkmode=external -v" +GOOS=linux \ +GOARCH=amd64 \ +TAGS="bindata sqlite sqlite_unlock_notify" \ +make build +``` diff --git a/docs/content/doc/installation/from-source.zh-cn.md b/docs/content/doc/installation/from-source.zh-cn.md index d9f54ba3c1..5d4ab0c3ae 100644 --- a/docs/content/doc/installation/from-source.zh-cn.md +++ b/docs/content/doc/installation/from-source.zh-cn.md @@ -103,3 +103,61 @@ GOOS=linux GOARCH=arm64 make build ```bash CC=aarch64-unknown-linux-gnu-gcc GOOS=linux GOARCH=arm64 TAGS="bindata sqlite sqlite_unlock_notify" make build ``` + +## 使用Linux与Zig编译或交叉编译 + +按照[Getting Started of Zig](https://ziglang.org/learn/getting-started/#installing-zig)来安装zig。 + +- 编译(Linux ➝ Linux) + +```sh +CC="zig cc -target x86_64-linux-gnu" \ +CGO_ENABLED=1 \ +CGO_CFLAGS="-O2 -g -pthread" \ +CGO_LDFLAGS="-linkmode=external -v" +GOOS=linux \ +GOARCH=amd64 \ +TAGS="bindata sqlite sqlite_unlock_notify" \ +make build +``` + +- 交叉编译(Linux ➝ Windows) + +```sh +CC="zig cc -target x86_64-windows-gnu" \ +CGO_ENABLED=1 \ +CGO_CFLAGS="-O2 -g -pthread" \ +GOOS=windows \ +GOARCH=amd64 \ +TAGS="bindata sqlite sqlite_unlock_notify" \ +make build +``` + +## 使用Windows与Zig编译或交叉编译 + +使用`GIT BASH`编译。 + +- 编译(Windows ➝ Windows) + +```sh +CC="zig cc -target x86_64-windows-gnu" \ +CGO_ENABLED=1 \ +CGO_CFLAGS="-O2 -g -pthread" \ +GOOS=windows \ +GOARCH=amd64 \ +TAGS="bindata sqlite sqlite_unlock_notify" \ +make build +``` + +- 交叉编译(Windows ➝ Linux) + +```sh +CC="zig cc -target x86_64-linux-gnu" \ +CGO_ENABLED=1 \ +CGO_CFLAGS="-O2 -g -pthread" \ +CGO_LDFLAGS="-linkmode=external -v" +GOOS=linux \ +GOARCH=amd64 \ +TAGS="bindata sqlite sqlite_unlock_notify" \ +make build +``` |