@@ -27,6 +27,8 @@ class Vls.MesonProject : Project {
2727 private string build_dir;
2828 private bool configured_once;
2929 private bool requires_general_build;
30+ private string [] extra_setup_args = {};
31+ private string [] extra_compile_args = {};
3032
3133 /**
3234 * Substitute special arguments like `@INPUT@` and `@OUTPUT@` as they
@@ -209,6 +211,9 @@ class Vls.MesonProject : Project {
209211 string proc_stdout, proc_stderr;
210212 int proc_status;
211213
214+ foreach (string arg in extra_setup_args)
215+ spawn_args + = arg;
216+
212217 string command_str = " " ;
213218 foreach (string part in spawn_args) {
214219 if (command_str != " " )
@@ -761,9 +766,13 @@ class Vls.MesonProject : Project {
761766 if (requires_general_build) {
762767 int proc_status;
763768 string proc_stdout, proc_stderr;
769+ string [] spawn_args = {" meson" , " compile" };
770+
771+ foreach (string arg in extra_compile_args)
772+ spawn_args + = arg;
764773
765774 Process . spawn_sync (build_dir,
766- { " meson " , " compile " } ,
775+ spawn_args ,
767776 null ,
768777 SpawnFlags . SEARCH_PATH ,
769778 null ,
@@ -781,9 +790,28 @@ class Vls.MesonProject : Project {
781790 base . build_if_stale (cancellable);
782791 }
783792
784- public MesonProject (string root_path , FileCache file_cache , Cancellable ? cancellable = null ) throws Error {
793+ public MesonProject (string root_path , FileCache file_cache ,
794+ Lsp .EditorOptions ? editor_options ,
795+ Cancellable ? cancellable = null ) throws Error {
785796 base (root_path, file_cache);
786- this . build_dir = DirUtils . make_tmp (@" vls-meson-$(str_hash (root_path))-XXXXXX" );
797+ var default_build_dir_template = @" vls-meson-$(str_hash (root_path))-XXXXXX" ;
798+ if (editor_options != null ) {
799+ debug (" overriding with VSCode Meson plugin settings: %s " ,
800+ Json . gobject_to_data (editor_options, null ));
801+ this . extra_setup_args = editor_options. mesonConfigureOptions;
802+ this . extra_compile_args = editor_options. mesonCompileOptions;
803+ if (editor_options. mesonBuildDir != null ) {
804+ var meson_build_dir = File . new_for_path (editor_options. mesonBuildDir);
805+ try {
806+ meson_build_dir. make_directory_with_parents (cancellable);
807+ this . build_dir = editor_options. mesonBuildDir;
808+ } catch (IOError . EXISTS e) {
809+ // ignore whether the build folder exists
810+ }
811+ }
812+ }
813+ if (this . build_dir == null )
814+ this . build_dir = DirUtils . make_tmp (default_build_dir_template);
787815 reconfigure_if_stale (cancellable);
788816 }
789817
0 commit comments