From 2248d63c1a32ae84bb6d0bde9021a8074db1b4c9 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Tue, 26 May 2009 10:46:54 +1000 Subject: Fixed qmake writing targets into the root of the current drive when DESTDIR=./ and using Windows, nmake and shadow builds. qmake would canonicalize the DESTDIR of "./" to "". Then it would check if the original DESTDIR ended with "/", and if so, append it to the new DESTDIR, resulting in a DESTDIR of "/" - the root of the current drive. Don't do that. This bug doesn't occur with in-source builds because qmake detects that the source and build directories are the same directory and replaces the DESTDIR of "./" with "" before it reaches the buggy code. Autotest: included Reviewed-by: Lincoln Ramsay --- qmake/generators/win32/winmakefile.cpp | 2 +- tests/auto/qmake/tst_qmake.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 87f55cf..c7f00dd 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -626,7 +626,7 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t) // do this here so we can set DEST_TARGET to be the complete path to the final target if it is needed. QString orgDestDir = var("DESTDIR"); QString destDir = Option::fixPathToTargetOS(orgDestDir, false); - if (orgDestDir.endsWith('/') || orgDestDir.endsWith(Option::dir_sep)) + if (!destDir.isEmpty() && (orgDestDir.endsWith('/') || orgDestDir.endsWith(Option::dir_sep))) destDir += Option::dir_sep; QString target = QString(project->first("TARGET")+project->first("TARGET_EXT")); target.remove("\""); diff --git a/tests/auto/qmake/tst_qmake.cpp b/tests/auto/qmake/tst_qmake.cpp index 70f1f3c..1178c81 100644 --- a/tests/auto/qmake/tst_qmake.cpp +++ b/tests/auto/qmake/tst_qmake.cpp @@ -63,6 +63,7 @@ public slots: private slots: void simple_app(); + void simple_app_shadowbuild(); void simple_lib(); void simple_dll(); void subdirs(); @@ -143,6 +144,21 @@ void tst_qmake::simple_app() QVERIFY( test_compiler.removeMakefile( workDir ) ); } +void tst_qmake::simple_app_shadowbuild() +{ + QString workDir = base_path + "/testdata/simple_app"; + QString buildDir = base_path + "/testdata/simple_app_build"; + + QVERIFY( test_compiler.qmake( workDir, "simple_app", buildDir )); + QVERIFY( test_compiler.make( buildDir )); + QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); + QVERIFY( test_compiler.makeClean( buildDir )); + QVERIFY( test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should still exist after a make clean + QVERIFY( test_compiler.makeDistClean( buildDir )); + QVERIFY( !test_compiler.exists( buildDir, "simple_app", Exe, "1.0.0" )); // Should not exist after a make distclean + QVERIFY( test_compiler.removeMakefile( buildDir ) ); +} + void tst_qmake::simple_dll() { QString workDir = base_path + "/testdata/simple_dll"; -- cgit v0.12