Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Case compatibility on linux from a windows project?
Forum Updated to NodeBB v4.3 + New Features

Case compatibility on linux from a windows project?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mbruelM Offline
    mbruelM Offline
    mbruel
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • mbruelM Offline
        mbruelM Offline
        mbruel
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          It does have super search and rename.
          If you rename the .h file in Creator ( in project list)
          , it will change includes too.

          1 Reply Last reply
          0
          • Paul ColbyP Offline
            Paul ColbyP Offline
            Paul Colby
            wrote on last edited by Paul Colby
            #5

            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.

            mbruelM 1 Reply Last reply
            3
            • Paul ColbyP Paul Colby

              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.

              mbruelM Offline
              mbruelM Offline
              mbruel
              wrote on last edited by mbruel
              #6

              @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.pl

              It 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!

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved