Created
May 20, 2021 19:50
-
-
Save Shastick/2dde526d39a9c7a822e5565f2d8752a3 to your computer and use it in GitHub Desktop.
Bazel go_repository rule invocation to get godror to build with rules_go and CGO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- BUILD.bazel.orig 2021-05-20 09:45:18.000000000 +0200 | |
+++ BUILD.bazel 2021-05-20 10:09:15.000000000 +0200 | |
@@ -1,4 +1,4 @@ | |
-load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") | |
+load("@io_bazel_rules_go//go:def.bzl", "go_test", "go_library") | |
go_library( | |
name = "godror", | |
@@ -22,7 +22,10 @@ | |
"subscr.c", | |
"subscr.go", | |
"version.go", | |
- ], | |
+ "odpi/src/dpiImpl.h", | |
+ "odpi/src/dpiErrorMessages.h", | |
+ "odpi/include/dpi.h", | |
+ ] + glob(["odpi/src/*.c"]), | |
cgo = True, | |
clinkopts = select({ | |
"@io_bazel_rules_go//go/platform:android": [ | |
@@ -33,7 +36,9 @@ | |
], | |
"//conditions:default": [], | |
}), | |
- copts = ["-Iodpi/include -Iodpi/src -Iodpi/embed"], | |
+ # Full path from the execroot (location substitution does not seem to work here) | |
+ # Note that you'll need to edit this if godror gets imported under a different name | |
+ copts = ["-Iexternal/com_github_godror_godror/odpi/include) -Iexternal/com_github_godror_godror/odpi/src"], | |
importpath = "github.com/godror/godror", | |
visibility = ["//visibility:public"], | |
deps = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- drv.go.orig 2021-05-19 21:32:04.000000000 +0200 | |
+++ drv.go 2021-05-19 21:28:44.000000000 +0200 | |
@@ -62,7 +62,7 @@ | |
/* | |
#cgo CFLAGS: -I./odpi/include -I./odpi/src -I./odpi/embed | |
-#include "dpi.c" | |
+#include "dpiImpl.h" | |
*/ | |
import "C" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
go_repository( | |
name = "com_github_godror_godror", | |
importpath = "github.com/godror/godror", | |
sum = "h1:tVMUrrV5OyJp2MtvVbL1ZUDO0/cquLJWu639F+RY3eU=", | |
version = "v0.24.6", | |
# Two patches required so that we can properly | |
# build this lib with CGO | |
patches = [ | |
"//<path_to_patch_dir>:drv.patch", | |
"//<path_to_patch_dir>:BUILD.patch", | |
] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment