Case compatibility on linux from a windows project?
-
Hi,
I'm picking up a big QT project that has been made on Windows without respecting the case for the file names. I'm using Linux and I'm having many issues with the case. Starting from the .pro where some case are wrong so some files are not imported but after renaming those it seems I'll have also many in the include of the headers.Is there an easy way in QT creator to tell him to ignore the case of the files?
The project is under svn so I don't want to rename the files to not loose the history. This means I'll probably have to rename many cpp files for the includes.
I believe the project was started without QT using Camel case for the file names but some have been made badly and others created with QT creator are all lowercase but included like the old style in Camel case...Any tricks to make it compile on Linux without so much renaming?
Cheers,
Matthieu -
Hi
Linux is by itself case sensitive with file names so there is no easy fix as far as I know.
If you rename via SVN tool, u should NOT loose any history.
(still same file)
What ever you do, do not rename directly without svn. then it blows up:) -
well I'm just picking up the project and will have the handover next month so I don't have access to the svn. At the moment I'm discovering the code with a snapshot (zip).
I guess the easiest solution would be a script that parse all the files for includes, check if the file exists, if not check if a filename without the case exists and then rename the header name in the include of the file.
I was hopping QT creator could do or simulate such thing or maybe that such script or addon could exist. -
Hi
It does have super search and rename.
If you rename the .h file in Creator ( in project list)
, it will change includes too. -
Definitely an annoying situation!
Personally, if the project is big enough (ie lots of files), then I'd write a small Bash script to do something like this (pseudo code only, aka untested):
while IFS= read -d '' -r FILENAME; do DIRNAME=`dirname "$FILENAME"` BASENAME=`basename "$FILENAME"` LOWERNAME=`echo "$BASENAME" | tr '[:upper:]' '[:lower:]'` if [ "$LOWERNAME" != "$BASENAME" ]; then echo "Renaming '$DIRNAME/$BASENAME' to '$DIRNAME/$LOWERNAME'" svn mv "$DIRNAME/$BASENAME" "$DIRNAME/$LOWERNAME" || exit SAFEBASENAME=`echo "$BASENAME" | sed -e 's/[|&]/\\&/g'` SAFELOWERNAME=`echo "$LOWERNAME" | sed -e 's/[]$*.^|/\\&/g'` sed -i -re "s|([^a-zA-Z1-9])$SAFEBASENAME\"|\1$SAFELOWERNAME\"|" ** * fi done < <(find . -name '*.cpp' -or -name '*.h' -or -name '*.pro' -type f -print0)
That should (in theory) rename all *.cpp, *.h and *.pro files that aren't already all lowercase (ignoring the directory names) via the
svn mv
command (so you keep you're svn history), then update all references to the renamed files in all files (sources, resources, project files, etc, including files not necessarily under revision control).Cheers.
-
@Paul-Colby
well that's a nice snippet!
I took the other option to keep the CamelCase file names as most of them are like this already (talking about around 3500 files). Plus I find it more readable when you browse the files in a explorer. (plus it will make a smaller svn commit, in fact I had only 41 files updated)
I've done a script in perl to do the job.
You can find it here if anyone is interested: https://github.com/mbruel/scripts/blob/master/correctIncludesCase.plIt is made for a QT project, (renaming also the generated UI headers includes) but it could be used for any other type of project.
Have a good weekend!