Skip to content

VSLinux bricklet documentation

dmitryfleytman edited this page May 25, 2012 · 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 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 bricklet integration

  1. Install required components
    1. 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%)
    2. Linux machine
      1. Install and configure sshd server
      2. Install and configure samba server
  2. Set up 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.
    3. 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)
    4. 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).
  3. Project Setup
    1. Put bricklet folder VSLinux to project source tree root
    2. Put contents of VSLinux/Makefile.template file into top-level Makefile
    3. 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
    4. Optionally edit file VSLinux/VS.vcxproj.template to define build clean and rebuild commands (if they differ from standard ones)
      1. NMakeBuildCommandLine defines command for Visual Studio "build project" action
      2. NMakeCleanCommandLine defines command for Visual Studio "clean project" action
      3. NMakeReBuildCommandLine defines command for Visual Studio "rebuild project" action
    5. Run make vcxproj on Linux or VSLinux/_make_vcxproj.bat on Windows to create Visual Studio project file
    6. Re-run project creation command each time you added files to source tree or just make a clean repository clone
    7. Optionally set of Visual Studio build configurations being generated may be customized
      1. See file VSLinux/dnx_list_files.buildcfg for description of build configuration definition syntax
      2. Project file must be recreated after configuration set changed
Clone this wiki locally