object-introspection/tools/combine_configs.py
Alastair Robertson 0330ef8945 Take list of pass-through types from config instead of hardcoding
As we now store ContainerInfo objects in OICodeGen::Config, we can not
copy it any more. Change all places that took copies to take const
references instead.

The copy in OICodeGen modified membersToStub, the contents of which form
part of OICache's hash. However, as OICache also previously had its own
copy, it would not have been OICodeGen's modifications.
2023-07-05 13:39:19 +01:00

68 lines
2.0 KiB
Python

#
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
import sys
import toml
def main():
if len(sys.argv) < 2:
print("usage: combine_configs.py OUTPUT_PATH INPUT_PATHS...")
return
out = {
"types": {
"containers": [],
"pass_through": [],
},
"headers": {
"user_paths": [],
"system_paths": [],
},
"codegen": {
"default_headers": set(),
"default_namespaces": set(),
},
}
for cfg_path in sys.argv[2:]:
cfg = toml.load(cfg_path)
types = cfg.get("types", None)
if types is not None:
out["types"]["containers"] += types.get("containers", [])
out["types"]["pass_through"] += types.get("pass_through", [])
headers = cfg.get("headers", None)
if headers is not None:
out["headers"]["user_paths"] += headers.get("user_paths", [])
out["headers"]["system_paths"] += headers.get("system_paths", [])
codegen = cfg.get("codegen", None)
if codegen is not None:
out["codegen"]["default_headers"].update(
codegen.get("default_headers", set())
)
out["codegen"]["default_namespaces"].update(
codegen.get("default_namespaces", set())
)
with open(sys.argv[1], "w") as f:
toml.dump(out, f)
if __name__ == "__main__":
main()