Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio Linux target improvement #211

Open
sammyfreg opened this issue Aug 16, 2022 · 5 comments
Open

Visual Studio Linux target improvement #211

sammyfreg opened this issue Aug 16, 2022 · 5 comments

Comments

@sammyfreg
Copy link

sammyfreg commented Aug 16, 2022

  • Visual Studio 2022 allows targeting a Linux platform as output.
  • Windows 10 allows to install a Linux distribution and run software in it, using WSL (Windows Subsystem for Linux).
  • Together, they allow to very conveniently test Linux build, directly from VS, using the platform Toolset ()

I saw that Sharpmake also allows us to target Linux in it Visual Studio projects, unfortunately, with only one 'Platform Toolset' (GCC for Remote Linux).

Would it be possible to add the new Linux Toolset to the project configuration? The WSL toolset would need to not have the '$(RemoteProjectDir)' added to the Output/Intermediate Directories.

image

@belkiss
Copy link
Contributor

belkiss commented Aug 16, 2022

Indeed, we could expose more options to allow this :)

Note that we mostly use cross-compilation with FastBuild and clang from windows when targeting linux, I hope to one day find time to write a sample in this repo to show how to do that :)

@sammyfreg
Copy link
Author

The depot https://github.com/sammyfreg/hello-world also generate a Linux solution using Sharpmake. I have been using this repo to test setuping my build system for a new project.

It seems like its not missing much to be able to specify a toolset targetting WSL. And using WSL seems much easier than setuping a remote Linux config.

@sammyfreg
Copy link
Author

I just noticed that we can already specify the Linux toolset on Sharpmake 0.21, using
conf.Options.Add(Linux.Options.General.VcPlatformToolset.WSL2_1_0);

I was still on 0.18, and that option wasn't available at the time. Now I only need to figure out some compiling error linked to path settings.

@sammyfreg
Copy link
Author

sammyfreg commented Aug 21, 2022

I have been unable to generate a working VS Linux project. It almost works but fails on the obj path.

Its giving me an error with a path badly joined with a 'home' directory and missing a '/'.
/mnt//~/projects/ExampleLibobj/linux_debugdefault

  • /mnt// + ~ ?
  • ExampleLibobj -> ExampleLib/obj

I have looked at the project file itself, and couldn't find any reference to the /mnt or ~ in its settings.

When comparing with a working minimal VS Linux project (created using 'new project' in VS) I have been unable to find any significant difference that would cause this path error.

  • New Project sets ToolsVersion="Current" while Sharpmake sets ToolsVersion="17.0"
  • New Project sets <PropertyGroup Label="Globals"><Keyword>Linux</Keyword> ... while Sharpmake does not

The one difference I could not explain for looking at the project file, was that the properties dialog was missing a few elements in the Sharpmake version :
SharpmakeLinux

Versus New Project version :
NewProjectLinux

However, adding the same properties values in the project file directly doesn't seem to fix the issue either. At this point, I believe I will set having a working VS Linux output, aside. If someone is interested in figuring this out, https://github.com/sammyfreg/hello-world contains all of the needed files (the sample is very simple, with only the bare minimum sources files)

@Sharlock93
Copy link
Contributor

Sharlock93 commented Feb 13, 2024

I just ran into this and its not fun. But I have managed to track the out of the box not working down to two problems, at least for me.

  1. is set to "", a newly created project in visual studio sets this to ~/projects, I do believe this becoming an option on the configuration would be great.
  2. RemoteProjectDir gets resolved using TargetPath
    image
    Changing this for both Library and None library output types to ProjectPath seems to do the trick.

I will try to put up a PR for this.

Edit: After testing this on a bigger project, a lot of different path problems showed up, it would require more than a single night, hopefully in the near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@belkiss @Sharlock93 @sammyfreg and others