forked from wang-bin/QtAV
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
target arch test in qmake support. fix mkspec error for Qt5
- Loading branch information
Showing
4 changed files
with
485 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
#Designed by Wang Bin(Lucas Wang). 2013 <[email protected]> | ||
|
||
#cache mkspecs. compare mkspec with cached one. if not equal, remove old cache to run new compile tests | ||
#TODO: Qt5 does not have QMAKE_MKSPECS, use QMAKE_SPEC, QMAKE_XSPEC | ||
mkspecs_build = $$[QMAKE_MKSPECS] | ||
mkspecs_build ~= s,\\\\,/,g #avoid warning for '\'. qmake knows how to deal with '/' | ||
!isEmpty(mkspecs_cached) { | ||
!isEqual(mkspecs_cached, $$mkspecs_build):CONFIG += recheck | ||
} else { | ||
CONFIG += recheck | ||
} | ||
|
||
##TODO: BUILD_DIR=>BUILD_ROOT | ||
#if not empty, it means the parent project may already set it | ||
isEmpty(out_dir):out_dir = $$OUT_PWD | ||
|
@@ -20,9 +10,11 @@ isEmpty(BUILD_DIR):BUILD_DIR=$$out_dir | |
message("BUILD_DIR=$$BUILD_DIR") | ||
|
||
greaterThan(QT_MAJOR_VERSION, 4) { | ||
mkspecs_build = $$[QMAKE_SPEC] | ||
#recheck:write_file($$BUILD_DIR/.qmake.cache) #FIXME: empty_file result in no qtCompileTest result in cache | ||
load(configure) | ||
} else { | ||
mkspecs_build = $$[QMAKE_MKSPECS] | ||
_QMAKE_CACHE_QT4_ = $$_QMAKE_CACHE_ | ||
#_QMAKE_CACHE_QT4_ is built in and always not empty | ||
isEmpty(_QMAKE_CACHE_QT4_)|isEqual(_QMAKE_CACHE_QT4_,) { | ||
|
@@ -42,6 +34,53 @@ greaterThan(QT_MAJOR_VERSION, 4) { | |
#load(configure.pri) #what's the difference? | ||
message("cache: $$_QMAKE_CACHE_QT4_") | ||
} | ||
mkspecs_build ~= s,\\\\,/,g #avoid warning for '\'. qmake knows how to deal with '/' | ||
|
||
defineTest(qtRunCommandQuitly) { | ||
#win32 always call windows command | ||
win32 { #QMAKE_HOST.os? | ||
system("$$1 2>&1 >nul")|return(false) #system always call win32 cmd | ||
} else { | ||
system("$$1 2>&1 >/dev/null")|return(false) | ||
} | ||
return(true) | ||
} | ||
|
||
defineTest(testArch) { | ||
test_dir = $$_PRO_FILE_PWD_/tests/arch | ||
test_out_dir = $$shadowed($$test_dir) | ||
qtRunCommandQuitly("$$QMAKE_MKDIR $$test_out_dir") | ||
win32:test_cmd_base = "cd /d $$system_quote($$system_path($$test_out_dir)) &&" | ||
else:test_cmd_base = "cd $$system_quote($$system_path($$test_out_dir)) &&" | ||
# Disable qmake features which are typically counterproductive for tests | ||
qmake_configs = "\"CONFIG -= qt debug_and_release app_bundle lib_bundle\"" | ||
# Clean up after previous run | ||
exists($$test_out_dir/Makefile):qtRunCommandQuitly("$$test_cmd_base $$QMAKE_MAKE distclean") | ||
|
||
message("$$test_cmd_base $$system_quote($$system_path($$QMAKE_QMAKE)) $$qmake_configs $$system_path($$test_dir)") | ||
qtRunCommandQuitly("$$test_cmd_base $$system_quote($$system_path($$QMAKE_QMAKE)) $$qmake_configs $$system_path($$test_dir)") { | ||
MSG=$$system("$$test_cmd_base $$QMAKE_MAKE 2>&1") | ||
} | ||
V = $$find(MSG, .*=.*) | ||
for(v, V) { | ||
v=$$replace(v, "", ) # "ARCH=x86". can not evalate with ". why \" may fail? eval("expr") | ||
greaterThan(QT_MAJOR_VERSION, 4):eval("$$v") | ||
else:eval("\"$$v\"") | ||
} | ||
export(ARCH) | ||
export(ARCH_SUB) | ||
cache(TARGET_ARCH, set, ARCH) | ||
cache(TARGET_ARCH_SUB, set, ARCH_SUB) | ||
message("target arch: $$ARCH") | ||
} | ||
|
||
#cache mkspecs. compare mkspec with cached one. if not equal, remove old cache to run new compile tests | ||
#Qt5 does not have QMAKE_MKSPECS, use QMAKE_SPEC, QMAKE_XSPEC | ||
isEmpty(mkspecs_cached)|!isEmpty(mkspecs_cached):!isEqual(mkspecs_cached, $$mkspecs_build) { | ||
CONFIG += recheck | ||
testArch() | ||
} | ||
|
||
cache(BUILD_DIR, set, BUILD_DIR) | ||
#cache(BUILD_ROOT, set, BUILD_DIR) | ||
cache(SOURCE_ROOT, set, SOURCE_ROOT) | ||
|
Oops, something went wrong.