-
Notifications
You must be signed in to change notification settings - Fork 18k
cgo generates some files in PWD, others in source directory. #533
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
Labels
Comments
Labels changed: added cgo. Owner changed to [email protected]. Status changed to Accepted. |
Comment 2 by [email protected]: Noticed today that I was a little hasty with that patch. It will crash if you don't give cgo anything it recognizes as a go file. And I've also noticed that just my original measure isn't sufficient when trying to integrate with a out-of-source build build system where the easiest path is to keep generated files in a separate tree than the original source. So I'm attaching a second path that makes is so you can also specify the destination directory for the generated files with an environment variable. ie: CGOUTDIR=/some/destination cgo -I.. /some/source/dir/something.go I used an environment variable because it was easy, and did't require making a major change in how cgo handles the command line. I don't care what the mechanism is as long as there's a way to do it. Attachments:
|
Using cgo is relatively tied into using Make.pkg at the moment, but it looks like this does affect us with the case of CGOFILES=subdir/lib1.go subdir/lib2.go I guess it isn't enough to have CGO put the output into subdir, since you could also have: CGOFILES=subdir1/lib.go subdir2/lib.go (which I think is a notoriously bad idea, but perhaps valid for some reason). Introducing new command line options into cgo is indeed a huge pain in the butt. Having a way to specify where the autogenerated files could be desirable, but does make the Make.pkg rules more complicated: running make clean assumes these files are in CWD as well, for instance. There are also a few rather minor issues in this patch. I'm happy to run with this patch; I'm also happy to review it and offer suggestions if you'd like to work on this functionality via codereview. See http://golang.org/doc/contribute.html if you're interested -- otherwise let me know and I'll hammer your patch into something `fuller'. |
#3: putting the output files in various locations is uncommon. Yet, using a build directory is the main problem. At the moment the files must be moved manually and removed too in case of a failure: . ├── build │ ├── _cgo_defun.c │ ├── _cgo_gotypes.go │ ├── _cgo_.o ├── gmp.cgo1.go ├── gmp.cgo2.c ├── gmp.go |
This issue was closed by revision 0432f28. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by [email protected]:
Attachments:
The text was updated successfully, but these errors were encountered: