VSLinux bricklet documentation

Dmitry Fleytman edited this page Jun 11, 2015 · 32 revisions

Table of Contents

What is VSLinux

VSLinux is a solution for Linux code developers that prefer to use Microsoft Visual Studio as code editor. VSLinux provides means to generate Visual Studio project for arbitrary source code tree, initiate builds on remote Linux machines and analyze compilation errors produced by remote system exactly as if it was local build with Microsoft compiler.

VSLinux bricklet use cases

The VSLinux bricklet isn't intended to replace the existing Linux development tools which are good and mature enough we believe.

It's rather a way to allow Windows developers to feel comfortable while making a transition to Linux world.

The "VS for Linux" bricklet should help people used to Visual Studio (or using it due to some environment limitations) to start developing for Linux with no pain.

  • Developers/companies used to develop on Windows making transition/porting to Linux
They're afraid of Linux, console, vi, emacs and even Eclipse (as they have to learn it) and want to minimize the learning efforts to bring a project on time.
  • Developers/companies used to/want to use extended VS IDE abilities (Visual Assist and the like)
It's worth to say, MS Visual Studio is a good IDE. And it brings even more extended by 3rd party add-ons like Visual Assist. Indeed, other IDEs provide generally the same features set - although there are people like the way MS Visual Studio does it.
  • Developers/companies working simultaneously on Windows and Linux projects or projects consist of both Linux and Windows parts.
As there is no choice but use the MS Visual Studio for Windows, it could be pretty convenient to unify the development environment and use it for Linux as well.

Also, other IDEs implements the same "build-on-remote" functionality developers need and use. For example, Eclipse has the Remote System Explorer plugin does exactly the same. So we don't invent a wheel. Rather, we just bring the same functionality to another common IDE - MS Visual Studio.

Another use case is Linux code browsing and learning. Imagine, you're developing for the Windows but have to learn the code of a Linux project. Indeed, you have the LXR allowing you to browse through the source of vanilla Linux kernel. But what if you have to work with a customized kernel? BusyBox? Host APD? etc.

It becomes easy with the "VS for Linux" bricklet. Just download/clone/checkout the code to either Windows or Linux, create a project using our batch or makefile - voila! Now you just open the generated project with MS Visual Studio and browse the sources.

VSLinux bricklet concepts

  • VSLinux bricklet is a solution for those who want to write and build Linux code using Microsoft Visual Studio
  • VSLinux provides seamless integration of Visual Studio with remote Linux build server
  • Integration allows to use all Visual Studio editing features, standard build and error lists navigation tools
  • VSLinux does not contain Visual Studio plugins or extensions thus it may be used with any Visual Studio edition including free Express editions
  • VSLinux is not tied to some specific programming language or build system and may be used in variety of scenarios
  • VSLinux components integrated once into project and committed/pushed to repository, recent Visual Studio project created with one command on each clone/checkout

VSLinux usage scenario

  1. Development setup consists of two nodes:
    1. Development computer with Windows and Visual Studio installed
    2. Build computer with Linux installed
  2. Source tree resides on Linux machine and is exposed to the Windows Machine by the means of Samba server
  3. User runs VSLinux script (either locally on Windows machine or remotely on Linux machine via SSH) to generate Visual Studio Project file
  4. User opens generated project file in Visual Studio, project contains all source code files needed, all Visual Studio code editing features may be used exactly as if it was project generated by one of Visual Studio wizards
  5. Generated project file also contains custom build steps so when build initiated special VSLinux script runs on Windows Machine
  6. Windows script uses SSH to invoke its counterpart on Linux machine
  7. Linux script initiates project compilation, filters output and transforms it into format understood by Visual Studio
  8. Compilation output travels back to Visual Studio via Windows script and being parsed by standard error navigation tools

VSLinux bricklet components

  1. Script and data templates to create Visual Studio project file for arbitrary source tree
  2. Scripts that initiate build on remote Linux server and transform Linux compiler output into format understood by Visual Studio

Step-by-step guide on VSLinux bricklet integration

Install required components

Windows machine
  1. Install Perl interpreter on your Windows machine (tested with ActivePerl: http://www.activestate.com/activeperl)
  2. Install PuTTY package (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) on your Windows machine
  3. Put Plink to %WINDIR% (or some other folder in %PATH%)
Linux machine
  1. Install and configure sshd server
  2. Install and configure samba server

Setup public key authentication

  1. Connect once to your Linux machine using Plink/PuTTY with the SSH protocol to add it to list of known hosts (issue from Windows command line (cmd): plink [you_build_server_addr_or_name])
  2. Generate and import SSH key:
    1. On your Linux machine:
      1. change into the ~/.ssh directory (you may have to create this folder if it does not exist, verify that access mask for this folder in 700, i.e. run chmod 700 ~/.ssh)
      2. open the file ~/.ssh/authorized_keys with your favorite editor (you may have to create this file if this is the first key you have put in it).
    2. On your Windows machine:
      1. Launch PuTTYgen application
      2. Generate a SSH-2 RSA key with no key passphrase
      3. Add the content of PuTTYgen's "Public key for pasting into authorized_keys file" field to the ~/.ssh/authorized_keys file on build server.
      4. Verify that access mask for authorized_keys file is 400 (i.e. run chmod 400 ~/.ssh/authorized_keys).
      5. Save the private key to the file by pressing the "Save private key" data - let's say [your_path]\[your_key].ppk. Answer "Yes" to approve saving the key with no passphrase.

Prepare Linux build server

  1. Make your home folder (or other folder that will hold all the source code) accessible via Samba
  2. Define and export VSLINUX_MAP_ROOT environment variable in .bashrc (or similar) file and set it to absolute path of folder that will be mapped as network drive on Windows (~ in most cases)

Prepare Windows machine

  1. Map your home folder (or other folder that will hold all the source code) on Linux build server as network drive
  2. Define VSLINUX_SSH_KEY environment variable and set it to [your_path]\[your_key].ppk
  3. Define the VSLINUX_SSH_USER environment variable and set it to your Linux build server username (if it differs from Windows one only, case does matters).

Setup Project Generator

  1. Put bricklet folder VSLinux to project source tree root
  2. Edit file VSLinux/dnx_list_files.cfg to define which files have to appear in Visual Studio project
    1. See comments inside the file for full file syntax description
  3. Optionally customize set of Visual Studio build configurations being generated
    1. See file VSLinux/dnx_list_files.buildcfg for description of build configuration definition syntax
  4. Run make -f VSLinux/Makefile.template vcxproj on Linux or VSLinux/_make_vcxproj.bat on Windows to create Visual Studio project file
  5. Re-run project creation command each time you added files to source tree or just make a clean repository clone
  6. Enjoy VSLinux!

Future directions

  1. Create Visual Studio wizard that will perform integration and project creation automatically

Special cases

Using VSLinux to navigate Linux kernel source

Known issues

  1. Visual Studio does not see target system includes