Skip to content

Commit

Permalink
Merge pull request #813 from daleglass-overte/get-vcpkg-path
Browse files Browse the repository at this point in the history
Add a way to get VCPKG path and hash ID
  • Loading branch information
JulianGro authored Feb 14, 2024
2 parents 1b77f54 + dbe04a9 commit 1221b46
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 17 deletions.
15 changes: 10 additions & 5 deletions hifi_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ def __init__(self, args):

qt_found = True
system_qt = True
print("Using system Qt")

if not self.args.quiet:
print("Using system Qt")

elif os.getenv('OVERTE_QT_PATH', "") != "":
# 2. Using an user-provided directory.
Expand All @@ -92,7 +94,9 @@ def __init__(self, args):
self.cmakePath = os.path.join(self.fullPath, 'lib', 'cmake')

qt_found = True
print("Using Qt from " + self.fullPath)

if not self.args.quiet:
print("Using Qt from " + self.fullPath)

else:
# 3. Using a pre-built Qt.
Expand Down Expand Up @@ -135,7 +139,8 @@ def __init__(self, args):
self.lockFile = os.path.join(lockDir, lockName)

if qt_found:
print("Found pre-built Qt5")
if not self.args.quiet:
print("Found pre-built Qt5")
return

if 'Windows' == system:
Expand All @@ -147,8 +152,8 @@ def __init__(self, args):
cpu_architecture = platform.machine()

if 'x86_64' == cpu_architecture:
# `major_version()` can return blank string on rolling release distros like arch
# The `or 0` conditional assignment prevents the int parsing error from hiding the useful Qt package error
# `major_version()` can return blank string on rolling release distros like arch
# The `or 0` conditional assignment prevents the int parsing error from hiding the useful Qt package error
u_major = int( distro.major_version() or '0' )
if distro.id() == 'ubuntu' or distro.id() == 'linuxmint':
if (distro.id() == 'ubuntu' and u_major == 20) or distro.id() == 'linuxmint' and u_major == 20:
Expand Down
3 changes: 2 additions & 1 deletion hifi_vcpkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def __init__(self, args):
os.makedirs(self.basePath)
self.path = os.path.join(self.basePath, self.id)

print("Using vcpkg path {}".format(self.path))
if not self.args.quiet:
print("Using vcpkg path {}".format(self.path))
lockDir, lockName = os.path.split(self.path)
lockName += '.lock'
if not os.path.isdir(lockDir):
Expand Down
41 changes: 30 additions & 11 deletions prebuild.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!python

# The prebuild script is intended to simplify life for developers and dev-ops. It's repsonsible for acquiring
# tools required by the build as well as dependencies on which we rely.
#
# The prebuild script is intended to simplify life for developers and dev-ops. It's repsonsible for acquiring
# tools required by the build as well as dependencies on which we rely.
#
# By using this script, we can reduce the requirements for a developer getting started to:
#
# * A working C++ dev environment like visual studio, xcode, gcc, or clang
# * Qt
# * Qt
# * CMake
# * Python 3.x
#
# The function of the build script is to acquire, if not already present, all the other build requirements
# The build script should be idempotent. If you run it with the same arguments multiple times, that should
# have no negative impact on the subsequent build times (i.e. re-running the prebuild script should not
# trigger a header change that causes files to be rebuilt). Subsequent runs after the first run should
# The build script should be idempotent. If you run it with the same arguments multiple times, that should
# have no negative impact on the subsequent build times (i.e. re-running the prebuild script should not
# trigger a header change that causes files to be rebuilt). Subsequent runs after the first run should
# execute quickly, determining that no work is to be done

import hifi_singleton
Expand Down Expand Up @@ -83,6 +83,10 @@ def parse_args():
parser.add_argument('--build-root', required=True, type=str, help='The location of the cmake build')
parser.add_argument('--ports-path', type=str, default=defaultPortsPath)
parser.add_argument('--ci-build', action='store_true', default=os.getenv('CI_BUILD') is not None)
parser.add_argument('--get-vcpkg-id', action='store_true', help='Get the VCPKG ID, the hash path of the full VCPKG path')
parser.add_argument('--get-vcpkg-path', action='store_true', help='Get the full VCPKG path, ID included.')
parser.add_argument('--quiet', action='store_true', default=False, help='Quiet mode with less output')

if True:
args = parser.parse_args()
else:
Expand All @@ -91,14 +95,18 @@ def parse_args():

def main():
# Fixup env variables. Leaving `USE_CCACHE` on will cause scribe to fail to build
# VCPKG_ROOT seems to cause confusion on Windows systems that previously used it for
# VCPKG_ROOT seems to cause confusion on Windows systems that previously used it for
# building OpenSSL
removeEnvVars = ['VCPKG_ROOT', 'USE_CCACHE']
for var in removeEnvVars:
if var in os.environ:
del os.environ[var]

args = parse_args()

if not args.quiet:
print(sys.argv)

assets_url = hifi_utils.readEnviromentVariableFromFile(args.build_root, 'EXTERNAL_BUILD_ASSETS')

if args.ci_build:
Expand Down Expand Up @@ -129,11 +137,22 @@ def main():
qt.writeConfig()
else:
if (os.environ["OVERTE_USE_SYSTEM_QT"]):
print("System Qt selected")
if not args.quiet:
print("System Qt selected")

else:
raise Exception("Internal error: System Qt not selected, but hifi_qt.py failed to return a cmake path")

pm = hifi_vcpkg.VcpkgRepo(args)

if args.get_vcpkg_id:
print(pm.id)
exit(0)

if args.get_vcpkg_path:
print(pm.path)
exit(0)

if qtInstallPath is not None:
pm.writeVar('QT_CMAKE_PREFIX_PATH', qtInstallPath)

Expand All @@ -149,7 +168,7 @@ def main():
if not pm.upToDate():
pm.bootstrap()

# Always write the tag, even if we changed nothing. This
# Always write the tag, even if we changed nothing. This
# allows vcpkg to reclaim disk space by identifying directories with
# tags that haven't been touched in a long time
pm.writeTag()
Expand Down Expand Up @@ -190,7 +209,7 @@ def main():

logger.info('end')

print(sys.argv)

try:
main()
except hifi_utils.SilentFatalError as fatal_ex:
Expand Down

0 comments on commit 1221b46

Please sign in to comment.