def set_path_and_name_from_node(context, node_name, value, path_property, name_property): """ Common routine for evaluating path and name from node text """ file_path_value = value.strip() if not file_path_value: return file_path_value = replace_vs_vars_with_cmake_vars( context, file_path_value) file_path_value = set_native_slash(file_path_value) path, name = get_dir_name_with_vars(context, file_path_value) result_name = replace_vs_vars_with_cmake_vars(context, name) result_path = cleaning_output(context, path) result_path = check_for_relative_in_path(context, result_path) message(context, '{} directory = {}'.format(node_name, result_path), '') message(context, '{} name = {}'.format(node_name, result_name), '') context.settings[context.current_setting][path_property] = [ result_path ] context.settings[context.current_setting][name_property] = [ result_name ]
def __parse_sln_projects_data(context, sln_text, solution_folders, sln_projects_data): """ Parse section with information about project at *.sln file :param context: context from input file :type context: Context :param sln_text: :param solution_folders: :param projects_data: :return: """ p = re.compile( r'(Project.*\s=\s\"(.*)\",\s\"(.*)\",.*({.*\})(?:.|\n)*?EndProject(?!Section))' ) for project_data_match in p.findall(sln_text): path = set_native_slash(project_data_match[2]) guid = project_data_match[3] _, ext = os.path.splitext(os.path.basename(path)) if 'proj' not in ext: solution_folders[guid] = path continue sln_projects_data[guid] = VSSolutionConverter.__parse_project_data( context, project_data_match, path )
def __parse_targets_file_of_nuget_package(context, targets_file_path): """ Parse *.targets files :param context: :param targets_file_path: :return: """ ext_properties = [] if not targets_file_path: return ext_properties targets_file = get_xml_data(context, targets_file_path) if targets_file is None: message( context, "Can't open {} file for package properties searching. Download nupkg " "and rerun converter again".format(targets_file_path), 'warn1') return ext_properties property_page_schema_nodes = targets_file['tree'] \ .xpath('//ns:ItemGroup/ns:PropertyPageSchema', namespaces=targets_file['ns']) if property_page_schema_nodes: for property_page_schema_node in property_page_schema_nodes: xml_schema_path = property_page_schema_node.get('Include') xml_schema_path = set_native_slash(xml_schema_path) xml_schema_path = xml_schema_path.replace( '$(MSBuildThisFileDirectory)', os.path.dirname(targets_file_path) + '/') xml_schema_file = get_xml_data( context, os.path.normpath(xml_schema_path)) if xml_schema_file: ext_property_nodes = xml_schema_file['tree'] \ .xpath('//ns:EnumProperty', namespaces=xml_schema_file['ns']) for ext_property_node in ext_property_nodes: ext_properties.append(ext_property_node.get('Name')) # next is just additional ugly trick for nuget if not ext_properties: ext_property_nodes = targets_file['tree'] \ .xpath('//ns:PropertyGroup' '[@Label="Default initializers for properties"]/*', namespaces=targets_file['ns']) for ext_property_node in ext_property_nodes: ext_properties.append( re.sub(r'{.*\}', '', ext_property_node.tag)) return ext_properties
def search_file_path(context, xml_file): """ Util function for checking file in path. """ xml_file = set_native_slash(xml_file) found_xml_file = get_actual_filename(context, xml_file) if found_xml_file is None: message(context, '{} file not exists. '.format(xml_file), 'error') return None if found_xml_file != xml_file: message(context, 'file reference probably has wrong case {}'.format(xml_file), 'warn4') return found_xml_file
def set_target_dependency_packages(context, attr_name, attr_value, ext_targets): """ Collects paths of mentioned *.targets files at context.import_projects """ del attr_name, attr_value for import_project_node in ext_targets: targets_file_path = import_project_node.get('Project') if targets_file_path is None: continue drive, _ = os.path.splitdrive(targets_file_path) if not drive: # targets_file_path is not absolute mount_point = get_mount_point(context.vcxproj_path) targets_file_path = set_native_slash( os.path.join(mount_point, targets_file_path)) targets_file_path = os.path.normpath(targets_file_path) context.import_projects.append(targets_file_path)