Commits

Manu Evans  committed f3ca01e Draft

Added Android support to Visual Studio projects via VS-Android

  • Participants
  • Parent commits f7048ed

Comments (0)

Files changed (9)

File src/_manifest.lua

 		"actions/vstudio/vs2010_vcxproj.lua",
 		"actions/vstudio/vs2010_vcxproj_user.lua",
 		"actions/vstudio/vs2010_vcxproj_filters.lua",
+		"actions/vstudio/vsandroid.lua",
 	
 		-- Xcode action
 		"actions/xcode/_xcode.lua",

File src/actions/vstudio/_vstudio.lua

 --
 
 	vstudio.vs200x_architectures = {
-		x64     = "x64",
-		xbox360 = "Xbox 360",
+		x64       = "x64",
+		xbox360   = "Xbox 360",
+		vsandroid = "Android",
 	}
 	
 	vstudio.vs2010_architectures = {
 		local arch
 		if _ACTION >= "vs2010" then
 			arch = vstudio.vs2010_architectures[cfg.architecture] or
-			       vstudio.vs2010_architectures[cfg.system]
+			       vstudio.vs2010_architectures[cfg.system] or
+			       vstudio.vs2010_architectures[cfg.toolset]
 		end
 		
 		arch = arch or vstudio.vs200x_architectures[cfg.architecture] or
-		       vstudio.vs200x_architectures[cfg.system] or "Win32"
-		
+		       vstudio.vs200x_architectures[cfg.system] or
+		       vstudio.vs200x_architectures[cfg.toolset] or "Win32"
+
 		return arch
 	end
 
 		x64     = "x64",
 		PS3     = "PS3",
 		Xbox360 = "Xbox 360",
+		Android = "Android",
 	}
 
 	

File src/actions/vstudio/vs2005_solution.lua

 					local slnplatform = vstudio.platform(slncfg)
 					local prjplatform = vstudio.projectplatform(prjcfg)
 					local architecture = vstudio.architecture(prjcfg)
-					
+
 					_p(2,'{%s}.%s|%s.ActiveCfg = %s|%s', prj.uuid, slncfg.buildcfg, slnplatform, prjplatform, architecture)
 					_p(2,'{%s}.%s|%s.Build.0 = %s|%s', prj.uuid, slncfg.buildcfg, slnplatform, prjplatform, architecture)
+
+					if prjcfg.toolset == "vsandroid" then
+						vstudio.vsandroid.projectConfigurationPlatforms(prj, slncfg, prjcfg, slnplatform, prjplatform, architecture)
+					end
 				end
 			end		
 		end

File src/actions/vstudio/vs2010_vcxproj.lua

 		end
 
 		_p(2,'<CharacterSet>%s</CharacterSet>', iif(cfg.flags.Unicode, "Unicode", "MultiByte"))
+
+		if cfg.toolset == "vsandroid" then
+			vstudio.vsandroid.configurationProperties(cfg)
+		end
+
 		_p(1,'</PropertyGroup>')
 	end
 
 			_p(3,'<CompileAs>CompileAsC</CompileAs>')
 		end
 
+		if cfg.toolset == "vsandroid" then
+			vstudio.vsandroid.clCompile(cfg)
+		end
+
 		_p(2,'</ClCompile>')
 	end
 

File src/actions/vstudio/vsandroid.lua

