Skip to content

Commit 3140735

Browse files
committed
extend cmake args to repoagent and cache
1 parent 3429d64 commit 3140735

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
@@ -93,8 +93,8 @@
9393

9494
ELEMENTS = {
9595
'backend': ['tag', 'org', 'cmake'],
96-
'repoagent': ['tag', 'org'],
97-
'cache': ['tag', 'org'],
96+
'repoagent': ['tag', 'org', 'cmake'],
97+
'cache': ['tag', 'org', 'cmake'],
9898
'filesystem': ['strict'],
9999
'endpoint': ['strict'],
100100
'feature': ['strict'],
@@ -458,40 +458,28 @@ def cmake_backend_extra_args(backend):
458458
return cmake_element_extra_args('backend', backend)
459459

460460

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

466464

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

472468

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

478472

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

484476

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

490480

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

496484

497485
def core_cmake_args(cmake_dir, install_dir):
@@ -562,17 +550,17 @@ def repoagent_cmake_args(images, ra, install_dir):
562550
args = []
563551

564552
cargs = args + [
565-
cmake_repoagent_arg("CMAKE_BUILD_TYPE", None, FLAGS.build_type),
566-
cmake_repoagent_arg("CMAKE_INSTALL_PREFIX", "PATH", install_dir),
553+
cmake_repoagent_arg(ra, "CMAKE_BUILD_TYPE", None, FLAGS.build_type),
554+
cmake_repoagent_arg(ra, "CMAKE_INSTALL_PREFIX", "PATH", install_dir),
567555
cmake_repoagent_arg(
568-
"TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization
556+
ra, "TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization
569557
),
570-
cmake_repoagent_arg("TRITON_COMMON_REPO_TAG", "STRING", FLAGS.component["common"]["tag"]),
571-
cmake_repoagent_arg("TRITON_CORE_REPO_TAG", "STRING", FLAGS.component["core"]["tag"]),
558+
cmake_repoagent_arg(ra, "TRITON_COMMON_REPO_TAG", "STRING", FLAGS.component["common"]["tag"]),
559+
cmake_repoagent_arg(ra, "TRITON_CORE_REPO_TAG", "STRING", FLAGS.component["core"]["tag"]),
572560
]
573561

574-
cargs.append(cmake_repoagent_enable("TRITON_ENABLE_GPU", "gpu" in FLAGS.feature))
575-
cargs += cmake_repoagent_extra_args()
562+
cargs.append(cmake_repoagent_enable(ra, "TRITON_ENABLE_GPU", "gpu" in FLAGS.feature))
563+
cargs += cmake_repoagent_extra_args(ra)
576564
cargs.append("..")
577565
return cargs
578566

@@ -586,17 +574,17 @@ def cache_cmake_args(images, cache, install_dir):
586574
args = []
587575

588576
cargs = args + [
589-
cmake_cache_arg("CMAKE_BUILD_TYPE", None, FLAGS.build_type),
590-
cmake_cache_arg("CMAKE_INSTALL_PREFIX", "PATH", install_dir),
577+
cmake_cache_arg(cache, "CMAKE_BUILD_TYPE", None, FLAGS.build_type),
578+
cmake_cache_arg(cache, "CMAKE_INSTALL_PREFIX", "PATH", install_dir),
591579
cmake_cache_arg(
592-
"TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization
580+
cache, "TRITON_REPO_ORGANIZATION", "STRING", FLAGS.github_organization
593581
),
594-
cmake_cache_arg("TRITON_COMMON_REPO_TAG", "STRING", FLAGS.component["common"]["tag"]),
595-
cmake_cache_arg("TRITON_CORE_REPO_TAG", "STRING", FLAGS.component["core"]["tag"]),
582+
cmake_cache_arg(cache, "TRITON_COMMON_REPO_TAG", "STRING", FLAGS.component["common"]["tag"]),
583+
cmake_cache_arg(cache, "TRITON_CORE_REPO_TAG", "STRING", FLAGS.component["core"]["tag"]),
596584
]
597585

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

0 commit comments

Comments
 (0)