From 2062ec23529e0ac7d11ef56bb02cda362dfc0301 Mon Sep 17 00:00:00 2001 From: Lawrence Tang Date: Wed, 16 Aug 2023 09:36:12 +0100 Subject: [PATCH] Add option to enable Linux cross builds for jit-format. Currently, when jit-format attempts to build a fresh version of compile-commands.json on Linux, it will always attempt a cross build, regardless of whether this is accurate for the host system. This patch adds an option to enable cross builds when on Linux, rather than defaulting to always building with -cross. --- src/jit-format/jit-format.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/jit-format/jit-format.cs b/src/jit-format/jit-format.cs index d1bcd433..5ce68790 100644 --- a/src/jit-format/jit-format.cs +++ b/src/jit-format/jit-format.cs @@ -40,6 +40,7 @@ public class Config private string _srcDirectory = null; private bool _untidy = false; private bool _noformat = false; + private bool _linuxCross = false; private bool _fix = false; private bool _verbose = false; private bool _ignoreErrors = false; @@ -63,13 +64,14 @@ public Config(string[] args) syntax.DefineOption("v|verbose", ref _verbose, "Enable verbose output."); syntax.DefineOption("untidy", ref _untidy, "Do not run clang-tidy"); syntax.DefineOption("noformat", ref _noformat, "Do not run clang-format"); + syntax.DefineOption("l|linux-cross", ref _linuxCross, "If on Linux, run the configure build as a cross build."); syntax.DefineOption("f|fix", ref _fix, "Fix formatting errors discovered by clang-format and clang-tidy."); syntax.DefineOption("i|ignore-errors", ref _ignoreErrors, "Ignore clang-tidy errors"); syntax.DefineOptionList("projects", ref _projects, "List of build projects clang-tidy should consider (e.g. dll, standalone, protojit, etc.). Default: dll"); syntax.DefineParameterList("filenames", ref _filenames, "Optional list of files that should be formatted."); }); - + // Run validation code on parsed input to ensure we have a sensible scenario. validate(); @@ -301,7 +303,7 @@ private void validate() { Console.WriteLine("Can't find compile_commands.json file. Running configure."); List commandArgs = new() { _arch, _build, "configureonly", "-cmakeargs", "-DCMAKE_EXPORT_COMPILE_COMMANDS=1" }; - if (_os.ToLower() == "linux") + if (_os.ToLower() == "linux" && _linuxCross) { commandArgs.Add("-cross"); }