Skip to content

Commit

Permalink
add write_file() like Qt5 qmake. building becomes simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Feb 14, 2013
1 parent 5de7efb commit 02cac12
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 25 deletions.
26 changes: 15 additions & 11 deletions QtAV.pro
Original file line number Diff line number Diff line change
@@ -1,11 1,15 @@
TEMPLATE = subdirs
CONFIG = ordered
SUBDIRS = libqtav examples tests

libqtav.file = src/libQtAV.pro
examples.depends = libqtav
tests.depends = libqtav

OTHER_FILES = README.md TODO.txt Changelog


TEMPLATE = subdirs
CONFIG = ordered
SUBDIRS = libqtav examples tests

libqtav.file = src/libQtAV.pro
examples.depends = libqtav
tests.depends = libqtav

OTHER_FILES = README.md TODO.txt Changelog


lessThan(QT_MAJOR_VERSION, 5):include(common.pri)
build_dir = "BUILD_DIR=$$OUT_PWD"
write_file($$PWD/.build.cache, build_dir)

18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 45,21 @@ page: [depends](https://sourceforge.net/projects/qtav/files/depends)

#### Build

cd your_build_dir
qmake QtAV_dir/QtAV.pro -r "BUILD_DIR=your_build_dir"
make -j4
For most platforms, just

The binaries will be created in $BUILD_DIR/bin
qmake
make

NOTE: If you are using QtCreator to build the project, you should go to Projects->Build Steps->qmake->Additional arguments, add "BUILD_DIR=your/buid/dir"
>>If the above command failed to build it, try
>> `cd your_build_dir`
>> `qmake QtAV_dir/QtAV.pro -r BUILD_DIR=your_build_dir`
>> `make`
>> The binaries will be created in $BUILD_DIR/bin.
>> If you are using QtCreator to build the project, you should go to Projects->Build Steps->qmake->Additional arguments, add "BUILD_DIR=your/buid/dir"
##### Build with MSVC

Expand Down
56 changes: 47 additions & 9 deletions common.pri
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 130,52 @@ defineReplace(qtLongName) {
return($$LONG_NAME)
}

lessThan(QT_MAJOR_VERSION, 5): {

defineTest(write_file) {
!isEmpty(4): error("write_file(name, [content var, [append]]) requires one to three arguments.")
##TODO: 1.how to replace old value
##getting the value requires a function whose parameter has var name and return a string. join() is the only function
## var name is $$2.
## 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")
}
for(val, $$2) {
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.")

#}

#}

}

#argument 1 is default dir if not defined
defineTest(getBuildRoot) {
!isEmpty($$2): unset(BUILD_DIR)
!isEmpty(2): unset(BUILD_DIR)
isEmpty(BUILD_DIR) {
BUILD_DIR=$$(BUILD_DIR)
isEmpty(BUILD_DIR) {
BUILD_DIR=$$[BUILD_DIR]
exists($$PROJECTROOT/.build.cache):include($$PROJECTROOT/.build.cache)
message("BUILD_DIR=$$BUILD_DIR")
isEmpty(BUILD_DIR) {
!isEmpty(1) {
BUILD_DIR=$$1
} else {
BUILD_DIR = $$OUT_PWD
warning(BUILD_DIR not specified, using $$BUILD_DIR)
BUILD_DIR=$$[BUILD_DIR]
isEmpty(BUILD_DIR) {
!isEmpty(1) {
BUILD_DIR=$$1
} else {
BUILD_DIR = $$OUT_PWD
warning(BUILD_DIR not specified, using $$BUILD_DIR)
}
}
}
}
Expand All @@ -162,15 195,20 @@ defineTest(preparePaths) {
#obj is platform dependent
OBJECTS_DIR = $$qtLongName($$BUILD_DIR/.obj/$$TARGET)
#before target name changed
!isEmpty(PROJECTROOT):TRANSLATIONS *= $$PROJECTROOT/i18n/$${TARGET}_zh-cn.ts $$PROJECTROOT/i18n/$${TARGET}_zh_CN.ts
isEqual(TEMPLATE, app) {
DESTDIR = $$BUILD_DIR/bin
# TARGET = $$qtLongName($$TARGET)
EXE_EXT =
win32: EXE_EXT = .exe
CONFIG(release, debug|release): !isEmpty(QMAKE_STRIP): QMAKE_POST_LINK = -$$QMAKE_STRIP $$DESTDIR/$${TARGET}$${EXE_EXT} #.exe in win
} else: DESTDIR = $$qtLongName($$BUILD_DIR/lib)
!build_pass:message(target: $$DESTDIR/$$TARGET)
!build_pass {
message(target: $$DESTDIR/$$TARGET)
!isEmpty(PROJECTROOT) {
TRANSLATIONS *= $$PROJECTROOT/i18n/$${TARGET}_zh-cn.ts $$PROJECTROOT/i18n/$${TARGET}_zh_CN.ts
export(TRANSLATIONS)
}
}
#export vars outside this function
export(MOC_DIR)
export(RCC_DIR)
Expand Down

0 comments on commit 02cac12

Please sign in to comment.