Module system and source tree reorg
James LewisMoss
jimdres@mindspring.com
25 Jul 2001 12:30:42 -0400
>>>>> On Wed, 25 Jul 2001 10:46:30 -0500, grib@billgribble.com (Bill Gribble) said:
Bill> 1. Modules are the basic organizing unit for the code. All the
Bill> code
Bill> needed for a module goes in one place, separate from the code
Bill> for other modules. In my source tree, this is in
Bill> subdirectories of src/modules/ but eventually it's my goal that
Bill> *all* of gnucash should be in modules, so maybe we should just
Bill> put modules in top-level subdirs of src/
Bill> 2. A module should be self-contained. All the stuff needed to
Bill> build
Bill> the module, including C code, Scheme code, g-wrap specs, g-wrap
Bill> helper files, tests, and documentation should all go in one
Bill> place. For example, the "engine" module looks like this:
Bill> src/modules/engine
Bill> Makefile.am gw-engine-spec.scm - g-wrap spec file for just
Bill> the engine API engine-helpers.{c,h} - g-wrap helper
Bill> functions for engine types,
Bill> from gnc-helpers.{c,h}
Bill> gncmod-engine.c - the actual module definition stub file
Bill> gnucash/ - subdir for Scheme module files
Bill> engine.scm - (gnucash engine) Scheme module
Bill> engine-init.scm - files from old src/scm (loaded by
Bill> engine.scm) gnc-numeric.scm commodity-table.scm
Bill> iso-4217-currencies.scm
Bill> engine/ - subdir for 'libgncengine.la' source
Bill> test/ - tests for libgncengine.la
Bill> test/ - tests for the "engine" module (libgncmod-engine.la)
Bill> What's nice about this is that for the first time all the code
Bill> needed to use the engine in an app is in one place, and I can
Bill> load it up from a Scheme script like so:
Bill> (use-modules (gnucash gnc-module)) (gnc:module-system-init)
Bill> (gnc:module-load "gnucash/engine" 0)
Bill> (let ((acc (gnc:malloc-account)))
Bill> ...)
The only thing I'd comment on here is that the module-system-init func
should not have to be run. It should conditionally be run a
module-load each time it's run. I know I know. That's not
efficient. But... To test if it has been run yet is an int compare.
Not overly processor intensive. And the first time someone forgets to
run the -init it'll probably take as long to figure out what's wrong
as all the processor time needed to do that int compare (who knows
really, but you get my point :).
Bill> subdir-name gnc-module-name
Bill> description
Bill> gnc-module n/a
Bill> the gnc-module library source. it's not a module itself.
Bill> You can either link with libgnc-module.la and call
Bill> gnc_module_system_init from C, or (use-modules (gnucash
Bill> gnc-module)) (gnc:module-system-init) from Scheme, which
Bill> dynamic-links the library and calls the init function.
Bill> gnc-app n/a
Bill> this would be where the actual gnucash application and
Bill> utilities live. It may be useful to have a module called
Bill> 'gnc-util' or something for non-gui utility code.
Bill> gnc-component gnucash/component
Bill> the gnc-component events-and-callbacks interface
Bill> gnc-engine gnucash/engine
Bill> the engine itself, with no backends. Where backends are now
Bill> directly 'dlopen'-ed, dlopen calls would be replaced with
Bill> gnc_module_loads; 'dlsym' can be replaced with
Bill> gnc_module_lookup
Bill> backend-file gnucash/engine/backend/file backend-postgres
Bill> gnucash/engine/backend/postgres backend-rpc
Bill> gnucash/engine/backend/rpc
Bill> the backends. A kernel-config-like thing at the top level,
Bill> or just more args to top-level configure, can switch
Bill> compilation on and off.
Maybe gnucash/backend instead.
Bill> report-core gnucash/report/core
Bill> non-gui code for representing and running reports. This
Bill> would be mostly report.scm plus html-*.scm. Should be useful
Bill> on its own without GUI.
Bill> report-guppi gnucash/report/guppi
Bill> support for guppi graphs in reports
Bill> reports-text gnucash/reports/basic
Bill> most of the non-graphing reports we have now
Bill> reports-guppi gucash/reports/guppi
Bill> reports that use guppi
Bill> qif-io-core gnucash/qif-io/core
Bill> non-gui code for importing and exporting QIF files. Should
Bill> be useful without GUI.
QIF stuff feels like a backend to me that doesn't write. It also
imports which might not be a bad idea for the other backends to do.
Jim
--
@James LewisMoss <dres@debian.org> | Blessed Be!
@ http://jimdres.home.mindspring.com | Linux is kewl!
@"Argue for your limitations and sure enough, they're yours." Bach