def create_data(self):
        """
        Create the data and convert each part of "vcxproj" project

        """

        # Write variables
        variables = ProjectVariables(self.data)
        variables.add_project_variables()

        files = ProjectFiles(self.data)
        files.collects_source_files()
        variables.add_cmake_project(files.language)
        variables.add_default_target()

        # Write Output Variables
        variables.add_cmake_output_directories()
        variables.write_project_messages()

        # Add includes files & directories
        if self.data['includecmake'] or self.data['include']:
            title = get_title('Includes', 'Include files and directories')
            self.data['cmake'].write(title)
        # Include ".cmake" file
        if self.data['includecmake']:
            files.add_include_cmake(self.data['includecmake'])
        # Write Include Directories
        depends = Dependencies(self.data)
        if self.data['include']:
            depends.write_include_dir()
        else:
            message('Include Directories is not set.', '')

        # Write Dependencies
        depends.write_dependencies()

        # Add additional code
        if self.data['additional'] is not None:
            files.add_additional_code(self.data['additional'])

        # Write and add Files
        files.write_source_files()
        if files.sources:
            files.add_target_artefact()
            # Write Flags
            all_flags = Flags(self.data)
            all_flags.write_flags()
            # Write Macro
            all_flags.write_defines_and_flags()

        # Link with other dependencies
        title = get_title('Link & Dependencies',
                          'Add project dependencies and Link to project')
        self.data['cmake'].write(title)
        depends.add_dependencies()
        depends.link_dependencies()
    def test_link_dependencies(self):
        """Link Dependencies"""

        self.data_test['cmake'] = get_cmake_lists('./')
        under_test = Dependencies(self.data_test)

        under_test.link_dependencies()
        self.data_test['cmake'].close()

        cmakelists_test = open('CMakeLists.txt', 'r')

        self.assertTrue('target_link_libraries(${PROJECT_NAME}' in cmakelists_test.read())

        cmakelists_test.close()
    def test_link_dependencies(self):
        """Link Dependencies"""

        self.data_test['cmake'] = get_cmake_lists('./')
        under_test = Dependencies(self.data_test)

        under_test.link_dependencies()
        self.data_test['cmake'].close()

        cmakelists_test = open('CMakeLists.txt')

        self.assertTrue(
            'target_link_libraries(${PROJECT_NAME}' in cmakelists_test.read())

        cmakelists_test.close()
    def test_write_include_dir(self):
        """Write Include Dirs"""

        self.data_test['cmake'] = get_cmake_lists('./')
        under_test = Dependencies(self.data_test)

        under_test.write_include_dir()
        self.data_test['cmake'].close()

        cmakelists_test = open('CMakeLists.txt')

        self.assertTrue(
            'include_directories(../../../external/g3log/latest/src)' in
            cmakelists_test.read())

        cmakelists_test.close()
    def test_write_include_dir(self):
        """Write Include Dirs"""

        self.data_test['cmake'] = get_cmake_lists('./')
        under_test = Dependencies(self.data_test)

        under_test.write_include_dir()
        self.data_test['cmake'].close()

        cmakelists_test = open('CMakeLists.txt', 'r')

        self.assertTrue(
            'include_directories(../../../external/g3log/latest/src)' in cmakelists_test.read()
        )

        cmakelists_test.close()
    def test_init_dependencies(self):
        """Initialize Dependencies"""

        under_test = Dependencies(self.data_test)

        self.assertTrue(under_test.cmake)
        self.assertTrue(under_test.tree)
        self.assertTrue(under_test.ns)
        self.assertFalse(under_test.custom_dependencies)
Example #7
0
    def create_data(self):
        """
        Create the data and convert each part of vcxproj project

        """

        # Write variables
        variables = ProjectVariables(self.data)
        variables.add_project_variables()
        variables.add_outputs_variables()

        files = ProjectFiles(self.data)
        files.write_files_variables()
        variables.add_cmake_project(files.language)
        variables.add_default_target()

        # Write Macro
        define_and_write_macro(self.data)

        # Write Output Variables
        variables.add_artefact_target_outputs()

        # Write Include Directories
        depends = Dependencies(self.data)
        if self.data['includes']:
            depends.write_include_dir()
        else:
            send('Include Directories is not set.', '')

        # Write Dependencies
        depends.write_dependencies()

        # Add additional code or not
        if self.data['additional_code'] is not None:
            files.add_additional_code(self.data['additional_code'])

        # Write Flags
        all_flags = Flags(self.data)
        all_flags.write_flags()

        # Write and add Files
        files.write_source_files()
        files.add_target_artefact()

        # Link with other dependencies
        depends.link_dependencies()
    def test_write_dependencies(self):
        """Write Dependencies"""

        self.data_test['cmake'] = get_cmake_lists('./')
        under_test = Dependencies(self.data_test)

        # Add dependencies from ".vcxproj"
        under_test.write_dependencies()
        self.data_test['cmake'].close()

        cmakelists_test = open('CMakeLists.txt')
        content_test = cmakelists_test.read()

        print(content_test)
        self.assertTrue('add_subdirectory("${G3LOGGER_DIR}"' in content_test)
        self.assertTrue(
            'link_directories(${DEPENDENCIES_DIR}/g3log)' in content_test)

        cmakelists_test.close()

        # Add dependencies from "parameters"
        dependencies = ['external/zlib/cmake/', '../../external/g3log/cmake/']
        self.data_test['dependencies'] = dependencies
        self.data_test['cmake'] = get_cmake_lists('./')
        under_test = Dependencies(self.data_test)

        under_test.write_dependencies()
        self.data_test['cmake'].close()

        cmakelists_test = open('CMakeLists.txt')
        content_test = cmakelists_test.read()

        self.assertTrue(
            'add_subdirectory(external/zlib/cmake/ ${CMAKE_BINARY_DIR}/lib1)'
            in content_test)
        self.assertTrue(
            'add_subdirectory(../../external/g3log/cmake/ ${CMAKE_BINARY_DIR}/lib2)'
            in content_test)
        self.assertTrue(
            'link_directories(${DEPENDENCIES_DIR}/g3log)' in content_test)

        cmakelists_test.close()
