diff --git a/.github/workflows/reusable-build.yml b/.github/workflows/reusable-build.yml index ad81fdf7a8..29bb6a7c13 100644 --- a/.github/workflows/reusable-build.yml +++ b/.github/workflows/reusable-build.yml @@ -135,11 +135,6 @@ jobs: path: packages key: ${{ runner.os }}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}}-${{env.BUILD_ARTIFACT_NAME}}-${{ hashFiles('**/packages.config') }}-${{env.msvc_tools_version}} - - name: Restore NuGet packages - if: steps.skip_check.outputs.should_skip != 'true' - working-directory: ${{env.GITHUB_WORKSPACE}} - run: nuget restore ${{env.SOLUTION_FILE_PATH}} - - name: Cache verifier project # The hash is based on the HEAD of the ebpf-verifier submodule, the Directory.Build.props file, and the build variant. if: steps.skip_check.outputs.should_skip != 'true' @@ -150,32 +145,14 @@ jobs: path: external/ebpf-verifier/build key: ${{ runner.os }}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}}-${{env.BUILD_ARTIFACT_NAME}}-${{ hashFiles('.git/modules/external/ebpf-verifier/HEAD') }}-${{ hashFiles('external/Directory.Build.props')}}-${{env.msvc_tools_version}} - - name: Create verifier project - if: steps.skip_check.outputs.should_skip != 'true' - working-directory: ${{env.GITHUB_WORKSPACE}} - env: - CXXFLAGS: /ZH:SHA_256 ${{env.CXX_FLAGS}} - LDFLAGS: ${{env.LD_FLAGS}} - run: | - cmake -G "Visual Studio 17 2022" -S external\ebpf-verifier -B external\ebpf-verifier\build - - - name: Create catch2 project - if: steps.skip_check.outputs.should_skip != 'true' - working-directory: ${{env.GITHUB_WORKSPACE}} - env: - CXXFLAGS: /ZH:SHA_256 ${{env.CXX_FLAGS}} - LDFLAGS: ${{env.LD_FLAGS}} - run: | - cmake -G "Visual Studio 17 2022" -S external\catch2 -B external\catch2\build -DBUILD_TESTING=OFF - - - name: Create ubpf project + - name: Configuring repo for first build if: steps.skip_check.outputs.should_skip != 'true' working-directory: ${{env.GITHUB_WORKSPACE}} env: CXXFLAGS: /ZH:SHA_256 ${{env.CXX_FLAGS}} LDFLAGS: ${{env.LD_FLAGS}} run: | - cmake -G "Visual Studio 17 2022" -S external\ubpf -B external\ubpf\build + .\scripts\initialize_ebpf_repo.ps1 - name: Build if: steps.skip_check.outputs.should_skip != 'true' diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index ed97f5abea..95ee4bb831 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -87,23 +87,18 @@ PE parse directory includes some malformed PE images as a part of the test suite The following steps need to be executed *once* before the first build on a new clone: -1. Launch `Developer Command Prompt for VS 2022` by running: +1. Launch a `Developer PowerShell for VS 2022` session. +1. Change directory to where the project is cloned (e.g. "`cd ebpf-for-windows`"). +1. Run the following script: - ```cmd - "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat" + ```ps + .\scripts\initialize_ebpf_repo.ps1 ``` -1. Change directory to where the project is cloned (e.g. `cd ebpf-for-windows`), and run the following commands: - - - `cmake -G "Visual Studio 17 2022" -S external\ebpf-verifier -B external\ebpf-verifier\build` - - `cmake -G "Visual Studio 17 2022" -S external\catch2 -B external\catch2\build -DBUILD_TESTING=OFF` - - `cmake -G "Visual Studio 17 2022" -S external\ubpf -B external\ubpf\build` - - `nuget restore ebpf-for-windows.sln` - >**Note**: you may get the following transitory error, which can be safely ignored as the *WiX Toolset* nuget package will be installed immediately afterwards: > > `error : The WiX Toolset v3.11 build tools must be installed to build this project. To download the WiX Toolset, see https://wixtoolset.org/releases/v3.11/stable` - - `del external\ebpf-verifier\build\obj\project.assets.json` (Note: the file may not be present) +> TIP: In case you need to "reset" the repo, without re-cloning it, you can just delete all the folders under the `\external` directory (but keep the files), and then re-run the above script. #### Building using Developer Command Prompt for VS 2022 diff --git a/scripts/initialize_ebpf_repo.ps1 b/scripts/initialize_ebpf_repo.ps1 new file mode 100644 index 0000000000..f45898a772 --- /dev/null +++ b/scripts/initialize_ebpf_repo.ps1 @@ -0,0 +1,24 @@ +# Copyright (c) Microsoft Corporation +# SPDX-License-Identifier: MIT + +# Define the commands to run +$commands = @( + "git submodule update --init --recursive", + "cmake -G 'Visual Studio 17 2022' -S external\ebpf-verifier -B external\ebpf-verifier\build", + "cmake -G 'Visual Studio 17 2022' -S external\catch2 -B external\catch2\build -DBUILD_TESTING=OFF", + "cmake -G 'Visual Studio 17 2022' -S external\ubpf -B external\ubpf\build", + "nuget restore ebpf-for-windows.sln" +) + +# Loop through each command and run them sequentially without opening a new window +foreach ($command in $commands) { + Write-Host ">> Running command: $command" + Invoke-Expression -Command $command + + # Check the exit code + if ($LASTEXITCODE -ne 0) { + Write-Host "Command failed. Exit code: $LASTEXITCODE" + Exit $LASTEXITCODE + } +} +Write-Host "All commands succeeded." \ No newline at end of file