# Path: mod/util.py
# def fix_path(path) :
# def get_workspace_dir(fips_dir) :
# def get_project_dir(fips_dir, proj_name) :
# def get_build_root_dir(fips_dir, proj_name):
# def get_deploy_root_dir(fips_dir, proj_name):
# def get_build_dir(fips_dir, proj_name, cfg) :
# def get_deploy_dir(fips_dir, proj_name, cfg) :
# def get_fips_dir(proj_dir, name):
# def get_configs_dir(proj_dir):
# def get_verbs_dir(proj_dir):
# def get_generators_dir(proj_dir):
# def get_toolchains_dir(proj_dir):
# def get_giturl_from_url(url) :
# def get_gitbranch_from_url(url) :
# def get_project_name_from_url(url) :
# def get_project_name_from_dir(proj_dir) :
# def load_fips_yml(proj_dir) :
# def lookup_target_cwd(proj_dir, target) :
# def is_valid_project_dir(proj_dir) :
# def ensure_valid_project_dir(proj_dir) :
# def is_git_url(url) :
# def confirm(question) :
# def url_download_hook(count, block_size, total_size) :
# def get_host_platform() :
# def get_cfg_target_list(fips_dir, proj_dir, cfg):
# def get_cfg_headersdirs_by_target(fips_dir, proj_dir, cfg):
# def get_cfg_defines_by_target(fips_dir, proj_dir, cfg):
# def get_num_cpucores():
# 
# Path: mod/log.py
# RED = '\033[1;31m'
# GREEN = '\033[1;32m'
# YELLOW = '\033[1;33m'
# BLUE = '\033[1;36m'
# DEF = '\033[0;0m'
# def error(msg, fatal=True) :
# def warn(msg) :
# def ok(item, status) :
# def failed(item, status) :
# def optional(item, status) :
# def info(msg) :
# def colored(color, msg) :
# 
# Path: mod/verb.py
# def import_verbs_from(proj_name, proj_dir, verb_dir) :
# def import_verbs(fips_dir, proj_dir) :
# 
# Path: mod/dep.py
# def get_imports(fips_dir, proj_dir) :
# def get_exports(proj_dir) :
# def get_policy(proj_dir, policy) :
# def _rec_get_all_imports_exports(fips_dir, proj_dir, result) :
# def get_all_imports_exports(fips_dir, proj_dir) :
# def _rec_fetch_imports(fips_dir, proj_dir, handled) :
# def fetch_imports(fips_dir, proj_dir) :
# def gather_imports(fips_dir, proj_dir) :
# def write_imports(fips_dir, proj_dir, cfg_name, imported) :
# def gather_and_write_imports(fips_dir, proj_dir, cfg_name) :
# def check_imports(fips_dir, proj_dir) :
# def check_local_changes(fips_dir, proj_dir) :
# def _rec_update_imports(fips_dir, proj_dir, handled) :
# def update_imports(fips_dir, proj_dir):
# 
# Path: mod/tools/cmake.py
# def check_exists(fips_dir, major=2, minor=8) :
# def run_gen(cfg, fips_dir, project_dir, build_dir, local_build, toolchain_path, defines) :
# def run_build(fips_dir, target, build_type, build_dir, num_jobs=1, args=None) :
# def run_clean(fips_dir, build_dir) :


import platform,subprocess, os, yaml, json, inspect, tempfile, glob, shutil
from mod import util, log, verb, dep
from mod.tools import cmake
            os.remove(launch_path)

#-------------------------------------------------------------------------------
def write_workspace_settings(fips_dir, proj_dir, cfg, proj_settings):
    '''write the VSCode launch.json, tasks.json and
    c_cpp_properties.json files from cmake output files
    '''
    log.info("=== writing Visual Studio Code config files...")
    vscode_dir = proj_dir + '/.vscode'
    if not os.path.isdir(vscode_dir):
        os.makedirs(vscode_dir)
    # fetch all project dependencies
    success, impex = dep.get_all_imports_exports(fips_dir, proj_dir)
    if not success :
        log.warn("missing import project directories, please run 'fips fetch'")
    vscode_extensions = list_extensions()
    has_cmake_tools = any('vector-of-bool.cmake-tools' in ext for ext in vscode_extensions)
    remove_vscode_tasks_launch_files(fips_dir, proj_dir, impex, cfg)
    write_tasks_json(fips_dir, proj_dir, vscode_dir, cfg)
    write_launch_json(fips_dir, proj_dir, vscode_dir, cfg, proj_settings)
    if has_cmake_tools:
        write_cmake_tools_settings(fips_dir, proj_dir, vscode_dir, cfg)
    else:
        write_c_cpp_properties_json(fips_dir, proj_dir, impex, cfg)
    write_code_workspace_file(fips_dir, proj_dir, impex, cfg)

#-------------------------------------------------------------------------------
def cleanup(fips_dir, proj_dir):
    '''goes through all dependencies and deletes the .vscode directory'''
    # fetch all project dependencies

