From 799c07fc2e59535711717588612ba57fa8c64922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcelo=20Lynch=20=F0=9F=A7=89?= Date: Tue, 18 Oct 2022 22:08:02 +0000 Subject: [PATCH] Merged PR 684203: Add NinjaHelloWorld example --- .gitignore | 2 ++ Examples/NinjaHelloWorld/README.md | 8 ++++++++ Examples/NinjaHelloWorld/build.bat | 1 + Examples/NinjaHelloWorld/build.ps1 | 1 + Examples/NinjaHelloWorld/config.dsc | 13 +++++++++++++ Examples/NinjaHelloWorld/src/build.ninja | 13 +++++++++++++ Examples/NinjaHelloWorld/src/hello.txt | 1 + 7 files changed, 39 insertions(+) create mode 100644 Examples/NinjaHelloWorld/README.md create mode 100644 Examples/NinjaHelloWorld/build.bat create mode 100644 Examples/NinjaHelloWorld/build.ps1 create mode 100644 Examples/NinjaHelloWorld/config.dsc create mode 100644 Examples/NinjaHelloWorld/src/build.ninja create mode 100644 Examples/NinjaHelloWorld/src/hello.txt diff --git a/.gitignore b/.gitignore index 96bd7ad1b..34f117dc0 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,8 @@ /examples/CMakeHelloWorld/Out/ /examples/MsBuildHelloWorld/Out/ /examples/MsBuildHelloWorld/Debug/ +/examples/NinjaHelloWorld/Out +/examples/NinjaHelloWorld/src/Out bin/ obj/ contentcache/ diff --git a/Examples/NinjaHelloWorld/README.md b/Examples/NinjaHelloWorld/README.md new file mode 100644 index 000000000..8c81c6a89 --- /dev/null +++ b/Examples/NinjaHelloWorld/README.md @@ -0,0 +1,8 @@ +# Instructions + +1. Setup BuildXL as explained in the documentation +2. Point the environment variable BUILDXL_BIN to the BuildXL binary folder path. For example, if you set up BuildXL in D:\BuildXL, then D:\BuildXL\Out\Bin\debug\win-x64 should be the value. +3. Be aware that BuildXL requires the Ninja executable to evaluate the build specification. This means that `ninja.exe` should be in your `PATH`. +4. Run .\build.ps1 from PowerShell, or equivalently build.bat from the command line prompt + +The build outputs (`hello_copy.txt`, `hello_world.txt`) will be located in `Out`. For further configuration options, see the `NinjaResolverSettings` in https://github.com/microsoft/BuildXL/blob/master/Public/Sdk/Public/Prelude/Prelude.Configuration.Resolvers.dsc \ No newline at end of file diff --git a/Examples/NinjaHelloWorld/build.bat b/Examples/NinjaHelloWorld/build.bat new file mode 100644 index 000000000..5e5f37fb2 --- /dev/null +++ b/Examples/NinjaHelloWorld/build.bat @@ -0,0 +1 @@ +%BUILDXL_BIN%/bxl /c:config.dsc /server- /disableProcessRetryOnResourceExhaustion+ \ No newline at end of file diff --git a/Examples/NinjaHelloWorld/build.ps1 b/Examples/NinjaHelloWorld/build.ps1 new file mode 100644 index 000000000..e4b085d86 --- /dev/null +++ b/Examples/NinjaHelloWorld/build.ps1 @@ -0,0 +1 @@ +& $Env:BUILDXL_BIN/bxl /c:config.dsc /server- /disableProcessRetryOnResourceExhaustion+ \ No newline at end of file diff --git a/Examples/NinjaHelloWorld/config.dsc b/Examples/NinjaHelloWorld/config.dsc new file mode 100644 index 000000000..5af284ffa --- /dev/null +++ b/Examples/NinjaHelloWorld/config.dsc @@ -0,0 +1,13 @@ +config({ + resolvers: [ + { + kind: "Ninja", + root: d`src`, + moduleName: "HelloWorld", + keepProjectGraphFile: true, + } + ], + + // Inbox SDK is not currently working with the Ninja resolver + disableInBoxSdkSourceResolver: true, +}); \ No newline at end of file diff --git a/Examples/NinjaHelloWorld/src/build.ninja b/Examples/NinjaHelloWorld/src/build.ninja new file mode 100644 index 000000000..badb284ec --- /dev/null +++ b/Examples/NinjaHelloWorld/src/build.ninja @@ -0,0 +1,13 @@ +rule copy_file + command = cmd /C "copy $in $out" + +rule copy_append + command = cmd /C copy $in $out && echo world! >> $out + +build ..\Out\hello_copy.txt: copy_file hello.txt + +build ..\Out\hello_world.txt: copy_append ..\Out\hello_copy.txt + +build helloworld: phony ..\Out\hello_world.txt + +default helloworld diff --git a/Examples/NinjaHelloWorld/src/hello.txt b/Examples/NinjaHelloWorld/src/hello.txt new file mode 100644 index 000000000..444ac3651 --- /dev/null +++ b/Examples/NinjaHelloWorld/src/hello.txt @@ -0,0 +1 @@ +Hello, \ No newline at end of file