You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

prepare_sdk.js 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. const fs = require('fs');
  2. const path = require('path');
  3. const packageJSON = require('../package.json');
  4. const SDKPackageJSON = require('./package.json');
  5. const androidSourcePath = '../android/sdk/src/main/java/org/jitsi/meet/sdk';
  6. const androidTargetPath = './android/src/main/java/org/jitsi/meet/sdk';
  7. const iosSrcPath = '../ios/sdk/src';
  8. const iosDestPath = './ios/src';
  9. /**
  10. * Copies a specified file in a way that recursive copy is possible.
  11. */
  12. function copyFileSync(source, target) {
  13. let targetFile = target;
  14. // If target is a directory, a new file with the same name will be created
  15. if (fs.existsSync(target)) {
  16. if (fs.lstatSync(target).isDirectory()) {
  17. targetFile = path.join(target, path.basename(source));
  18. }
  19. }
  20. fs.copyFileSync(source, targetFile);
  21. }
  22. /**
  23. * Copies a specified directory recursively.
  24. */
  25. function copyFolderRecursiveSync(source, target) {
  26. let files = [];
  27. const targetFolder = path.join(target, path.basename(source));
  28. if (!fs.existsSync(targetFolder)) {
  29. fs.mkdirSync(targetFolder, { recursive: true });
  30. }
  31. if (fs.lstatSync(source).isDirectory()) {
  32. files = fs.readdirSync(source);
  33. files.forEach(file => {
  34. const curSource = path.join(source, file);
  35. if (fs.lstatSync(curSource).isDirectory()) {
  36. copyFolderRecursiveSync(curSource, targetFolder);
  37. } else {
  38. copyFileSync(curSource, targetFolder);
  39. }
  40. });
  41. }
  42. }
  43. /**
  44. * Merges the dependency versions from the root package.json with the dependencies of the SDK package.json.
  45. */
  46. function mergeDependencyVersions() {
  47. for (const key in SDKPackageJSON.dependencies) {
  48. if (SDKPackageJSON.dependencies.hasOwnProperty(key)) {
  49. SDKPackageJSON.dependencies[key] = packageJSON.dependencies[key] || packageJSON.devDependencies[key];
  50. }
  51. }
  52. const data = JSON.stringify(SDKPackageJSON, null, 4);
  53. fs.writeFileSync('package.json', data);
  54. }
  55. // TODO: put this in a seperate step
  56. mergeDependencyVersions();
  57. copyFolderRecursiveSync(
  58. '../images',
  59. '.'
  60. );
  61. copyFolderRecursiveSync(
  62. '../sounds',
  63. '.'
  64. );
  65. copyFolderRecursiveSync(
  66. '../lang',
  67. '.'
  68. );
  69. copyFolderRecursiveSync(
  70. '../modules',
  71. '.'
  72. );
  73. copyFolderRecursiveSync(
  74. '../react',
  75. '.'
  76. );
  77. copyFolderRecursiveSync(
  78. '../service',
  79. '.'
  80. );
  81. copyFolderRecursiveSync(
  82. '../ios/sdk/sdk.xcodeproj',
  83. './ios'
  84. );
  85. copyFolderRecursiveSync(
  86. `${iosSrcPath}/callkit`,
  87. iosDestPath
  88. );
  89. copyFolderRecursiveSync(
  90. `${iosSrcPath}/dropbox`,
  91. iosDestPath
  92. );
  93. fs.copyFileSync(
  94. `${iosSrcPath}/AppInfo.m`,
  95. `${iosDestPath}/AppInfo.m`
  96. );
  97. fs.copyFileSync(
  98. `${iosSrcPath}/AudioMode.m`,
  99. `${iosDestPath}/AudioMode.m`
  100. );
  101. fs.copyFileSync(
  102. `${iosSrcPath}/InfoPlistUtil.m`,
  103. `${iosDestPath}/InfoPlistUtil.m`
  104. );
  105. fs.copyFileSync(
  106. `${iosSrcPath}/InfoPlistUtil.h`,
  107. `${iosDestPath}/InfoPlistUtil.h`
  108. );
  109. fs.copyFileSync(
  110. `${iosSrcPath}/JavaScriptSandbox.m`,
  111. `${iosDestPath}/JavaScriptSandbox.m`
  112. );
  113. fs.copyFileSync(
  114. `${iosSrcPath}/JitsiAudioSession.m`,
  115. `${iosDestPath}/JitsiAudioSession.m`
  116. );
  117. fs.copyFileSync(
  118. `${iosSrcPath}/JitsiAudioSession.h`,
  119. `${iosDestPath}/JitsiAudioSession.h`
  120. );
  121. fs.copyFileSync(
  122. `${iosSrcPath}/JitsiAudioSession+Private.h`,
  123. `${iosDestPath}/JitsiAudioSession+Private.h`
  124. );
  125. fs.copyFileSync(
  126. `${iosSrcPath}/LocaleDetector.m`,
  127. `${iosDestPath}/LocaleDetector.m`
  128. );
  129. fs.copyFileSync(
  130. `${iosSrcPath}/POSIX.m`,
  131. `${iosDestPath}/POSIX.m`
  132. );
  133. fs.copyFileSync(
  134. `${iosSrcPath}/Proximity.m`,
  135. `${iosDestPath}/Proximity.m`
  136. );
  137. copyFolderRecursiveSync(
  138. `${androidSourcePath}/log`,
  139. `${androidTargetPath}/log`
  140. );
  141. copyFolderRecursiveSync(
  142. `${androidSourcePath}/net`,
  143. `${androidTargetPath}/log`
  144. );
  145. fs.copyFileSync(
  146. `${androidSourcePath}/AndroidSettingsModule.java`,
  147. `${androidTargetPath}/AndroidSettingsModule.java`
  148. );
  149. fs.copyFileSync(
  150. `${androidSourcePath}/AppInfoModule.java`,
  151. `${androidTargetPath}/AppInfoModule.java`
  152. );
  153. fs.copyFileSync(
  154. `${androidSourcePath}/AudioDeviceHandlerConnectionService.java`,
  155. `${androidTargetPath}/AudioDeviceHandlerConnectionService.java`
  156. );
  157. fs.copyFileSync(
  158. `${androidSourcePath}/AudioDeviceHandlerGeneric.java`,
  159. `${androidTargetPath}/AudioDeviceHandlerGeneric.java`
  160. );
  161. fs.copyFileSync(
  162. `${androidSourcePath}/AudioModeModule.java`,
  163. `${androidTargetPath}/AudioModeModule.java`
  164. );
  165. fs.copyFileSync(
  166. `${androidSourcePath}/ConnectionService.java`,
  167. `${androidTargetPath}/ConnectionService.java`
  168. );
  169. fs.copyFileSync(
  170. `${androidSourcePath}/JavaScriptSandboxModule.java`,
  171. `${androidTargetPath}/JavaScriptSandboxModule.java`
  172. );
  173. fs.copyFileSync(
  174. `${androidSourcePath}/LocaleDetector.java`,
  175. `${androidTargetPath}/LocaleDetector.java`
  176. );
  177. fs.copyFileSync(
  178. `${androidSourcePath}/LogBridgeModule.java`,
  179. `${androidTargetPath}/LogBridgeModule.java`
  180. );
  181. fs.copyFileSync(
  182. `${androidSourcePath}/PictureInPictureModule.java`,
  183. `${androidTargetPath}/PictureInPictureModule.java`
  184. );
  185. fs.copyFileSync(
  186. `${androidSourcePath}/ProximityModule.java`,
  187. `${androidTargetPath}/ProximityModule.java`
  188. );
  189. fs.copyFileSync(
  190. `${androidSourcePath}/RNConnectionService.java`,
  191. `${androidTargetPath}/RNConnectionService.java`
  192. );