Skip to content

Commit

Permalink
Showing 3 changed files with 74 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@
/dind-*.rc
/os-version-defs
/.make/
/cmd/oc/oc.syso
*.swp
.vimrc
.vagrant-openshift.json*
70 changes: 68 additions & 2 deletions hack/lib/build/binaries.sh
Original file line number Diff line number Diff line change
@@ -219,6 +219,11 @@ os::build::internal::build_binaries() {
local_ldflags+=" -s"
fi

#Add Windows File Properties/Version Info and Icon Resource for oc.exe
if [[ "$platform" == "windows/amd64" ]]; then
os::build::generate_windows_versioninfo
fi

if [[ ${#nonstatics[@]} -gt 0 ]]; then
GOOS=${platform%/*} GOARCH=${platform##*/} go install \
-pkgdir "${OS_OUTPUT_PKGDIR}/${platform}" \
@@ -234,6 +239,10 @@ os::build::internal::build_binaries() {
fi
fi

if [[ "$platform" == "windows/amd64" ]]; then
rm ${OS_ROOT}/cmd/oc/oc.syso
fi

for test in "${tests[@]:+${tests[@]}}"; do
local outfile="${OS_OUTPUT_BINPATH}/${platform}/$(basename ${test})"
# disabling cgo allows use of delve
@@ -249,7 +258,64 @@ os::build::internal::build_binaries() {
}
readonly -f os::build::build_binaries

# Generates the set of target packages, binaries, and platforms to build for.
# Generates the .syso file used to add compile-time VERSIONINFO metadata to the
# Windows binary.
function os::build::generate_windows_versioninfo() {
os::util::ensure::gopath_binary_exists 'goversioninfo' 'github.com/josephspurrier/goversioninfo/cmd/goversioninfo'
os::build::version::get_vars
local major="${OS_GIT_MAJOR}"
local minor="${OS_GIT_MINOR%+}"
local patch="${OS_GIT_PATCH}"
local windows_versioninfo_file=`mktemp --suffix=".versioninfo.json"`
cat <<EOF >"${windows_versioninfo_file}"
{
"FixedFileInfo":
{
"FileVersion": {
"Major": ${major},
"Minor": ${minor},
"Patch": ${patch}
},
"ProductVersion": {
"Major": ${major},
"Minor": ${minor},
"Patch": ${patch}
},
"FileFlagsMask": "3f",
"FileFlags ": "00",
"FileOS": "040004",
"FileType": "01",
"FileSubType": "00"
},
"StringFileInfo":
{
"Comments": "",
"CompanyName": "Red Hat, Inc.",
"InternalName": "openshift client",
"FileVersion": "${OS_GIT_VERSION}",
"InternalName": "oc",
"LegalCopyright": "© Red Hat, Inc. Licensed under the Apache License, Version 2.0",
"LegalTrademarks": "",
"OriginalFilename": "oc.exe",
"PrivateBuild": "",
"ProductName": "OpenShift Client",
"ProductVersion": "${OS_GIT_VERSION}",
"SpecialBuild": ""
},
"VarFileInfo":
{
"Translation": {
"LangID": "0409",
"CharsetID": "04B0"
}
}
}
EOF
goversioninfo -o ${OS_ROOT}/cmd/oc/oc.syso ${windows_versioninfo_file}
}
readonly -f os::build::generate_windows_versioninfo

# Generates the set of target packages, binaries, and platforms to build for.
# Accepts binaries via $@, and platforms via OS_BUILD_PLATFORMS, or defaults to
# the current platform.
function os::build::export_targets() {
@@ -533,4 +599,4 @@ function os::build::commit_range() {

echo "$1"
}
readonly -f os::build::commit_range
readonly -f os::build::commit_range
8 changes: 5 additions & 3 deletions hack/lib/build/version.sh
Original file line number Diff line number Diff line change
@@ -40,10 +40,11 @@ function os::build::version::openshift_vars() {
# Try to match the "git describe" output to a regex to try to extract
# the "major" and "minor" versions and whether this is the exact tagged
# version or whether the tree is between two tagged versions.
if [[ "${OS_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)*([-].*)?$ ]]; then
if [[ "${OS_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)(\.[0-9]+)*([-].*)?$ ]]; then
OS_GIT_MAJOR=${BASH_REMATCH[1]}
OS_GIT_MINOR=${BASH_REMATCH[2]}
if [[ -n "${BASH_REMATCH[4]}" ]]; then
OS_GIT_PATCH=${BASH_REMATCH[3]}
if [[ -n "${BASH_REMATCH[5]}" ]]; then
OS_GIT_MINOR+="+"
fi
fi
@@ -111,10 +112,11 @@ OS_GIT_TREE_STATE='${OS_GIT_TREE_STATE-}'
OS_GIT_VERSION='${OS_GIT_VERSION-}'
OS_GIT_MAJOR='${OS_GIT_MAJOR-}'
OS_GIT_MINOR='${OS_GIT_MINOR-}'
OS_GIT_PATCH='${OS_GIT_PATCH-}'
KUBE_GIT_COMMIT='${KUBE_GIT_COMMIT-}'
KUBE_GIT_VERSION='${KUBE_GIT_VERSION-}'
ETCD_GIT_VERSION='${ETCD_GIT_VERSION-}'
ETCD_GIT_COMMIT='${ETCD_GIT_COMMIT-}'
EOF
}
readonly -f os::build::version::save_vars
readonly -f os::build::version::save_vars

0 comments on commit c8c201d

Please sign in to comment.