glide-vc icon indicating copy to clipboard operation
glide-vc copied to clipboard

Running into problems when trying to preserve C files

Open VoR0220 opened this issue 8 years ago • 9 comments

tried this: glide vc --keep 'Makefile' '**/*.h' '**/*.cpp*'

but it still appears to be deleting my necessary cpp and such files...any hints?

VoR0220 avatar Aug 08 '16 18:08 VoR0220

@VoR0220 Are these files inside a package that has been kept by glide-vc or inside a dir not kept by glide-vc? Currently --keep will only keep files inside needed go packages.

Can you describe your use case?

sgotti avatar Aug 08 '16 19:08 sgotti

it is inside a needed go package, but it's a C Go extension. Basically I'm trying to port in a crypto library whereby there is C GO extensions added in but I can't seem to figure out how to make that happen.

VoR0220 avatar Aug 08 '16 19:08 VoR0220

it's a directory that's referenced by the package...

VoR0220 avatar Aug 08 '16 19:08 VoR0220

I get the feeling I'm not going to like the answer I'm about to get...

VoR0220 avatar Aug 08 '16 19:08 VoR0220

it's a directory that's referenced by the package...

glide-vc by default keeps cpp and hpp file inside the needed packages since this is how cgo works (https://golang.org/cmd/cgo/)

I'm not sure how you make cgo work if you put cpp/hpp files in a directory outside the using package and why this is inside the vendor dir (is it a program vendoring your cgo based go library?).

Can you provide some details on your program and what you are trying to do since it's not completely clear to me (or just a github repo with the whole project)?

sgotti avatar Aug 08 '16 20:08 sgotti

I think I've come to the conclusion that it's not VC that's the problem, it's the way I'm structuring my dockerfile. If I run into any more problems though, I will be certain to contact you. Thanks for your help. I hope the day comes when this is implemented into the main glide.

VoR0220 avatar Aug 09 '16 15:08 VoR0220

Okay I can reproduce the issue now. Basically it's this directory right here: https://github.com/ethereum/go-ethereum/tree/master/crypto/secp256k1

Basically the problem is that I try to keep libsecp256k1 directory intact, and I can't seem to get it to keep it. I've tried many variations of this below example:

glide vc --keep 'go-ethereum/crypto/*' 'go-ethereum/crypto/secpk256k1/*' './vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/*' 'vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/include/*' 'vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/obj/*' 'vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/src/*' --dryrun

VoR0220 avatar Oct 02 '16 00:10 VoR0220

I should clarify, I manage to get crypto and secpk256k1, just not the subsequent c libs.

VoR0220 avatar Oct 02 '16 00:10 VoR0220

@VoR0220 Thanks for the additional information. https://github.com/ethereum/go-ethereum/tree/master/crypto/secp256k1 is using cgo in a strange way. It bundles libsecp256k1 source code and builds the cgo required functions using relative includes to some of its .c and .h files. I think this is done to avoid the user having libsecp256k1 installed on their system and link against it (like its usually done) but instead compile and link only the required functions during a go build.

There's no way (without code analysis) for glide-vc to infer the additional cgo required files inside other dirs like this case. So I can think of two solutions:

  • Just implement an additional step that will copy back ./vendor/github.com/ethereum/go-ethereum/crypto/secp256k1/libsecp256k1/ after running glide-vc
  • Extend --keep to also keep any file in the vendor dir. Now --keep only keeps additional files inside required packages dir (not subdirs or other non required packages) but probably this can be relaxed (and add better documentation to explain that --keep shouldn't be needed and used only for special cases like this and not to fix improper glide configurations/missing packages).

sgotti avatar Oct 03 '16 07:10 sgotti