3rdparty_packages2make.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. from packages import getPackage, iterDownloadablePackages
  2. import sys
  3. def printPackagesMake():
  4. patchesDir = 'build/3rdparty'
  5. sourceDir = 'derived/3rdparty/src'
  6. tarballsDir = 'derived/3rdparty/download'
  7. print('SOURCE_DIR:=%s' % sourceDir)
  8. print()
  9. print('# Information about packages.')
  10. print('# Generated from the data in "build/packages.py".')
  11. print()
  12. tarballs = []
  13. for package in iterDownloadablePackages():
  14. makeName = package.getMakeName()
  15. tarball = tarballsDir + '/' + package.getTarballName()
  16. tarballs.append(tarball)
  17. print('# %s' % package.niceName)
  18. print('PACKAGE_%s:=%s' % (makeName, package.getSourceDirName()))
  19. print('TARBALL_%s:=%s' % (makeName, tarball))
  20. print('# Download:')
  21. print('%s:' % tarball)
  22. print('\tmkdir -p %s' % tarballsDir)
  23. print('\t$(PYTHON) build/download.py %s/%s %s' % (
  24. package.downloadURL, package.getTarballName(), tarballsDir
  25. ))
  26. packageSourceDirName = package.getSourceDirName()
  27. packageSourceDir = sourceDir + '/' + packageSourceDirName
  28. patchFile = '%s/%s.diff' % (patchesDir, packageSourceDirName)
  29. print('# Verify:')
  30. verifyMarker = '%s.verified' % tarball
  31. print('%s: %s' % (verifyMarker, tarball))
  32. print('\t$(PYTHON) build/checksum.py %s %d %s' % (
  33. tarball,
  34. package.fileLength,
  35. ' '.join('%s=%s' % item for item in package.checksums.items())
  36. ))
  37. print('\ttouch %s' % verifyMarker)
  38. print('# Extract:')
  39. extractMarker = '%s/.extracted' % packageSourceDir
  40. print('%s: %s $(wildcard %s)' % (extractMarker, verifyMarker, patchFile))
  41. print('\trm -rf %s' % packageSourceDir)
  42. print('\tmkdir -p %s' % sourceDir)
  43. print('\t$(PYTHON) build/extract.py %s %s %s' % (
  44. tarball, sourceDir, packageSourceDirName
  45. ))
  46. print('\ttest ! -e %s || $(PYTHON) build/patch.py %s %s' % (
  47. patchFile, patchFile, sourceDir
  48. ))
  49. print('\ttouch %s' % extractMarker)
  50. print()
  51. print('# Convenience target to download all source packages.')
  52. print('.PHONY: download')
  53. print('download: %s' % ' '.join(tarballs))
  54. if __name__ == '__main__':
  55. if len(sys.argv) == 1:
  56. printPackagesMake()
  57. else:
  58. print('Usage: python3 3rdparty_packages2make.py', file=sys.stderr)
  59. sys.exit(2)