Example #1
0
	def setUp(self):
		self._sln_file = 'test/fixtures/simple2012/Win32Project1/Win32Project1.sln'
		self._abs_sln_file = sln2gyp.normpath(os.path.abspath(self._sln_file))
		self._abs_sln_dir = sln2gyp.normpath(os.path.dirname(self._abs_sln_file))

		self._solution = sln2gyp.Solution(self._sln_file)
Example #2
0
	def test_parse_vs2012_project_test(self):
		self.assertEqual(sln2gyp.normpath(os.path.dirname(self._abs_sln_file)), sln2gyp.normpath(self._solution.solution_dir))
		self.assertEqual(self._abs_sln_file, self._solution.solution_file)

		# assert Solution#configurations
		def assert_configurations():
			configurations = self._solution.configurations
			self.assertEqual(2, len(configurations))
			self.assertEqual('Debug', configurations[0].configuration())
			self.assertEqual('Win32', configurations[0].platform())
			self.assertEqual('Release', configurations[1].configuration())
			self.assertEqual('Win32', configurations[1].platform())
		assert_configurations()

		# assert Solution#projects
		def assert_projects():
			self.assertEqual(1, len(self._solution.projects))

			# assert Solution#projects()[0]
			project = self._solution.projects[0]
			def assert_project():
				expected_project_dir = self._abs_sln_dir + '/Win32Project1'
				self.assertEqual(expected_project_dir, project.project_dir)

				expected_project_file = expected_project_dir + '/Win32Project1.vcxproj'
				self.assertEqual(expected_project_file, project.project_file)

				self.assertEqual('Win32Project1', project.name)
				self.assertEqual('{D5FE8C9E-25D9-43C1-A4E8-DE7ECBF2F02F}', project.guid)
				self.assertEqual('4.0', project.tools_version)

				def assert_options_debug():
					debug = sln2gyp.Configuration.create_from_string('Debug|Win32')

					link_options = project.link_options.get(debug)
					compile_options = project.compile_options.get(debug)
					project_options = project.project_options.get(debug)
					properties = project.properties.get(debug)

					self.assertEqual('Windows', link_options['SubSystem'])

					self.assertEqual('Disabled', compile_options['Optimization'])
					self.assertEqual(['WIN32', '_DEBUG', '_WINDOWS', '%(PreprocessorDefinitions)'], compile_options['PreprocessorDefinitions'])
					self.assertEqual('false', compile_options['SDLCheck'])
					self.assertEqual(['..\depend'], compile_options['AdditionalIncludeDirectories'])

					self.assertEqual('v110', project_options['PlatformToolset'])
					self.assertEqual('true', project_options['UseDebugLibraries'])
					self.assertEqual('Unicode', project_options['CharacterSet'])

					self.assertEqual('true', properties['LinkIncremental'])

					self.assertEqual('stdafx.cpp', project.precompiled_source(debug))
				assert_options_debug()

				def assert_options_release():
					release = sln2gyp.Configuration.create_from_string('Release|Win32')

					link_options = project.link_options.get(release)
					compile_options = project.compile_options.get(release)
					project_options = project.project_options.get(release)
					properties = project.properties.get(release)

					self.assertEqual('Windows', link_options['SubSystem'])

					self.assertEqual('MaxSpeed', compile_options['Optimization'])
					self.assertEqual(['WIN32', 'NDEBUG', '_WINDOWS', '%(PreprocessorDefinitions)'], compile_options['PreprocessorDefinitions'])
					self.assertEqual('true', compile_options['SDLCheck'])
					self.assertEqual(['..\depend'], compile_options['AdditionalIncludeDirectories'])

					self.assertEqual('v110', project_options['PlatformToolset'])
					self.assertEqual('false', project_options['UseDebugLibraries'])
					self.assertEqual('Unicode', project_options['CharacterSet'])

					self.assertEqual('false', properties['LinkIncremental'])

					self.assertEqual('stdafx.cpp', project.precompiled_source(release))
				assert_options_release()
			assert_project()

			def assert_sources():
				source_list = project.sources

				self.assertEqual(6, len(source_list))
				self.assertEqual('stdafx.cpp', source_list[0])
				self.assertEqual('Win32Project1.cpp', source_list[1])
				self.assertEqual('Resource.h', source_list[2])
				self.assertEqual('stdafx.h', source_list[3])
				self.assertEqual('targetver.h', source_list[4])
				self.assertEqual('Win32Project1.h', source_list[5])
			assert_sources()

			def assert_configurations():
				configurations = project.configurations
				self.assertEqual(2, len(configurations))

				first = configurations[0]
				self.assertEqual('Debug', first.configuration())
				self.assertEqual('Win32', first.platform())

				second = configurations[1]
				self.assertEqual('Release', second.configuration())
				self.assertEqual('Win32', second.platform())
			assert_configurations()

			def assert_type():
				options = project.project_options

				debug = sln2gyp.Configuration('Debug', 'Win32')
				self.assertEqual('Application', options.get(debug)['ConfigurationType'])

				release = sln2gyp.Configuration('Release', 'Win32')
				self.assertEqual('Application', options.get(release)['ConfigurationType'])
			assert_type()
		assert_projects()