Proposed CEF code generator tool

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Proposed CEF code generator tool

Postby magreenblatt » Tue Dec 15, 2015 11:04 pm

Hi All,

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
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Proposed CEF code generator tool

Postby edjamesx » Tue Feb 02, 2016 7:06 am

That's a great Idea. It wold help for more customization.

Instead of making use of chromium binary distribution for CEF (this is how we compile CEF today), If we can get the source for CEF binary distribution from chrome it will be great, which allows us to selectively disable or enable the features.
edjamesx
Newbie
 
Posts: 2
Joined: Wed Dec 23, 2015 1:39 am

Re: Proposed CEF code generator tool

Postby magreenblatt » Tue Feb 02, 2016 11:12 am

edjamesx wrote:That's a great Idea. It wold help for more customization.

Instead of making use of chromium binary distribution for CEF (this is how we compile CEF today), If we can get the source for CEF binary distribution from chrome it will be great, which allows us to selectively disable or enable the features.

Do you mean a website that allows you to enable/disable features and then provides a download of the resulting source code + binary distribution? Or something else?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Proposed CEF code generator tool

Postby edjamesx » Wed Feb 03, 2016 11:33 am

I meant, CEF has code in two parts , API code , binary distribution for each platforms.

If we were able to access the source instead of binary distribution , it would allow for more customization.

sorry if I missed out anything. This is how I compiled my source...for CEF
edjamesx
Newbie
 
Posts: 2
Joined: Wed Dec 23, 2015 1:39 am

Re: Proposed CEF code generator tool

Postby magreenblatt » Wed Feb 03, 2016 5:02 pm

edjamesx wrote:I meant, CEF has code in two parts , API code , binary distribution for each platforms.

If we were able to access the source instead of binary distribution , it would allow for more customization.

sorry if I missed out anything. This is how I compiled my source...for CEF

I'm still not completely clear on what you mean. How would you use the source code without the binary distribution? Or do you mean distribute all of the source code as a separate zip file (instead of including it with the platform binaries) and make it easier to drop in the binaries for different platforms?
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 19 guests