Skip to content

Commit

Permalink
common.pri: fix create empty error in windows
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Feb 15, 2013
1 parent 02cac12 commit 8689730
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,18 @@ defineReplace(qtLongName) {
return($$LONG_NAME)
}

defineTest(empty_file) {
isEmpty(1): error("empty_file(name) requires one argument")
#"type NUL >filename" can create an empty file in windows, see http://stackoverflow.com/questions/210201/how-to-create-empty-text-file-from-a-batch-file
# 'echo. >file' or 'echo >file' will insert a new line, so use stderr
win32:isEmpty(QMAKE_SH) {
system("echo. 2> $$1")|return(false)
} else {
#if sh is after win's echo, then "echo >$$1" fails because win's echo is used
system("sh -c echo 2> $$1")|return(false)
}
}

lessThan(QT_MAJOR_VERSION, 5): {

defineTest(write_file) {
Expand All @@ -140,21 +152,17 @@ defineTest(write_file) {
## echo a string with "\n" will fail, so we can not use join
#val = $$join($$2, $$escape_expand(\n))$$escape_expand(\n)
isEmpty(3)|!isEqual(3, append) {
#win32:system("echo. > $$1")|return(false) #may has sh
#else
system("$$QMAKE_DEL_FILE $$1")
#system("$$QMAKE_DEL_FILE $$1") #for win commad "del", path format used in qmake such as D:/myfile is not supported, "/" will be treated as an otpion for "del"
empty_file($$1)
}
for(val, $$2) {
system("echo $$val >> $$1")|return(false)
system("echo $$val >> \"$$1\"")|return(false)
}
return(true)
}

#defineTest(cache) {
# !isEmpty(4): error("cache(var, [set|add|sub] [transient] [super], [srcvar]) requires one to three arguments.")

#}

#}

}
Expand All @@ -165,8 +173,9 @@ defineTest(getBuildRoot) {
isEmpty(BUILD_DIR) {
BUILD_DIR=$$(BUILD_DIR)
isEmpty(BUILD_DIR) {
exists($$PROJECTROOT/.build.cache):include($$PROJECTROOT/.build.cache)
message("BUILD_DIR=$$BUILD_DIR")
build_cache = $$PROJECTROOT/.build.cache #use root project's cache for subdir projects
!exists($$build_cache):build_cache = $$PWD/.build.cache #common.pri is in the root dir of a sub project
exists($$build_cache):include($$build_cache)
isEmpty(BUILD_DIR) {
BUILD_DIR=$$[BUILD_DIR]
isEmpty(BUILD_DIR) {
Expand Down Expand Up @@ -215,7 +224,7 @@ defineTest(preparePaths) {
export(UI_DIR)
export(OBJECTS_DIR)
export(DESTDIR)
export(TARGET)
#export(TARGET)
return(true)
}
COMMON_PRI_INCLUDED = 1
Expand Down

0 comments on commit 8689730

Please sign in to comment.