diff --git a/modules/android/_preload.lua b/modules/android/_preload.lua index f14162fcfa..b3e3521b8c 100644 --- a/modules/android/_preload.lua +++ b/modules/android/_preload.lua @@ -65,6 +65,7 @@ "3.5", "3.6", "3.8", + "5.0", }, } diff --git a/modules/android/tests/_tests.lua b/modules/android/tests/_tests.lua index 63fb41ed2c..ed92cf27a3 100644 --- a/modules/android/tests/_tests.lua +++ b/modules/android/tests/_tests.lua @@ -3,4 +3,5 @@ require ("android") return { "test_android_files.lua", "test_android_project.lua", + "test_config_props.lua" } diff --git a/modules/android/tests/test_android_project.lua b/modules/android/tests/test_android_project.lua index de96fbcdd0..c247d81dc8 100644 --- a/modules/android/tests/test_android_project.lua +++ b/modules/android/tests/test_android_project.lua @@ -112,3 +112,18 @@ -std=c++1z %(AdditionalOptions) ]] end + + + function suite.precompiledHeader() + location "build" + pchheader "include/foo.h" + prepare() + test.capture [[ + + Use + ../include/foo.h + Disabled + Enabled + true +]] + end diff --git a/modules/android/tests/test_config_props.lua b/modules/android/tests/test_config_props.lua new file mode 100644 index 0000000000..5ab5c6c237 --- /dev/null +++ b/modules/android/tests/test_config_props.lua @@ -0,0 +1,73 @@ + local p = premake + local suite = test.declare("android_config_props") + local vc2010 = p.vstudio.vc2010 + local project = p.project + + +-- +-- Setup +-- + + local wks, prj + + function suite.setup() + p.action.set("vs2015") + wks, prj = test.createWorkspace() + end + + local function prepare() + system "android" + local cfg = test.getconfig(prj, "Debug") + vc2010.configurationProperties(cfg) + end + + +-- +-- Check the structure with the default project values. +-- + + function suite.structureIsCorrect_onDefaultValues() + prepare() + test.capture [[ + + Application + false + Unicode + + ]] + end + + +-- +-- Check the configuration type for different architectures. +-- + + function suite.architecture_ARM() + architecture "ARM" + prepare() + test.capture [[ + + Application + false + Unicode + + ]] + end + +-- +-- Check toolchainversion +-- + + function suite.toolchainversion_clang_5_0() + toolchainversion '5.0' + prepare() + test.capture [[ + + Application + false + Unicode + Clang_5_0 + + ]] + end + diff --git a/modules/android/vsandroid_vcxproj.lua b/modules/android/vsandroid_vcxproj.lua index 298e1e6919..754eb94a57 100644 --- a/modules/android/vsandroid_vcxproj.lua +++ b/modules/android/vsandroid_vcxproj.lua @@ -142,26 +142,27 @@ if _ACTION >= "vs2015" then local gcc_map = { - ["_"] = "GCC_4_9", -- default ["4.6"] = "GCC_4_6", ["4.8"] = "GCC_4_8", ["4.9"] = "GCC_4_9", } local clang_map = { - ["_"] = "Clang_3_8", -- default ["3.4"] = "Clang_3_4", ["3.5"] = "Clang_3_5", ["3.6"] = "Clang_3_6", ["3.8"] = "Clang_3_8", + ["5.0"] = "Clang_5_0", } - local map = iif(cfg.toolset == "gcc", gcc_map, clang_map) - local ts = map[cfg.toolchainversion or "_"] - if ts == nil then - p.error('Invalid toolchainversion for the selected toolset (%s).', cfg.toolset or "clang") - end + if cfg.toolchainversion ~= nil then + local map = iif(cfg.toolset == "gcc", gcc_map, clang_map) + local ts = map[cfg.toolchainversion] + if ts == nil then + p.error('Invalid toolchainversion for the selected toolset (%s).', cfg.toolset or "clang") + end - _p(2, "%s", ts) + vc2010.element("PlatformToolset", nil, ts) + end else local archMap = { arm = "armv5te", -- should arm5 be default? vs-android thinks so... @@ -278,6 +279,12 @@ if cfg.system == p.ANDROID then local opts = cfg.buildoptions + if cfg.disablewarnings and #cfg.disablewarnings > 0 then + for _, warning in ipairs(cfg.disablewarnings) do + table.insert(opts, '-Wno-'..warning) + end + end + local cpp_langmap = { ["C++17"] = "-std=c++1z", ["gnu++17"] = "-std=gnu++1z", @@ -314,7 +321,7 @@ premake.override(vc2010, "exceptionHandling", function(oldfn, cfg, condition) if cfg.system == p.ANDROID then -- Note: Android defaults to 'off' - if cfg.exceptionhandling then + if cfg.exceptionhandling and cfg.exceptionhandling ~= premake.OFF then if _ACTION >= "vs2015" then vc2010.element("ExceptionHandling", condition, "Enabled") else @@ -329,7 +336,7 @@ premake.override(vc2010, "runtimeTypeInfo", function(oldfn, cfg, condition) if cfg.system == premake.ANDROID then -- Note: Android defaults to 'off' - if cfg.rtti then + if cfg.rtti and cfg.rtti ~= premake.OFF then vc2010.element("RuntimeTypeInfo", condition, "true") end else @@ -337,6 +344,13 @@ end end) + premake.override(vc2010, "precompiledHeaderFile", function(oldfn, fileName, cfg) + if cfg.system == premake.ANDROID then + vc2010.element("PrecompiledHeaderFile", nil, "%s", path.rebase(fileName, cfg.basedir, cfg.location)) + else + oldfn(fileName, cfg) + end + end) -- -- Extend Link. diff --git a/modules/vstudio/vs2010_vcxproj.lua b/modules/vstudio/vs2010_vcxproj.lua index 740497d781..d96a021233 100644 --- a/modules/vstudio/vs2010_vcxproj.lua +++ b/modules/vstudio/vs2010_vcxproj.lua @@ -2263,6 +2263,9 @@ end end + function m.precompiledHeaderFile(fileName, cfg) + m.element("PrecompiledHeaderFile", nil, "%s", fileName) + end function m.precompiledHeader(cfg, condition) local prjcfg, filecfg = p.config.normalize(cfg) @@ -2275,7 +2278,7 @@ else if not prjcfg.flags.NoPCH and prjcfg.pchheader then m.element("PrecompiledHeader", nil, "Use") - m.element("PrecompiledHeaderFile", nil, "%s", prjcfg.pchheader) + m.precompiledHeaderFile(prjcfg.pchheader, prjcfg) else m.element("PrecompiledHeader", nil, "NotUsing") end