-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathedk2-build.ps1
executable file
·103 lines (86 loc) · 2.65 KB
/
edk2-build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/pwsh
# Copyright 2018-2019, Bingxing Wang <uefi-oss-projects@imbushuo.net>
# All rights reserved.
#
# This script builds EDK2 content.
# EDK2 setup script should be called before invoking this script.
#
Param
(
[switch] $Clean,
[switch] $UseNewerGcc
)
Import-Module $PSScriptRoot/PsModules/redirector.psm1
Import-Module $PSScriptRoot/PsModules/elf.psm1
Write-Host "Task: EDK2 build"
# Targets. Ensure corresponding DSC/FDF files exist
$availableTargets = @(
"NintendoSwitch"
)
# Check package path.
if ($null -eq (Test-Path -Path "NintendoSwitchPkg")) {
Write-Error -Message "NintendoSwitchPkg is not found."
return -2
}
# Probe GCC
# Probe GCC. Use the most suitable one
$ccprefix = Get-GnuAarch64CrossCollectionPath -AllowFallback
if ($null -eq $ccprefix) { return -1 }
if ($false -eq (Test-GnuAarch64CrossCollectionVersionRequirements)) {
Write-Warning "Failed to check GCC version, build may fail!"
}
$env:GCC5_AARCH64_PREFIX = $ccprefix
Write-Output "Use GCC at $($ccprefix) to run builds."
# Build base tools if not exist (dev).
if (($false -eq (Test-Path -Path "BaseTools")) -or ($Clean -eq $true)) {
Write-Output "Build base tools."
make -C BaseTools
if (-not $?) {
Write-Error "Base tools target failed."
return $?
}
}
if ($true -eq $Clean) {
foreach ($target in $availableTargets) {
Write-Output "Clean target $($target)."
build -a AARCH64 -p NintendoSwitchPkg/$($target).dsc -t GCC5 clean
if (-not $?) {
Write-Error "Clean target $($target) failed."
return $?
}
}
# Apply workaround for "NUL"
Get-ChildItem -Path Build/**/NUL -Recurse | Remove-Item -Force
}
# Check current commit ID and write it into file for SMBIOS reference. (Trim it)
# Check current date and write it into file for SMBIOS reference too. (MM/dd/yyyy)
Write-Output "Stamp build."
$commit = git rev-parse HEAD
$date = (Get-Date).Date.ToString("MM/dd/yyyy")
if ($commit) {
$commit = $commit.Substring(0, 8)
$releaseInfoContent = @(
"#ifndef __SMBIOS_RELEASE_INFO_H__",
"#define __SMBIOS_RELEASE_INFO_H__",
"#ifdef __IMPL_COMMIT_ID__",
"#undef __IMPL_COMMIT_ID__",
"#endif",
"#define __IMPL_COMMIT_ID__ `"$($commit)`"",
"#ifdef __RELEASE_DATE__",
"#undef __RELEASE_DATE__",
"#endif",
"#define __RELEASE_DATE__ `"$($date)`"",
"#endif"
)
Set-Content -Path NintendoSwitchPkg/Include/FwReleaseInfo.h -Value $releaseInfoContent -ErrorAction SilentlyContinue -Force
}
foreach ($target in $availableTargets) {
Write-Output "Build NintendoSwitchPkg for $($target) (DEBUG)."
build -a AARCH64 -p NintendoSwitchPkg/$($target).dsc -t GCC5
if (-not $?) {
Write-Error "Build target $($target) failed."
return $?
}
}
# Invoke ELF build.
Copy-ElfImages