@@ -27,6 +27,9 @@ class Vls.MesonProject : Project {
2727 private string build_dir;
2828 private bool configured_once;
2929 private bool requires_general_build;
30+ private string [] special_args = {};
31+ private string [] special_comp = {};
32+ private string [] special_envp = {};
3033
3134 /**
3235 * Substitute special arguments like `@INPUT@` and `@OUTPUT@` as they
@@ -292,10 +295,14 @@ class Vls.MesonProject : Project {
292295 debug (" %sconfiguring build dir %s ..." , configured_once ? " re" : " " , build_dir);
293296 if (configured_once)
294297 spawn_args + = " --reconfigure" ;
298+ foreach (var item in special_comp) {
299+ warning(" meson setup arg %s " , item);
300+ spawn_args + = item;
301+ }
295302 Process . spawn_sync (
296303 build_dir,
297304 spawn_args,
298- null ,
305+ special_envp ,
299306 SpawnFlags . SEARCH_PATH ,
300307 null ,
301308 out proc_stdout,
@@ -761,10 +768,15 @@ class Vls.MesonProject : Project {
761768 if (requires_general_build) {
762769 int proc_status;
763770 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+ }
764776
765777 Process . spawn_sync (build_dir,
766- { " meson " , " compile " } ,
767- null ,
778+ spwan_args ,
779+ special_envp ,
768780 SpawnFlags . SEARCH_PATH ,
769781 null ,
770782 out proc_stdout,
@@ -783,6 +795,38 @@ class Vls.MesonProject : Project {
783795
784796 public MesonProject (string root_path , FileCache file_cache , Cancellable ? cancellable = null ) throws Error {
785797 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+ }
786830 this . build_dir = DirUtils . make_tmp (@" vls-meson-$(str_hash (root_path))-XXXXXX" );
787831 reconfigure_if_stale (cancellable);
788832 }
0 commit comments