Skip to content

Commit

Permalink
Automate repo init & reset (#3108)
Browse files Browse the repository at this point in the history
* add init script & doc update

* Update doc

Co-authored-by: Dave Thaler <[email protected]>

* Update docs/GettingStarted.md

Co-authored-by: Igor Klemenski <[email protected]>

* modify ci/cd script

* optimize

* nit

* fix break from #3104

* Revert "optimize"

This reverts commit 611bf6e.

* sync

* check exit code

* nit

---------

Co-authored-by: Dave Thaler <[email protected]>
Co-authored-by: Igor Klemenski <[email protected]>
  • Loading branch information
3 people authored Dec 8, 2023
1 parent 3f5e0ba commit 911cefc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 36 deletions.
27 changes: 2 additions & 25 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down
17 changes: 6 additions & 11 deletions docs/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 24 additions & 0 deletions scripts/initialize_ebpf_repo.ps1
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit 911cefc

Please sign in to comment.