# Path: mod/util.py
# def fix_path(path) :
# def get_workspace_dir(fips_dir) :
# def get_project_dir(fips_dir, proj_name) :
# def get_build_root_dir(fips_dir, proj_name):
# def get_deploy_root_dir(fips_dir, proj_name):
# def get_build_dir(fips_dir, proj_name, cfg) :
# def get_deploy_dir(fips_dir, proj_name, cfg) :
# def get_fips_dir(proj_dir, name):
# def get_configs_dir(proj_dir):
# def get_verbs_dir(proj_dir):
# def get_generators_dir(proj_dir):
# def get_toolchains_dir(proj_dir):
# def get_giturl_from_url(url) :
# def get_gitbranch_from_url(url) :
# def get_project_name_from_url(url) :
# def get_project_name_from_dir(proj_dir) :
# def load_fips_yml(proj_dir) :
# def lookup_target_cwd(proj_dir, target) :
# def is_valid_project_dir(proj_dir) :
# def ensure_valid_project_dir(proj_dir) :
# def is_git_url(url) :
# def confirm(question) :
# def url_download_hook(count, block_size, total_size) :
# def get_host_platform() :
# def get_cfg_target_list(fips_dir, proj_dir, cfg):
# def get_cfg_headersdirs_by_target(fips_dir, proj_dir, cfg):
# def get_cfg_defines_by_target(fips_dir, proj_dir, cfg):
# def get_num_cpucores():
# 
# Path: mod/log.py
# RED = '\033[1;31m'
# GREEN = '\033[1;32m'
# YELLOW = '\033[1;33m'
# BLUE = '\033[1;36m'
# DEF = '\033[0;0m'
# def error(msg, fatal=True) :
# def warn(msg) :
# def ok(item, status) :
# def failed(item, status) :
# def optional(item, status) :
# def info(msg) :
# def colored(color, msg) :
# 
# Path: mod/verb.py
# def import_verbs_from(proj_name, proj_dir, verb_dir) :
# def import_verbs(fips_dir, proj_dir) :
# 
# Path: mod/dep.py
# def get_imports(fips_dir, proj_dir) :
# def get_exports(proj_dir) :
# def get_policy(proj_dir, policy) :
# def _rec_get_all_imports_exports(fips_dir, proj_dir, result) :
# def get_all_imports_exports(fips_dir, proj_dir) :
# def _rec_fetch_imports(fips_dir, proj_dir, handled) :
# def fetch_imports(fips_dir, proj_dir) :
# def gather_imports(fips_dir, proj_dir) :
# def write_imports(fips_dir, proj_dir, cfg_name, imported) :
# def gather_and_write_imports(fips_dir, proj_dir, cfg_name) :
# def check_imports(fips_dir, proj_dir) :
# def check_local_changes(fips_dir, proj_dir) :
# def _rec_update_imports(fips_dir, proj_dir, handled) :
# def update_imports(fips_dir, proj_dir):
# 
# Path: mod/tools/cmake.py
# def check_exists(fips_dir, major=2, minor=8) :
# def run_gen(cfg, fips_dir, project_dir, build_dir, local_build, toolchain_path, defines) :
# def run_build(fips_dir, target, build_type, build_dir, num_jobs=1, args=None) :
# def run_clean(fips_dir, build_dir) :


# Path: mod/tools/vscode.py
import platform,subprocess, os, yaml, json, inspect, tempfile, glob, shutil
from mod import util, log, verb, dep
from mod.tools import cmake

            os.remove(launch_path)

#-------------------------------------------------------------------------------
def write_workspace_settings(fips_dir, proj_dir, cfg, proj_settings):
    '''write the VSCode launch.json, tasks.json and
    c_cpp_properties.json files from cmake output files
    '''
    log.info("=== writing Visual Studio Code config files...")
    vscode_dir = proj_dir + '/.vscode'
    if not os.path.isdir(vscode_dir):
        os.makedirs(vscode_dir)
    # fetch all project dependencies
    success, impex = dep.get_all_imports_exports(fips_dir, proj_dir)
    if not success :
        log.warn("missing import project directories, please run 'fips fetch'")
    vscode_extensions = list_extensions()
    has_cmake_tools = any('vector-of-bool.cmake-tools' in ext for ext in vscode_extensions)
    remove_vscode_tasks_launch_files(fips_dir, proj_dir, impex, cfg)
    write_tasks_json(fips_dir, proj_dir, vscode_dir, cfg)
    write_launch_json(fips_dir, proj_dir, vscode_dir, cfg, proj_settings)
    if has_cmake_tools:
        write_cmake_tools_settings(fips_dir, proj_dir, vscode_dir, cfg)
    else:
        write_c_cpp_properties_json(fips_dir, proj_dir, impex, cfg)
    write_code_workspace_file(fips_dir, proj_dir, impex, cfg)

#-------------------------------------------------------------------------------
def cleanup(fips_dir, proj_dir):
    '''goes through all dependencies and deletes the .vscode directory'''
    # fetch all project dependencies

    success, impex = dep.get_all_imports_exports(fips_dir, proj_dir)