| 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors |
| 3 | |
| 4 | //go:build !cgo && (darwin || freebsd || linux || netbsd) |
| 5 | |
| 6 | // Package fakecgo implements the Cgo runtime (runtime/cgo) entirely in Go. |
| 7 | // This allows code that calls into C to function properly when CGO_ENABLED=0. |
| 8 | // |
| 9 | // # Goals |
| 10 | // |
| 11 | // fakecgo attempts to replicate the same naming structure as in the runtime. |
| 12 | // For example, functions that have the prefix "gcc_*" are named "go_*". |
| 13 | // This makes it easier to port other GOOSs and GOARCHs as well as to keep |
| 14 | // it in sync with runtime/cgo. |
| 15 | // |
| 16 | // # Support |
| 17 | // |
| 18 | // Currently, fakecgo only supports macOS on amd64 & arm64. It also cannot |
| 19 | // be used with -buildmode=c-archive because that requires special initialization |
| 20 | // that fakecgo does not implement at the moment. |
| 21 | // |
| 22 | // # Usage |
| 23 | // |
| 24 | // Using fakecgo is easy just import _ "github.com/ebitengine/purego" and then |
| 25 | // set the environment variable CGO_ENABLED=0. |
| 26 | // The recommended usage for fakecgo is to prefer using runtime/cgo if possible |
| 27 | // but if cross-compiling or fast build times are important fakecgo is available. |
| 28 | // Purego will pick which ever Cgo runtime is available and prefer the one that |
| 29 | // comes with Go (runtime/cgo). |
| 30 | package fakecgo |
| 31 | |
| 32 | //go:generate go run gen.go |