| OLD | NEW |
| 1 Adblock Plus core | 1 Adblock Plus core |
| 2 ================= | 2 ================= |
| 3 | 3 |
| 4 This repository contains the generic Adblock Plus code that's shared between | 4 This repository contains the generic Adblock Plus code that's shared between |
| 5 platforms. This repository is not designed to be used directly, but instead to | 5 platforms. This repository is not designed to be used directly, but instead to |
| 6 serve as a dependency for `adblockplus`, `adblockpluschrome` and | 6 serve as a dependency for `adblockplus`, `adblockpluschrome` and |
| 7 `libadblockplus`. | 7 `libadblockplus`. |
| 8 | 8 |
| 9 Compiling C++ code | 9 Compiling C++ code |
| 10 ------------------ | 10 ------------------ |
| 11 | 11 |
| 12 ### Purpose | 12 ### Purpose |
| 13 | 13 |
| 14 In order to improve performance and memory usage, some of the code (located | 14 In order to improve performance and memory usage, some of the code (located |
| 15 inside the `compiled` directory) is written in C++ and compiled to JavaScript | 15 inside the `compiled` directory) is written in C++ and compiled to JavaScript |
| 16 via Empscripten. | 16 via Empscripten. |
| 17 | 17 |
| 18 ### Requirements | 18 ### Requirements |
| 19 | 19 |
| 20 * [Emscripten 1.37.3](https://github.com/kripken/emscripten) | 20 * [Emscripten 1.37.3](https://github.com/kripken/emscripten) |
| 21 * [Python 2.7](https://www.python.org) | 21 * [Python 2.7](https://www.python.org) |
| 22 | 22 |
| 23 ### Running Emscripten | 23 ### Running Emscripten |
| 24 | 24 |
| 25 After installing and configuring Emscripten you can run the following command: | 25 After installing and configuring Emscripten you can run the following commands: |
| 26 | 26 |
| 27 python compile | 27 mkdir build |
| 28 meson build |
| 29 ninja |
| 28 | 30 |
| 29 This will produce a `lib/compiled.js` exporting the classes defined in C++ code. | 31 This will produce a `build/compiled.js` exporting the classes defined |
| 32 in C++ code. |
| 30 | 33 |
| 31 ### Technical details | 34 ### Technical details |
| 32 | 35 |
| 33 Compilation is currently a two-step process. In the bindings generation step, | 36 Compilation is currently a two-step process. In the bindings generation step, |
| 34 the source files are compiled into `compiled/bindings.cpp.js` with the | 37 the source files are compiled into `compiled/bindings.cpp.js` with the |
| 35 `PRINT_BINDINGS` symbol defined. This application is then executed via Node.js | 38 `PRINT_BINDINGS` symbol defined. This application is then executed via Node.js |
| 36 and will print JavaScript wrappers for the C++ classes to | 39 and will print JavaScript wrappers for the C++ classes to |
| 37 `compiled/bindings.js` according to definitions within the `EMSCRIPTEN_BINDINGS` | 40 `build/bindings.js` according to definitions within the `EMSCRIPTEN_BINDINGS` |
| 38 macro in `compiled/bindings.cpp`. | 41 macro in `compiled/bindings.cpp`. |
| 39 | 42 |
| 40 In the actual compilation step the source files are compiled into | 43 In the actual compilation step the source files are compiled into |
| 41 `lib/compiled.js` without the `PRINT_BINDINGS` symbol, so that the | 44 `build/compiled.js` without the `PRINT_BINDINGS` symbol, so that the |
| 42 `EMSCRIPTEN_BINDINGS` macro ignores its contents and merely emits some generic | 45 `EMSCRIPTEN_BINDINGS` macro ignores its contents and merely emits some generic |
| 43 functions necessary for the JavaScript bindings to work. The previously | 46 functions necessary for the JavaScript bindings to work. The previously |
| 44 generated `compiled/bindings.js` file is added to the end of Emscripten output. | 47 generated `compiled/bindings.js` file is added to the end of Emscripten output. |
| 45 | 48 |
| 46 The binding generation approach is heavily inspired by | 49 The binding generation approach is heavily inspired by |
| 47 [embind](http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_an
d_javascript/embind.html). | 50 [embind](http://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_an
d_javascript/embind.html). |
| 48 However, embind doesn't use a separate build step to produce the bindings, the | 51 However, embind doesn't use a separate build step to produce the bindings, the |
| 49 bindings are rather generated dynamically at run time. As a side-effect, it | 52 bindings are rather generated dynamically at run time. As a side-effect, it |
| 50 increases the build size considerably and also imposes a significant performance | 53 increases the build size considerably and also imposes a significant performance |
| 51 penalty. Also, generating JavaScript code dynamically is discouraged for browser | 54 penalty. Also, generating JavaScript code dynamically is discouraged for browser |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 Linting | 88 Linting |
| 86 ------- | 89 ------- |
| 87 | 90 |
| 88 You can lint the code using [ESLint](http://eslint.org). | 91 You can lint the code using [ESLint](http://eslint.org). |
| 89 | 92 |
| 90 eslint *.js chrome lib test | 93 eslint *.js chrome lib test |
| 91 | 94 |
| 92 You will need to set up ESLint and our configuration first, see | 95 You will need to set up ESLint and our configuration first, see |
| 93 [eslint-config-eyeo](https://hg.adblockplus.org/codingtools/file/tip/eslint-conf
ig-eyeo) | 96 [eslint-config-eyeo](https://hg.adblockplus.org/codingtools/file/tip/eslint-conf
ig-eyeo) |
| 94 for more information. | 97 for more information. |
| OLD | NEW |