@@ -27,6 +27,9 @@ 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 [] special_args = {};
31
+ private string [] special_comp = {};
32
+ private string [] special_envp = {};
30
33
31
34
/**
32
35
* Substitute special arguments like `@INPUT@` and `@OUTPUT@` as they
@@ -292,10 +295,14 @@ class Vls.MesonProject : Project {
292
295
debug (" %sconfiguring build dir %s ..." , configured_once ? " re" : " " , build_dir);
293
296
if (configured_once)
294
297
spawn_args + = " --reconfigure" ;
298
+ foreach (var item in special_comp) {
299
+ warning(" meson setup arg %s " , item);
300
+ spawn_args + = item;
301
+ }
295
302
Process . spawn_sync (
296
303
build_dir,
297
304
spawn_args,
298
- null ,
305
+ special_envp ,
299
306
SpawnFlags . SEARCH_PATH ,
300
307
null ,
301
308
out proc_stdout,
@@ -761,10 +768,15 @@ class Vls.MesonProject : Project {
761
768
if (requires_general_build) {
762
769
int proc_status;
763
770
string proc_stdout, proc_stderr;
771
+ string [] spwan_args = {" meson" , " compile" };
772
+ foreach (var item in special_comp) {
773
+ warning(" meson compile arg %s " , item);
774
+ spwan_args + = item;
775
+ }
764
776
765
777
Process . spawn_sync (build_dir,
766
- { " meson " , " compile " } ,
767
- null ,
778
+ spwan_args ,
779
+ special_envp ,
768
780
SpawnFlags . SEARCH_PATH ,
769
781
null ,
770
782
out proc_stdout,
@@ -783,6 +795,38 @@ class Vls.MesonProject : Project {
783
795
784
796
public MesonProject (string root_path , FileCache file_cache , Cancellable ? cancellable = null ) throws Error {
785
797
base (root_path, file_cache);
798
+ // read system envionment;
799
+ string [] system_env_key = Environment . list_variables();
800
+ if (system_env_key != null ) {
801
+ foreach (var item in system_env_key) {
802
+ var sys_env = item+ " =" + Environment . get_variable(item);
803
+ debug(" system env is %s " , sys_env);
804
+ special_envp + = sys_env;
805
+ }
806
+ }
807
+ // get config from settings.json
808
+ var check_path = root_path + " /.vscode/settings.json" ;
809
+ warning(" meson check option at %s " , check_path);
810
+ var settings_json = File . new_for_path(check_path);
811
+ if (settings_json. query_exists()) {
812
+ var dis = new DataInputStream (settings_json. read());
813
+ var settings_json_parser = new Json .Parser ();
814
+ settings_json_parser. load_from_stream(dis);
815
+ var root_node = settings_json_parser. get_root();
816
+ var root_object = root_node. get_object();
817
+ var ret_options = root_object. get_array_member(" mesonbuild.configureOptions" );
818
+ foreach (var option in ret_options. get_elements()) {
819
+ var opt = option. get_string();
820
+ special_args + = opt;
821
+ }
822
+ var compile_options = root_object. get_array_member(" mesonbuild.compileOptions" );
823
+ foreach (var option in compile_options. get_elements()) {
824
+ var opt = option. get_string();
825
+ special_comp + = opt;
826
+ }
827
+ // maybe can reuse mesonbuild buildDir
828
+ // this.build_dir = root_object.get_string_member_with_default("mesonbuild.buildFolder", root_path +"/builddir");
829
+ }
786
830
this . build_dir = DirUtils . make_tmp (@" vls-meson-$(str_hash (root_path))-XXXXXX" );
787
831
reconfigure_if_stale (cancellable);
788
832
}
0 commit comments