ssl.me 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. ssl.me - SSL Plugin. This is the interface above SSL providers.
  3. */
  4. Me.load({
  5. targets: {
  6. ssl: {
  7. configurable: true,
  8. description: 'Secure Socket Layer Interface',
  9. discovers: [ 'mbedtls', 'openssl', 'matrixssl', 'nanossl' ],
  10. uses: [ 'mbedtls', 'openssl', 'matrixssl', 'nanossl' ],
  11. config: function (target) {
  12. let provider
  13. for each (p in target.discovers) {
  14. let ptarget = me.targets[p]
  15. if (ptarget.explicit) {
  16. if (ptarget.enable) {
  17. provider = p
  18. break
  19. } else if (ptarget.explicit != 'without') {
  20. throw 'Required SSL provider "' + p + '" is not enabled'
  21. }
  22. }
  23. }
  24. for each (p in target.discovers) {
  25. if (p == provider) {
  26. continue
  27. }
  28. if (me.targets[p] && me.targets[p].enable && !provider) {
  29. provider = p
  30. } else if (provider) {
  31. me.targets[p].enable = false
  32. me.targets[p].diagnostic = 'Using the "' + provider + '" SSL provider instead.'
  33. }
  34. }
  35. if (provider) {
  36. let from = me.targets[provider]
  37. target.provider = provider
  38. for each (field in ['defines', 'includes', 'libraries', 'libpaths']) {
  39. if (from[field]) {
  40. target[field] = from[field]
  41. }
  42. }
  43. target.description += ' (' + me.targets[provider].description + ')'
  44. } else {
  45. throw 'No enabled SSL providers.\n'
  46. }
  47. if (me.options.gen) {
  48. if (me.platform.os == 'windows' || me.platform.os == 'vxworks') {
  49. for each (p in target.discovers) {
  50. if (me.targets[p].enable && p != 'mbedtls') {
  51. me.targets[p].enable = false
  52. me.targets[p].diagnostic = 'Building by default without SSL'
  53. target.description = ' Secure Socket Layer (disabled by default)'
  54. }
  55. }
  56. }
  57. }
  58. },
  59. without: function(target) {
  60. for each (p in target.discovers) {
  61. me.targets[p].enable = false
  62. me.targets[p].diagnostic = 'configured --without ssl'
  63. }
  64. }
  65. }
  66. }
  67. })