I'm considering the creation of a code generator tool for CEF C++ projects. Starting with a CEF binary distribution and using the provided GUI tool you'll be able to create a completely separate directory structure including CMake configuration and C++ code for a custom CEF-based client application. The resulting code can then be further customized either by hand or by re-running the GUI tool.
Functionality supported by this tool could include:
- Set app name, title, icon, etc.
- Choose singleton or multi-run behavior
- Custom top menu
- Custom context menus
- Map menu items to execution of C++ or JS functions
- Map custom schemes to zip files, directories, etc (using CefResourceManager)
- Enable JS bindings (using CefMessageRouter)
- Specify external protocols to support
- Specify URLs to whitelist or blacklist (e.g. only allow access to domains of your choice)
- Configure popup behavior (allow, block, etc)
- Configure plugin behavior (allow, block, etc)
- Configure common settings & command-line flags
- Upgrade/downgrade CEF versions (provided you don't modify the generated code too much)
The system will work approximately as follows:
1. ceftemplate project that is basically cefsimple plus all of the above functionality. The ceftemplate code will compile successfully as part of CEF development but effectively do nothing (empty default method implementations, etc). It will include comments that can be pre-processed to add/remove/customize sections of code using the tool provided in #2.
2. cefgenerator tool written in C++ that is built as part of the CEF/Chromium build (may have build dependencies on Chromium code). This tool will provide a command-line interface for reading a config JSON file and outputting a customized version of the ceftemplate project in a separate tree structure (example below). This executable will be included in the binary distribution (will have no CEF/Chromium runtime dependencies).
3. cefgeneratorui tool written in HTML/JS that will provide a UI for reading/writing the config JSON file. As part of the CEF build process the cefgenerator tool will be used to generate C++ source code and package this HTML/JS into an executable. This executable will be included in the binary distribution (will have dependencies on ceftemplate (packaged as a zip file), cefgenerator and CEF).
The output of running cefgenerator for third-party client applications will be a directory structure like the following:
- Code: Select all
src/
CMakeLists.txt <-- builds clientapp1 and clientapp2
macros.cmake
clientapp1.json <-- config file for cefgenerator to make clientapp1
clientapp1/
CMakeLists.txt
*.cc, *.h <-- generated source code with optional customizations
clientapp2.json <-- config file for cefgenerator to make clientapp2
clientapp2/
CMakeLists.txt
*.cc, *.h <-- generated source code with optional customizations
third_party/
cef/
win32/ <-- complete CEF binary distribution for Win32.
linux64/ <-- complete CEF binary distribution for Linux64.
.../ <-- and other platforms
The source code for #2 and #3 will be modular such that it can easily be maintained while evolving the CEF public API. For example, the C++ generator code and HTML/JS UI code for each feature will be written as separate modules that are implicitly loaded at build or run time. Adding a new feature will involve:
1. Develop the feature in CEF.
2. Add the minimal feature code to ceftemplate with appropriate pre-processor comments.
3. Add new C++ and HTML/JS modules to cefgenerator for configuring the feature.
4. The feature will be supported by the next CEF binary distribution build.
Some areas that are not yet determined:
- Full set of functionality that the template pre-processor needs to support
- How to support user modifications to generated code without breaking future add/remove using the generator tool
- Actual code structure, helper libraries, etc., required for the various tools
- How to write unit tests for the new tools and resulting client applications -- I'm leaning towards https://github.com/philsquared/Catch
Would this tool be useful to you? Any suggestions/requests/etc?
Thanks,
Marshall