Click here to Skip to main content
15,888,579 members
Articles / Programming Languages / VBScript
Tip/Trick

Automatically Translate makefile C/C++ Project for Visual Studio

Rate me:
Please Sign up or sign in to vote.
5.00/5 (19 votes)
25 Feb 2015CPOL2 min read 71.5K   5.1K   23   10
A tool for translating C/C++ makefile projects in Visual Studio compatible ones

Introduction

How many times did you imagine to handle that opensource, makefile project with your favourite IDE, but due the project size started to translate it by hand resulting in a boring and time consuming activity? Well, I imagined it too. Actually, I have on my development PC lots of such projects, and some are really complicated to handle (like a complete new network stack in the linux kernel).

After some time searching on the internet, I did not find anything which was comfortable or free to use, and I decided to write my own utility to handle this particular problem.

Visual Studio IDE comes with a particular project, called Makefile project, which allows to use the IDE functionalities while building your source with an external build system. What I did was just some basic reverse engineering on the Makefile project Visual Studio index files to realize how it was handled by the IDE. Once I got the general vision on how the sources and filters were organized, I just wrote this very basic tool which does all the dirty work for you.

This tool is a beta script, so maybe that it does not cover all the possible makefile project types. Luckily source code is included, so feel free to modify them to better adapt to your wishes.

How the Tool Works

The tool is a simple script which uses Windows Script Host to perform its action. It will collect information from the selected folder(and all sub folders) and organize them in a Visual Studio Makefile compatible format.
At the beginning of the file, there are just 2 variables to fill in order to make it work:

  • root: The root folder under which the tool will scan for known/interesting file.
  • name: The project name. This name will be used to name the project files and the project itself.

Note that the project file will be created under the root folder and the file references will be local to root location. If you move the projects file, then the editor will not be able to open them in Solution Explorer.

The script will maintain the root folder structure format for both headers and sources files. The script has be embedded with enough comments to make you able to modify it (just using Notepad, for example). Feel free to personalize it in order to include other files you wish to use in your Visual Studio IDE.

Using the Tool

The tool, as it is, only needs to start a shell (Powershell or Command Prompt) and invoke it as follows:

cscript.exe vscreate.vbs

History

  • 01/28/2015 - Initial commit of the tool (C# language)
  • 02/25/2015 - Tool translated in VBScript scripting language; compiling with .NET is no longer required
  • 02/27/2015 - Resolved bug which caused empties folders to not be evaluated as filters

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Italy Italy
I'm a Software Engineer with deep and extended knowledge in Computer Networks and low level environments as kernels and drivers. My core competencies are C/C++ and Assembly programming languages, in both user- and kernel-space, together with an problem-solving oriented mindset and huge imagination to develop alternative approach to deal with them.

Comments and Discussions

 
PraiseVery Nice Script Pin
Chandan_srivastava8-Jul-21 1:43
Chandan_srivastava8-Jul-21 1:43 
GeneralRe: Very Nice Script Pin
Kewin Rausch8-Jul-21 6:04
professionalKewin Rausch8-Jul-21 6:04 
PraiseAnother Vote of Five Pin
Laurie Stearn20-Apr-18 19:19
Laurie Stearn20-Apr-18 19:19 
GeneralMy vote of 5 Pin
gchen210131-Aug-16 21:31
gchen210131-Aug-16 21:31 
GeneralRe: My vote of 5 Pin
Kewin Rausch17-Sep-16 7:14
professionalKewin Rausch17-Sep-16 7:14 
QuestionConverted solution cannot be compiled... Pin
will785-Jul-15 23:03
will785-Jul-15 23:03 
AnswerRe: Converted solution cannot be compiled... Pin
Kewin Rausch12-Jul-15 22:57
professionalKewin Rausch12-Jul-15 22:57 
I guess you have to fill the settings of the Project regarding the compiler you're going to use with your Solution. By default I left those field empties, so if you compile VS can't find a suitable compiler.

Should be enough to download a compiler (MinGw for example) and set the right path in order to reach it.
QuestionGreat, but... Pin
tweber20127-Jun-15 11:07
tweber20127-Jun-15 11:07 
AnswerRe: Great, but... Pin
Kewin Rausch9-Jun-15 3:49
professionalKewin Rausch9-Jun-15 3:49 
GeneralRe: Great, but... Pin
tweber20129-Jun-15 7:42
tweber20129-Jun-15 7:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.