 
   componentGen = componentLibDefinitions componentLib, 'createComponent'
   files = {}
+  files[outputDir + "/componentlib-ports.h"] = componentGen.ports
   files[outputDir + "/componentlib-ids.h"] = componentGen.ids
-  files[outputDir + "/componentlib-ports.h"] = componentGen.ports
+  files[outputDir + "/componentlib-factory.hpp"] = componentGen.factory
   files[outputDir + "/componentlib-map.json"] = componentGen.map
-  files[outputDir + "/componentlib.hpp"] = componentGen.all
+
+  lib = componentGen.components + '\n' + componentGen.ids + componentGen.factory 
+  files[outputDir + "/componentlib.hpp"] = lib
 
   graphData = commandstream.cmdStreamFromGraph(componentLib, graph, null, true)
   graphMaps = generateGraphMaps componentLib, graph

  map[key].id

componentLibDefinitions = (componentLib, factoryMethodName) ->
  ids = generateConstInt("Id", componentLib.getComponents(true, true))
  ports = generateComponentPortDefinitions(componentLib)

  includes = generateComponentIncludes(componentLib)
  factory = generateComponentFactory(componentLib, factoryMethodName)
  sourceOutput = includes + "\n\n" + factory
  all = ids + ports + sourceOutput
  map = generateComponentMap componentLib

  r =
    ids: ids
    ports: ports
    includes: includes
    factory: factory
    source: sourceOutput
    map: map
    all: all
  return r

getDefinitions = (baseDir) ->

  files[outputBase + "_maps.h"] = graphMaps

  includes = "// !!! generated by: microflo generate\n"
  includes += "// Graph definition \n" 
  includes += include(outputBase + ".h") + '\n'
  includes += "#define MICROFLO_EMBED_GRAPH 1" + '\n'

  includes += include(path.join(microfloDir, 'microflo.h')) + '\n'

  if enableMaps
    includes += "// Graph metadata\n" 
    includes += include(outputBase + "_maps.h") + "\n"

  includes += include(mainFile) + '\n'

  includes += '// Components \n'
  includes += include('./componentlib-ports.h') + '\n'
  includes += componentGen.components

  includes += '// Component factory \n'
  includes += include('./componentlib-ids.h') + '\n'
  includes += include('./componentlib-factory.hpp') + '\n'

  files[outputFile] = includes