+--
+-- vsandroid.lua
+-- VS-Android helpers for vs2010.
+-- Copyright (c) 2012 Manu Evans and the Premake project
+--
+
+	premake.vstudio.vsandroid = { }
+	local vsandroid = premake.vstudio.vsandroid
+	local vstudio = premake.vstudio
+	local project = premake5.project
+	local config = premake5.config
+
+
+--
+-- Write the VS-Android related ProjectConfigurationPlatforms section.
+--
+
+	function vsandroid.projectConfigurationPlatforms(prj, slncfg, prjcfg, slnplatform, prjplatform, architecture)
+
+		_p(2,'{%s}.%s|%s.Deploy.0 = %s|%s', prj.uuid, slncfg.buildcfg, slnplatform, prjplatform, architecture)
+
+	end
+
+--
+-- Write the VS-Android configuration property group.
+--
+
+	function vsandroid.configurationProperties(cfg)
+
+			-- TODO-ANDROID: we need a way to select the GCC toolchain version...
+
+			if cfg.architecture == "armv7" then
+				_p(2,'<PlatformToolset>arm-linux-androideabi-4.6</PlatformToolset>')
+				_p(2,'<AndroidArch>armv7-a</AndroidArch>')
+			elseif cfg.architecture == "armv5" then
+				_p(2,'<PlatformToolset>arm-linux-androideabi-4.6</PlatformToolset>')
+				_p(2,'<AndroidArch>armv5te</AndroidArch>')
+			elseif cfg.architecture == "x32" then
+				_p(2,'<PlatformToolset>x86-4.6</PlatformToolset>')
+				_p(2,'<AndroidArch>x86</AndroidArch>')
+			elseif cfg.architecture == "mips" then
+				_p(2,'<PlatformToolset>mipsel-linux-android-4.6</PlatformToolset>')
+				_p(2,'<AndroidArch>mips</AndroidArch>')
+			end
+
+--			_p(2,'<AndroidAPILevel>%s</AndroidAPILevel>', -- TODO-ANDROID: we need the android api level -- )
+
+	end
+
+
+--
+-- Write the VS-Android <ClCompile> compiler settings.
+--
+
+	function vsandroid.clCompile(cfg)
+
+		vsandroid.warnings(cfg)
+
+		_p(3,'<OptimizationLevel>%s</OptimizationLevel>', vsandroid.optimization(cfg))
+
+		if cfg.flags.NoExceptions then
+			_p(3,'<GccExceptionHandling>false</GccExceptionHandling>')
+		else
+			_p(3,'<GccExceptionHandling>true</GccExceptionHandling>')
+		end
+
+		if cfg.flags.Symbols then
+			_p(3,'<GenerateDebugInformation>true</GenerateDebugInformation>')
+		end
+
+	end
+
+
+--
+-- Convert Premake warning flags to Visual Studio equivalents.
+--
+
+	function vsandroid.warnings(cfg)
+
+		if cfg.flags.NoWarnings then
+			_p(3,'<Warnings>DisableAllWarnings</Warnings>')
+		elseif cfg.flags.ExtraWarnings then
+			_p(3,'<Warnings>AllWarnings</Warnings>')
+		end
+
+		-- Ohter warning blocks only when NoWarnings are not specified
+		if cfg.flags.NoWarnings then
+			return
+		end
+
+		if cfg.flags.FatalWarnings then
+			_p(3,'<WarningsAsErrors>true</WarningsAsErrors>')
+		end
+
+	end
+
+
+--
+-- Translate Premake's optimization flags to the VS-Android equivalents.
+--
+
+	function vsandroid.optimization(cfg)
+
+		local result = "O0"
+
+		for _, flag in ipairs(cfg.flags) do
+			if flag == "Optimize" then
+				result = "O3"
+			elseif flag == "OptimizeSize" then
+				result = "Os"
+			elseif flag == "OptimizeSpeed" then
+				result = "O3"
+			end
+		end
+
+		return result
+
+	end

File src/base/api.lua

 			"universal",
 			"x32",
 			"x64",
+			"armv5",
+			"armv7",
+			"mips",
+		},
+		aliases = {
+			x86 = 'x32',
+			x86_64 = 'x64',
 		},
 	}
 
 		scope = "config",
 		kind = "string",
 		allowed = {
-			"gcc"
+			"gcc",
+			"vsandroid"
 		},
 	}
 

File src/base/cmdline.lua

 			{ "universal64", "Mac OS X Universal, 64-bit only" },
 			{ "ps3",         "Playstation 3 (experimental)" },
 			{ "xbox360",     "Xbox 360 (experimental)" },
+			{ "android",     "Android (experimental)" },
 		}
 	}
 	

File src/base/globals.lua

 			iscrosscompiler = true,
 			namestyle       = "windows",
 		},
+		Android = 
+		{ 
+			cfgsuffix       = "android",
+			iscrosscompiler = true,
+		},
 	}
 
 

File src/base/premake.lua

 	premake.UNIVERSAL   = "universal"
 	premake.WINDOWEDAPP = "WindowedApp"
 	premake.WINDOWS     = "windows"
+	premake.ANDROID     = "android"
 	premake.X32         = "x32"
 	premake.X64         = "x64"
 	premake.XBOX360     = "xbox360"
+	premake.WII         = "wii"
 
 
 --
 		{
 			sharedlib = { prefix = "lib", extension = ".so" },
 			staticlib = { prefix = "lib", extension = ".a" },
-			
 		},
-		
+
 		macosx = 
 		{
 			sharedlib = { prefix = "lib", extension = ".dylib" },
 			staticlib = { prefix = "lib", extension = ".a" },
 		},
-		
+
+		wii = 
+		{
+			consoleapp  = { extension = ".elf" },
+			windowedapp = { extension = ".elf" },
+			sharedlib   = { prefix = "lib", extension = ".so" },
+			staticlib   = { prefix = "lib", extension = ".a" },
+		},
+
 		ps3 =
 		{
 			consoleapp = { extension = ".elf" },
 			sharedlib  = { prefix = "lib" },
 			staticlib  = { prefix = "lib", extension = ".a" },
 		},
-		
+
 		windows = 
 		{
 			consoleapp  = { extension = ".exe" },
 			windowedapp = { extension = ".exe" },
 			sharedlib   = { extension = ".dll" },
 			staticlib   = { extension = ".lib" },
+		},
+
+		android = 
+		{
+			consoleapp  = { extension = ".so" },
+			windowedapp = { extension = ".so" },
+			sharedlib   = { prefix = "lib", extension = ".so" },
+			staticlib   = { prefix = "lib", extension = ".a" },
 		}
 	}
-	
+
 	premake.systems.bsd     = premake.systems.linux
 	premake.systems.haiku   = premake.systems.linux
 	premake.systems.solaris = premake.systems.linux
-	premake.systems.wii     = premake.systems.linux
 	premake.systems.xbox360 = premake.systems.windows
-	
-	
+
+
 --
 -- Open a file for output, and call a function to actually do the writing.
 -- Used by the actions to generate solution and project files.