ameyp / CscopeSublime

A Cscope plugin for Sublime Text 2 and 3
89 stars 37 forks source link

Database build and rebuild should use 2 different commands #62

Closed vanrijn closed 7 years ago

vanrijn commented 7 years ago

From the tail end discussion of issue #56, I think there's some cleanup needed around the cscope database generating and rebuilding.

CscopeSublime didn't use to ever let you rebuild or build for the first time a cscope database. This was a recent addition I made. We've not been getting a lot of requests for this ability, so I'm not really inclined to sink a lot of time into expanding this functionality. But I do think we could do database rebuild or first-time-build better, so I'll open another issue to track this.

cscope's database building is complicated and non-trivial. The easy way to do this is to have a single source directory and run "cscope -R" on that directory to produce a cscope.out database file at the top level of that directory. But you can do a lot of variations on this approach. You can keep the database file in a different directory entirely by creating a cscope.files file that contains all the filenames you want cscope to index. You have complete control over what files end up in the cscope.files list too, so if you have a huge code base and only want to index the C or C++ files and not Java, Python, Perl, or whatever else, you can do this. But there's no simple way to do this in a way that will work for everybody. Personally, I have a shell script called cscope-indexer that came from an old Linux distro and probably https://github.com/To1ne/xcscope/blob/master/cscope-indexer originally that I use to build and rebuild my cscope database. Other people will have a variety of commands they use to build their cscope index, such as found here: https://stackoverflow.com/questions/11718272/build-cscope-out-files-in-a-separate-directory . I don't see an easy, elegant, and easy-to-maintain way to provide a solution that would work for everyone for this. So I think I'm going to intentionally try to limit the database building/rebuilding functionality that this plugin provides. If there's an existing cscope.out file that we can find, I believe there's a trivial command that we can do to rebuild it. If there's not an existing cscope.out file, but we know where it should go (i.e. a project that only has one path folder defined), we can continue to do what we're doing today and build it the first time. But I don't think I want to put more work into this than that. I'm certainly open to code contributions and pull requests if this functionality is wanted, but I just haven't seen any demand/request for it yet to justify the work.

But I would like to at least separate the "first time build" and "rebuild" logic for the cscope database because I believe these should actually be different arguments passed to cscope.

vanrijn commented 7 years ago

Ok, this was actually easier than I thought it would be. Also, I believe I was wrong and we don't need 2 different commands for the initial database creation and subsequent rebuilds.