Skip to content

Commit 7453c18

Browse files
committed
Normalize floatabi valid values, add tests
1 parent 5353206 commit 7453c18

File tree

5 files changed

+227
-17
lines changed

5 files changed

+227
-17
lines changed

modules/vstudio/_preload.lua

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,21 @@
655655
scope = "config",
656656
kind = "string",
657657
allowed = {
658-
"soft",
659-
"softfp",
660-
"hard",
658+
"Soft",
659+
"SoftFP",
660+
"Hard",
661661
},
662+
aliases = {
663+
[ "soft" ] = "Soft",
664+
[ "softfp" ] = "SoftFP",
665+
[ "hard" ] = "Hard",
666+
}
662667
}
663668

669+
p.api.deprecateAlias("floatabi", "soft", "Use `Soft` instead.")
670+
p.api.deprecateAlias("floatabi", "softfp", "Use `SoftFP` instead.")
671+
p.api.deprecateAlias("floatabi", "hard", "Use `Hard` instead.")
672+
664673
p.api.register {
665674
name = "androidapilevel",
666675
scope = "config",
@@ -718,8 +727,13 @@
718727
kind = "string"
719728
}
720729

730+
p.ARMv5 = "ARMv5"
731+
p.ARMv7 = "ARMv7"
732+
p.MIPS = "MIPS"
733+
p.MIPS64 = "MIPS64"
734+
721735
p.api.addAllowed("system", p.ANDROID)
722-
p.api.addAllowed("architecture", { "armv5", "armv7", "mips", "mips64" })
736+
p.api.addAllowed("architecture", { p.ARMv5, p.ARMv7, p.MIPS, p.MIPS64 })
723737
p.api.addAllowed("vectorextensions", { "NEON", "MXU" })
724738
p.api.addAllowed("exceptionhandling", {"UnwindTables"})
725739
p.api.addAllowed("kind", p.PACKAGING)
@@ -783,6 +797,19 @@
783797
runtimechecks("Default")
784798
end)
785799

800+
-- Deprecate lower case versions of some architectures for consistency
801+
p.api.addAliases("architecture", {
802+
[ "armv5" ] = p.ARMv5,
803+
[ "armv7" ] = p.ARMv7,
804+
[ "mips" ] = p.MIPS,
805+
[ "mips64" ] = p.MIPS64,
806+
})
807+
808+
p.api.deprecateAlias("architecture", "armv5", "Use `ARMv5` instead.")
809+
p.api.deprecateAlias("architecture", "armv7", "Use `ARMv7` instead.")
810+
p.api.deprecateAlias("architecture", "mips", "Use `MIPS` instead.")
811+
p.api.deprecateAlias("architecture", "mips64", "Use `MIPS64` instead.")
812+
786813
--
787814
-- Decide when the full module should be loaded.
788815
--