Example #9
0
    def create_data(self):
        """
        Create the data and convert each part of "vcxproj" project

        """

        # Write variables
        variables = ProjectVariables(self.data)
        variables.add_project_variables()
        variables.add_outputs_variables()

        files = ProjectFiles(self.data)
        files.write_files_variables()
        variables.add_cmake_project(files.language)
        variables.add_default_target()

        # Write Macro
        define_and_write_macro(self.data)

        # Write Output Variables
        variables.add_artefact_target_outputs()

        # Write Include Directories
        depends = Dependencies(self.data)
        if self.data['includes']:
            depends.write_include_dir()
        else:
            send('Include Directories is not set.', '')

        # Write Dependencies
        depends.write_dependencies()

        # Add additional code or not
        if self.data['additional_code'] is not None:
            files.add_additional_code(self.data['additional_code'])

        # Write Flags
        all_flags = Flags(self.data)
        all_flags.write_flags()

        # Write and add Files
        files.write_source_files()
        files.add_target_artefact()

        # Link with other dependencies
        depends.link_dependencies()
Example #10
0
    def test_write_dependencies(self):
        """Write Dependencies"""

        self.data_test['cmake'] = get_cmake_lists('./')
        under_test = Dependencies(self.data_test)

        under_test.write_dependencies()
        self.data_test['cmake'].close()

        cmakelists_test = open('CMakeLists.txt', 'r')
        content_test = cmakelists_test.read()

        self.assertTrue(
            'add_subdirectory(platform/cmake/g3log ${CMAKE_BINARY_DIR}/g3log'
            in content_test)
        self.assertTrue(
            'add_subdirectory(platform/cmake/zlib ${CMAKE_BINARY_DIR}/zlib' in
            content_test)

        cmakelists_test.close()

        dependencies = ['external/zlib/cmake/', '../../external/g3log/cmake/']
        self.data_test['dependencies'] = dependencies
        self.data_test['cmake'] = get_cmake_lists('./')
        under_test = Dependencies(self.data_test)

        under_test.write_dependencies()
        self.data_test['cmake'].close()

        cmakelists_test = open('CMakeLists.txt', 'r')
        content_test = cmakelists_test.read()

        self.assertTrue(
            'add_subdirectory(external/zlib/cmake/ ${CMAKE_BINARY_DIR}/lib1)'
            in content_test)
        self.assertTrue(
            'add_subdirectory(../../external/g3log/cmake/ ${CMAKE_BINARY_DIR}/lib2)'
            in content_test)

        cmakelists_test.close()
    def test_write_dependencies(self):
        """Write Dependencies"""

        self.data_test['cmake'] = get_cmake_lists('./')
        under_test = Dependencies(self.data_test)

        under_test.write_dependencies()
        self.data_test['cmake'].close()

        cmakelists_test = open('CMakeLists.txt', 'r')
        content_test = cmakelists_test.read()

        self.assertTrue(
            'add_subdirectory(platform/cmake/g3log ${CMAKE_BINARY_DIR}/g3log' in content_test)
        self.assertTrue(
            'add_subdirectory(platform/cmake/zlib ${CMAKE_BINARY_DIR}/zlib' in content_test)

        cmakelists_test.close()

        dependencies = ['external/zlib/cmake/', '../../external/g3log/cmake/']
        self.data_test['dependencies'] = dependencies
        self.data_test['cmake'] = get_cmake_lists('./')
        under_test = Dependencies(self.data_test)

        under_test.write_dependencies()
        self.data_test['cmake'].close()

        cmakelists_test = open('CMakeLists.txt', 'r')
        content_test = cmakelists_test.read()

        self.assertTrue(
            'add_subdirectory(external/zlib/cmake/ ${CMAKE_BINARY_DIR}/lib1)' in content_test)
        self.assertTrue(
            'add_subdirectory(../../external/g3log/cmake/ ${CMAKE_BINARY_DIR}/lib2)' in content_test)

        cmakelists_test.close()