OLD | NEW |
(Empty) | |
| 1 Experimental CMake build for adblockpluscore |
| 2 ============================================ |
| 3 |
| 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 |
| 6 existing README.md intact. |
| 7 |
| 8 Requirements |
| 9 ------------ |
| 10 |
| 11 * [CMake](https://cmake.org). The Emscripten toolchain file requires version |
| 12 3.4.3 or newer. |
| 13 * [Emscripten 1.37](https://kripken.github.io/emscripten-site/) |
| 14 |
| 15 Configuring CMake |
| 16 ----------------- |
| 17 |
| 18 CMake uses a cache to hold configuration information that is not an ordinary |
| 19 part of the write-build-test cycle. Thus the first invocation of CMake requires |
| 20 extra configuration parameters. Subsequent invocations do not require these. |
| 21 We require two such kinds of configuration data: |
| 22 * Generator for build system |
| 23 * Emscriptem tool chain |
| 24 |
| 25 ### Build system generator |
| 26 |
| 27 CMake is a cross-platform build system generator. It has the capability of |
| 28 generating project files for a number of build systems, including those that |
| 29 are an integral part of an IDE. Specifically, these include makefiles in |
| 30 several variants, ninja, Eclipse, Visual Studio, and XCode. |
| 31 |
| 32 To set up the cache with a generator, use the `-G` option on the CMake command |
| 33 line. The quickest way to find the exact text to use as the argument to this |
| 34 option is run CMake with the `--help` option`. Further information is available |
| 35 in the CMake documentation; see cmake-generators(7). |
| 36 |
| 37 ### Emscripten |
| 38 |
| 39 CMake treats Emscripten as a cross-compiler. CMake can auto-detect native |
| 40 compilers but requires pre-configuration for cross-compilers. Emscripten |
| 41 provides a CMake toolchain file for this purpose. The location of this file is |
| 42 what CMake ultimately needs. |
| 43 |
| 44 The most direct way to specify the path to the toolchain file is to define a |
| 45 cache variable directly on the CMake command line. The toolchain file is |
| 46 buried within the Emscripten installation. The name of the cache variable and |
| 47 the specific location of the file are visible within the following command |
| 48 line fragment: |
| 49 |
| 50 ``` |
| 51 cmake -DCMAKE_TOOLCHAIN_FILE=<EmscriptenRoot>/cmake/Modules/Platform/Emscrip
ten.cmake [...] |
| 52 ``` |
| 53 |
| 54 Note that the `<EmscriptenRoot>` about is _not_ the root of the Emscripten |
| 55 SDK. Within the SDK, the location is `<SdkRoot>/emscripten/<version>` |
| 56 |
| 57 This toolchain file assumes that it's running within an Emscripten shell with |
| 58 all paths and environment variables set up. CMake will appear to configure |
| 59 correctly outside this, but will not find executables, etc. |
| 60 |
| 61 |
| 62 Notes |
| 63 ----- |
| 64 |
| 65 ### Setting up Emscripten under Cygwin. |
| 66 |
| 67 tl;dr version: Don't. |
| 68 |
| 69 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 |
| 71 Windows executables and the transition from Cygwin path names to Windows path |
| 72 names doesn't work correctly. |
| 73 |
| 74 https://github.com/kripken/emscripten/issues/3947 |
| 75 |
| 76 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. |
| 78 |
| 79 |
| 80 Work-in-Progress Notes |
| 81 ---------------------- |
| 82 |
| 83 There are a number of 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 |
| 97 ### Other targets |
| 98 |
| 99 There are no targets for testing or documentation. |
| 100 |
| 101 ### Location of generated files |
| 102 |
| 103 The generated files are built in the root directory at present. This works fine |
| 104 for an out-of-source build with CMake. It might work less fine in the long term |
| 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 |
OLD | NEW |