Application of Vs2012 in Linux development (6): Rewriting the build process of the Makefile project

Source: Internet
Author: User

The compilation process for MSBuild is actually defined by a series of targets files, and when we perform build, batch build, and cleanup commands in the IDE, VS finds the corresponding task for those commands and executes it, let's analyze the process one at a time.

When you perform a build operation, MSBuild executes a task called "Build", which is defined in the targets file:

< Target

Name= "Build"

Condition= " ' $ (_invalidconfigurationwarning) '! = ' true ' "

dependsontargets= "$ (builddependson)"

Returns= "@ (Managedtargetpath); @ (Winmdfullpath)" >

< ItemGroup >

< Managedtargetpath Include =" $ (TargetPath) " Condition =" ' $ (managedassembly) ' = = ' true ' "/>

</ ItemGroup >

</ Target >

Here the BuildDependsOn is defined as:

< BuildDependsOn >

_prepareforbuild;

$ (buildsteps);

Afterbuild;

Finalizebuildstatus;

</ BuildDependsOn >

Expanding the Buildsteps:

< buildsteps Condition =" ' $ (buildsteps) ' = = ' ">

Resolvereferences;

Prepareforbuild;

Initializebuildstatus;

Buildgeneratesources;

Buildcompile;

Buildlink;

</ buildsteps >

This means that MSBuild will perform these tasks in turn:

_prepareforbuild;

Resolvereferences;

Prepareforbuild;

Initializebuildstatus;

Buildgeneratesources;

Buildcompile;

Buildlink;

Afterbuild;

Finalizebuildstatus;

But when our project was compiled with Makefile, we didn't have to let MSBuild control the whole process, because the process was already done in makefile, and we just had to reload the build as a task.

< Target

Name= "Build"

Condition= " ' $ (gnuprojecttype) ' = = ' UBoot ' or ' $ (gnuprojecttype) ' = = ' Linuxkernel ' or ' $ (gnuprojecttype) ' = = ' Linuxmakeapp ' "

>

< Embedlinuxmaketask

TargetName= "Build"

projectdir= "$ (projectdir)"

hostip= "$ (host_ip)"

hostuser= "$ (host_user)"

hostpasswd= "$ (host_passwd)"

Python2= "$ (python2_exe)"

pythonfile= "$ (pythonfile)"

/>

</ Target >

Of course, you need to tell Msbuild,embedlinuxmaketask where this task is before this:

< UsingTask TaskName =" Embedlinuxmaketask " assemblyfile =" EmbedLinux.dll "/>

This way, when compiling uboot, kernels, or applications that use Makefile, MSBuild will automate the task of Embedlinuxmaketask defined in EmbedLinux.dll!!

In the implementation of this task, we will execute the script specified by Pythonfile and redirect the output of this script to the Compile Information Output window of vs. This script is part of the project file and needs to be done with the compile and error message conversion functions. The SSH login operation is a generic operation that is placed in the implementation code of the task.

The Embedlinuxmaketask execution process is:

? Load Python2.exe

? Write environment variables in VS in Python

? Defining the behavior of the default compilation and information transformations

? Loads the specified compilation script in the project, overwriting the default behavior

? Start a logon operation

? Performs a compile operation to complete the conversion of the error message during the compilation process

? Returns the result of make

Application of Vs2012 in Linux development (6): Rewriting the build process of the Makefile project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.