Skip to content

Commit

Permalink
improve program file for vsxmake #5642
Browse files Browse the repository at this point in the history
  • Loading branch information
waruqi committed Sep 23, 2024
1 parent 6295d86 commit 886cc71
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions xmake/plugins/project/vsxmake/getinfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ function main(outputdir, vsinfo)
-- init solution directory
vsinfo.solution_dir = path.absolute(path.join(outputdir, "vsxmake" .. vsinfo.vstudio_version))
vsinfo.programdir = _make_dirs(xmake.programdir())
vsinfo.programfile = _make_dirs(xmake.programfile())
vsinfo.projectdir = project.directory()
vsinfo.sln_projectfile = path.relative(project.rootfile(), vsinfo.solution_dir)
local projectfile = path.filename(project.rootfile())
Expand Down
3 changes: 3 additions & 0 deletions xmake/scripts/vsxmake/vsproj/Xmake.Defaults.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@

<PropertyGroup Label="XmakePathsResolve">
<_XmakeProgramDir>$(XmakeProgramDir)</_XmakeProgramDir>
<_XmakeProgramFile>$(XmakeProgramFile)</_XmakeProgramFile>
<_XmakeProjectDir>$(XmakeProjectDir)</_XmakeProjectDir>
<_XmakeScriptDir>$(XmakeScriptDir)</_XmakeScriptDir>

<!-- resolve if they are relative paths -->
<_XmakeProgramDir Condition="!$([System.IO.Path]::IsPathRooted('$(_XmakeProgramDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(_XmakeProgramDir)'))</_XmakeProgramDir>
<_XmakeProgramFile Condition="!$([System.IO.Path]::IsPathRooted('$(_XmakeProgramFile)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(_XmakeProgramFile)'))</_XmakeProgramFile>
<_XmakeProjectDir Condition="!$([System.IO.Path]::IsPathRooted('$(_XmakeProjectDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(_XmakeProjectDir)'))</_XmakeProjectDir>
<_XmakeScriptDir Condition="!$([System.IO.Path]::IsPathRooted('$(_XmakeScriptDir)'))">$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)\$(_XmakeScriptDir)'))</_XmakeScriptDir>

<!-- normalize paths -->
<XmakeProgramDir>$([System.IO.Path]::GetFullPath('$(_XmakeProgramDir)'))</XmakeProgramDir>
<XmakeProgramFile>$([System.IO.Path]::GetFullPath('$(_XmakeProgramFile)'))</XmakeProgramFile>
<XmakeProjectDir>$([System.IO.Path]::GetFullPath('$(_XmakeProjectDir)'))</XmakeProjectDir>
<XmakeScriptDir>$([System.IO.Path]::GetFullPath('$(_XmakeScriptDir)'))</XmakeScriptDir>
</PropertyGroup>
Expand Down
9 changes: 6 additions & 3 deletions xmake/scripts/vsxmake/vsproj/Xmake.targets
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

<!-- these paths resolved in Xmake.Default.props, just normalize -->
<XmakeProgramDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeProgramDir)/'))</XmakeProgramDirResolved>
<XmakeProgramFileResolved>$([System.IO.Path]::GetFullPath('$(XmakeProgramFile)/'))</XmakeProgramFileResolved>
<XmakeProjectDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeProjectDir)/'))</XmakeProjectDirResolved>
<XmakeScriptDirResolved>$([System.IO.Path]::GetFullPath('$(XmakeScriptDir)/'))</XmakeScriptDirResolved>
</PropertyGroup>
Expand Down Expand Up @@ -61,7 +62,7 @@
<_XmakeCommonFlags>$(_XmakeCommonFlags.Trim())</_XmakeCommonFlags>
<_XmakeTarget>"$(XmakeTarget.Trim())"</_XmakeTarget>

<_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramDirResolved)xmake.exe'))"</_XmakeExecutable>
<_XmakeExecutable>"$([System.IO.Path]::GetFullPath('$(XmakeProgramFileResolved)'))"</_XmakeExecutable>
<_XmakeEnv>
pushd $(XmakeProjectDirResolved)
set XMAKE_CONFIGDIR=$(XmakeConfigDirResolved.TrimEnd('\').TrimEnd('/'))
Expand All @@ -82,8 +83,8 @@
Text="File '$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).targets' not found" />
<Warning Condition="'$(XmakeCudaVersion)' != '' And !Exists('$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).props')"
Text="File '$(VCTargetsPath)\BuildCustomizations\CUDA $(XmakeCudaVersion).props' not found" />
<Error Condition="!Exists('$(XmakeProgramDirResolved)\xmake.exe')"
Text="xmake.exe not found at '$(XmakeProgramDirResolved)', please set XMAKE_PROGRAM_DIR in environments or XmakeProgramDir in vcxproj file" />
<Error Condition="!Exists('$(XmakeProgramFileResolved)')"
Text="xmake.exe not found at '$(XmakeProgramFileResolved)'" />
<Error Condition="'$(XmakeProjectFile)' == '' And !Exists('$(XmakeProjectDirResolved)\xmake.lua')"
Text="xmake.lua not found at '$(XmakeProjectDirResolved)', please set XmakeProjectDir in vcxproj file" />
<Error Condition="'$(XmakeProjectFile)' != '' And !Exists('$(XmakeProjectDirResolved)\$(XmakeProjectFile)')"
Expand Down Expand Up @@ -150,6 +151,7 @@ MSBuild Properties:
XmakeRunArgs: $(XmakeRunArgs)
Xmake Path:
XmakeProgramDir: $(XmakeProgramDir)
XmakeProgramFile: $(XmakeProgramFile)
XmakeProjectDir: $(XmakeProjectDir)
XmakeScriptDir: $(XmakeScriptDir)
XmakeBuilDir: $(XmakeBuilDir)
Expand All @@ -159,6 +161,7 @@ MSBuild Properties:
XmakeRunDir: $(XmakeRunDir)
Xmake Resolved Path:
XmakeProgramDir: $(XmakeProgramDirResolved)
XmakeProgramFile: $(XmakeProgramFileResolved)
XmakeProjectDir: $(XmakeProjectDirResolved)
XmakeScriptDir: $(XmakeScriptDirResolved)
XmakeBuilDir: $(XmakeBuilDirResolved)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<PropertyGroup Label="XmakeProgram">
<XmakeProgramDir Condition="'$(XmakeProgramDir)' == ''">$(XMAKE_PROGRAM_DIR)</XmakeProgramDir>
<XmakeProgramDir Condition="'$(XmakeProgramDir)' == ''">#programdir#</XmakeProgramDir>
<XmakeProgramFile Condition="'$(XmakeProgramFile)' == ''">$(XMAKE_PROGRAM_FILE)</XmakeProgramDir>
<XmakeProgramFile Condition="'$(XmakeProgramFile)' == ''">#programfile#</XmakeProgramFile>
</PropertyGroup>
<Import Project="$(XmakeProgramDir)\scripts\vsxmake\vsproj\Xmake.Defaults.props" />
#Import(XmakeConfig)#
Expand Down

0 comments on commit 886cc71

Please sign in to comment.