blob: 4ccd7d37b903b3c1d6cfe7afb41644d55a718360 [file] [log] [blame]
Scott Bakerd87c02a2018-10-29 16:24:29 -07001#!/usr/bin/env python
2
3# Copyright 2017-present Open Networking Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17import os
18from xosgenx.generator import XOSProcessor, XOSProcessorArgs
19
20# These assume a traditional CORD/SEBA hierarchy is checked out using `repo`
21
22SCRIPT_DIR=os.path.dirname(os.path.realpath(__file__))
23BASE_DIR=os.path.join(SCRIPT_DIR,"..","..","..")
Matteo Scandoloe1576802019-03-06 15:23:40 -080024SERVICES_DIR=os.path.join(BASE_DIR,"orchestration","xos-services")
Scott Bakerd87c02a2018-10-29 16:24:29 -070025CORE_XPROTO=os.path.join(BASE_DIR,"orchestration","xos","xos","core","models","core.xproto")
26TARGET=os.path.join(BASE_DIR,"orchestration","xos","lib","xos-genx","xosgenx","targets","fieldlist.xtarget")
27
28def get_all_xproto():
29 xprotos=[]
30 for service_name in os.listdir(SERVICES_DIR):
31 if service_name.startswith("."):
32 continue
33 service_path = os.path.join(SERVICES_DIR, service_name)
34 if not os.path.isdir(service_path):
35 continue
36 models_dir = os.path.join(service_path, "xos", "synchronizer", "models")
37 if not os.path.isdir(models_dir):
38 continue
39 for xproto_name in os.listdir(models_dir):
40 if xproto_name.startswith("."):
41 continue
42 if not xproto_name.endswith(".xproto"):
43 continue
44 xproto_pathname = os.path.join(models_dir, xproto_name)
45 xprotos.append(xproto_pathname)
46 return xprotos
47
48xprotos = get_all_xproto() + [CORE_XPROTO]
49args = XOSProcessorArgs(files=xprotos,
50 target=TARGET,
51 verbosity=1
52 )
53output = XOSProcessor.process(args)