Skip to content

Commit 903b3aa

Browse files
authored
Fix targetdir and objdir for Linux and Android (premake#2464)
* Linux and Android don't assume that the path is relative to project dir when specifying targetdir which causes issues For consistency, apply to all platforms and fix unit tests * Add tests for absolute path
1 parent 574dd5e commit 903b3aa

File tree

9 files changed

+85
-53
lines changed

9 files changed

+85
-53
lines changed

modules/vstudio/tests/android/test_android_project.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@
158158
prepareOutputProperties()
159159
test.capture [[
160160
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
161-
<IntDir>obj\Debug\</IntDir>
161+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
162+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
162163
<TargetName>MyProject</TargetName>
163164
<TargetExt>
164165
</TargetExt>

modules/vstudio/tests/linux/test_linux_files.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ local vc2010 = p.vstudio.vc2010
5151
prepareOutputProperties()
5252
test.capture [[
5353
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
54-
<IntDir>obj\Debug\</IntDir>
54+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
55+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
5556
<TargetName>MyProject</TargetName>
5657
<TargetExt>
5758
</TargetExt>

modules/vstudio/tests/vc2010/test_config_props.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@
300300
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
301301
<ConfigurationType>Makefile</ConfigurationType>
302302
<UseDebugLibraries>false</UseDebugLibraries>
303-
<OutDir>bin\Debug\</OutDir>
304-
<IntDir>obj\Debug\</IntDir>
303+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
304+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
305305
</PropertyGroup>
306306
]]
307307
end
@@ -313,8 +313,8 @@
313313
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
314314
<ConfigurationType>Makefile</ConfigurationType>
315315
<UseDebugLibraries>false</UseDebugLibraries>
316-
<OutDir>bin\Debug\</OutDir>
317-
<IntDir>obj\Debug\</IntDir>
316+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
317+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
318318
</PropertyGroup>
319319
]]
320320
end

modules/vstudio/tests/vc2010/test_output_props.lua

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ function suite.onClangTidy()
3535
test.capture [[
3636
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
3737
<LinkIncremental>true</LinkIncremental>
38-
<OutDir>bin\Debug\</OutDir>
39-
<IntDir>obj\Debug\</IntDir>
38+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
39+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
4040
<TargetName>MyProject</TargetName>
4141
<TargetExt>.exe</TargetExt>
4242
</PropertyGroup>
@@ -53,8 +53,8 @@ function suite.onRunCodeAnalysis()
5353
test.capture [[
5454
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
5555
<LinkIncremental>true</LinkIncremental>
56-
<OutDir>bin\Debug\</OutDir>
57-
<IntDir>obj\Debug\</IntDir>
56+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
57+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
5858
<TargetName>MyProject</TargetName>
5959
<TargetExt>.exe</TargetExt>
6060
</PropertyGroup>
@@ -70,8 +70,8 @@ end
7070
test.capture [[
7171
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7272
<LinkIncremental>true</LinkIncremental>
73-
<OutDir>bin\Debug\</OutDir>
74-
<IntDir>obj\Debug\</IntDir>
73+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
74+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
7575
<TargetName>MyProject</TargetName>
7676
<TargetExt>.exe</TargetExt>
7777
</PropertyGroup>
@@ -104,7 +104,7 @@ end
104104
prepare()
105105
test.capture [[
106106
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
107-
<OutDir>bin\Debug\</OutDir>
107+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
108108
]]
109109
end
110110

@@ -131,7 +131,7 @@ end
131131
test.capture [[
132132
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
133133
<LinkIncremental>true</LinkIncremental>
134-
<OutDir>..\bin\</OutDir>
134+
<OutDir>$(ProjectDir)..\bin\</OutDir>
135135
]]
136136
end
137137

@@ -142,7 +142,17 @@ end
142142
test.capture [[
143143
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
144144
<LinkIncremental>true</LinkIncremental>
145-
<OutDir>..\bin\</OutDir>
145+
<OutDir>$(ProjectDir)..\bin\</OutDir>
146+
]]
147+
end
148+
149+
function suite.outDir_onTargetDirAbsolute()
150+
targetdir "C:/bin"
151+
prepare()
152+
test.capture [[
153+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
154+
<LinkIncremental>true</LinkIncremental>
155+
<OutDir>C:\bin\</OutDir>
146156
]]
147157
end
148158

@@ -156,8 +166,19 @@ end
156166
test.capture [[
157167
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
158168
<LinkIncremental>true</LinkIncremental>
159-
<OutDir>bin\Debug\</OutDir>
160-
<IntDir>..\tmp\Debug\</IntDir>
169+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
170+
<IntDir>$(ProjectDir)..\tmp\Debug\</IntDir>
171+
]]
172+
end
173+
174+
function suite.intDir_onTargetDirAbsolute()
175+
objdir "C:/tmp"
176+
prepare()
177+
test.capture [[
178+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
179+
<LinkIncremental>true</LinkIncremental>
180+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
181+
<IntDir>C:\tmp\Debug\</IntDir>
161182
]]
162183
end
163184

@@ -171,8 +192,8 @@ end
171192
test.capture [[
172193
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
173194
<LinkIncremental>true</LinkIncremental>
174-
<OutDir>bin\Debug\</OutDir>
175-
<IntDir>obj\Debug\</IntDir>
195+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
196+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
176197
<TargetName>MyTarget</TargetName>
177198
]]
178199
end
@@ -210,7 +231,7 @@ end
210231
test.capture [[
211232
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
212233
<LinkIncremental>true</LinkIncremental>
213-
<OutDir>bin\Debug\</OutDir>
234+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
214235
]]
215236
end
216237

@@ -225,8 +246,8 @@ end
225246
test.capture [[
226247
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
227248
<LinkIncremental>true</LinkIncremental>
228-
<OutDir>bin\Debug\</OutDir>
229-
<IntDir>obj\Debug\</IntDir>
249+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
250+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
230251
<TargetName>MyProject</TargetName>
231252
<TargetExt>.exe</TargetExt>
232253
<GenerateManifest>false</GenerateManifest>
@@ -244,8 +265,8 @@ end
244265
test.capture [[
245266
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
246267
<LinkIncremental>true</LinkIncremental>
247-
<OutDir>bin\Debug\</OutDir>
248-
<IntDir>obj\Debug\</IntDir>
268+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
269+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
249270
<TargetName>MyProject</TargetName>
250271
<TargetExt>
251272
</TargetExt>
@@ -265,8 +286,8 @@ end
265286
test.capture [[
266287
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
267288
<LinkIncremental>true</LinkIncremental>
268-
<OutDir>bin\Debug\</OutDir>
269-
<IntDir>obj\Debug\</IntDir>
289+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
290+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
270291
<TargetName>MyProject</TargetName>
271292
<TargetExt>.exe</TargetExt>
272293
<ExtensionsToDeleteOnClean>*.temp1;*.temp2;$(ExtensionsToDeleteOnClean)</ExtensionsToDeleteOnClean>
@@ -285,8 +306,8 @@ end
285306
test.capture [[
286307
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
287308
<LinkIncremental>true</LinkIncremental>
288-
<OutDir>bin\Debug\</OutDir>
289-
<IntDir>obj\Debug\</IntDir>
309+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
310+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
290311
<TargetName>MyProject</TargetName>
291312
<TargetExt>.exe</TargetExt>
292313
<IncludePath>$(DXSDK_DIR)\Include;$(IncludePath)</IncludePath>
@@ -300,8 +321,8 @@ end
300321
test.capture [[
301322
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
302323
<LinkIncremental>true</LinkIncremental>
303-
<OutDir>bin\Debug\</OutDir>
304-
<IntDir>obj\Debug\</IntDir>
324+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
325+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
305326
<TargetName>MyProject</TargetName>
306327
<TargetExt>.exe</TargetExt>
307328
<LibraryPath>$(DXSDK_DIR)\lib\x86;$(LibraryPath)</LibraryPath>
@@ -319,8 +340,8 @@ end
319340
test.capture [[
320341
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
321342
<LinkIncremental>true</LinkIncremental>
322-
<OutDir>bin\Debug\</OutDir>
323-
<IntDir>obj\Debug\</IntDir>
343+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
344+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
324345
<TargetName>MyProject</TargetName>
325346
<TargetExt>.exe</TargetExt>
326347
<ExecutablePath>$(ProjectDir)..\Include;$(ExecutablePath)</ExecutablePath>
@@ -334,8 +355,8 @@ end
334355
test.capture [[
335356
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
336357
<LinkIncremental>true</LinkIncremental>
337-
<OutDir>bin\Debug\</OutDir>
338-
<IntDir>obj\Debug\</IntDir>
358+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
359+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
339360
<TargetName>MyProject</TargetName>
340361
<TargetExt>.exe</TargetExt>
341362
<ExecutablePath>C:\Include;$(ExecutablePath)</ExecutablePath>

modules/vstudio/tests/vc2019/test_output_props.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ function suite.onClangTidy_Enabled()
3535
test.capture [[
3636
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
3737
<LinkIncremental>true</LinkIncremental>
38-
<OutDir>bin\Debug\</OutDir>
39-
<IntDir>obj\Debug\</IntDir>
38+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
39+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
4040
<TargetName>MyProject</TargetName>
4141
<TargetExt>.exe</TargetExt>
4242
<EnableClangTidyCodeAnalysis>true</EnableClangTidyCodeAnalysis>
@@ -54,8 +54,8 @@ function suite.onClangTidy_Disabled()
5454
test.capture [[
5555
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
5656
<LinkIncremental>true</LinkIncremental>
57-
<OutDir>bin\Debug\</OutDir>
58-
<IntDir>obj\Debug\</IntDir>
57+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
58+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
5959
<TargetName>MyProject</TargetName>
6060
<TargetExt>.exe</TargetExt>
6161
<EnableClangTidyCodeAnalysis>false</EnableClangTidyCodeAnalysis>
@@ -73,8 +73,8 @@ function suite.onRunCodeAnalysis_Enabled()
7373
test.capture [[
7474
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
7575
<LinkIncremental>true</LinkIncremental>
76-
<OutDir>bin\Debug\</OutDir>
77-
<IntDir>obj\Debug\</IntDir>
76+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
77+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
7878
<TargetName>MyProject</TargetName>
7979
<TargetExt>.exe</TargetExt>
8080
<RunCodeAnalysis>true</RunCodeAnalysis>
@@ -92,8 +92,8 @@ function suite.RunCodeAnalysis_Disabled()
9292
test.capture [[
9393
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
9494
<LinkIncremental>true</LinkIncremental>
95-
<OutDir>bin\Debug\</OutDir>
96-
<IntDir>obj\Debug\</IntDir>
95+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
96+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
9797
<TargetName>MyProject</TargetName>
9898
<TargetExt>.exe</TargetExt>
9999
<RunCodeAnalysis>false</RunCodeAnalysis>

modules/vstudio/tests/vc2019/test_toolset_settings.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ function suite.onAllModulesPublicOn()
109109
test.capture [[
110110
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
111111
<LinkIncremental>true</LinkIncremental>
112-
<OutDir>bin\Debug\</OutDir>
113-
<IntDir>obj\Debug\</IntDir>
112+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
113+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
114114
<TargetName>MyProject</TargetName>
115115
<TargetExt>.exe</TargetExt>
116116
<AllProjectBMIsArePublic>true</AllProjectBMIsArePublic>
@@ -125,8 +125,8 @@ function suite.onAllModulesPublicOff()
125125
test.capture [[
126126
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
127127
<LinkIncremental>true</LinkIncremental>
128-
<OutDir>bin\Debug\</OutDir>
129-
<IntDir>obj\Debug\</IntDir>
128+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
129+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
130130
<TargetName>MyProject</TargetName>
131131
<TargetExt>.exe</TargetExt>
132132
<AllProjectBMIsArePublic>false</AllProjectBMIsArePublic>

modules/vstudio/tests/vc2022/test_output_props.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ function suite.onExternalIncludeDirs()
3535
test.capture [[
3636
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
3737
<LinkIncremental>true</LinkIncremental>
38-
<OutDir>bin\Debug\</OutDir>
39-
<IntDir>obj\Debug\</IntDir>
38+
<OutDir>$(ProjectDir)bin\Debug\</OutDir>
39+
<IntDir>$(ProjectDir)obj\Debug\</IntDir>
4040
<TargetName>MyProject</TargetName>
4141
<TargetExt>.exe</TargetExt>
4242
<ExternalIncludePath>src\include;$(ExternalIncludePath)</ExternalIncludePath>

modules/vstudio/vs2010_vcxproj.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@
393393
}
394394
else
395395
return {
396+
m.outDir,
396397
m.intDir,
397398
m.targetName,
398399
m.targetExt,
@@ -418,6 +419,7 @@
418419
}
419420
else
420421
return {
422+
m.outDir,
421423
m.intDir,
422424
m.targetName,
423425
m.targetExt,
@@ -2833,6 +2835,11 @@
28332835

28342836
function m.intDir(cfg)
28352837
local objdir = vstudio.path(cfg, cfg.objdir)
2838+
2839+
if not path.isabsolute(objdir) then
2840+
objdir = "$(ProjectDir)" .. objdir
2841+
end
2842+
28362843
m.element("IntDir", nil, "%s\\", objdir)
28372844
end
28382845

@@ -3079,7 +3086,13 @@
30793086

30803087
function m.outDir(cfg)
30813088
local outdir = vstudio.path(cfg, cfg.buildtarget.directory)
3089+
3090+
if not path.isabsolute(outdir) then
3091+
outdir = "$(ProjectDir)" .. outdir
3092+
end
3093+
30823094
m.element("OutDir", nil, "%s\\", outdir)
3095+
30833096
end
30843097

30853098

modules/vstudio/vs2015_androidproj.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116

117117
m.elements.outputProperties = function(cfg)
118118
return {
119-
m.androidOutDir,
119+
vc2010.outDir,
120120
vc2010.intDir,
121121
vc2010.targetName,
122122
}
@@ -136,10 +136,6 @@
136136
end
137137
end
138138

139-
function m.androidOutDir(cfg)
140-
vc2010.element("OutDir", nil, "%s\\", cfg.buildtarget.directory)
141-
end
142-
143139
--
144140
-- Write a configuration's item definition group, which contains all
145141
-- of the per-configuration compile and link settings.

0 commit comments

Comments
 (0)