microsoft / BuildXL

Microsoft Build Accelerator
MIT License
917 stars 146 forks source link

Better examples #1285

Open jyoungman19111 opened 3 years ago

jyoungman19111 commented 3 years ago

I would appreciate some better examples of an msbuild project with multiple modules. I have not been able to put together a C++ build based on the current documentation.

smera commented 3 years ago

In order to use MSBuild under BuildXL the code you are trying to build has to comply with MSBuild static graph. This is what allows BuildXL to discover the build graph before the build begins. My recommendation is to first try to build with plain MSBuild passing /graph. After that gives you a successful build, you can try to add BuildXL on top (BuildXL does not require that your MSBuild-based code builds with /isolate, but in that case you need to disable it with useLegacyProjectIsolation: true as part of the BuildXL MSBuild resolver configuration)

jyoungman19111 commented 3 years ago

Am I doing something wrong here? I am not invoking a build, just the graph.

MSBuild d:\Test\Code\src\oss\EventLog_Reg\eventlog_reg_VS2019.vcxproj -graph -isolate Microsoft (R) Build Engine version 16.10.0+4242f381a for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved.

Build started 5/26/2021 5:02:40 PM. Static graph loaded in 0.296 seconds: 1 nodes, 0 edges Project "d:\Test\Code\src\oss\EventLog_Reg\eventlog_reg_VS2019.vcxproj" on node 1 (Build target(s)). InitializeBuildStatus: Creating "win32\Debug\eventlog_reg.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified. ClCompile: All outputs are up-to-date. ResourceCompile: All outputs are up-to-date. Link: All outputs are up-to-date. eventlog_reg_VS2019.vcxproj -> v:\code\win32\Debug\bin\rtproglog_eventlog_reg.exe

