Skip to content

Commit 304b1a7

Browse files
committed
extend cmake args to repoagent and cache
1 parent 17ca196 commit 304b1a7

1 file changed

Lines changed: 28 additions & 40 deletions

File tree

build.py

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@
9494

9595
ELEMENTS = {
9696
'backend': ['tag', 'org', 'cmake'],
97-
'repoagent': ['tag', 'org'],
98-
'cache': ['tag', 'org'],
97+
'repoagent': ['tag', 'org', 'cmake'],
98+
'cache': ['tag', 'org', 'cmake'],
9999
'filesystem': ['strict'],
100100
'endpoint': ['strict'],
101101
'feature': ['strict'],
@@ -459,40 +459,28 @@ def cmake_backend_extra_args(backend):
459459
return cmake_element_extra_args('backend', backend)
460460

461461

462-
def cmake_repoagent_arg(name, type, value):
463-
# For now there is no override for repo-agents
464-
type = ":{}".format(type) if type else ""
465-
return '"-D{}{}={}"'.format(name, type, value)
462+
def cmake_repoagent_arg(*args, **kwargs):
463+
return cmake_element_arg('repoagent', *args, **kwargs)
466464

467465

468-
def cmake_repoagent_enable(name, flag):
469-
# For now there is no override for repo-agents
470-
value = "ON" if flag else "OFF"
471-
return '"-D{}:BOOL={}"'.format(name, value)
466+
def cmake_repoagent_enable(*args, **kwargs):
467+
return cmake_element_enable('repoagent', *args, **kwargs)
472468

473469

474-
def cmake_repoagent_extra_args():
475-
# For now there is no extra args for repo-agents
476-
args = []
477-
return args
470+
def cmake_repoagent_extra_args(repoagent):
471+
return cmake_element_extra_args('repoagent', repoagent)
478472

479473

480-
def cmake_cache_arg(name, type, value):
481-
# For now there is no override for caches
482-
type = ":{}".format(type) if type else ""
483-
return '"-D{}{}={}"'.format(name, type, value)
474+
def cmake_cache_arg(*args, **kwargs):
475+
return cmake_element_arg('cache', *args, **kwargs)
484476

485477

486-
def cmake_cache_enable(name, flag):
487-
# For now there is no override for caches
488-
value = "ON" if flag else "OFF"
489-
return '"-D{}:BOOL={}"'.format(name, value)
478+
def cmake_cache_enable(*args, **kwargs):
479+
return cmake_element_enable('cache', *args, **kwargs)
490480

491481

492-
def cmake_cache_extra_args():
493-
# For now there is no extra args for caches
494-
args = []
495-
return args
482+
def cmake_cache_extra_args(cache):
483+
return cmake_element_extra_args('cache', cache)
496484

497485

498486
def core_cmake_args(cmake_dir, install_dir):
@@ -563,17 +551,17 @@ def repoagent_cmake_args(images, ra, install_dir):
563551
args = []
564552

565553
cargs = args + [
566-
cmake_repoagent_arg("CMAKE_BUILD_TYPE", None, FLAGS.build_type),
567-
cmake_repoagent_arg("CMAKE_INSTALL_PREFIX", "PATH", install_dir),
554+
cmake_repoagent_arg(ra, "CMAKE_BUILD_TYPE", None, FLAGS.build_type),
555+
cmake_repoagent_arg(ra, "CMAKE_INSTALL_PREFIX", "PATH", install_dir),
568556
cmake_repoagent_arg(
569-
"TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization
557+
ra, "TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization
570558
),
571-
cmake_repoagent_arg("TRITON_COMMON_REPO_TAG", "STRING", FLAGS.component["common"]["tag"]),
572-
cmake_repoagent_arg("TRITON_CORE_REPO_TAG", "STRING", FLAGS.component["core"]["tag"]),
559+
cmake_repoagent_arg(ra, "TRITON_COMMON_REPO_TAG", "STRING", FLAGS.component["common"]["tag"]),
560+
cmake_repoagent_arg(ra, "TRITON_CORE_REPO_TAG", "STRING", FLAGS.component["core"]["tag"]),
573561
]
574562

575-
cargs.append(cmake_repoagent_enable("TRITON_ENABLE_GPU", "gpu" in FLAGS.feature))
576-
cargs += cmake_repoagent_extra_args()
563+
cargs.append(cmake_repoagent_enable(ra, "TRITON_ENABLE_GPU", "gpu" in FLAGS.feature))
564+
cargs += cmake_repoagent_extra_args(ra)
577565
cargs.append("..")
578566
return cargs
579567

@@ -587,17 +575,17 @@ def cache_cmake_args(images, cache, install_dir):
587575
args = []
588576

589577
cargs = args + [
590-
cmake_cache_arg("CMAKE_BUILD_TYPE", None, FLAGS.build_type),
591-
cmake_cache_arg("CMAKE_INSTALL_PREFIX", "PATH", install_dir),
578+
cmake_cache_arg(cache, "CMAKE_BUILD_TYPE", None, FLAGS.build_type),
579+
cmake_cache_arg(cache, "CMAKE_INSTALL_PREFIX", "PATH", install_dir),
592580
cmake_cache_arg(
593-
"TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization
581+
cache, "TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization
594582
),
595-
cmake_cache_arg("TRITON_COMMON_REPO_TAG", "STRING", FLAGS.component["common"]["tag"]),
596-
cmake_cache_arg("TRITON_CORE_REPO_TAG", "STRING", FLAGS.component["core"]["tag"]),
583+
cmake_cache_arg(cache, "TRITON_COMMON_REPO_TAG", "STRING", FLAGS.component["common"]["tag"]),
584+
cmake_cache_arg(cache, "TRITON_CORE_REPO_TAG", "STRING", FLAGS.component["core"]["tag"]),
597585
]
598586

599-
cargs.append(cmake_cache_enable("TRITON_ENABLE_GPU", 'gpu' in FLAGS.feature))
600-
cargs += cmake_cache_extra_args()
587+
cargs.append(cmake_cache_enable(cache, "TRITON_ENABLE_GPU", 'gpu' in FLAGS.feature))
588+
cargs += cmake_cache_extra_args(cache)
601589
cargs.append("..")
602590
return cargs
603591

0 commit comments

Comments
 (0)