Skip to content

Commit

Permalink
[GR-53353] CMakeNinjaProject support for multitarget
Browse files Browse the repository at this point in the history
PullRequest: mx/1781
  • Loading branch information
zapster committed Apr 9, 2024
2 parents b0f35c6 + c2ef308 commit e655ab3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
16 changes: 16 additions & 0 deletions mx.mx/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -1100,5 +1100,21 @@
"maven": False,
"graalCompilerSourceEdition": "ignore",
},
"DEFAULT_CMAKE_TOOLCHAIN": {
"native": True,
"platformDependent": True,
"description": "Default (empty) ninja toolchain for an OS-dependent toolchain found on the PATH",
"native_toolchain": {
"kind": "cmake",
"target": {
# all defaults (host compiler, host os/arch/libc, no variant)
},
},
"layout": {
"toolchain.cmake": "string:",
},
"maven": False,
"graalCompilerSourceEdition": "ignore",
},
},
}
2 changes: 1 addition & 1 deletion src/mx/_impl/mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18147,7 +18147,7 @@ def alarm_handler(signum, frame):
_CACHE_DIR = get_env('MX_CACHE_DIR', join(dot_mx_dir(), 'cache'))

# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
version = VersionSpec("7.21.2") # revert 7.19.4 "[GR-51382] Change default tracker to 'rsspercentiles' and copy 99th rss percentile into max-rss"
version = VersionSpec("7.22.0") # CMakeNinjaProject support for multitarget

_mx_start_datetime = datetime.utcnow()

Expand Down
14 changes: 12 additions & 2 deletions src/mx/_impl/mx_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def __init__(self, suite, name, deps, workingSets, subDir, ninja_targets=None, n
if self._cmake_toolchain:
self.buildDependencies += [self._cmake_toolchain]

@property
def toolchain_kind(self):
return "cmake" if self._multitarget else None

def resolveDeps(self):
super(CMakeNinjaProject, self).resolveDeps()
self._cmake_toolchain = mx.distribution(self._cmake_toolchain, context=self) if self._cmake_toolchain else None
Expand Down Expand Up @@ -164,6 +168,12 @@ def mklink():
return src_link
return src_dir

def generate_manifest_for_task(self, task, output_dir, filename):
extra_cmake_config = []
if task.toolchain:
extra_cmake_config.append("-DCMAKE_TOOLCHAIN_FILE=" + os.path.join(task.toolchain.get_path(), "toolchain.cmake"))
self.generate_manifest(output_dir, filename, extra_cmake_config=extra_cmake_config)

def generate_manifest(self, output_dir, filename, extra_cmake_config=None):
source_dir = self.sourceDir(create=True)
if self._cmake_subdir:
Expand Down Expand Up @@ -199,8 +209,8 @@ def generate_manifest(self, output_dir, filename, extra_cmake_config=None):
shutil.copyfile(os.path.join(output_dir, mx_native.Ninja.default_manifest), path)
return True

def _build_task(self, target_arch, args):
return CMakeNinjaBuildTask(args, self, target_arch, self._ninja_targets)
def _build_task(self, target_arch, args, toolchain=None):
return CMakeNinjaBuildTask(args, self, target_arch, self._ninja_targets, toolchain=toolchain)

def getResults(self, replaceVar=mx_subst.results_substitutions):
return [mx_subst.as_engine(replaceVar).substitute(rt, dependency=self) for rt in self.results]
Expand Down

0 comments on commit e655ab3

Please sign in to comment.