| LEFT | RIGHT |
| 1 Experimental CMake build for adblockpluscore | 1 Experimental CMake build for adblockpluscore |
| 2 ============================================ | 2 ============================================ |
| 3 | 3 |
| 4 This files describes an experimental build using CMake. For the duration of | 4 This files describes an experimental build using CMake. For the duration of |
| 5 this experiment, this file will describe the build independently, leaving the | 5 this experiment, this file will describe the build independently, leaving the |
| 6 existing README.md intact. | 6 existing README.md intact. |
| 7 | 7 |
| 8 Requirements | 8 Requirements |
| 9 ------------ | 9 ------------ |
| 10 | 10 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 the specific location of the file are visible within the following command | 47 the specific location of the file are visible within the following command |
| 48 line fragment: | 48 line fragment: |
| 49 | 49 |
| 50 ``` | 50 ``` |
| 51 cmake -DCMAKE_TOOLCHAIN_FILE=<EmscriptenRoot>/cmake/Modules/Platform/Emscrip
ten.cmake [...] | 51 cmake -DCMAKE_TOOLCHAIN_FILE=<EmscriptenRoot>/cmake/Modules/Platform/Emscrip
ten.cmake [...] |
| 52 ``` | 52 ``` |
| 53 | 53 |
| 54 Note that the `<EmscriptenRoot>` about is _not_ the root of the Emscripten | 54 Note that the `<EmscriptenRoot>` about is _not_ the root of the Emscripten |
| 55 SDK. Within the SDK, the location is `<SdkRoot>/emscripten/<version>` | 55 SDK. Within the SDK, the location is `<SdkRoot>/emscripten/<version>` |
| 56 | 56 |
| 57 This toolchain file assumes that it's running within an Emscripten shell with | 57 #### Emscripten environment |
| 58 all paths and environment variables set up. CMake will appear to configure | |
| 59 correctly outside this, but will not find executables, etc. | |
| 60 | 58 |
| 59 The Emscripten toolchain file is not particularly mature and can somewhat |
| 60 brittle in practice. In particular, it does not attempt to see if it's being |
| 61 used from within its SDK installation tree. Instead, it assumes that it is |
| 62 running from within an Emscripten shell. It requires all relevant executables |
| 63 to be present with the search path. It expects to find certain environment |
| 64 variables. |
| 65 |
| 66 Therefore, it is highly recommended that initial configuration of CMake be run |
| 67 from within an Emscripten shell. These are available from the Emscripten SDK. |
| 68 CMake will appear to configure correctly in other circumstances, but it can |
| 69 fail otherwise. |
| 70 |
| 71 Using CMake |
| 72 ----------- |
| 73 |
| 74 CMake supports build both inside the source tree and outside it. The CMake |
| 75 working directory is whatever the current directory is when CMake is initially |
| 76 configured. The project root is specified on the command line of this |
| 77 configuration run. For an in-source build, simply run CMake in the project root. |
| 78 |
| 79 The present CMakeLists.txt is better suited for an out-of-source build. It |
| 80 does not put its intermediate or output files in any special place, so they all |
| 81 end up in the build directory. |
| 82 |
| 83 ### Configurations |
| 84 |
| 85 The present CMakeLists.txt supports four configurations: |
| 86 * Release - `compile` |
| 87 * Debug - `compile -d` |
| 88 * ReleaseTrace - `compile -t` |
| 89 * DebugTrace - `compile -d -t` |
| 90 |
| 91 A single-configuration generator, such as `make` or `ninja`, supports only one |
| 92 configuration per CMake build directory. Multiple build directories for |
| 93 different configurations, however, work just fine; each build directory gets |
| 94 its own CMake cache and working directory. [EH: I have a test setup locally |
| 95 with all four configurations and some scripts to configure everything and to |
| 96 build everything.] If no configuration is specified, it defaults to "Release". |
| 97 |
| 98 ``` |
| 99 cmake -DCMAKE_BUILD_TYPE=Release [...] |
| 100 ``` |
| 101 |
| 102 A multiple-configuration generator, such as for Eclipse or XCode, makes all |
| 103 configurations available through the user interface of the IDE. |
| 61 | 104 |
| 62 Notes | 105 Notes |
| 63 ----- | 106 ----- |
| 64 | 107 |
| 65 ### Setting up Emscripten under Cygwin. | 108 ### Setting up Emscripten under Cygwin. |
| 66 | 109 |
| 67 tl;dr version: Don't. | 110 tl;dr version: Don't. |
| 68 | 111 |
| 69 It's a known issue that the Emscripten tool chain as distributed does not work | 112 It's a known issue that the Emscripten tool chain as distributed does not work |
| 70 under Cygwin. The core of the issue is that Emscripten uses a number of native | 113 under Cygwin. The core of the issue is that Emscripten uses a number of native |
| 71 Windows executables and the transition from Cygwin path names to Windows path | 114 Windows executables and the transition from Cygwin path names to Windows path |
| 72 names doesn't work correctly. | 115 names doesn't work correctly. |
| 73 | 116 |
| 74 https://github.com/kripken/emscripten/issues/3947 | 117 https://github.com/kripken/emscripten/issues/3947 |
| 75 | 118 |
| 76 Once the command `emcc -v` runs correctly, CMake will be able to set up the | 119 Once the command `emcc -v` runs correctly, CMake will be able to set up the |
| 77 Emscripten tool chain. Even then, there will still be errors in other ways. | 120 Emscripten tool chain. Even then, there will still be errors in other ways. |
| 78 | 121 |
| 79 | 122 |
| 80 Work-in-Progress Notes | 123 Draft Notes |
| 81 ---------------------- | 124 ----------- |
| 82 | 125 |
| 83 There are a number of known deficiencies. | 126 There are a few known deficiencies. |
| 84 | |
| 85 ### Configurations | |
| 86 | |
| 87 The compile script has two options `--debug` and `--trace`. The current CMake | |
| 88 file has debug on and trace off. The right way to do with is with CMake | |
| 89 configurations: "Release", "ReleaseTrace", "Debug", "DebugTrace". | |
| 90 | |
| 91 ### Building bindings | |
| 92 | |
| 93 As of the present version, the step to run the bindings generator always runs | |
| 94 whether it needs to or not. This deficiency arises because the obvious way to do | |
| 95 this in CMake uses phony make targets that have this behavior. | |
| 96 | 127 |
| 97 ### Other targets | 128 ### Other targets |
| 98 | 129 |
| 99 There are no targets for testing or documentation. | 130 There are no targets for testing or documentation. |
| 100 | 131 |
| 101 ### Location of generated files | 132 ### eslint |
| 102 | 133 |
| 103 The generated files are built in the root directory at present. This works fine | 134 There's no provision for ignoring compiled-js files in eslint. This is only an |
| 104 for an out-of-source build with CMake. It might work less fine in the long term | 135 issue for an in-source-tree build. |
| 105 for an in-source build, but it has been expedient to date to put these files | |
| 106 in different locations from the `compile` script to make "before" vs. "after" | |
| 107 comparisons more quickly. Here's a list of these changes. | |
| 108 | |
| 109 * `compiled/bindings.cpp.js` --> `binding-generator.js` | |
| 110 * `compiled/bindings.js` --> `bindings.js` | |
| 111 * `lib/compiled.js` --> `compiled.js` | |
| 112 * `lib/compiled.js.symbols` --> `compiled.js.symbols` | |
| 113 | |
| LEFT | RIGHT |