Skip to content

Commit

Permalink
Integrate Linux support for Visual Studio as part of the vstudio modu…
Browse files Browse the repository at this point in the history
…le (#2124)

* Integrate Linux support for Visual Studio as part of the vstudio module

* Add documentation for the new Linux apis

* Fixed cppdialect mappings

* Add more information to incorrect toolchainversion message

* Fix whitespace

* Add documentation for toolchainversion Linux variants

* Use lowercase for toolchainversion

* Change to longer name

* Trim down the functions that Linux supports

* Add Linux apis to the sidebar

* Fix incorrect indentation from the web editor

* Restore original formatting

* Specify that the API is only valid from beta 3 onward
  • Loading branch information
redorav authored Dec 9, 2023
1 parent e3855de commit 897b646
Show file tree
Hide file tree
Showing 10 changed files with 559 additions and 46 deletions.
25 changes: 9 additions & 16 deletions modules/android/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@
api.addAllowed("flags", { "Thumb" })
api.addAllowed("kind", p.PACKAGING)

api.addAllowed("toolchainversion", {
"4.6", -- NDK GCC versions
"4.8",
"4.9",
"3.4", -- NDK clang versions
"3.5",
"3.6",
"3.8",
"5.0", })

premake.action._list["vs2015"].valid_kinds = table.join(premake.action._list["vs2015"].valid_kinds, { p.PACKAGING })
premake.action._list["vs2017"].valid_kinds = table.join(premake.action._list["vs2017"].valid_kinds, { p.PACKAGING })
Expand Down Expand Up @@ -54,22 +63,6 @@
kind = "integer",
}

api.register {
name = "toolchainversion",
scope = "config",
kind = "string",
allowed = {
"4.6", -- NDK GCC versions
"4.8",
"4.9",
"3.4", -- NDK clang versions
"3.5",
"3.6",
"3.8",
"5.0",
},
}

api.register {
name = "stl",
scope = "config",
Expand Down
42 changes: 42 additions & 0 deletions modules/vstudio/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,48 @@
tokens = true,
}

p.api.register {
name = "toolchainversion",
scope = "config",
kind = "string",
allowed = {}
}

--
-- Register Linux properties
--

p.api.addAllowed("toolchainversion", { "remote", "wsl", "wsl2" })

-- Directory in the remote machine where our files will be copied before compilation
p.api.register {
name = "remoterootdir",
scope = "config",
kind = "string",
}

-- Relative per-project directory. Set to empty for the entire project to be copied as is
-- Should default to empty really for the more seamless experience
p.api.register {
name = "remoteprojectrelativedir",
scope = "config",
kind = "string",
}

-- Directory in the remote machine where the build is deployed
-- Only applies to WSL projects
p.api.register {
name = "remotedeploydir",
scope = "config",
kind = "string",
}

p.api.register {
name = "remoteprojectdir",
scope = "config",
kind = "string",
}

--
-- Decide when the full module should be loaded.
--
Expand Down
6 changes: 6 additions & 0 deletions modules/vstudio/tests/vc2010/test_globals.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ end
test.capture [[
<PropertyGroup Label="Globals">
<ProjectGuid>{42B5DBC6-AE1F-903D-F75D-41E363076E92}</ProjectGuid>
<Keyword>Linux</Keyword>
<RootNamespace>MyProject</RootNamespace>
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
<ApplicationType>Linux</ApplicationType>
<TargetLinuxPlatform>Generic</TargetLinuxPlatform>
<ApplicationTypeRevision>1.0</ApplicationTypeRevision>
</PropertyGroup>
]]
end
Expand Down
Loading

5 comments on commit 897b646

@Pantong51
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Using x86 for linux builds defaults to WIN32

@redorav
Copy link
Collaborator Author

@redorav redorav commented on 897b646 Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Using x86 for linux builds defaults to WIN32

Just tried it and you're right, it's due to these lines. Shouldn't be hard to come up with a proper solution. Not sure why this remapping is needed, someone with a bit more knowledge should be able to chime in

if win32 and isnative and arch == "x86" then
	arch = "Win32"
end

@Pantong51
Copy link

@Pantong51 Pantong51 commented on 897b646 Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also noting, which may be an issue from the above Win32. That my additional includes get .lib added on after the .a(links { "static.a" } shows static.a.lib

There are also a lot of other issues i'm not sure if is a premake issue or wsl issue.

Copying files, you need to rebuild to get new files on wsl
Not finding libs and having to manually copy them
Not getting correct paths when linking to other premake projects
targetdir and objdir are just fully ignored

My situation is a large existing project. As such cannot share much. If needed i can create a demo project in the future that shows these issues

@redorav
Copy link
Collaborator Author

@redorav redorav commented on 897b646 Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good way to test that would be to recreate a similar (simpler) setup in VS native and see what's missing from the Premake generated one. Another good test, if it's possible for you, is to test it with x64? I never experienced the x86 issue because I don't compile for 32-bit platforms, so that one's on me. I'll see if I can fix it this weekend

@redorav
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be working now

Please sign in to comment.