Open Hombre57 opened 6 years ago
That sounds like a very good idea. I have a recursive ImportSourcesFromSubdir
CMake function lying around somewhere...
I like the idea.
though I don't know if it's worth loosing the files' history for bisecting.
What makes you think you'd lose history?
@Beep6581
What makes you think you'd lose history?
I may not know git enough, but moving a file means deleting it in its old location and creating it in its new location. But I may be wrong.
@Beep6581 I'm also worried about active branch and how to merge them.
@Hombre57 git will not lose history when moving files. Use git mv
to be safe.
https://git-scm.com/book/en/v2/Git-Internals-Moving-Files
And here's what Gordon Ramsay has to say about it: https://web.archive.org/web/20150209075907/http://permalink.gmane.org:80/gmane.comp.version-control.git/217
@Beep6581 I'll make test with git mv
later this week or by the w.e., thanks for the hint.
@Hombre57 shoot if you need help with this.
Maybe now would be a good time to go ahead with this.
@Beep6581 I'm not at home until Sunday night, with limited access to my laptop, so if not too late, I'll try that on Monday or Tuesday.
@Beep6581 @Floessie I've made some test with the git mv
command. Files has been moved, but all include
statment related to the moved files has to be updated, and I don't know what will happen when merging this branch to dev, regarding the other opened branches. This is too much work for me. So unless you have a magical cmake command to add the the new subfolder to the include search path, I'd better close this issue or pass over.
First, do we have a consensus that the proposed structure in the first post is the way to go?
@Beep6581 I've tested to this new structure, but there's a lot of work to do for the include declaration, so I gave up. A better source tree would be nice, but I don't think it'll be ready for 5.5. I'd remove it from this milestone.
@Hombre57 I've pushed a new branch with the structure from your first proposal. Feel free to shuffle other files as well.
I dislike the relative includes needed ATM. Shouldn't we make the source root path the only include path (apart from the current dir), and all relative paths absolute to that? Ideas welcome. Things like ../../../rtengine/something.h
are just ugly, rtengine/something.h
would be so much nicer.
Best, Flössie
@Floessie Wow, that was fast ! I'm testing that now.
I dislike the relative includes needed ATM. Shouldn't we make the source root path the only include path (apart from the current dir), and all relative paths absolute to that?
If possible, I'd set 2 include path (in that order) :
The idea is to be able to simply specify #include "myheader.h"
to load the header of the current file or files from subdirectories, and e.g. #include "rtgui/window/editwindow.h"
for files from parent directories.
To avoid error, source files shouldn't have the same name. Never.
If you find this too confusing, or error prone, I'd stick to your suggestion.
@Floessie There's some other files to shuffle, yes, that appears in between. I'll do that tomorrow, too late now.
@Hombre57
The idea is to be able to simply specify #include "myheader.h" to load the header of the current file or files from subdirectories, and e.g. #include "rtgui/window/editwindow.h" for files from parent directories.
That's exactly what I was thinking about. :smile: Something like include_directories(${CMAKE_SOURCE_DIR})
should do, because the current dir is always searched first by the preprocessor/compiler AFAIK. The ../../../
lunacy could be replaced with the "full path" by a regex.
This is the CMake snippet I was talking about much earlier:
function(IMPORT_SOURCES_FROM_SUBDIR subdir sources_variable)
set(result ${${sources_variable}})
set(sources)
include("${CMAKE_CURRENT_LIST_DIR}/${subdir}/SOURCES.cmake")
foreach(src ${sources})
list(APPEND result "${subdir}/${src}")
endforeach()
set(${sources_variable} ${result} PARENT_SCOPE)
endfunction()
A SOURCES.cmake
in a subdir looks like this:
set(sources
file_a.cpp
file_b.cpp
)
Used like this:
include(ImportSourcesFromSubdir)
IMPORT_SOURCES_FROM_SUBDIR(dir_a all_sources)
IMPORT_SOURCES_FROM_SUBDIR(dir_b all_sources)
HTH, Flössie
@Floessie @heckflosse @Beep6581 @Thanatomanic Just tested today to locally merge dev
into better-source-tree
and the other way round, as expected git doesn't follow the file relocation. At least through Eclipse's git. So rearanging files without breaking other branches seem difficult (if not impossible). Should we leave things as is and close this issue ?
Git tracks content, not filenames.
We should clean up the tree, but let's wait till after 5.5.
RT's source tree for the code part is quite flat actually : only 3 folders (rtengine, rtexif - that might be dropped, and rtgui).
Would it be useful for newcomers to have a more self-explanatory source tree ? I don't think we can put each tool's GUI and engine in their own directory, because the engine part is mostly made os shared code (between tools)
I'm thinking about :
...though I don't know if it's worth loosing the files' history for bisecting.