3rdparty_packages2make.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.iteritems())
  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 >> sys.stderr, \
  59. 'Usage: python 3rdparty_packages2make.py'
  60. sys.exit(2)