| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 libadblockplus | 1 libadblockplus |
| 2 ============== | 2 ============== |
| 3 | 3 |
| 4 A C++ library offering the core functionality of Adblock Plus. | 4 A C++ library offering the core functionality of Adblock Plus. |
| 5 | 5 |
| 6 Getting/updating the dependencies | 6 Getting/updating the dependencies |
| 7 --------------------------------- | 7 --------------------------------- |
| 8 | 8 |
| 9 libadblockplus has dependencies that aren't part of this repository. They are | 9 libadblockplus has dependencies that aren't part of this repository. They are |
| 10 retrieved and updated during the build process, but you can also manually update | 10 retrieved and updated during the build process, but you can also manually update |
| 11 them by running the following: | 11 them by running the following: |
| 12 | 12 |
| 13 ./ensure_dependencies.py | 13 ./ensure_dependencies.py |
| 14 | 14 |
| 15 Additionally one should provide V8 headers in order to build libadblockplus | |
| 16 library and V8 prebuilt libraries in order to link a binary (executable, shared | |
| 17 object/DLL), even libadblockplus tests. For more details see below. | |
| 18 | |
| 15 Building | 19 Building |
| 16 -------- | 20 -------- |
| 17 | 21 |
| 18 ### Supported target platforms and prerequisites | 22 ### Supported target platforms and prerequisites |
| 19 | 23 |
| 20 You need a C++11 compatible compiler to build libadblockplus. | 24 You need a C++14 compatible compiler to build libadblockplus. Below there is |
| 25 the list of tested tools. | |
| 21 | 26 |
| 22 Win32: | 27 Win32: |
| 23 * At least v140 Visual C++ toolset (available in Microsoft Visual Studio 2015). | 28 * At least v141 Visual C++ toolset (available in Microsoft Visual Studio 2017). |
| 24 | 29 |
| 25 Linux: | 30 Linux: |
| 26 * g++ 5.2 | 31 * g++ 7.3 |
| 27 | 32 |
| 28 Mac: | 33 Mac: |
| 29 * clang 3.6 for OS X/macOS (Xcode should be installed and its developer tools sh ould be "selected"). | 34 * Apple LLVM 9.1.0 for OS X/macOS (Xcode should be installed and its developer t ools should be "selected"). |
| 30 | 35 |
| 31 Android: | 36 Android: |
| 32 * The host system should be Linux or OS X | 37 * The host system should be Linux or OS X |
| 33 * android-ndk-r12b Here are the links for downloading | 38 * android-ndk-r16b, here are the links for downloading |
| 34 [OS X](https://dl.google.com/android/repository/android-ndk-r12b-darwin-x86_64 .zip), | 39 [OS X](https://dl.google.com/android/repository/android-ndk-r16b-darwin-x86_64 .zip), |
| 35 [Linux 64](https://dl.google.com/android/repository/android-ndk-r12b-linux-x86 _64.zip). | 40 [Linux 64](https://dl.google.com/android/repository/android-ndk-r16b-linux-x86 _64.zip). |
| 36 * g++ multilib | 41 * g++ multilib |
| 37 | 42 |
| 38 If you have a compilation issue with another compiler please [create an issue](h ttps://issues.adblockplus.org/). | 43 If you have a compilation issue with another compiler please [create an issue](h ttps://issues.adblockplus.org/). |
| 39 | 44 |
| 40 You also need Python 2.7 and ensure that `python.exe` is in your `PATH`. | 45 You also need Python 2.7 and ensure that `python.exe` is in your `PATH`. |
| 41 | 46 |
| 42 ### Unix | 47 ### Unix |
| 43 | 48 |
| 49 * Prepare V8 and set environment variables LIBV8_LIB_DIR and LIBV8_INCLUDE_DIR. | |
| 50 LIBV8_INCLUDE_DIR should point to the include directory of V8, e.g. | |
| 51 `.../v8/include` and there should be `libv8_monolith.a` in the directory | |
| 52 LIBV8_LIB_DIR. | |
|
hub
2018/05/23 18:27:05
it would be nice to have directions to optionally
anton
2018/05/24 07:41:55
yes, i completely agree.
It can be unclear on what
sergei
2018/05/24 08:45:42
That's all right but can we do it in the following
hub
2018/05/24 12:29:51
There is somewhat a connection. I tried to build o
sergei
2018/05/25 10:05:24
I have added the mentioning of the V8 version in t
| |
| 53 | |
| 44 Using Make: | 54 Using Make: |
| 45 | 55 |
| 46 make | 56 make |
| 47 | 57 |
| 48 The default target architecture is the architecture of a host. In order to build for a different architecture pass `ARCH` to `make`, e.g. run: | 58 The default target architecture is the architecture of a host. In order to build for a different architecture pass `TARGET_ARCH` to `make`, e.g. run: |
| 49 | 59 |
| 50 make ARCH=ia32 | 60 make TARGET_ARCH=ia32 |
| 51 | 61 |
| 52 supported values are `ia32` and `x64`. | 62 supported values are `ia32` and `x64`. |
| 53 | 63 |
| 54 | 64 |
| 55 To build and run the tests: | 65 To build and run the tests: |
| 56 | 66 |
| 57 make test | 67 make test |
| 58 | 68 |
| 59 Likewise, use the following with `ARCH`: | 69 Likewise, use the following with `TARGET_ARCH`: |
| 60 | 70 |
| 61 make test ARCH=ia32 | 71 make test TARGET_ARCH=ia32 |
| 62 | 72 |
| 63 To run specific tests, you can specify a filter: | 73 To run specific tests, you can specify a filter: |
| 64 | 74 |
| 65 make test FILTER=*.Matches | 75 make test FILTER=*.Matches |
| 66 | 76 |
| 67 ### Windows | 77 ### Windows |
| 68 | 78 |
| 69 * Execute `createsolution.bat` to generate project files, this will create | 79 * Prepare V8. Let's say V8 is prepared in `build/v8`. There should be V8 |
| 70 `build\ia32\libadblockplus.sln` (solution for the 32 bit build) and | 80 headers in `build/v8/include` and binaries in |
| 71 `build\x64\libadblockplus.sln` (solution for the 64 bit build). Unfortunately, | 81 `build/v8/win-%PLATFORM%.%CONFIGURATION%`, e.g ensure that there is |
| 72 V8 doesn't support creating both from the same project files. | 82 `v8_monolith.lib` available as `build/v8/win-x64.release/v8_monolith.lib`. |
| 83 | |
| 84 * Set GYP variable `v8_dir` pointing to the prepared V8, `<path to build/v8>`. | |
| 85 E.g. `set "GYP_DEFINES=v8_dir=e:/v8-6.7"` and execute `createsolution.bat` to | |
| 86 generate project files, this will create `build\ia32\libadblockplus.sln` | |
| 87 (solution for the 32 bit build) and `build\x64\libadblockplus.sln` (solution | |
| 88 for the 64 bit build). | |
| 89 | |
| 73 * Open `build\ia32\libadblockplus.sln` or `build\x64\libadblockplus.sln` in | 90 * Open `build\ia32\libadblockplus.sln` or `build\x64\libadblockplus.sln` in |
| 74 Visual Studio and build the solution there. Alternatively you can use the | 91 Visual Studio and build the solution there. Alternatively you can use the |
| 75 `msbuild` command line tool, e.g. run `msbuild /m build\ia32\libadblockplus.sln` | 92 `msbuild` command line tool, e.g. run `msbuild /m build\ia32\libadblockplus.sln` |
| 76 from the Visual Studio Developer Command Prompt to create a 32 bit debug build. | 93 from the Visual Studio Developer Command Prompt to create a 32 bit debug build. |
| 77 | 94 |
| 78 Tested on Microsoft Visual Studio 2015 Community Edition. | 95 Tested on Microsoft Visual Studio 2017 Community Edition. |
| 96 | |
| 97 For more details see CI configuration for appveyor. | |
| 79 | 98 |
| 80 ### Building for Android | 99 ### Building for Android |
| 81 | 100 |
| 82 First set ANDROID_NDK_ROOT environment variable to your Android NDK directory. | 101 Configure V8 as for Unix and set ANDROID_NDK_ROOT environment variable to your |
| 102 Android NDK directory. | |
| 83 | 103 |
| 84 To build for *x86* arch run: | 104 To build for *x86* arch run: |
| 85 | 105 |
| 86 make android_x86 | 106 make TARGET_OS=android TARGET_ARCH=ia32 |
| 87 | 107 |
| 88 To build for *arm* or *arm64* arch run: | 108 To build for *arm* or *arm64* arch run: |
| 89 | 109 |
| 90 make android_arm | 110 make TARGET_OS=android TARGET_ARCH=arm |
| 91 | 111 |
| 92 or | 112 or |
| 93 make android_arm64 | 113 make TARGET_OS=android TARGET_ARCH=arm64 |
| 94 | 114 |
| 95 Usage | 115 Usage |
| 96 ----- | 116 ----- |
| 97 | 117 |
| 98 You can use libadblockplus to build an ad blocker. Or, strictly speaking, a web | 118 You can use libadblockplus to build an ad blocker. Or, strictly speaking, a web |
| 99 content filter. Just like Adblock Plus, it can detect resources that should be | 119 content filter. Just like Adblock Plus, it can detect resources that should be |
| 100 blocked based on their URL and context information, and generate CSS selectors | 120 blocked based on their URL and context information, and generate CSS selectors |
| 101 to hide DOM elements. | 121 to hide DOM elements. |
| 102 | 122 |
| 103 The basic usage is explained below, see the | 123 The basic usage is explained below, see the |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 ### Unix | 266 ### Unix |
| 247 | 267 |
| 248 The shell is automatically built by `make`, you can run it as follows: | 268 The shell is automatically built by `make`, you can run it as follows: |
| 249 | 269 |
| 250 build/out/abpshell | 270 build/out/abpshell |
| 251 | 271 |
| 252 ### Windows | 272 ### Windows |
| 253 | 273 |
| 254 Just run the project *abpshell*. | 274 Just run the project *abpshell*. |
| 255 | 275 |
| 256 Building with prebuilt V8 | 276 Building V8 |
| 257 ------------------------- | 277 ------------------------- |
| 258 | 278 |
| 259 This functionality is only for internal usage. | 279 Just in case one can find args files to build V8 in `v8-args` directory. |
| 260 | |
| 261 ## How to use it: | |
| 262 Let's say that v8 is stored in `libadblockplus/v8-bins`. | |
| 263 ### Windows | |
| 264 | |
| 265 set "GYP_DEFINES=libv8_include_dir=../../v8-bins/win/include libv8_lib_dir=. ./../v8-bins/win/Win32/<(CONFIGURATION_NAME) libv8_no_build=true" | |
| 266 createsolution.bat | |
| 267 | |
| 268 ### *nix | |
| 269 | |
| 270 [ANDROID_NDK_ROOT=....] make [android_...] LIBV8_LIB_DIR=../v8-bins/libs LIB V8_INCLUDE_DIR=../v8-bins/include | |
| 271 | |
| 272 The rest is the same. | |
| 273 | 280 |
| 274 Linting | 281 Linting |
| 275 ------- | 282 ------- |
| 276 | 283 |
| 277 You can lint the code using [ESLint](http://eslint.org). | 284 You can lint the code using [ESLint](http://eslint.org). |
| 278 | 285 |
| 279 npm run eslint | 286 npm run eslint |
| 280 | 287 |
| 281 In order to set up ESLint and | 288 In order to set up ESLint and |
| 282 [configuration eslint-config-eyeo](https://hg.adblockplus.org/codingtools/file/t ip/eslint-config-eyeo) you need [Node.js 7 or higher](https://nodejs.org/) and o nce it is installed please run `npm install` in the repository directory. | 289 [configuration eslint-config-eyeo](https://hg.adblockplus.org/codingtools/file/t ip/eslint-config-eyeo) you need [Node.js 7 or higher](https://nodejs.org/) and o nce it is installed please run `npm install` in the repository directory. |
| 283 | 290 |
| OLD | NEW |