-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/go: Support C/C++ compiler flags when using SWIG through the build tool #6696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Might this be added via a -swigflags ? Attachments:
|
Updated with go test support Attachments:
|
Travis, I don't think -swigflags is a good choice. Consider that a application depends on multiple packages that use swig to each wrap an external C++ library; when building the application you would have to specify -swigflags and pass in each package's header/library dependencies? I think a better approach might be to use something like CGO does with it's 'magic' "#cgo CFLAGS: foo" and "#cgo LDFLAGS: foo" (only adapted for swig) because then compiler and linker flags could be set per-package and it would be less tedius. I'm not sure that -swigflags would really have any benifits over the example workaround from the OP. Stephen |
My proposed CL is at: https://golang.org/cl/96320043 |
CL https://golang.org/cl/96320043 mentions this issue. |
I also struggled a bit with this. Then I found out that the swig build chain uses the flags set by cgo. So by adding a dummy file alongside the .swigcxx with only #cgo directives and import "C", cgo will be invoked prior to swig, and the flags you set with #cgo will be passed on to your swig build. |
Yes, I'll do my best to get it in ASAP and before the Go 1.5 feature freeze. I will prioritize it and hopefully have it in before (or around) Jan, 1st. |
@slimsag |
@slimsag |
@michael-schaller apologies for my latency on this issue. I've just checked and we do not need to do anything to support this use case anymore. Since SWIG code is now built using CGO instead of the old plan-9 C compilers, you can simply use a At this point, unless there is opposition to using the
The
Then I declared a simple C function in the SWIG package to retrieve a preprocessor-defined value (see
The SWIG package has the grunt of the code and our
Build and run it:
which produces:
|
Thanks for the worked example. |
@slimsag |
The text was updated successfully, but these errors were encountered: