Skip to content

Commit

Permalink
Ninja: use header dependencies for better rebuild support
Browse files Browse the repository at this point in the history
  • Loading branch information
lieser committed Oct 23, 2023
1 parent 3a02016 commit 07b8806
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
2 changes: 2 additions & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2185,6 +2185,8 @@ def test_exe_extra_ldflags():
'os': options.os,
'arch': options.arch,
'compiler': options.compiler,
'compiler_is_gcc_or_clang': options.compiler == 'gcc' or options.compiler == 'clang',
'compiler_is_msvc': options.compiler == 'msvc',
'cpu_family': arch.family,
'endian': options.with_endian,
'cpu_is_64bit': arch.wordsize == 64,
Expand Down
48 changes: 45 additions & 3 deletions src/build-data/ninja.in
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,55 @@ SCRIPTS_DIR = %{scripts_dir}
INSTALLED_LIB_DIR = %{libdir}

rule compile_lib
command = %{cxx} %{lib_flags} ${ABI_FLAGS} ${LANG_FLAGS} ${CXXFLAGS} -DBOTAN_IS_BEING_BUILT ${WARN_FLAGS} ${isa_flags} %{include_paths} %{dash_c} $in %{dash_o}$out
%{if compiler_is_gcc_or_clang}
depfile = $out.d
deps = gcc
%{endif}
%{if compiler_is_msvc}
deps = msvc
%{endif}
command = %{cxx} %{lib_flags} ${ABI_FLAGS} ${LANG_FLAGS} ${CXXFLAGS} -DBOTAN_IS_BEING_BUILT ${WARN_FLAGS} ${isa_flags} %{include_paths} %{dash_c} $
%{if compiler_is_gcc_or_clang}
-MD -MF $out.d $
%{endif}
%{if compiler_is_msvc}
/showIncludes $
%{endif}
$in %{dash_o}$out

rule compile_exe
command = %{cxx} ${ABI_FLAGS} ${LANG_FLAGS} ${CXXFLAGS} -DBOTAN_IS_BEING_BUILT ${WARN_FLAGS} ${isa_flags} %{include_paths} %{dash_c} $in %{dash_o}$out
%{if compiler_is_gcc_or_clang}
depfile = $out.d
deps = gcc
%{endif}
%{if compiler_is_msvc}
deps = msvc
%{endif}
command = %{cxx} ${ABI_FLAGS} ${LANG_FLAGS} ${CXXFLAGS} -DBOTAN_IS_BEING_BUILT ${WARN_FLAGS} ${isa_flags} %{include_paths} %{dash_c} $
%{if compiler_is_gcc_or_clang}
-MD -MF $out.d $
%{endif}
%{if compiler_is_msvc}
/showIncludes $
%{endif}
$in %{dash_o}$out

rule compile_example_exe
command = %{cxx} ${ABI_FLAGS} ${LANG_FLAGS} ${CXXFLAGS} ${WARN_FLAGS} ${isa_flags} %{include_paths} %{dash_c} $in %{dash_o}$out
%{if compiler_is_gcc_or_clang}
depfile = $out.d
deps = gcc
%{endif}
%{if compiler_is_msvc}
deps = msvc
%{endif}
command = %{cxx} ${ABI_FLAGS} ${LANG_FLAGS} ${CXXFLAGS} ${WARN_FLAGS} ${isa_flags} %{include_paths} %{dash_c} $
%{if compiler_is_gcc_or_clang}
-MD -MF $out.d $
%{endif}
%{if compiler_is_msvc}
/showIncludes $
%{endif}
$in %{dash_o}$out

# The primary target
build all: phony %{all_targets}
Expand Down
4 changes: 2 additions & 2 deletions src/editors/vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"detail": "Default ./configure.py invocation for gcc. Run your own if you want.",
"group": "build",
"type": "shell",
"command": "python3 ./configure.py --cc gcc --compiler-cache=ccache --without-documentation --debug-mode --build-targets=\"static,tests,bogo_shim\"",
"command": "python3 ./configure.py --cc gcc --compiler-cache=ccache --build-tool=ninja --without-documentation --debug-mode --build-targets=\"static,tests,bogo_shim\"",
"presentation": {
"reveal": "always",
"panel": "shared",
Expand All @@ -22,7 +22,7 @@
"args": [
]
},
"command": "python ./configure.py --cc msvc --compiler-cache=sccache.exe --without-documentation --debug-mode --build-targets=\"static,tests\"",
"command": "python ./configure.py --cc msvc --compiler-cache=sccache.exe --build-tool=ninja --link-method=hardlink --without-documentation --debug-mode --build-targets=\"static,tests\"",
"presentation": {
"reveal": "always",
"panel": "shared",
Expand Down

0 comments on commit 07b8806

Please sign in to comment.