#build-script #build-dependencies #cargo-build #compile #go #link #cgo

build cgo_oligami

A library for build scripts to compile custom Go code

6 releases

0.3.6 Nov 9, 2023
0.3.5 Sep 18, 2023

#240 in Build Utils

Download history 36/week @ 2024-07-29 3/week @ 2024-09-16 49/week @ 2024-09-23 12/week @ 2024-09-30 7/week @ 2024-10-07 21/week @ 2024-10-14 31/week @ 2024-10-21 13/week @ 2024-10-28 41/week @ 2024-11-04

107 downloads per month
Used in oracle-nosql-db-sdk-rust

MIT license

18KB
304 lines

cgo-rs

A library for build scripts to compile custom Go code, inspired by the excellent cc crate.

It is intended that you use this library from within your build.rs file by adding the cgo crate to your build-dependencies:

[build-dependencies]
cgo_oligami = "*"

Examples

The following example will statically compile the Go package and instruct cargo to link the resulting library (libexample).

fn main() {
    cgo::Build::new()
        .package("pkg/example/main.go")
        .build("example");
}

windows cannot support

Golang is not support llvm on windows so Rust cannot link Golang staticlib on windows https://github.com/golang/go/issues/17014 If you use, dynamiclib https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute

support

mac and linux without alpine

memo

https://zenn.dev/koya_iwamura/articles/bb9b590b57d825 https://tip.golang.org/doc/go1.21#go-command

Minimum Version

  • rust 1.64
  • go 1.21.1

Dependencies

~215–305KB