Skip to content

Commit fe8bda7

Browse files
author
Derek Hower
committed
Separate C++ format from generation
1 parent 4f39532 commit fe8bda7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,5 @@ repos:
5656
rev: "v19.1.7"
5757
hooks:
5858
- id: clang-format
59+
types_or: [c++, c]
5960
files: \.(hpp|cpp)$

backends/cpp_hart_gen/tasks.rake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ rule %r{#{CPP_HART_GEN_DST}/[^/]+/src/[^/]+\.cxx} => proc { |tname|
7373
end
7474

7575
# a config-specifc generated header
76-
rule %r{#{CPP_HART_GEN_DST}/.*/include/udb/cfgs/[^/]+/[^/]+\.hxx} => proc { |tname|
76+
rule %r{#{CPP_HART_GEN_DST}/.*/include/udb/cfgs/[^/]+/[^/]+\.hxx\.unformatted} => proc { |tname|
7777
parts = tname.split("/")
7878
filename = parts[-1]
7979
[
@@ -96,7 +96,12 @@ rule %r{#{CPP_HART_GEN_DST}/.*/include/udb/cfgs/[^/]+/[^/]+\.hxx} => proc { |tna
9696

9797
FileUtils.mkdir_p File.dirname(t.name)
9898
File.write(t.name, erb.result(CppHartGen::TemplateEnv.new(cfg_arch).get_binding))
99-
sh "clang-format -i #{t.name}"
99+
end
100+
101+
rule %r{#{CPP_HART_GEN_DST}/.*/include/udb/cfgs/[^/]+/[^/]+\.hxx} => proc { |tname|
102+
[tname.rsub(".unformatted", "")]
103+
} do |t|
104+
sh "clang-format #{t.name.rsub('.unformatted', '')} > #{t.name}"
100105
end
101106

102107
rule %r{#{CPP_HART_GEN_DST}/.*/src/cfgs/[^/]+/[^/]+\.cxx} => proc { |tname|
@@ -141,7 +146,8 @@ rule %r{#{CPP_HART_GEN_DST}/[^/]+/build/Makefile} => [
141146
"cmake",
142147
"-S#{CPP_HART_GEN_DST}/#{build_name}",
143148
"-B#{CPP_HART_GEN_DST}/#{build_name}/build",
144-
"-DCONFIG_LIST=\"#{ENV['CONFIG'].gsub(',', ';')}\""
149+
"-DCONFIG_LIST=\"#{ENV['CONFIG'].gsub(',', ';')}\"",
150+
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
145151
].join(" ")
146152

147153
sh cmd

0 commit comments

Comments
 (0)