summaryrefslogtreecommitdiff
path: root/apps/soreduce/Library.h
blob: 46cb03feac7b678dd47fa112d1008efcfe0028ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// -*- C++ -*-
#ifndef _LIBRARY_H_
#define _LIBRARY_H_

// -*- C++ -*-
// $Id$

// File: Library.h

// Author: Phil Mesnier

// A Library is a collection of Obj_Modules that define a single shared 
// library. It is used to manipulate the list of unresolved references by 
// removing those that are resolved and adding those brought in by new modules
// that are required to resolve references.  The Library is responsible 
// for outputting a specialized makefile build the reduce footprint library.

#include "Obj_Module.h"

// The Makefile generator class serves as the base class used to output the
// custom makefiles (or in the future, project files) used to build the 
// subsetted libraries.
// The base class will make libACE_subset.so

class Makefile_Generator
{
public:
  Makefile_Generator (const ACE_CString&  );
  virtual ~Makefile_Generator();

  void write_prolog (const ACE_CString& );
  void write_file (const ACE_CString& );
  void write_epilog ();

protected:
  virtual void write_libdeps();
  virtual void write_initial_rules();
  virtual void write_final_rules();

  ofstream makefile_;
  ACE_CString libname_;
  ACE_CString makefilename_;
};

// Generate makefiles for  libraries dependant on ACE, that are not TAO.
class Make_ACE_Dep_Lib : public Makefile_Generator
{
public:
  Make_ACE_Dep_Lib (const ACE_CString& );

protected:
  virtual void write_libdeps();
};

// Generates makefiles for libTAO_subset.so
class Make_TAO_Lib : public Make_ACE_Dep_Lib
{
public:
  Make_TAO_Lib (const ACE_CString& );

protected:
  virtual void write_libdeps();
  virtual void write_initial_rules();
  virtual void write_final_rules();
};

// Generates makefiles for libs dependant on TAO.  This has a problem when
// building libraries in the orbsvcs tree. 
class Make_TAO_Dep_Lib : public Make_TAO_Lib
{
public:
  Make_TAO_Dep_Lib (const ACE_CString& );

protected:
  virtual void write_libdeps();
};

//----------------------------------------------------------------------------

class Library 
{
public:

  Library (const ACE_TCHAR *name = 0 ); 
  /// Constructor is responsible for loading all of the modules related to the
  /// library
  ~Library ();

  // Resolve interates over the supplied list of undefined signatures to locate
  // modules that contain definitions. Any symbol defined in a module marked as
  // exported is simply removed from the undef list. Any symbol defined in a
  // module not yet exported removed from the undef list, the module is marked
  // as exported, and its unresolved symbols are added to the undef list.
  void resolve (Sig_List &undefs);

  // Outputs a list of files suitable for inclusion in a makefile to produce
  // a subsetted library. If the argument is non-zero, reference countes for
  // each module are also listed.
  void write_export_list ( int );

  // set the path to find the .so files
  void set_path (const ACE_TCHAR *p );

  // Load the actual .so files from the path.
  void load_modules();

  // returns the library name
  const ACE_CString &name () const;

  // returns non-zero if the module count is > 0.
  int has_modules () const;

private:
  ACE_CString name_;
  ACE_CString path_;
  
  int num_modules_;
  int num_exports_;
  int num_extrefs_;
 
  Obj_Module **modules_;
  Sig_List exported_;
  Makefile_Generator *makefile_;
};

#endif /* _LIBRARY_H_ */