2021-09-02 02:57:35 +03:00
|
|
|
|
# Copyright (c) Microsoft Corporation
|
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
|
|
param($OutDir)
|
|
|
|
|
|
2021-09-07 22:22:49 +03:00
|
|
|
|
$file_name = ($OutDir + "\" + "git_commit_id.h")
|
2021-09-02 02:57:35 +03:00
|
|
|
|
$commit_id = git rev-parse HEAD
|
2021-09-07 22:22:49 +03:00
|
|
|
|
$new_content = '#define GIT_COMMIT_ID "' + $commit_id + '"' + "`n"
|
|
|
|
|
[string]$old_commit_id = ""
|
|
|
|
|
if (Test-Path $file_name) {
|
|
|
|
|
[string]$old_content = ""
|
|
|
|
|
$old_content = Get-Content $file_name
|
|
|
|
|
$old_commit_id = $old_content.Split('"')[1]
|
|
|
|
|
}
|
|
|
|
|
if ($old_commit_id -ne $commit_id) {
|
|
|
|
|
Write-Output "Commit ID changed, regenerating $file_name"
|
|
|
|
|
$new_content | out-file -FilePath $file_name
|
|
|
|
|
}
|