Skip to content

Commit 6e32b34

Browse files
authored
Merge pull request #8335 from The-OpenROAD-Project-staging/odb-gen-includes
odb: generate some includes based on the schema
2 parents 96512a3 + 2519d78 commit 6e32b34

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+70
-0
lines changed

src/odb/src/codeGenerator/gen.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,22 @@ def generate_relations(schema):
268268
make_child_next_field(child, relation)
269269

270270

271+
def add_include(klass, key, include, cpp=False, sys=False):
272+
for field in klass["fields"]:
273+
if key in field["type"]:
274+
if sys:
275+
klass["h_sys_includes"].insert(0, include)
276+
else:
277+
klass["h_includes"].insert(0, include)
278+
279+
if cpp:
280+
if sys:
281+
klass["cpp_sys_includes"].insert(0, include)
282+
else:
283+
klass["cpp_includes"].insert(0, include)
284+
break
285+
286+
271287
def preprocess_klass(klass):
272288
klass["declared_classes"].insert(0, "dbIStream")
273289
klass["declared_classes"].insert(1, "dbOStream")
@@ -280,6 +296,11 @@ def preprocess_klass(klass):
280296
klass["cpp_includes"].extend(["dbTable.h", "dbTable.hpp", "odb/db.h", f"{name}.h"])
281297
if klass["hasBitFields"]:
282298
klass["cpp_sys_includes"].extend(["cstdint", "cstring"])
299+
add_include(klass, "dbObject", "dbCore.h", cpp=True)
300+
add_include(klass, "dbId<", "odb/dbId.h")
301+
add_include(klass, "dbVector", "dbVector.h")
302+
add_include(klass, "dbObjectType", "odb/dbObject.h", cpp=True)
303+
add_include(klass, "tuple", "tuple", cpp=True, sys=True)
283304
for field in klass["fields"]:
284305
if field.get("table", False):
285306
page_size_part = f", {field['page_size']}" if "page_size" in field else ""

src/odb/src/db/dbAccessPoint.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@
55
#include "dbAccessPoint.h"
66

77
#include <array>
8+
#include <tuple>
89

10+
#include "dbCore.h"
911
#include "dbDatabase.h"
1012
#include "dbTable.h"
1113
#include "dbTable.hpp"
1214
#include "odb/db.h"
15+
#include "odb/dbObject.h"
1316
#include "odb/dbTypes.h"
1417
// User Code Begin Includes
1518
#include <algorithm>

src/odb/src/db/dbAccessPoint.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
#pragma once
66

77
#include <array>
8+
#include <tuple>
89

910
#include "dbCore.h"
1011
#include "dbVector.h"
12+
#include "odb/dbId.h"
13+
#include "odb/dbObject.h"
1114
#include "odb/odb.h"
1215
// User Code Begin Includes
1316
#include <utility>

src/odb/src/db/dbBusPort.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#pragma once
66

77
#include "dbCore.h"
8+
#include "odb/dbId.h"
89
#include "odb/odb.h"
910
// User Code Begin Includes
1011
#include "dbModuleBusPortModBTermItr.h"

src/odb/src/db/dbChip.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <unordered_map>
99

1010
#include "dbCore.h"
11+
#include "odb/dbId.h"
1112
#include "odb/geom.h"
1213
#include "odb/odb.h"
1314

src/odb/src/db/dbChipInst.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <unordered_map>
99

1010
#include "dbCore.h"
11+
#include "odb/dbId.h"
1112
#include "odb/dbTypes.h"
1213
#include "odb/geom.h"
1314
#include "odb/odb.h"

src/odb/src/db/dbDatabase.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "dbCore.h"
88
#include "dbHashTable.h"
9+
#include "odb/dbId.h"
910
#include "odb/odb.h"
1011
// User Code Begin Includes
1112
#include <iostream>

src/odb/src/db/dbGCellGrid.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include <map>
88

99
#include "dbCore.h"
10+
#include "dbVector.h"
1011
#include "odb/db.h"
12+
#include "odb/dbId.h"
1113
#include "odb/odb.h"
1214
// User Code Begin Includes
1315
#include "dbVector.h"

src/odb/src/db/dbGDSARef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "dbCore.h"
1313
#include "dbGDSStructure.h"
14+
#include "odb/dbId.h"
1415
#include "odb/odb.h"
1516

1617
namespace odb {

src/odb/src/db/dbGDSSRef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "dbCore.h"
1313
#include "dbGDSStructure.h"
14+
#include "odb/dbId.h"
1415
#include "odb/odb.h"
1516

1617
namespace odb {

0 commit comments

Comments
 (0)