modules/vstudio/tests/_tests.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ return {
118118
-- Android projects
119119
"android/test_android_build_settings.lua",
120120
"android/test_android_files.lua",
121+
"android/test_android_floats.lua",
121122
"android/test_android_project.lua",
122123
"android/test_android_toolset.lua",
123124

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
--
2+
-- test_android_floats.lua
3+
-- Test Android float settings
4+
-- Author: Nick Clark
5+
-- Copyright (c) 2026 Jess Perkins and the Premake project
6+
--
7+
8+
local p = premake
9+
local suite = test.declare("test_android_floats")
10+
local vc2010 = p.vstudio.vc2010
11+
12+
--
13+
-- Setup
14+
--
15+
16+
local wks, prj
17+
18+
function suite.setup()
19+
p.action.set("vs2013")
20+
wks = test.createWorkspace()
21+
end
22+
23+
local function prepare()
24+
prj = test.getproject(wks, 1)
25+
system "android"
26+
local cfg = test.getconfig(prj, "Debug", platform)
27+
vc2010.androidAdditionalCompileOptions(cfg)
28+
vc2010.gccClangAdditionalCompileOptions(cfg)
29+
end
30+
31+
32+
--
33+
-- Test software floating point ABI on ARM
34+
--
35+
36+
37+
function suite.softFloatingPoint_ARM()
38+
floatabi "Soft"
39+
architecture "ARM"
40+
prepare()
41+
test.capture [[
42+
<AdditionalOptions>-mfloat-abi=soft %(AdditionalOptions)</AdditionalOptions>
43+
]]
44+
end
45+
46+
47+
--
48+
-- Test softfp floating point ABI on ARM
49+
--
50+
51+
52+
function suite.softfpFloatingPoint_ARM()
53+
floatabi "SoftFP"
54+
architecture "ARM"
55+
prepare()
56+
test.capture [[
57+
<AdditionalOptions>-mfpu=vfp -mfloat-abi=softfp %(AdditionalOptions)</AdditionalOptions>
58+
]]
59+
end
60+
61+
62+
--
63+
-- Test hard floating point ABI on ARM
64+
--
65+
66+
67+
function suite.hardFloatingPoint_ARM()
68+
floatabi "Hard"
69+
architecture "ARM"
70+
prepare()
71+
test.capture [[
72+
<AdditionalOptions>-mfpu=vfp -mfloat-abi=hard %(AdditionalOptions)</AdditionalOptions>
73+
]]
74+
end
75+
76+
77+
--
78+
-- Test software floating point ABI on ARMv7
79+
--
80+
81+
82+
function suite.softFloatingPoint_ARMv7()
83+
floatabi "Soft"
84+
architecture "ARMv7"
85+
prepare()
86+
test.capture [[
87+
<AdditionalOptions>-mfloat-abi=soft %(AdditionalOptions)</AdditionalOptions>
88+
]]
89+
end
90+
91+
92+
--
93+
-- Test softfp floating point ABI on ARMv7
94+
--
95+
96+
97+
function suite.softfpFloatingPoint_ARMv7()
98+
floatabi "SoftFP"
99+
architecture "ARMv7"
100+
prepare()
101+
test.capture [[
102+
<AdditionalOptions>-mfpu=vfpv3-d16 -mfloat-abi=softfp %(AdditionalOptions)</AdditionalOptions>
103+
]]
104+
105+
end
106+
107+
108+
--
109+
-- Test hard floating point ABI on ARMv7
110+
--
111+
112+
113+
function suite.hardFloatingPoint_ARMv7()
114+
floatabi "Hard"
115+
architecture "ARMv7"
116+
prepare()
117+
test.capture [[
118+
<AdditionalOptions>-mfpu=vfpv3-d16 -mfloat-abi=hard %(AdditionalOptions)</AdditionalOptions>
119+
]]
120+
end
121+
122+
123+
--
124+
-- Test soft floating point ABI on ARMv7 with Neon vector extensions
125+
--
126+
127+
128+
function suite.softFloatingPoint_ARMv7_Neon()
129+
floatabi "Soft"
130+
architecture "ARMv7"
131+
vectorextensions "Neon"
132+
prepare()
133+
test.capture [[
134+
<AdditionalOptions>-mfloat-abi=soft %(AdditionalOptions)</AdditionalOptions>
135+
]]
136+
end
137+
138+
139+
--
140+
-- Test softfp floating point ABI on ARMv7 with Neon vector extensions
141+
--
142+
143+
function suite.softfpFloatingPoint_ARMv7_Neon()
144+
floatabi "SoftFP"
145+
architecture "ARMv7"
146+
vectorextensions "Neon"
147+
prepare()
148+
test.capture [[
149+
<AdditionalOptions>-mfpu=neon -mfloat-abi=softfp %(AdditionalOptions)</AdditionalOptions>
150+
]]
151+
end
152+
153+
154+
--
155+
-- Test hard floating point ABI on ARMv7 with Neon vector extensions
156+
--
157+
158+
function suite.hardFloatingPoint_ARMv7_Neon()
159+
floatabi "Hard"
160+
architecture "ARMv7"
161+
vectorextensions "Neon"
162+
prepare()
163+
test.capture [[
164+
<AdditionalOptions>-mfpu=neon -mfloat-abi=hard %(AdditionalOptions)</AdditionalOptions>
165+
]]
166+
end
167+
168+
169+
--
170+
-- Test MIPS architecture with MXU vector extensions
171+
--
172+
173+
174+
function suite.mips_Mxu()
175+
floatabi "Soft"
176+
architecture "MIPS"
177+
vectorextensions "MXU"
178+
prepare()
179+
test.capture [[
180+
<AdditionalOptions>-mmxu %(AdditionalOptions)</AdditionalOptions>
181+
]]
182+
end

modules/vstudio/vs2010_vcxproj.lua

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4216,7 +4216,7 @@
42164216
return false
42174217
end
42184218

4219-
if not cfg.architecture or string.startswith(cfg.architecture, "arm") then
4219+
if not cfg.architecture or string.startswith(cfg.architecture, p.ARM) then
42204220
-- we might want to define the arch to generate better code
42214221
-- if not alreadyHas(cfg.buildoptions, "-march=") then
42224222
-- if cfg.architecture == "armv6" then
@@ -4227,22 +4227,22 @@
42274227
-- end
42284228

42294229
-- ARM has a comprehensive set of floating point options
4230-
if cfg.fpu ~= "Software" and cfg.floatabi ~= "soft" then
4230+
if cfg.fpu ~= "Software" and cfg.floatabi ~= "Soft" then
42314231

4232-
if cfg.architecture == "armv7" then
4232+
if cfg.architecture == p.ARMv7 then
42334233

42344234
-- armv7 always has VFP, may not have NEON
42354235

42364236
if not alreadyHas(cfg.buildoptions, "-mfpu=") then
42374237
if cfg.vectorextensions == "NEON" then
42384238
table.insert(cfg.buildoptions, "-mfpu=neon")
4239-
elseif cfg.fpu == "Hardware" or cfg.floatabi == "softfp" or cfg.floatabi == "hard" then
4239+
elseif cfg.fpu == "Hardware" or cfg.floatabi == "SoftFP" or cfg.floatabi == "Hard" then
42404240
table.insert(cfg.buildoptions, "-mfpu=vfpv3-d16") -- d16 is the lowest common denominator
42414241
end
42424242
end
42434243

42444244
if not alreadyHas(cfg.buildoptions, "-mfloat-abi=") then
4245-
if cfg.floatabi == "hard" then
4245+
if cfg.floatabi == "Hard" then
42464246
table.insert(cfg.buildoptions, "-mfloat-abi=hard")
42474247
else
42484248
-- Android should probably use softfp by default for compatibility
@@ -4255,22 +4255,22 @@
42554255
-- armv5/6 may not have VFP
42564256

42574257
if not alreadyHas(cfg.buildoptions, "-mfpu=") then
4258-
if cfg.fpu == "Hardware" or cfg.floatabi == "softfp" or cfg.floatabi == "hard" then
4258+
if cfg.fpu == "Hardware" or cfg.floatabi == "SoftFP" or cfg.floatabi == "Hard" then
42594259
table.insert(cfg.buildoptions, "-mfpu=vfp")
42604260
end
42614261
end
42624262

42634263
if not alreadyHas(cfg.buildoptions, "-mfloat-abi=") then
4264-
if cfg.floatabi == "softfp" then
4264+
if cfg.floatabi == "SoftFP" then
42654265
table.insert(cfg.buildoptions, "-mfloat-abi=softfp")
4266-
elseif cfg.floatabi == "hard" then
4266+
elseif cfg.floatabi == "Hard" then
42674267
table.insert(cfg.buildoptions, "-mfloat-abi=hard")
42684268
end
42694269
end
42704270

42714271
end
42724272

4273-
elseif cfg.floatabi == "soft" then
4273+
elseif cfg.floatabi == "Soft" then
42744274

42754275
table.insert(cfg.buildoptions, "-mfloat-abi=soft")
42764276

@@ -4282,7 +4282,7 @@
42824282
table.insert(cfg.buildoptions, "-mbig-endian")
42834283
end
42844284

4285-
elseif cfg.architecture == "mips" then
4285+
elseif cfg.architecture == p.MIPS then
42864286

42874287
-- TODO...
42884288

website/docs/floatabi.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ floatabi ("value")
1010

1111
| Value | Description |
1212
|-------|-------------|
13-
| soft | Compiler will generate software library calls for floating-point operations. |
14-
| softfp | Compiler will generate hardware floating-point instructions, but will still use software float calling conventions. |
15-
| hard | Compiler will generate floating-point instructions using FPU-specific calling conventions. |
13+
| Soft | Compiler will generate software library calls for floating-point operations. |
14+
| SoftFP | Compiler will generate hardware floating-point instructions, but will still use software float calling conventions. |
15+
| Hard | Compiler will generate floating-point instructions using FPU-specific calling conventions. |
1616

1717
## Applies To ###
1818

0 commit comments

Comments
 (0)