Skip to content

Commit 911cefc

Browse files
gtrevidthalerrectified95
authoredDec 8, 2023
Automate repo init & reset (#3108)
* 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]>
1 parent 3f5e0ba commit 911cefc

File tree

3 files changed

+32
-36
lines changed

3 files changed

+32
-36
lines changed
 

‎.github/workflows/reusable-build.yml

+2-25
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ jobs:
135135
path: packages
136136
key: ${{ runner.os }}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}}-${{env.BUILD_ARTIFACT_NAME}}-${{ hashFiles('**/packages.config') }}-${{env.msvc_tools_version}}
137137

138-
- name: Restore NuGet packages
139-
if: steps.skip_check.outputs.should_skip != 'true'
140-
working-directory: ${{env.GITHUB_WORKSPACE}}
141-
run: nuget restore ${{env.SOLUTION_FILE_PATH}}
142-
143138
- name: Cache verifier project
144139
# The hash is based on the HEAD of the ebpf-verifier submodule, the Directory.Build.props file, and the build variant.
145140
if: steps.skip_check.outputs.should_skip != 'true'
@@ -150,32 +145,14 @@ jobs:
150145
path: external/ebpf-verifier/build
151146
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}}
152147

153-
- name: Create verifier project
154-
if: steps.skip_check.outputs.should_skip != 'true'
155-
working-directory: ${{env.GITHUB_WORKSPACE}}
156-
env:
157-
CXXFLAGS: /ZH:SHA_256 ${{env.CXX_FLAGS}}
158-
LDFLAGS: ${{env.LD_FLAGS}}
159-
run: |
160-
cmake -G "Visual Studio 17 2022" -S external\ebpf-verifier -B external\ebpf-verifier\build
161-
162-
- name: Create catch2 project
163-
if: steps.skip_check.outputs.should_skip != 'true'
164-
working-directory: ${{env.GITHUB_WORKSPACE}}
165-
env:
166-
CXXFLAGS: /ZH:SHA_256 ${{env.CXX_FLAGS}}
167-
LDFLAGS: ${{env.LD_FLAGS}}
168-
run: |
169-
cmake -G "Visual Studio 17 2022" -S external\catch2 -B external\catch2\build -DBUILD_TESTING=OFF
170-
171-
- name: Create ubpf project
148+
- name: Configuring repo for first build
172149
if: steps.skip_check.outputs.should_skip != 'true'
173150
working-directory: ${{env.GITHUB_WORKSPACE}}
174151
env:
175152
CXXFLAGS: /ZH:SHA_256 ${{env.CXX_FLAGS}}
176153
LDFLAGS: ${{env.LD_FLAGS}}
177154
run: |
178-
cmake -G "Visual Studio 17 2022" -S external\ubpf -B external\ubpf\build
155+
.\scripts\initialize_ebpf_repo.ps1
179156
180157
- name: Build
181158
if: steps.skip_check.outputs.should_skip != 'true'

‎docs/GettingStarted.md

+6-11
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,18 @@ PE parse directory includes some malformed PE images as a part of the test suite
8787

8888
The following steps need to be executed *once* before the first build on a new clone:
8989

90-
1. Launch `Developer Command Prompt for VS 2022` by running:
90+
1. Launch a `Developer PowerShell for VS 2022` session.
91+
1. Change directory to where the project is cloned (e.g. "`cd ebpf-for-windows`").
92+
1. Run the following script:
9193

92-
```cmd
93-
"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat"
94+
```ps
95+
.\scripts\initialize_ebpf_repo.ps1
9496
```
95-
1. Change directory to where the project is cloned (e.g. `cd ebpf-for-windows`), and run the following commands:
96-
97-
- `cmake -G "Visual Studio 17 2022" -S external\ebpf-verifier -B external\ebpf-verifier\build`
98-
- `cmake -G "Visual Studio 17 2022" -S external\catch2 -B external\catch2\build -DBUILD_TESTING=OFF`
99-
- `cmake -G "Visual Studio 17 2022" -S external\ubpf -B external\ubpf\build`
100-
- `nuget restore ebpf-for-windows.sln`
101-
10297
>**Note**: you may get the following transitory error, which can be safely ignored as the *WiX Toolset* nuget package will be installed immediately afterwards:
10398
>
10499
> `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`
105100
106-
- `del external\ebpf-verifier\build\obj\project.assets.json` (Note: the file may not be present)
101+
> 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.
107102
108103
#### Building using Developer Command Prompt for VS 2022
109104

‎scripts/initialize_ebpf_repo.ps1

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright (c) Microsoft Corporation
2+
# SPDX-License-Identifier: MIT
3+
4+
# Define the commands to run
5+
$commands = @(
6+
"git submodule update --init --recursive",
7+
"cmake -G 'Visual Studio 17 2022' -S external\ebpf-verifier -B external\ebpf-verifier\build",
8+
"cmake -G 'Visual Studio 17 2022' -S external\catch2 -B external\catch2\build -DBUILD_TESTING=OFF",
9+
"cmake -G 'Visual Studio 17 2022' -S external\ubpf -B external\ubpf\build",
10+
"nuget restore ebpf-for-windows.sln"
11+
)
12+
13+
# Loop through each command and run them sequentially without opening a new window
14+
foreach ($command in $commands) {
15+
Write-Host ">> Running command: $command"
16+
Invoke-Expression -Command $command
17+
18+
# Check the exit code
19+
if ($LASTEXITCODE -ne 0) {
20+
Write-Host "Command failed. Exit code: $LASTEXITCODE"
21+
Exit $LASTEXITCODE
22+
}
23+
}
24+
Write-Host "All commands succeeded."

0 commit comments

Comments
 (0)
Please sign in to comment.