@@ -27,6 +27,8 @@ class Vls.MesonProject : Project {
27
27
private string build_dir;
28
28
private bool configured_once;
29
29
private bool requires_general_build;
30
+ private string [] extra_setup_args = {};
31
+ private string [] extra_compile_args = {};
30
32
31
33
/**
32
34
* Substitute special arguments like `@INPUT@` and `@OUTPUT@` as they
@@ -209,6 +211,9 @@ class Vls.MesonProject : Project {
209
211
string proc_stdout, proc_stderr;
210
212
int proc_status;
211
213
214
+ foreach (string arg in extra_setup_args)
215
+ spawn_args + = arg;
216
+
212
217
string command_str = " " ;
213
218
foreach (string part in spawn_args) {
214
219
if (command_str != " " )
@@ -761,9 +766,13 @@ class Vls.MesonProject : Project {
761
766
if (requires_general_build) {
762
767
int proc_status;
763
768
string proc_stdout, proc_stderr;
769
+ string [] spawn_args = {" meson" , " compile" };
770
+
771
+ foreach (string arg in extra_compile_args)
772
+ spawn_args + = arg;
764
773
765
774
Process . spawn_sync (build_dir,
766
- { " meson " , " compile " } ,
775
+ spawn_args ,
767
776
null ,
768
777
SpawnFlags . SEARCH_PATH ,
769
778
null ,
@@ -781,9 +790,28 @@ class Vls.MesonProject : Project {
781
790
base . build_if_stale (cancellable);
782
791
}
783
792
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 {
785
796
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);
787
815
reconfigure_if_stale (cancellable);
788
816
}
789
817
0 commit comments