This repository has been archived by the owner on Dec 10, 2020. It is now read-only.
forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug that recognized "C" as a remote package.
The `import "C"` statement has special semantics and imports of this form are satisfied by the Go distribution with links to local libraries using the C calling convention. Pants did not recognize this and would attempt to fetch "C" and fail since "C" is not part of the stdlib and is also not a remote package. This change fixes import scanning code to know about "C" and also centralizes the import logic in `ImportOracle`. Testing Done: Added a new failing `test_issues_2616` to `GoFetchTest` that this change fixes as well `compile` and `run` integration tests for Cgo that aren't directly related to this change but do exercise the full pipeline of interest for Cgo code. Also did not check in the motivating example since it requires ImageMagick libs, but adding `contrib/go/examples/3rdparty/go/github.com/gographics/imagick/BUILD`: ```python # Auto-generated by pants! # To re-generate run: `pants buildgen.go --materialize --remote` go_remote_libraries( rev='02d20b370cf9bac9d1d8297397c7e4b20a92add4', packages=[ 'imagick', ] ) ``` Demonstrates a successful resolve and compile for remote Cgo code (the scary output below is just 3 compile warnings in ImageMagick): ``` ./pants compile contrib/go/examples/3rdparty/go/github.com/gographics/imagick ... 09:43:02 00:00 [resolve] ... 09:43:02 00:00 [go] Invalidated 1 target.INFO] Downloading https://github.com/gographics/imagick/archive/02d20b370cf9bac9d1d8297397c7e4b20a92add4.tar.gz... 09:43:04 00:02 [github.com/gographics/imagick/imagick] ... 09:43:04 00:02 [compile] ... 09:43:04 00:02 [go] Invalidated 1 target. 09:43:04 00:02 [install] # github.com/gographics/imagick/imagick .pants.d/compile/go/contrib.go.examples.3rdparty.go.github.com.gographics.imagick.imagick/src/github.com/gographics/imagick/imagick/magick_core_env.go: In function ‘_cgo_85b92643e208_Cfunc_IsMagickInstantiated’: .pants.d/compile/go/contrib.go.examples.3rdparty.go.github.com.gographics.imagick.imagick/src/github.com/gographics/imagick/imagick/magick_core_env.go:54:2: warning: ‘IsMagickInstantiated’ is deprecated [-Wdeprecated-declarations] In file included from /usr/include/ImageMagick-6/magick/MagickCore.h:95:0, from /usr/include/ImageMagick-6/wand/MagickWand.h:72, from .pants.d/compile/go/contrib.go.examples.3rdparty.go.github.com.gographics.imagick.imagick/src/github.com/gographics/imagick/imagick/magick_core_env.go:8: /usr/include/ImageMagick-6/magick/deprecate.h:205:3: note: declared here IsMagickInstantiated(void) magick_attribute((deprecated)), ^ # github.com/gographics/imagick/imagick .pants.d/compile/go/contrib.go.examples.3rdparty.go.github.com.gographics.imagick.imagick/src/github.com/gographics/imagick/imagick/magick_wand_image.go: In function ‘_cgo_85b92643e208_Cfunc_MagickRadialBlurImage’: .pants.d/compile/go/contrib.go.examples.3rdparty.go.github.com.gographics.imagick.imagick/src/github.com/gographics/imagick/imagick/magick_wand_image.go:3032:2: warning: ‘MagickRadialBlurImage’ is deprecated [-Wdeprecated-declarations] In file included from /usr/include/ImageMagick-6/wand/MagickWand.h:78:0, from .pants.d/compile/go/contrib.go.examples.3rdparty.go.github.com.gographics.imagick.imagick/src/github.com/gographics/imagick/imagick/magick_wand_image.go:9: /usr/include/ImageMagick-6/wand/deprecate.h:109:3: note: declared here MagickRadialBlurImage(MagickWand *,const double) ^ .pants.d/compile/go/contrib.go.examples.3rdparty.go.github.com.gographics.imagick.imagick/src/github.com/gographics/imagick/imagick/magick_wand_image.go: In function ‘_cgo_85b92643e208_Cfunc_MagickRadialBlurImageChannel’: .pants.d/compile/go/contrib.go.examples.3rdparty.go.github.com.gographics.imagick.imagick/src/github.com/gographics/imagick/imagick/magick_wand_image.go:3049:2: warning: ‘MagickRadialBlurImageChannel’ is deprecated [-Wdeprecated-declarations] // image that is added back into the original. ^ In file included from /usr/include/ImageMagick-6/wand/MagickWand.h:78:0, from .pants.d/compile/go/contrib.go.examples.3rdparty.go.github.com.gographics.imagick.imagick/src/github.com/gographics/imagick/imagick/magick_wand_image.go:9: /usr/include/ImageMagick-6/wand/deprecate.h:111:3: note: declared here MagickRadialBlurImageChannel(MagickWand *,const ChannelType,const double) ^ ... 09:43:14 00:12 [complete] SUCCESS ``` CI went green here: https://travis-ci.org/pantsbuild/pants/builds/93049583 Bugs closed: 2616, 2619 Reviewed at https://rbcommons.com/s/twitter/r/3170/
- Loading branch information
Showing
11 changed files
with
271 additions
and
67 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Auto-generated by pants! | ||
# To re-generate run: `pants buildgen.go --materialize --remote` | ||
|
||
go_binary() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
/* | ||
#include <stdlib.h> | ||
*/ | ||
import "C" | ||
|
||
import "fmt" | ||
|
||
func main() { | ||
fmt.Printf("Random from C: %d", int(C.random())) | ||
} |
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
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
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
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
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
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
Oops, something went wrong.