Skip to content

Commit efa4565

Browse files
committed
Swift: move generated code to generated directory
1 parent f52119d commit efa4565

File tree

12 files changed

+19
-20
lines changed

12 files changed

+19
-20
lines changed

swift/codegen/cppgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def generate(opts, renderer):
6666
processor = Processor({cls.name: cls for cls in schema.load(opts.schema).classes}, opts.trap_affix)
6767
out = opts.cpp_output
6868
renderer.render(cpp.ClassList(processor.get_classes(), opts.cpp_namespace, opts.trap_affix,
69-
opts.cpp_include_dir), out / f"{opts.trap_affix}Classes.h")
69+
opts.cpp_include_dir, opts.schema), out / f"{opts.trap_affix}Classes.h")
7070

7171

7272
tags = ("cpp", "schema")

swift/codegen/lib/cpp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ class TrapList:
104104
namespace: str
105105
trap_affix: str
106106
include_dir: str
107+
source: str
107108

108109

109110
@dataclass
@@ -112,6 +113,7 @@ class TagList:
112113

113114
tags: List[Tag]
114115
namespace: str
116+
source: str
115117

116118

117119
@dataclass
@@ -150,3 +152,4 @@ class ClassList:
150152
namespace: str
151153
trap_affix: str
152154
include_dir: str
155+
source: str

swift/codegen/templates/cpp_classes.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// generated by {{generator}}
1+
// generated by {{generator}} from {{source}}
22
// clang-format off
33
#pragma once
44

swift/codegen/templates/trap_tags.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// generated by {{generator}}
1+
// generated by {{generator}} from {{source}}
22
// clang-format off
33
#pragma once
44

swift/codegen/templates/trap_traps.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// generated by {{generator}}
1+
// generated by {{generator}} from {{source}}
22
// clang-format off
33
#pragma once
44

swift/codegen/trapgen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def generate(opts, renderer):
6868
for d in e.rhs:
6969
tag_graph.setdefault(d.type, set()).add(e.lhs)
7070

71-
renderer.render(cpp.TrapList(traps, opts.cpp_namespace, opts.trap_affix, opts.cpp_include_dir),
71+
renderer.render(cpp.TrapList(traps, opts.cpp_namespace, opts.trap_affix, opts.cpp_include_dir, opts.dbscheme),
7272
out / f"{opts.trap_affix}Entries.h")
7373

7474
tags = []
@@ -79,7 +79,7 @@ def generate(opts, renderer):
7979
index=index,
8080
id=tag,
8181
))
82-
renderer.render(cpp.TagList(tags, opts.cpp_namespace), out / f"{opts.trap_affix}Tags.h")
82+
renderer.render(cpp.TagList(tags, opts.cpp_namespace, opts.dbscheme), out / f"{opts.trap_affix}Tags.h")
8383

8484

8585
tags = ("cpp", "dbscheme")

swift/extractor/SwiftDispatcher.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
#include "swift/extractor/trap/TrapArena.h"
44
#include "swift/extractor/trap/TrapLabelStore.h"
5-
// autogenerated file
6-
#include "swift/extractor/trap/TrapClasses.h"
5+
#include "swift/extractor/trap/generated/TrapClasses.h"
76
#include "swift/extractor/SwiftTagTraits.h"
87
#include <swift/AST/SourceFile.h>
98
#include <swift/Basic/SourceManager.h>

swift/extractor/SwiftExtractor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <llvm/Support/FileSystem.h>
1313
#include <llvm/Support/Path.h>
1414

15-
#include "swift/extractor/trap/TrapClasses.h"
15+
#include "swift/extractor/trap/generated/TrapClasses.h"
1616
#include "swift/extractor/trap/TrapOutput.h"
1717
#include "swift/extractor/SwiftDispatcher.h"
1818

swift/extractor/SwiftTagTraits.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
#pragma once
22

33
#include <swift/AST/ASTVisitor.h>
4-
5-
// autogenerated header
6-
#include "swift/extractor/trap/TrapTags.h"
4+
#include "swift/extractor/trap/generated/TrapTags.h"
75

86
namespace codeql {
97

swift/extractor/trap/BUILD.bazel

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ genrule(
22
name = "trapgen",
33
srcs = ["//swift:dbscheme"],
44
outs = [
5-
"TrapEntries.h",
6-
"TrapTags.h",
5+
"generated/TrapEntries.h",
6+
"generated/TrapTags.h",
77
],
88
cmd = " ".join([
99
"$(location //swift/codegen:trapgen)",
1010
"--dbscheme $<",
1111
"--cpp-include-dir " + package_name(),
12-
"--cpp-output $(RULEDIR)",
12+
"--cpp-output $(RULEDIR)/generated",
1313
]),
1414
exec_tools = ["//swift/codegen:trapgen"],
1515
)
@@ -21,13 +21,13 @@ genrule(
2121
"//swift/codegen:schema_includes",
2222
],
2323
outs = [
24-
"TrapClasses.h",
24+
"generated/TrapClasses.h",
2525
],
2626
cmd = " ".join([
2727
"$(location //swift/codegen:cppgen)",
2828
"--schema $(location //swift/codegen:schema)",
2929
"--cpp-include-dir " + package_name(),
30-
"--cpp-output $(RULEDIR)",
30+
"--cpp-output $(RULEDIR)/generated",
3131
]),
3232
exec_tools = ["//swift/codegen:cppgen"],
3333
)

0 commit comments

Comments
 (0)