-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
98 lines (86 loc) · 3.22 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# IBM_PROLOG_BEGIN_TAG
# This is an automatically generated prolog.
#
# $Source: setup.py $
#
# OpenPOWER sbe Project
#
# Contributors Listed Below - COPYRIGHT 2021,2024
# [+] International Business Machines Corp.
#
#
# 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.
#
# IBM_PROLOG_END_TAG
import os.path
import os
"""
Setuptools is an open source package to distribute python modules.
Documentation on setuptools can be found on the web.
This particular setup tool used in the OpenBMC to pack as part of the BMC image
to parse the SBE FFDC that will be added in the PEL user data section
for the SBE failure.
"""
from setuptools import setup
from setuptools.command.build_py import build_py
package_directories = {
# User Data packages.
# Component package names must be in the form of: `udparsers.xyyyy`.
# Where 'x' is PEL creator system, for example 'o' for the BMC and
# 'b' for the Hostboot. 'yyyy' is the 4 digit component ID (lowercase).
# Refer: https://github.com/openbmc/phosphor-logging/tree/master/extensions/openpower-pels#adding-python3-modules-for-pel-userdata-and-src-parsing
"udparsers.o4500": "public/src/tools/debug/plugins/ebmc/",
"udparsers.poztraceutils": "public/src/tools/trace/",
"udparsers.pozdebugutils": "public/src/tools/debug/"
}
# TODO: add golden image stringfiles
# currently need to run simics and then untar and find the gldnstringfile
custom_data_files = [
('ody_data',['images/odyssey/runtime/sppe/odysseySppeStringFile_DD1',])
]
def check_environment_files():
"""
Check the environment for the needed files
SBE setup.py is invoked in two contexts:
1 - op-build, where the images file exists, post build
2 - OpenBMC, where the images file does NOT exist
OpenBMC clones a clean SBE PPE repo (source only)
setup.py will fail if data_files do not exist,
so if we encounter a missing file, clear the
expectation and only populate the wheel with
the usual python source files.
"""
for i in custom_data_files:
for x in i[1]:
if not os.path.isfile(x):
custom_data_files.clear()
return
class BuildCommand(build_py):
"""
Subclass the build_py command
This allows the capability to add custom build
steps.
"""
def run(self):
# First run the regular build_py
build_py.run(self)
# Now run the custom step we need
check_environment_files()
setup(
name = "poz-pel-parser",
cmdclass = {"build_py":BuildCommand},
version = os.getenv('PELTOOL_VERSION', '0.1'),
packages = package_directories.keys(),
data_files = custom_data_files,
package_dir = package_directories,
)