sgotti / glide-vc

Glide vendor cleaner
MIT License
53 stars 10 forks source link

Running into problems when trying to preserve C files #18

Open VoR0220 opened 8 years ago

VoR0220 commented 8 years ago

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

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

sgotti commented 8 years ago

@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?

VoR0220 commented 8 years ago

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 commented 8 years ago

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

VoR0220 commented 8 years ago

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

sgotti commented 8 years ago

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)?

VoR0220 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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

sgotti commented 8 years ago

@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: