From bb155cc1dd6736b217e70ededa3adcec721c15cb Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 9 Apr 2012 17:48:38 +0200 Subject: [PATCH] Implement/fix build system for mmg-qt --- .gitignore | 3 +++ Rakefile | 42 ++++++++++++++++++++++++++++++--------- ac/qt4.m4 | 4 ++++ build-config.in | 1 + rake.d/target.rb | 9 ++++++--- src/mmg-qt/Rakefile | 4 ++++ src/mmg-qt/forms/Rakefile | 4 ++++ 7 files changed, 55 insertions(+), 12 deletions(-) create mode 100644 src/mmg-qt/Rakefile create mode 100644 src/mmg-qt/forms/Rakefile diff --git a/.gitignore b/.gitignore index 8e44f7c80..6676c4d28 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ *.deps *.exe +*.moc +*.moco *.o *~ /Debug @@ -46,6 +48,7 @@ /src/mkvpropedit /src/mmg/mmg /src/mmg/mmg-gui +/src/mmg-qt/mmg-qt /src/tools/ac3parser /src/tools/base64tool /src/tools/diracparser diff --git a/Rakefile b/Rakefile index 842364196..6887e0b31 100644 --- a/Rakefile +++ b/Rakefile @@ -78,6 +78,7 @@ def setup_globals } $build_tools ||= c?(:TOOLS) + $build_mmg_qt = c?(:USE_QT) && c?(:BUILD_MMGQT) cflags_common = "-Wall -Wno-comment #{c(:OPTIMIZATION_CFLAGS)} -D_FILE_OFFSET_BITS=64 #{c(:MATROSKA_CFLAGS)} #{c(:EBML_CFLAGS)} #{c(:EXTRA_CFLAGS)} #{c(:DEBUG_CFLAGS)} #{c(:PROFILING_CFLAGS)} #{c(:USER_CPPFLAGS)} -DPACKAGE=\\\"#{c(:PACKAGE)}\\\" -DVERSION=\\\"#{c(:VERSION)}\\\" -DMTX_LOCALE_DIR=\\\"#{c(:localedir)}\\\" -DMTX_PKG_DATA_DIR=\\\"#{c(:pkgdatadir)}\\\" -DMTX_DOC_DIR=\\\"#{c(:docdir)}\\\"" ldflags_extra = c?(:MINGW) ? '' : "-Wl,--enable-auto-import" @@ -104,7 +105,8 @@ def define_default_task targets = $applications.clone # Build the stuff in the 'src/tools' directory only if requested - targets << "apps:tools" if $build_tools + targets << "apps:tools" if $build_tools + targets << "apps:mmg-qt" if $build_mmg_qt # The tags file -- but only if it exists already if File.exists?("TAGS") @@ -154,7 +156,7 @@ cxx_compiler = lambda do |t| sources = t.sources.empty? ? [ t.prerequisites.first ] : t.sources dep = dependency_output_name_for t.name - runq " CXX #{sources.first}", "#{c(:CXX)} #{$flags[:cxxflags]} #{$system_includes} -c -MMD -MF #{dep} -o #{t.name} #{sources.join(" ")}", :allow_failure => true + runq " CXX #{sources.first}", "#{c(:CXX)} #{$flags[:cxxflags]} #{$system_includes} -c -MMD -MF #{dep} -o #{t.name} -x c++ #{sources.join(" ")}", :allow_failure => true handle_deps t.name, last_exit_code, true end @@ -231,11 +233,12 @@ rule '.h' => '.ui' do |t| runq " UIC #{t.source}", "#{c(:UIC)} #{t.sources.join(" ")} > #{t.name}" end -# Rake does not support rules like '.moc.cpp' => '.h'. Therefore -# Target creats 'file' entries for all .moc.cpp entries submitted via -# Target#sources. -$moc_compiler = lambda do |t| - runq " MOC #{t.prerequisites.first}", "#{c(:MOC)} #{c(:QT_CFLAGS)} #{t.prerequisites.join(" ")} > #{t.name}" +rule '.moc' => '.h' do |t| + runq " MOC #{t.prerequisites.first}", "#{c(:MOC)} #{c(:QT_CFLAGS)} -nw #{t.prerequisites.join(" ")} > #{t.name}" +end + +rule '.moco' => '.moc' do |t| + cxx_compiler.call t end # Tag files @@ -472,7 +475,7 @@ task :clean do patterns = %w{ src/**/*.o lib/**/*.o src/**/lib*.a lib/**/lib*.a src/**/*.gch src/**/*.exe src/**/*.dll src/**/*.dll.a - src/**/*.moc.cpp src/info/ui/*.h src/mmg-qt/forms/*.h + src/info/ui/*.h src/mmg-qt/forms/*.h src/**/*.moc src/**/*.moco po/*.mo doc/guide/**/*.hhk } patterns += $applications + $tools.collect { |name| "src/tools/#{name}" } @@ -589,7 +592,7 @@ Application.new("src/mkvinfo"). sources("src/info/resources.o", :if => c?(:MINGW)). libraries(common_libs). only_if(c?(:USE_QT)). - sources("src/info/qt_ui.cpp", "src/info/qt_ui.moc.cpp", "src/info/rightclick_tree_widget.moc.cpp", $mkvinfo_ui_files). + sources("src/info/qt_ui.cpp", "src/info/qt_ui.moc", "src/info/rightclick_tree_widget.moc", $mkvinfo_ui_files). libraries(:qt). end_if. only_if(!c?(:USE_QT) && c?(:USE_WXWIDGETS)). @@ -639,6 +642,27 @@ if c?(:USE_WXWIDGETS) create end +# +# mmg-qt +# + +if $build_mmg_qt + ui_files = FileList["src/mmg-qt/forms/**/*.ui"].to_a + ui_files.each do |ui| + file ui.ext('cpp').gsub(/forms\//, '') => ui.ext('h') + end + + Application.new("src/mmg-qt/mmg-qt"). + description("Build the mmg-qt executable"). + aliases("mmg-qt"). + sources(FileList["src/mmg-qt/**/*.cpp"], ui_files). + sources((FileList["src/mmg-qt/**/*.h"].to_a - ui_files.collect { |ui| ui.ext 'h' }).collect { |h| h.ext 'moc' }). + sources("src/mmg-qt/resources.o", :if => c?(:MINGW)). + libraries(common_libs, :qt). + png_icon("share/icons/64x64/mkvmergeGUI.png"). + create +end + # # Applications in src/tools # diff --git a/ac/qt4.m4 b/ac/qt4.m4 index dc65cc802..0737c1f37 100644 --- a/ac/qt4.m4 +++ b/ac/qt4.m4 @@ -153,6 +153,9 @@ return 0; AC_MSG_RESULT(no: test program could not be compiled) fi fi + + AC_ARG_WITH(mmg-qt,[AS_HELP_STRING([--with-mmg-qt],[build mmg-qt (not working yet, only for development)])], + [BUILD_MMGQT=yes],[BUILD_MMGQT=no]) fi if test x"$have_qt" != "xyes" ; then @@ -164,3 +167,4 @@ AC_SUBST(UIC) AC_SUBST(QT_CFLAGS) AC_SUBST(QT_LIBS) AC_SUBST(USE_QT) +AC_SUBST(BUILD_MMGQT) diff --git a/build-config.in b/build-config.in index 590e69d8c..47ad474fd 100644 --- a/build-config.in +++ b/build-config.in @@ -123,6 +123,7 @@ ZLIB_LIBS = @ZLIB_LIBS@ # Which additional stuff to compile USE_WXWIDGETS = @USE_WXWIDGETS@ USE_QT = @USE_QT@ +BUILD_MMGQT = @BUILD_MMGQT@ TRANSLATIONS = @TRANSLATIONS@ MANPAGES_TRANSLATIONS = @MANPAGES_TRANSLATIONS@ diff --git a/rake.d/target.rb b/rake.d/target.rb index 147d35dcb..362d3e2b2 100644 --- a/rake.d/target.rb +++ b/rake.d/target.rb @@ -59,22 +59,25 @@ class Target return self if !@only_if || (options.include?(:if) && !options[:if]) ext_map = { - '.ui' => 'h', + '.ui' => 'h', + '.moc' => '.moco', } + obj_re = /\.(?:moc)?o$/ + list = list.collect { |e| e.respond_to?(:to_a) ? e.to_a : e }.flatten file_mode = (options[:type] || :file) == :file new_sources = list.collect { |entry| file_mode ? (entry.respond_to?(:to_a) ? entry.to_a : entry) : FileList["#{entry}/*.c", "#{entry}/*.cpp"].to_a }.flatten new_deps = new_sources.collect { |file| [ file.ext(ext_map[ file.pathmap('%x') ] || 'o'), file ] } @sources = ( @sources + new_sources ).uniq - @objects = ( @objects + new_deps.collect { |a| a.first }.select { |file| /\.o$/.match file } ).uniq + @objects = ( @objects + new_deps.collect { |a| a.first }.select { |file| obj_re.match file } ).uniq @dependencies = ( @dependencies + new_deps.collect { |a| a.first } ).uniq @file_deps = ( @file_deps + new_deps ).uniq self end def dependencies(*list) - @dependencies += list.select { |entry| !entry.blank? } if @only_if + @dependencies += list.flatten.select { |entry| !entry.blank? } if @only_if self end diff --git a/src/mmg-qt/Rakefile b/src/mmg-qt/Rakefile new file mode 100644 index 000000000..ca85ee005 --- /dev/null +++ b/src/mmg-qt/Rakefile @@ -0,0 +1,4 @@ +#!/usr/bin/env rake +# -*- mode: ruby; -*- + +import ['..', '../..', '../../..'].collect { |subdir| FileList[File.dirname(__FILE__) + "/#{subdir}/build-config.in"].to_a }.flatten.compact.first.gsub(/build-config.in/, 'Rakefile') diff --git a/src/mmg-qt/forms/Rakefile b/src/mmg-qt/forms/Rakefile new file mode 100644 index 000000000..ca85ee005 --- /dev/null +++ b/src/mmg-qt/forms/Rakefile @@ -0,0 +1,4 @@ +#!/usr/bin/env rake +# -*- mode: ruby; -*- + +import ['..', '../..', '../../..'].collect { |subdir| FileList[File.dirname(__FILE__) + "/#{subdir}/build-config.in"].to_a }.flatten.compact.first.gsub(/build-config.in/, 'Rakefile')