build system: support for creating a compilation database

This commit is contained in:
Moritz Bunkus 2018-02-26 20:37:34 +01:00
parent 1b21706ca7
commit e960dc86fa
4 changed files with 24 additions and 6 deletions

7
.gitignore vendored
View File

@ -9,13 +9,15 @@
*.o
*.o-[0-9a-f]*
*~
.doconf.*
/.cquery_cached_index
/.doconf.*
/Debug
/Release
/autom4te.cache
/build-config
/build-config.local
/build-stamp
/compile_commands.json
/config.cache
/config.guess
/config.h
@ -48,6 +50,7 @@
/po/*.mo
/po/mkvtoolnix.pot
/po/qt/*.qm
/rake.d/compilation_database.rb
/rake.d/dependency.d
/share/icons/*/*.h
/src/*/qt_resources.cpp
@ -79,9 +82,9 @@
/tests/unit/common/common
/tests/unit/merge/merge
/tests/unit/propedit/propedit
/tools/macos/unlock_keychain.sh
BROWSE
Makefile
TAGS
lib*.a
.rsync-filter
/tools/macos/unlock_keychain.sh

View File

@ -1,3 +1,12 @@
# Version ?
## Build system changes
* A compilation database (in the form of a file `compile_commands.json`) can
be built automatically if the variable `BUILD_COMPILATION_DATABASE` is set
to `yes` (e.g. as `rake BUILD_COMPILATION_DATABASE=yes`).
# Version 21.0.0 "Tardigrades Will Inherit The Earth" 2018-02-24
## New features and enhancements

View File

@ -11,10 +11,12 @@ if (version[0] < 2) && (version[1] < 9)
end
# Change to base directory before doing anything
$source_dir = File.absolute_path(File.dirname(__FILE__))
$build_dir = $source_dir
if FileUtils.pwd != File.dirname(__FILE__)
new_dir = File.absolute_path(File.dirname(__FILE__))
puts "Entering directory `#{new_dir}'"
Dir.chdir new_dir
puts "Entering directory `#{$source_dir}'"
Dir.chdir $source_dir
end
# Set number of threads to use if it is unset and we're running with
@ -50,6 +52,7 @@ require_relative "rake.d/target"
require_relative "rake.d/application"
require_relative "rake.d/installer"
require_relative "rake.d/library"
require_relative "rake.d/compilation_database"
require_relative "rake.d/format_string_verifier"
require_relative "rake.d/pch"
require_relative "rake.d/po"
@ -272,6 +275,8 @@ cxx_compiler = lambda do |*args|
:allow_failure => true
]
Mtx::CompilationDatabase.add "directory" => $source_dir, "file" => source, "command" => args[2]
if pchi.pretty_flags
PCH.runq(*args[0..2], args[3].merge(pchi.pretty_flags))
else
@ -887,7 +892,7 @@ end
namespace :clean do
desc "Remove all compiled and generated files ('tarball' clean)"
task :dist => :clean do
run "rm -f config.h config.log config.cache build-config TAGS src/info/static_plugins.cpp src/mkvtoolnix-gui/static_plugins.cpp", :allow_failure => true
run "rm -f config.h config.log config.cache build-config TAGS src/mkvtoolnix-gui/static_plugins.cpp #{Mtx::CompilationDatabase.database_file_name}", :allow_failure => true
end
desc "Remove all compiled and generated files ('git' clean)"

View File

@ -143,6 +143,7 @@ ZLIB_LIBS = @ZLIB_LIBS@
USE_QT = @USE_QT@
APPIMAGE_BUILD = @APPIMAGE_BUILD@
BUILD_TOOLS = @BUILD_TOOLS@
BUILD_COMPILATION_DATABASE = no
TRANSLATIONS = @TRANSLATIONS@
MANPAGES_TRANSLATIONS = @MANPAGES_TRANSLATIONS@