Ejemplo n.º 1
0
    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 parse(self, context):
     context.xml_data = get_xml_data(context, context.vcxproj_path)
     tree = context.xml_data['tree']
     root = tree.getroot()
     context.current_node = root
     self._parse_nodes(context, root)
     context.current_node = None
     context.files.apply_files_to_context(context)
     context.dependencies.set_target_references(context)
Ejemplo n.º 3
0
    def init_context(self, context, vs_project):
        """
        Initialize context for given VS project

        :param context: converter context
        :type context: Context
        :param vs_project: VS project path (.vcxproj)
        :type vs_project: str
        """

        context.vcxproj = get_xml_data(context, vs_project)
Ejemplo n.º 4
0
 def parse(self, context):
     filters_file = get_actual_filename(context,
                                        context.vcxproj_path + '.filters')
     if filters_file is not None:
         self.filters = get_xml_data(context, filters_file)
     tree = context.vcxproj['tree']
     root = tree.getroot()
     self._parse_nodes(context, root)
     context.flags.apply_flags_to_context(context)
     context.files.apply_files_to_context(context)
     context.dependencies.apply_target_dependency_packages(context)
     if not context.has_only_headers:
         context.flags.define_pch_cpp_file(context)
 def parse(self, context):
     context.xml_data = get_vcxproj_data(context, context.vcxproj_path)
     filters_file = get_actual_filename(context,
                                        context.vcxproj_path + '.filters')
     if filters_file is not None:
         self.filters = get_xml_data(context, filters_file)
     tree = context.xml_data['tree']
     root = tree.getroot()
     context.current_node = root
     self._parse_nodes(context, root)
     context.current_node = None
     context.flags.apply_flags_to_context(context)
     context.files.apply_files_to_context(context)
     context.dependencies.apply_target_dependency_packages(context)
     if context.sources:
         context.flags.define_pch_cpp_file(context)
Ejemplo n.º 6
0
    def __get_info_from_packages_config(context):
        """
        Parse packages.config file

        :param context:
        :return:
        """
        packages_xml = get_xml_data(
            context,
            os.path.join(os.path.dirname(context.vcxproj_path),
                         context.packages_config_path))
        if not packages_xml:
            return None
        extension = packages_xml['tree'].xpath('/packages/package')
        packages_xml_data = {}
        for ref in extension:
            package_id = ref.get('id')
            package_version = ref.get('version')
            id_version = '{}.{}'.format(package_id, package_version)
            packages_xml_data[id_version] = [package_id, package_version]
        return packages_xml_data