From: Serge Mera @.> Sent: Wednesday, April 7, 2021 1:14 PM To: microsoft/BuildXL @.> Cc: Youngman, James [External/Artech] James.Youngman@Emerson.com; Author @.***> Subject: [EXTERNAL] Re: [microsoft/BuildXL] Better examples (#1285)

In order to use MSBuild under BuildXL the code you are trying to build has to comply with MSBuild static graph [github.com]https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_dotnet_msbuild_blob_main_documentation_specs_static-2Dgraph.md&d=DwMCaQ&c=jOURTkCZzT8tVB5xPEYIm3YJGoxoTaQsQPzPKJGaWbo&r=xP-E-JQ7-c0Vg44oT8cmSNA7y6J-0y9Y5QWOoO-wl1s&m=qk-JQ5mQvwkpfFHpvMMHf9WTa_qBZ_Z_BPRq2SKiCP8&s=mpZ-RupVOAen7aiQwKnTdlhHNlVIZVE56skqjjFrM18&e=. This is what allows BuildXL to discover the build graph before the build begins. My recommendation is to first try to build with plain MSBuild passing /graph. After that gives you a successful build, you can try to add BuildXL on top (BuildXL does not require that your MSBuild-based code builds with /isolate, but in that case you need to disable it with useLegacyProjectIsolation: true as part of the BuildXL MSBuild resolver configuration)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub [github.com]https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_microsoft_BuildXL_issues_1285-23issuecomment-2D815120920&d=DwMCaQ&c=jOURTkCZzT8tVB5xPEYIm3YJGoxoTaQsQPzPKJGaWbo&r=xP-E-JQ7-c0Vg44oT8cmSNA7y6J-0y9Y5QWOoO-wl1s&m=qk-JQ5mQvwkpfFHpvMMHf9WTa_qBZ_Z_BPRq2SKiCP8&s=Ox-GfIR-fx6St_ih7V9E3nkBoD2DScHM8TWk8S9uJ0s&e=, or unsubscribe [github.com]https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ASFSHAJSM5A6CC5Y5ZPXRG3THSOHDANCNFSM42NF2EWA&d=DwMCaQ&c=jOURTkCZzT8tVB5xPEYIm3YJGoxoTaQsQPzPKJGaWbo&r=xP-E-JQ7-c0Vg44oT8cmSNA7y6J-0y9Y5QWOoO-wl1s&m=qk-JQ5mQvwkpfFHpvMMHf9WTa_qBZ_Z_BPRq2SKiCP8&s=84kwDP2004VQQ-ZH9OTjuQgX7exY4Ygkh6BaRTurJvQ&e=.

smera commented 3 years ago

If you were able to build that single project with MSBuild, you should be able to achieve the equivalent with MSBuild under BuildXL. Using this as a base example: MSBuildHelloWorld, you can configure msBuildSearchLocations to point to the MSBuild folder you are using in your example above, and fileNameEntryPoints to point to that project file. The result should be equivalent, BuildXL will schedule an MSBuild call on the given project. The available configuration for the MSBuild resolver is here.

jyoungman19111 commented 3 years ago

This example does not seem to work for a system with multiple modules, at least I haven’t gotten it to work.

I have a 4 module build, A requires B and B requires C. So C and D should build in parallel, followed by B then A. Nothing happens.

Each module will build separately but not together.

Also I have a problem with the -graph option in msbuild, It generates a graph AND also runs a debug build every time.

Thanks for your help.

Jim

From: Serge Mera @.> Sent: Thursday, June 3, 2021 11:59 AM To: microsoft/BuildXL @.> Cc: Youngman, James [External/Artech] James.Youngman@Emerson.com; Author @.***> Subject: [EXTERNAL] Re: [microsoft/BuildXL] Better examples (#1285)

If you were able to build that single project with MSBuild, you should be able to achieve the equivalent with MSBuild under BuildXL. Using this as a base example: MSBuildHelloWorld [github.com]https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_microsoft_BuildXL_blob_master_Examples_MsBuildHelloWorld_config.bc&d=DwMCaQ&c=jOURTkCZzT8tVB5xPEYIm3YJGoxoTaQsQPzPKJGaWbo&r=xP-E-JQ7-c0Vg44oT8cmSNA7y6J-0y9Y5QWOoO-wl1s&m=dfUIGKkScU4h0ov119L8wyPw9QQNCPdK2akUOoTvU_w&s=qVIXcq5PKoWTgoci4uvL4iHLl4S-1wnJEovq72uW9iM&e=, you can configure msBuildSearchLocations to point to the MSBuild folder you are using in your example above, and fileNameEntryPoints to point to that project file. The result should be equivalent, BuildXL will schedule an MSBuild call on the given project. The available configuration for the MSBuild resolver is here [github.com]https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_microsoft_BuildXL_blob_master_Public_Sdk_Public_Prelude_Prelude.Configuration.Resolvers.dsc-23L152&d=DwMCaQ&c=jOURTkCZzT8tVB5xPEYIm3YJGoxoTaQsQPzPKJGaWbo&r=xP-E-JQ7-c0Vg44oT8cmSNA7y6J-0y9Y5QWOoO-wl1s&m=dfUIGKkScU4h0ov119L8wyPw9QQNCPdK2akUOoTvU_w&s=F9uJl5rPj-kI35F7nL2nmqAsGLBatg_yCh3P2ysNn78&e=.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub [github.com]https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_microsoft_BuildXL_issues_1285-23issuecomment-2D854030035&d=DwMCaQ&c=jOURTkCZzT8tVB5xPEYIm3YJGoxoTaQsQPzPKJGaWbo&r=xP-E-JQ7-c0Vg44oT8cmSNA7y6J-0y9Y5QWOoO-wl1s&m=dfUIGKkScU4h0ov119L8wyPw9QQNCPdK2akUOoTvU_w&s=6mVSEUWs28uxEDX5HYgLMsbYMvJpm9njSWXR5kBS9Co&e=, or unsubscribe [github.com]https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_ASFSHALA4RZ2LFO5TV4XHRTTQ6YD7ANCNFSM42NF2EWA&d=DwMCaQ&c=jOURTkCZzT8tVB5xPEYIm3YJGoxoTaQsQPzPKJGaWbo&r=xP-E-JQ7-c0Vg44oT8cmSNA7y6J-0y9Y5QWOoO-wl1s&m=dfUIGKkScU4h0ov119L8wyPw9QQNCPdK2akUOoTvU_w&s=Y2w-2thgRpfK_OfEN4fm-Na3UGskMg0FUzOuzMtOD1w&e=.

smera commented 3 years ago

What is a 'module' from your point of view? An MSBuild project?

For your question about the MSBuild behavior when passing '-graph', That option is using a statically computed graph for scheduling, so that it both generates the graph and build is by design. You may want to follow with the MSBuild team/docs for that.

My suggestion is 1) get to build that single project you showed above with msbuild + bxl. The result should be the same as doing it with msbuild alone. 2) get to a multi-project build, trying with msbuild first and then with msbuild + bxl.

If you get any failures, please feel free to share the logs here.

Thanks, Serge.