File indexing completed on 2024-05-12 04:22:35

0001 #!/usr/bin/python3
0002 import os
0003 import sys
0004 import subprocess
0005 import multiprocessing
0006 import shutil
0007 
0008 localCachePath = os.environ.pop('KDECI_CACHE_PATH')
0009 kritaCacheDir = os.path.join(localCachePath, 'krita-deps')
0010 if not os.path.isdir(kritaCacheDir):
0011     os.makedirs(kritaCacheDir)
0012 
0013 buildPath = os.path.join(os.getcwd(), '_build_plugins')
0014 if os.path.isdir(buildPath):
0015     shutil.rmtree(buildPath)
0016 os.makedirs(buildPath)
0017 
0018 cpuCount = int(multiprocessing.cpu_count())
0019 useCcacheForBuilds = os.environ.pop('KDECI_INTERNAL_USE_CCACHE') == 'True'
0020 
0021 cmakeCommand = [
0022     # Run CMake itself
0023     'cmake',
0024     '-G Ninja',
0025     '-DINSTALL_ROOT={}'.format(os.path.join(os.getcwd(), '_install')),
0026     '-DEXTERNALS_DOWNLOAD_DIR={}'.format(kritaCacheDir),
0027     '-DCMAKE_BUILD_TYPE={}'.format(os.environ.pop('KDECI_BUILD_TYPE')),
0028     os.path.join(os.getcwd(), '3rdparty_plugins')
0029 ]
0030 
0031 if useCcacheForBuilds:
0032     # Then instruct CMake accordingly...
0033     cmakeCommand.append('-DCMAKE_C_COMPILER_LAUNCHER=ccache')
0034     cmakeCommand.append('-DCMAKE_CXX_COMPILER_LAUNCHER=ccache')
0035 
0036     # Since we build external projects, we should propagate the 
0037     # ccache options via the environment variables...
0038     os.environ['CMAKE_C_COMPILER_LAUNCHER'] = 'ccache'
0039     os.environ['CMAKE_CXX_COMPILER_LAUNCHER'] = 'ccache'
0040 
0041 
0042 commandToRun = ' '.join(cmakeCommand)
0043 
0044 # Run the CMake command
0045 try:
0046     print( "## RUNNING: " + commandToRun )
0047     subprocess.check_call( commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True, cwd=buildPath)
0048 except Exception:
0049     print("## Failed to configure plugins")
0050     sys.exit(1)
0051 
0052 commandToRun = 'cmake --build . --target all --parallel {cpu_count}'.format(cpu_count = cpuCount)
0053 
0054 # Run the CMake command
0055 try:
0056     print( "## RUNNING: " + commandToRun )
0057     subprocess.check_call( commandToRun, stdout=sys.stdout, stderr=sys.stderr, shell=True, cwd=buildPath)
0058 except Exception:
0059     print("## Failed to build plugins")
0060     sys.exit(1)