Skip to content

Commit dd0ed1c

Browse files
committed
move library_paths to element attribute (similar to org, tag)
1 parent c275890 commit dd0ed1c

1 file changed

Lines changed: 20 additions & 23 deletions

File tree

build.py

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
THIS_SCRIPT_DIR = os.path.dirname(os.path.abspath(getsourcefile(lambda: 0)))
9494

9595
ELEMENTS = {
96-
'backend': ['tag', 'org'],
96+
'backend': ['tag', 'org', 'lib'],
9797
'repoagent': ['tag', 'org'],
9898
'cache': ['tag', 'org'],
9999
'filesystem': ['strict'],
@@ -615,11 +615,11 @@ def backend_repo(be):
615615
return "{}_backend".format(be)
616616

617617

618-
def backend_cmake_args(images, be, install_dir, library_paths):
618+
def backend_cmake_args(images, be, install_dir):
619619
cmake_build_type = FLAGS.build_type
620620

621621
if be == "onnxruntime":
622-
args = onnxruntime_cmake_args(images, library_paths)
622+
args = onnxruntime_cmake_args(images)
623623
elif be == "openvino":
624624
args = openvino_cmake_args()
625625
elif be == "python":
@@ -723,7 +723,7 @@ def pytorch_cmake_args(images):
723723
return cargs
724724

725725

726-
def onnxruntime_cmake_args(images, library_paths):
726+
def onnxruntime_cmake_args(images):
727727
cargs = [
728728
cmake_backend_arg(
729729
"onnxruntime",
@@ -2119,7 +2119,6 @@ def backend_build(
21192119
build_dir,
21202120
install_dir,
21212121
images,
2122-
library_paths,
21232122
):
21242123
tag, github_organization = FLAGS.backend[be]["tag"], FLAGS.backend[be]["org"]
21252124
repo_build_dir = os.path.join(build_dir, be, "build")
@@ -2142,7 +2141,7 @@ def backend_build(
21422141
cmake_script.mkdir(repo_build_dir)
21432142
cmake_script.cwd(repo_build_dir)
21442143
cmake_script.cmake(
2145-
backend_cmake_args(images, be, repo_install_dir, library_paths)
2144+
backend_cmake_args(images, be, repo_install_dir)
21462145
)
21472146
cmake_script.makeinstall()
21482147

@@ -2542,15 +2541,6 @@ def enable_all(default):
25422541
default="/tmp",
25432542
help="Temporary directory used for building inside docker.",
25442543
)
2545-
parser.add_argument(
2546-
"--library-paths",
2547-
action="append",
2548-
metavar=("<backend>","<library_path>"),
2549-
nargs=2,
2550-
required=False,
2551-
default=[],
2552-
help="Specify library paths for given backend in build.",
2553-
)
25542544
parser.add_argument(
25552545
"--build-type",
25562546
required=False,
@@ -2675,6 +2665,16 @@ def enable_all(default):
26752665
default=[],
26762666
help=f'Select <org> for specified <{element}>, to use the fork of the corresponding repository from <org> instead of the default --github-organization value.',
26772667
)
2668+
if 'lib' in properties:
2669+
group.add_argument(
2670+
f"--{element}-library-path",
2671+
action="append",
2672+
metavar=(f"<{element}>","<library_path>"),
2673+
nargs=2,
2674+
required=False,
2675+
default=[],
2676+
help=f'Specify library paths for specified <{element}> in build.',
2677+
)
26782678

26792679
parser.add_argument(
26802680
"--min-compute-capability",
@@ -2904,15 +2904,18 @@ def do_tag(element, map, key, value):
29042904
map[key]["tag"] = value
29052905
def do_org(element, map, key, value):
29062906
map[key]["org"] = value
2907+
def do_lib(element, map, key, value):
2908+
map[key]["lib"] = value
29072909
attr_fns = {
29082910
"enable": do_enable,
29092911
"disable": do_disable,
29102912
"tag": do_tag,
29112913
"org": do_org,
2914+
"library_path": do_lib,
29122915
}
29132916
for element in ELEMENTS:
29142917
map = getattr(FLAGS, element)
2915-
attr_names = [f"enable_{element}", f"disable_{element}", f"{element}_tag", f"{element}_org"]
2918+
attr_names = [f"enable_{element}", f"disable_{element}", f"{element}_tag", f"{element}_org", f"{element}_library_path"]
29162919
for attr_name in attr_names:
29172920
attr = getattr(FLAGS, attr_name, None)
29182921
if not attr: continue
@@ -2948,6 +2951,7 @@ def do_org(element, map, key, value):
29482951
f'{element} "{key}"',
29492952
'at tag/branch "{}"'.format(info["tag"]) if "tag" in info else "",
29502953
'from org "{}"'.format(info["org"]) if "org" in info else "",
2954+
'with library path "{}"'.format(info["lib"]) if "lib" in info else "",
29512955
])))
29522956

29532957
# Initialize map of docker images.
@@ -2965,12 +2969,6 @@ def do_org(element, map, key, value):
29652969
if "base" in images:
29662970
images["buildbase"] = images["base"]
29672971

2968-
# Initialize map of library paths for each backend.
2969-
library_paths = {}
2970-
for key,val in FLAGS.library_paths:
2971-
log('backend "{}" library path "{}"'.format(parts[0], parts[1]))
2972-
library_paths[key] = val
2973-
29742972
# Parse any explicitly specified cmake arguments
29752973
for key,val in FLAGS.extra_core_cmake_arg:
29762974
log('CMake core extra "-D{}={}"'.format(key, val))
@@ -3069,7 +3067,6 @@ def do_org(element, map, key, value):
30693067
script_build_dir,
30703068
script_install_dir,
30713069
images,
3072-
library_paths,
30733070
)
30743071

30753072
# Commands to build each repo agent...

0 commit comments

Comments
 (0)