LibraryDefinition.st
author fm
Tue, 15 Aug 2006 20:06:04 +0200
changeset 9530 a60552823186
parent 9529 5f870d05954a
child 9533 fae577b43add
permissions -rw-r--r--
merge

"
 COPYRIGHT (c) 2006 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

"{ Package: 'stx:libbasic3' }"

Object subclass:#ProjectDefinition
        instanceVariableNames:''
        classVariableNames:''
        poolDictionaries:''
        category:'System-Support-Projects'
!

!ProjectDefinition class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 2006 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
! !

!ProjectDefinition class methodsFor:'instance creation'!

definitionClassForPackage:aPackageID
    ^ self definitionClassForPackage:aPackageID createIfAbsent:false

    "Modified: / 11-08-2006 / 14:29:21 / cg"
!

definitionClassForPackage:aPackageID createIfAbsent:doCreateIfAbsent
    |class|

    class := Smalltalk at:(aPackageID asString copy replaceAny:':/' with:$_) asSymbol.
    class isNil ifTrue:[
        doCreateIfAbsent ifTrue:[
            ^ self newForPackage:aPackageID    
        ]
    ].
    ^ class.

    "Created: / 11-08-2006 / 14:28:51 / cg"
!

newForPackage:packageID
    ^ self 
        newNamed:(self initialClassNameForDefinitionOf:packageID) 
        package:packageID.

    "Created: / 11-08-2006 / 14:27:19 / cg"
!

newNamed:newName package:packageID
    |newClass|

    "/ for now, we are strict.
    self assert:(self initialClassNameForDefinitionOf:packageID) = newName.
    newClass := self
                    subclass:(newName asSymbol)
                    instanceVariableNames:''
                    classVariableNames:''
                    poolDictionaries:''
                    category:(self defaultCategory).

    newClass package:packageID asSymbol.
    ^ newClass

    "Created: / 09-08-2006 / 17:57:37 / fm"
    "Modified: / 09-08-2006 / 19:27:53 / fm"
    "Modified: / 11-08-2006 / 14:18:01 / cg"
! !

!ProjectDefinition class methodsFor:'accessing'!

defaultCategory
    ^'* Projects *'

    "Created: / 11-08-2006 / 14:16:49 / cg"
!

initialClassNameForDefinitionOf:aPackageId
    |s|

    s := aPackageId asString copy replaceAny:':/' with:$_.
    (s endsWith:$_) ifTrue:[
        s := s copyWithoutLast:1
    ].
    ^ s

"
   DapasXProject initialClassNameForDefinitionOf:'bosch:dapasx/interactiver_editor' 
   DapasXProject initialClassNameForDefinitionOf:'stx:libbasic' 
   DapasXProject initialClassNameForDefinitionOf:'stx:goodies/xml' 
"

    "Created: / 09-08-2006 / 17:44:47 / fm"
    "Modified: / 11-08-2006 / 14:00:05 / cg"
!

libraryName
       ^ self libraryNameFor: self package

"
   bosch_dapasx_datenbasis_Definition libraryName   
"

    "Modified: / 09-08-2006 / 18:20:29 / fm"
!

libraryNameFor: aProjectID
       ^ aProjectID asString copy replaceAny:':/' with:$_

"
   bosch_dapasx_datenbasis libraryName   
"

    "Modified: / 09-08-2006 / 18:20:29 / fm"
    "Modified: / 11-08-2006 / 14:02:06 / cg"
!

module

^self moduleOfClass: self

"
   bosch_dapasx_datenbasis_Definition module
   DapasX_Datenbasis module
"

    "Created: / 08-08-2006 / 20:24:53 / fm"
    "Modified: / 09-08-2006 / 16:16:37 / fm"
!

moduleDirectory

^self moduleDirectoryFor: self package 

"
    bosch_dapasx_datenbasis_Definition moduleDirectory    
    bosch_dapasx_parameter_system_Definition moduleDirectory
"

    "Created: / 08-08-2006 / 20:25:39 / fm"
!

moduleDirectoryFor: aProjectID

^(aProjectID subStrings: $:) last

"
    bosch_dapasx_datenbasis_Definition moduleDirectory    
    bosch_dapasx_parameter_system_Definition moduleDirectory
"

    "Created: / 08-08-2006 / 20:25:39 / fm"
!

moduleFor: aProjectID

^(aProjectID subStrings: $:) first

"
   DapasXProject module
   DapasX_Datenbasis module
"

    "Created: / 09-08-2006 / 16:16:16 / fm"
!

moduleOfClass: aClass

^self moduleFor: aClass package 

"
   DapasXProject module
   DapasX_Datenbasis module
"

    "Created: / 09-08-2006 / 16:16:16 / fm"
!

msdosPathToPackage:aPackageID
"Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"

        ^ self msdosPathToTop , '\..\' , (aPackageID asString copy replaceAll:$: by:$/)

"
   DapasX_Datenbasis pathToPackage:'bosch:dapasx/kernel'
"

    "Created: / 09-08-2006 / 16:35:22 / fm"
!

msdosPathToTop
"Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"


       ^self msdosPathToTopFor: self package 

"
   bosch_dapasx_datenbasis_Definition msdosPathToTop    
   DapasX_Datenbasis pathToTop  
"

    "Created: / 09-08-2006 / 15:45:54 / fm"
!

msdosPathToTopFor: aProjectID
"Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"


       ^ (((1 to:(aProjectID asCollectionOfSubstringsSeparatedByAny:':/') size)
            collect:[:n | '..\']) asStringWith:'') , 'stx'    

"
   self msdosPathToTopFor: #'bosch:dapasx/datenbasis'   

"

    "Created: / 09-08-2006 / 15:45:54 / fm"
!

packageName

^self packageNameFor: self package


"
   bosch_dapasx_hw_schnittstellen_Definition  packageName
   bosch_dapasx_datenbasis_Definition packageName
   bosch_dapasx_parameter_system_Definition packageName
"

    "Created: / 08-08-2006 / 20:24:53 / fm"
    "Modified: / 09-08-2006 / 16:16:37 / fm"
!

packageNameFor: aProjectID

^((aProjectID asString copy replaceAny:'/' with:$:) subStrings: $:) last


"
   bosch_dapasx_hw_schnittstellen  packageName
   bosch_dapasx_datenbasis packageName
   bosch_dapasx_parameter_system packageName
"

    "Created: / 08-08-2006 / 20:24:53 / fm"
    "Modified: / 09-08-2006 / 16:16:37 / fm"
    "Modified: / 11-08-2006 / 14:02:32 / cg"
!

parentProject

    ^(self parentProjectFor: self package)

"
    bosch_dapasx_hw_schnittstellen_Definition  parentProject
    DapasX_Datenbasis parentProject
"

    "Created: / 07-08-2006 / 20:18:27 / fm"
    "Modified: / 08-08-2006 / 10:47:37 / fm"
!

parentProjectFor: aProjectID

    ^(aProjectID subStrings: $/) first

"
    bosch_dapasx_hw_schnittstellen  parentProject
"

    "Created: / 07-08-2006 / 20:18:27 / fm"
    "Modified: / 08-08-2006 / 10:47:37 / fm"
    "Modified: / 11-08-2006 / 14:02:56 / cg"
!

pathToProject

       ^ self pathToProjectFor: self package

"
   bosch_dapasx_datenbasis_Definition pathToProject  
"

    "Modified: / 09-08-2006 / 18:20:29 / fm"
!

pathToProjectFor: aProjectID

       ^ aProjectID asString copy replaceAny:':/' with:$\

"
   self pathToProjectFor: #'bosch:dapasx/datenbasis'   
"

    "Modified: / 09-08-2006 / 18:20:29 / fm"
!

unixPathToPackage:aPackageID
"Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"

        ^ self unixPathToTop , '/../' , (aPackageID asString copy replaceAll:$: by:$/)

"
   DapasX_Datenbasis pathToPackage:'bosch:dapasx/kernel'
"

    "Created: / 09-08-2006 / 16:35:22 / fm"
!

unixPathToTop
"Returns the path to stx counting the number of $/ and $: in the package name and adding for each one '../' to get the ST/X top directory"


       ^ (((1 to:(self package asCollectionOfSubstringsSeparatedByAny:':/') size)
            collect:[:n | '../']) asStringWith:'') , 'stx'    

"
   DapasXProject pathToTop    
   DapasX_Datenbasis pathToTop  
"

    "Created: / 09-08-2006 / 15:45:54 / fm"
! !

!ProjectDefinition class methodsFor:'file generation'!

allClassNames
    ^ (self compiled_classNames , self autoloaded_classNames , self excluded_classNames)
!

generate_abbrev_dot_stc
    ^ String 
        streamContents:[:s | 
            self allClassNames do:[:eachClassName | 
                |cls fn|

                cls := Smalltalk classNamed:eachClassName.
                cls autoload.
                s nextPutAll:eachClassName.
                s nextPutAll:' '.
                fn := cls classFilename asFilename withoutSuffix baseName.
                (fn includes:Character space) ifTrue:[
                    s nextPutAll:fn storeString.
                ] ifFalse:[
                    s nextPutAll:fn.
                ].
                s nextPutAll:' '.
                s nextPutAll:cls package.
                s nextPutAll:' '.
                s nextPutAll:cls category asString storeString.
                s nextPutAll:' '.
                s nextPutAll:(cls theMetaclass instVarNames size) printString.
                s cr.
            ]
        ]

    "
        DapasXProject generate_abbrev_dot_stc
        DapasX_Datenbasis generate_abbrev_dot_stc
        bosch_dapasx_interactiver_editor generate_abbrev_dot_stc
    "

    "Created: / 09-08-2006 / 11:24:39 / fm"
    "Modified: / 11-08-2006 / 14:01:51 / cg"
!

generate_bc_dot_def                         

    ^self replaceMappings: self bc_dot_def_mappings 
            in: self bc_dot_def

"
  DapasXProject generate_bc_dot_def
  DapasX_Datenbasis generate_bc_dot_def

"

    "Modified: / 09-08-2006 / 11:30:42 / fm"
!

generate_libInit_dot_cc

    ^self replaceMappings: self libInit_dot_cc_mappings 
            in: self libInit_dot_cc

"
  DapasXProject generate_libInit_dot_cc
  DapasX_Datenbasis generate_libInit_dot_cc

"

    "Created: / 08-08-2006 / 12:47:16 / fm"
    "Modified: / 09-08-2006 / 11:30:52 / fm"
!

generate_make_dot_proto   

    ^self replaceMappings: self make_dot_proto_mappings 
            in: self make_dot_proto

"
  DapasXProject generate_make_dot_proto
  DapasX_Datenbasis generate_make_dot_proto

"

    "Modified: / 09-08-2006 / 11:31:01 / fm"
!

generate_make_dot_spec

    ^self replaceMappings: self make_dot_spec_mappings 
            in: self make_dot_spec

"
  DapasXProject generate_make_dot_spec
  DapasX_Datenbasis generate_make_dot_spec
  bosch_dapasx_kernel_Definition generate_make_dot_spec

"

    "Modified: / 09-08-2006 / 11:31:09 / fm"
!

generate_nt_dot_def                           

    ^self replaceMappings: self nt_dot_def_mappings 
            in: self nt_dot_def

"
  DapasXProject generate_nt_dot_def
  DapasX_Datenbasis generate_nt_dot_def

"

    "Modified: / 09-08-2006 / 11:31:21 / fm"
!

generate_nt_dot_mak         

    ^self replaceMappings: self nt_dot_mak_mappings 
            in: self nt_dot_mak

"
  DapasXProject generate_nt_dot_mak
  DapasX_Datenbasis generate_nt_dot_mak

"

    "Modified: / 09-08-2006 / 11:46:14 / fm"
!

generate_packageName_dot_rc

    ^self replaceMappings: self packageName_dot_rc_mappings 
            in: self packageName_dot_rc

"
  bosch_dapasx_datenbasis generate_packageName_dot_rc
  bosch_dapasx_hw_schnittstellen  generate_packageName_dot_rc

"

    "Modified: / 09-08-2006 / 11:31:09 / fm"
    "Modified: / 11-08-2006 / 14:01:56 / cg"
! !

!ProjectDefinition class methodsFor:'file templates'!

bc_dot_def

^ 
'LIBRARY        %(LIBRARY_NAME)
DESCRIPTION     %(DESCRIPTION)
CODE            PRELOAD MOVEABLE DISCARDABLE
SEGMENTS
    INITCODE    PRELOAD DISCARDABLE
EXPORTS
    __%(C_LIBRARY_NAME)_Init     @1
'

    "Created: / 08-08-2006 / 12:26:58 / fm"
    "Modified: / 08-08-2006 / 19:32:27 / fm"
!

classLine_libInit_dot_cc

^'_%(CLASS)_Init(pass,__pRT__,snd);'

    "Created: / 08-08-2006 / 12:51:44 / fm"
    "Modified: / 08-08-2006 / 15:46:05 / fm"
!

extensionLine_libInit_dot_cc

^'_%(LIBRARY_NAME)_extensions_Init(pass,__pRT__,snd);'

    "Created: / 08-08-2006 / 15:48:56 / fm"
    "Modified: / 08-08-2006 / 19:32:33 / fm"
!

libInit_dot_cc

^ 
'/*
 * DO NOT EDIT 
 * automagically generated from Make.proto (by make libInit.cc)
 */
#define __INDIRECTVMINITCALLS__
#include <stc.h>
#define INIT_TEXT_SECT /* as nothing */
#ifdef WIN32
# pragma codeseg INITCODE "INITCODE"
#else /* not WIN32 */
# if defined(__GNUC__) && !!defined(NO_SECTION_ATTRIBUTES)
#  if (__GNUC__  == 2 && __GNUC_MINOR__ >= 7) || __GNUC__ > 2
#   undef INIT_TEXT_SECT
#   define INIT_TEXT_SECT __attribute__((section(".stxitext")))
#  endif
# endif /* not GNUC */
#endif /* not WIN32 */
#ifdef INIT_TEXT_SECT
extern void _%(LIBRARY_NAME)_Init() INIT_TEXT_SECT;
#endif
void _%(LIBRARY_NAME)_Init(pass, __pRT__, snd)
OBJ snd; struct __vmData__ *__pRT__; {
__BEGIN_PACKAGE2__("%(LIBRARY_NAME)", _%(LIBRARY_NAME)_Init, "%(PACKAGE)");
%(CLASSES)
%(EXTENSION)
__END_PACKAGE__();
}'

    "Created: / 08-08-2006 / 12:40:45 / fm"
    "Modified: / 08-08-2006 / 19:33:01 / fm"
!

make_dot_proto

^ 
'#
# Warning: once you modify this file, do not rerun
# stmkmp again - otherwise, your changes are lost.
#
# The Makefile as generated by this Make.proto supports the following targets:
#    make         - compile all st-files to a classLib
#    make install - install the classLib in /opt/smalltalk/...
#    make clean   - clean all temp files
#    make clobber - clean all

#
# position (of this package) in directory hierarchy:
# (must point to ST/X top directory, for tools and includes)
TOP=%(TOP)


# subdirectories where targets are to be made:
SUBDIRS=%(SUBDIRECTORIES)


# subdirectories where Makefiles are to be made:
# (only define if different from SUBDIRS)
# ALLSUBDIRS=


# if your embedded C code requires any system includes, 
# add the path(es) here:, 
# ********** OPTIONAL: MODIFY the next lines ***
# LOCALINCLUDES=-Ifoo -Ibar
LOCALINCLUDES=%(LOCAL_INCLUDES)


# if you need any additional defines for embedded C code, 
# add them here:, 
# ********** OPTIONAL: MODIFY the next lines ***
# LOCALDEFINES=-Dfoo -Dbar -DDEBUG
LOCALDEFINES=%(LOCAL_DEFINES)


#
# The next 2 defines should be left as-is
#  for a class-library package, you can uncomment the following:
#  (it does not hurt much, if you leave it as is - but you may NOT
#   uncomment it if object files are to be loaded individually later).
# INITCODESEPFLAG=$(SEPINITCODE)
#
#  the following MAY ONLY be uncommented for classes/classLibs,
#  which are ALWAYS statically included in the executable.
#  (i.e. NEVER for those which are subject to dynamic loading).
# COMMONSYMFLAG=$(COMMONSYMBOLS)
#
STCLOCALOPT=-I. $(LOCALINCLUDES) $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) -H. ''-P$(PACKAGE)'' ''-Z$(LIBNAME)'' $(COMMONSYMFLAG) $(INITCODESEPFLAG)


# ********** OPTIONAL: MODIFY the next line ***
# additional C-libraries that should be pre-linked with the class-objects
LD_OBJ_LIBS=


# ********** OPTIONAL: MODIFY the next line ***
# additional C targets or libraries should be added below
LOCAL_EXTRA_TARGETS=

all:: preMake classLibRule postMake


# add more install actions here
install::

# add more install actions for aux-files (resources) here
installAux::

# add more preMake actions here
preMake::

# add more postMake actions here
postMake:: cleanjunk

cleanjunk::

clean::
        -rm -f *.o *.H

clobber::
        -rm -f *.so *.dll

',
"
$(INSTALLBASE)::
        @test -d $@ || mkdir $@

$(INSTALLBASE)/packages:: $(INSTALLBASE)
        @test -d $@ || mkdir $@

$(INSTALLBASE)/packages/$(MODULE):: $(INSTALLBASE)/packages
        @test -d $@ || mkdir $@

$(INSTALLBASE)/packages/$(MODULE)/dapasx:: $(INSTALLBASE)/packages/$(MODULE)
        @test -d $@ || mkdir $@

$(INSTALLBASE)/packages/$(MODULE)/dapasx/interactiver_editor:: $(INSTALLBASE)/packages/$(MODULE)/dapasx
        @test -d $@ || mkdir $@

$(INSTALLBASE)/packages/$(MODULE)/$(MODULE_DIR):: $(INSTALLBASE)/packages/$(MODULE)
        @test -d $@ || mkdir $@
"
'
# if other things are to be compiled,
# add target definitions here,
# and list them in LOCAL_EXTRA_TARGETS above.
# (care for make syntax - TABS are required in the actions)
# foo:  foo.o
#         $(CC) -o foo foo.o

# ''make depend'' will add dependency info between
# BEGIN...END below
#
# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
# ENDMAKEDEPEND --- do not remove this line

'

    "Created: / 08-08-2006 / 20:45:36 / fm"
    "Modified: / 09-08-2006 / 16:50:23 / fm"
!

make_dot_spec

^ 
'#
# This file contains specifications which are common to all platforms.
#
# Warning: once you modify this file, do not rerun
# stmkmp again - otherwise, your changes are lost.
#
# This file contains definitions for Unix based platforms.
#




# module and directory-in-module;
# these should correspond to the directory hierarchy
# location (otherwise, ST/X will have a hard time to
# find out the packages location from its packageID)
MODULE=%(MODULE)
MODULE_DIR=%(MODULE_DIRECTORY)


# the name of your classLibrary:
# ********** REQUIRED: CHECK the next line ***
LIBNAME=%(LIBRARY_NAME)


# the package is stored as an ID in classes and methods
# to identify code belonging to this project.
# It also specifies the position in the source repository
# and directory tree, when packages are loaded by packageID.
# ********** REQUIRED: CHECK the next line ***
PACKAGE=$(MODULE):$(MODULE_DIR)


# Argument(s) to the stc compiler.
#  -H.         : create header files locally
#                (if removed, they will be created as common
#  -Pxxx       : defines the package
#  -Zxxx       : a prefix for variables within the classLib
#  -Dxxx       : defines passed to to CC for inline C-code
#  -Ixxx       : include path passed to CC for inline C-code
#  +optspace   : optimized for space
#  +optspace2  : optimized more for space
#  +optspace3  : optimized even more for space
#  +optinline  : generate inline code for some ST constructs
#  +inlineNew  : additionally inline new
#  +inlineMath : additionally inline some floatPnt math stuff
#
# ********** OPTIONAL: MODIFY the next line(s) ***
# STCLOCALOPTIMIZATIONS=+optinline +inlineNew
# STCLOCALOPTIMIZATIONS=+optspace3
STCLOCALOPTIMIZATIONS=+optspace3


# Argument(s) to the stc compiler.
#  -warn            : no warnings
#  -warnNonStandard : no warnings about ST/X extensions
#  -warnEOLComments : no warnings about EOL comment extension
#  -warnPrivacy     : no warnings about privateClass extension
#
# ********** OPTIONAL: MODIFY the next line(s) ***
# STCWARNINGS=-warn
# STCWARNINGS=-warnNonStandard
# STCWARNINGS=-warnEOLComments
STCWARNINGS=

OBJS= \
%(OBJECTS)
'

    "Created: / 08-08-2006 / 19:31:29 / fm"
    "Modified: / 09-08-2006 / 15:10:57 / fm"
!

nt_dot_def

^
'LIBRARY        %(LIBRARY_NAME)
DESCRIPTION     %(DESCRIPTION)
VERSION         %(VERSION_NUMBER)
CODE            EXECUTE READ 
DATA            READ WRITE
SECTIONS
    INITCODE    READ EXECUTE 
    INITDATA    READ WRITE
EXPORTS 
    _%(LIBRARY_NAME)_Init      @1
IMPORTS'

    "Modified: / 08-08-2006 / 19:33:14 / fm"
!

nt_dot_mak

^
'#
# This file contains make rules for the win32 platform (using borland-bcc).
#
# Warning: once you modify this file, do not rerun
# stmkmp again - otherwise, your changes are lost.
#
TOP=%(TOP)

!!INCLUDE $(TOP)\rules\stdHeader_nt

!!INCLUDE Make.spec

LOCALINCLUDES=%(LOCAL_INCLUDES)

STCLOCALOPT=-I. $(LOCALINCLUDES) -H. $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) ''-P$(PACKAGE)'' ''-Z$(LIBNAME)'' $(COMMONSYMFLAG) $(INITCODESEPFLAG)

ALL::  $(LIBJPEG) $(LIBDIR)\$(LIBNAME).lib $(BINDIR)\$(LIBNAME).dll

!!INCLUDE $(TOP)\rules\stdRules_nt

# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
# ENDMAKEDEPEND --- do not remove this line
'

    "Created: / 09-08-2006 / 11:44:20 / fm"
    "Modified: / 09-08-2006 / 19:59:32 / fm"
!

objectLine_make_dot_spec

^'    %(CLASS).$(O) \'

    "Created: / 08-08-2006 / 20:16:46 / fm"
!

packageName_dot_rc

^ 
'VS_VERSION_INFO VERSIONINFO
  FILEVERSION     0,1,1,1
  PRODUCTVERSION  0,1,1,1
  FILEFLAGSMASK   VS_FF_DEBUG | VS_FF_PRERELEASE
  FILEFLAGS       VS_FF_PRERELEASE | VS_FF_SPECIALBUILD
  FILEOS          VOS_NT_WINDOWS32
  FILETYPE        VFT_DLL
  FILESUBTYPE     VS_USER_DEFINED

BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "040904E4"
    BEGIN
      VALUE "CompanyName", "%(COMPANY_NAME)\0"
      VALUE "FileDescription", "%(FILE_DESCRIPTION)\0"
      VALUE "FileVersion", "%(FILE_VERSION)\0"
      VALUE "InternalName", "%(INTERNAL_NAME)\0"
      VALUE "LegalCopyright", "%(LEGAL_COPYRIGHT)\0"
      VALUE "ProductName", "%(PRODUCT_NAME)\0"
      VALUE "ProductVersion", "%(PRODUCT_VERSION)\0"
    END

  END

  BLOCK "VarFileInfo"
  BEGIN                               //  Language   |    Translation
    VALUE "Translation", 0x409, 0x4E4 // U.S. English, Windows Multilingual
  END
END
'


    "Created: / 08-08-2006 / 19:31:29 / fm"
    "Modified: / 09-08-2006 / 15:10:57 / fm"
! !

!ProjectDefinition class methodsFor:'mappings'!

bc_dot_def_mappings
    ^ (Dictionary new)
        at:#'LIBRARY_NAME' put:[ self libraryName ];
        at:#'C_LIBRARY_NAME' put:[ self st2c:self libraryName ];
        at:#'DESCRIPTION'
            put:[
                    |d|

                    d := self description.
                    (d isEmptyOrNil ifTrue:[ 'test' ] ifFalse:[ d ]) storeString.
                ];
        yourself

    "Created: / 09-08-2006 / 11:17:59 / fm"
!

classLine_libInit_dot_cc_mappings: aClassName

^Dictionary new                                               
    at: #'CLASS' put: [self st2c:aClassName];
    yourself

    "Created: / 08-08-2006 / 14:04:00 / fm"
    "Modified: / 09-08-2006 / 18:27:07 / fm"
!

extensionLine_libInit_dot_cc_mappings

^Dictionary new                                               
    at: #'LIBRARY_NAME' put: [self libraryName];
    yourself

    "Created: / 09-08-2006 / 11:19:59 / fm"
!

libInit_dot_cc_mappings

^Dictionary new
    at: #'LIBRARY_NAME' put: [self st2c:self libraryName];
    at: #'PACKAGE' put: [self package];
    at: #'CLASSES' put: [self generateClassLines_libInit_dot_cc];
    at: #'EXTENSION' put: [self generateExtensionLine_libInit_dot_cc];

    yourself

    "Created: / 09-08-2006 / 11:20:24 / fm"
!

make_dot_proto_mappings

^Dictionary new
    at: #'TOP' put: [self unixPathToTop];
    at: #'SUBDIRECTORIES' put: [self generateSubDirectories];
    at: #'LOCAL_INCLUDES' put: [self generateUnixLocalIncludes];
    at: #'LOCAL_DEFINES' put: [''];
    yourself

    "Created: / 09-08-2006 / 11:20:45 / fm"
    "Modified: / 09-08-2006 / 16:44:48 / fm"
!

make_dot_spec_mappings

^Dictionary new
    at: #'MODULE' put: [self module];  
    at: #'MODULE_DIRECTORY' put: [self moduleDirectory];  
    at: #'LIBRARY_NAME' put: [self libraryName];
    at: #'OBJECTS' put: [self generateObjects_make_dot_spec];  
    yourself

    "Created: / 09-08-2006 / 11:21:06 / fm"
!

nt_dot_def_mappings

^Dictionary new
    at: #'LIBRARY_NAME' put: [self libraryName];
    at: #'DESCRIPTION' put: [self description storeString];
    at: #'VERSION_NUMBER' put: [self versionNumber];
    yourself

    "Created: / 09-08-2006 / 11:21:21 / fm"
!

nt_dot_mak_mappings

^Dictionary new
    at: #'TOP' put: [self msdosPathToTop]; 
    at: #'LOCAL_INCLUDES' put: [self generateMsdosLocalIncludes];
    yourself

    "Created: / 09-08-2006 / 11:44:36 / fm"
    "Modified: / 09-08-2006 / 20:00:01 / fm"
!

objectLine_make_dot_spec_mappings: aClassName

^Dictionary new                                               
    at: #'CLASS' put: [(Smalltalk classNamed:aClassName) classFilename asFilename withoutSuffix baseName];
    yourself

    "Created: / 08-08-2006 / 20:17:28 / fm"
    "Modified: / 09-08-2006 / 18:26:52 / fm"
!

packageName_dot_rc_mappings

^Dictionary new
    at: #'COMPANY_NAME' put: [self companyName];
    at: #'FILE_DESCRIPTION' put: [self fileDescription];
    at: #'FILE_VERSION' put: [self fileVersion];
    at: #'INTERNAL_NAME' put: [self internalName];
    at: #'LEGAL_COPYRIGHT' put: [self legalCopyright];
    at: #'PRODUCT_NAME' put: [self productName];
    at: #'PRODUCT_VERSION' put: [self productVersion];
    yourself

    "Created: / 09-08-2006 / 11:21:21 / fm"
!

replaceMappings: mappings in: fileTemplate
"Replaces the defined variable mappings found in a file template with the corresponding information"

^ fileTemplate bindWithArguments:mappings.

"
self replaceMappings: (self nt_dot_def_mappingsFor: self) in: self nt_dot_def  
"

    "Created: / 08-08-2006 / 11:44:27 / fm"
    "Modified: / 08-08-2006 / 12:46:13 / fm"
!

st2c:aString
        ^ (aString asString
            copyReplaceString:'_' withString:('_',($_ codePoint printStringRadix:8)))
                replaceAny:':' with:$_
! !

!ProjectDefinition class methodsFor:'mappings support'!

generateClassLines_libInit_dot_cc

^self compiled_classNames 
    inject: ''
    into:[:classLines :className | 
        |newClassLine mappings|
        mappings := self classLine_libInit_dot_cc_mappings: className.
        newClassLine := self replaceMappings: mappings  
                            in: self classLine_libInit_dot_cc.
        classLines concatenate: newClassLine 
                    and: String lf
    ]

"
    DapasXProject generateClassLines_libInit_dot_cc
    bosch_dapasx_datenbasis_Definition  generateClassLines_libInit_dot_cc

"

    "Created: / 09-08-2006 / 11:21:48 / fm"
!

generateExtensionLine_libInit_dot_cc
      |mappings|
^self extensionMethodNames isEmpty
    ifTrue:['']
    ifFalse:[ mappings := self extensionLine_libInit_dot_cc_mappings.
              self replaceMappings: mappings  
                            in: self extensionLine_libInit_dot_cc.]
"
    DapasXProject generateExtensionLine_libInit_dot_cc
    DapasX_Datenbasis generateExtensionLine_libInit_dot_cc

"

    "Created: / 09-08-2006 / 11:23:34 / fm"
!

generateMsdosLocalIncludes

^self searchForProjectsWhichProvideHeaderFiles
    inject: ''
    into:[:objectLines :includeProjectName |    
            objectLines , ' -I',(self msdosPathToPackage: includeProjectName) 
    ]

"
    DapasXProject generateLocalIncludes
    DapasX_Datenbasis generateLocalIncludes

"

    "Created: / 09-08-2006 / 16:46:49 / fm"
!

generateObjects_make_dot_spec 
    |pivateClassesOf classes|

    classes := self compiled_classes.
    pivateClassesOf := IdentityDictionary new.
    classes do:[:each | pivateClassesOf at:each put:(each allPrivateClasses)].

    classes topologicalSort:[:a :b |
        "/ a must come before b iff:
        "/    b is a subclass of a
        "/    b has a private class which is a subclass of a

        |mustComeBefore pivateClassesOfB|
        mustComeBefore := b isSubclassOf:a.
        pivateClassesOfB := pivateClassesOf at:b.
        pivateClassesOfB do:[:eachClassInB |
            mustComeBefore := mustComeBefore or:[eachClassInB isSubclassOf:a]
        ].
        mustComeBefore
    ].

    ^ String streamContents:[:s |
        classes do:[:eachClass |
            |mappings newObjectLine|

            mappings := self objectLine_make_dot_spec_mappings: eachClass name.
            newObjectLine := self replaceMappings: mappings in: self objectLine_make_dot_spec.
            s nextPutAll:newObjectLine. 
            s cr. 
        ]
    ]
"
    DapasXProject generateObjects_make_dot_spec
    DapasX_Datenbasis generateObjects_make_dot_spec

"

    "Created: / 09-08-2006 / 11:24:39 / fm"
!

generatePrerequisiteProjectsPaths

^self prerequisiteProjects
    inject: ''
    into:[:objectLines :subProjectName |    
        objectLines
            concatenate: String lf
            and: ' -I'
            and: subProjectName 
    ]

"
    DapasXProject generatePrerequisiteProjectsPaths
    DapasX_Datenbasis generatePrerequisiteProjectsPaths

"

    "Created: / 09-08-2006 / 12:34:20 / fm"
!

generateSubDirectories

^self subProjects 
    inject: ''
    into:[:objectLines :subProjectName |    
        objectLines
            concatenate: ' '
            and: subProjectName 
    ]

"
    DapasXProject generateSubDirectories
    DapasX_Datenbasis generateSubDirectories

"

    "Created: / 09-08-2006 / 11:26:59 / fm"
!

generateUnixLocalIncludes

^self searchForProjectsWhichProvideHeaderFiles
    inject: ''
    into:[:objectLines :includeProjectName |    
            objectLines , ' -I',(self unixPathToPackage: includeProjectName) 
    ]

"
    DapasXProject generateLocalIncludes
    DapasX_Datenbasis generateLocalIncludes

"

    "Created: / 09-08-2006 / 16:46:49 / fm"
!

prerequisiteProjectsOrdered

^self prerequisiteProjects asSortedCollection:[:a :b | ]

"
    DapasXProject generatePrerequisiteProjectsPaths
    DapasX_Datenbasis generatePrerequisiteProjectsPaths

"

    "Created: / 09-08-2006 / 13:12:01 / fm"
! !

!ProjectDefinition class methodsFor:'project description'!

autoloaded_classNames
    "classes listed here will NOT be compiled, but remain autoloaded.
     to be excluded from the build process can be user-defined in my subclasses"

    ^#()

    "Created: / 07-08-2006 / 19:02:57 / fm"
    "Modified: / 07-08-2006 / 21:25:25 / fm"
!

classNames            
    "this is a stupid default, a correponding method with real names
     is generated in my subclasses"

    ^#()

    "Created: / 07-08-2006 / 19:02:57 / fm"
    "Modified: / 07-08-2006 / 21:25:25 / fm"
!

compiled_classNames          
    "this is a stupid default, a correponding method with real names
     is generated in my subclasses"

    ^#()

    "Created: / 07-08-2006 / 19:02:57 / fm"
    "Modified: / 07-08-2006 / 21:25:25 / fm"
!

compiled_classes
    ^ self compiled_classNames collect:[:eachName| (Smalltalk at:eachName asSymbol)]

    "Created: / 09-08-2006 / 16:28:15 / fm"
    "Modified: / 09-08-2006 / 18:02:28 / fm"
!

compiled_classesDo:aBlock
    self compiled_classes do:aBlock.

    "Created: / 09-08-2006 / 16:28:15 / fm"
    "Modified: / 09-08-2006 / 18:02:28 / fm"
!

description
"Returns a description string which will appear in nt.def and in the files info inside it's properties "

^''

    "Created: / 08-08-2006 / 11:15:01 / fm"
!

excluded_classNames
    "this is a stupid default, a correponding method with real names
     to be excluded from the build process can be user-defined in my subclasses"

    ^#()

    "Created: / 07-08-2006 / 19:02:57 / fm"
    "Modified: / 07-08-2006 / 21:25:25 / fm"
!

extensionMethodNames

    ^#()

    "Created: / 08-08-2006 / 11:07:08 / fm"
!

postLoadAction
    "raise an error: must be redefined in concrete subclass(es)"

    ^ self subclassResponsibility

    "Created: / 08-08-2006 / 11:07:40 / fm"
!

preUnloadAction
    "raise an error: must be redefined in concrete subclass(es)"

    ^ self subclassResponsibility

    "Created: / 08-08-2006 / 11:07:40 / fm"
!

prerequisiteProjects

    ^#()

    "Created: / 08-08-2006 / 21:17:34 / fm"
!

subProjects

    ^#()

    "Created: / 08-08-2006 / 11:08:23 / fm"
!

versionNumber
"Returns a version string which will appear in nt.def and in the files info inside it's properties "

^''

    "Created: / 08-08-2006 / 11:35:52 / fm"
! !

!ProjectDefinition class methodsFor:'project information'!

companyName
    ^'eXept Software AG'
!

fileDescription
    ^self productName,' ',  self packageName
!

fileVersion
    ^self revision ? '0.1.1.1'
!

internalName
    ^self packageName
!

legalCopyright
    ^'Copyright eXept Software AG 2006 (until payment)'
!

productName
    ^'Product Name'
!

productVersion
    ^'0.1.1.1'
! !

!ProjectDefinition class methodsFor:'public update description'!

compileDescriptionMethods
    self forEachMethodsCodeToCompileDo:[:code :category |
        self theMetaclass 
            compile: code
            classified: category.
    ].

"
    DapasXProject compileDescriptionMethods
    DapasX_Datenbasis compileDescriptionMethods
    bosch_dapasx_interactiver_editor compileDescriptionMethods
"

    "Created: / 09-08-2006 / 18:00:31 / fm"
    "Modified: / 11-08-2006 / 14:01:29 / cg"
!

forEachFileNameAndGeneratorMethodDo:aTwoArgBlock
|fileNamesAndSelectors|

    fileNamesAndSelectors := #( 
     #('Make.proto' #'generate_make_dot_proto')
     #('Make.spec'  #'generate_make_dot_spec') 
     #('libInit.cc' #'generate_libInit_dot_cc') 
     #('bc.def'     #'generate_bc_dot_def') 
     #('nt.mak'     #'generate_nt_dot_mak') 
     #('nt.def'     #'generate_nt_dot_def') 
     #('abbrev.stc' #'generate_abbrev_dot_stc') 
    ) asOrderedCollection.

    fileNamesAndSelectors 
        add: (Array with: self packageName, '.rc' 
                    with: #'generate_packageName_dot_rc').
    fileNamesAndSelectors pairsDo:aTwoArgBlock
! !

!ProjectDefinition class methodsFor:'sanity checks'!

searchForInconsistencies
    self searchForNeverCompiledSuperclasses.

"
    self searchForInconsistencies
    DapasX_Datenbasis searchForInconsistencies  
"

    "Created: / 09-08-2006 / 16:30:46 / fm"
!

searchForNeverCompiledSuperclasses
      self compiled_classesDo:[:includedClass | 
            includedClass allSuperclassesDo:[:eachSuperClass |
                eachSuperClass package == Project noProjectID ifTrue:[ 
                    self inconsistency:'uncompiled superclass: ' , eachSuperClass name
                ].
            ]
      ].

"
    self searchForNeverCompiledSuperclasses
    DapasX_Datenbasis searchForNeverCompiledSuperclasses  
"

    "Created: / 09-08-2006 / 16:31:54 / fm"
! !

!ProjectDefinition class methodsFor:'testing'!

isProjectDefinition
    ^ self ~~ ProjectDefinition

    "Created: / 10-08-2006 / 16:24:02 / cg"
! !

!ProjectDefinition class methodsFor:'update description'!

autoloadedClassNamesGeneratedCodeToCompile
    |classNamesCode|

   classNamesCode := 'autoloaded_classNames', String lf, '"This method has been automatically generated"'.
   classNamesCode := classNamesCode, String lf, self autoloadedClassNamesGeneratedString. 
   ^classNamesCode

"
    DapasXProject autoloadedClassNamesGeneratedCodeToCompile
    DapasX_Datenbasis autoloadedClassNamesGeneratedCodeToCompile

"

    "Created: / 08-08-2006 / 15:07:06 / fm"
!

autoloadedClassNamesGeneratedString
    | |

    ^ String streamContents:[:s |
        s nextPutAll:'^#('.
        self searchForClassesWithProject do:[:eachClass |
            (false "eachClass wasAutoloaded" or:[ eachClass isLoaded not ]) ifTrue:[
                (self compiled_classNames includes:eachClass name) ifFalse:[
                    (self excluded_classNames includes:eachClass name) ifFalse:[
                        s cr; nextPutAll:eachClass name asString storeString
                    ]
                ]
             ]
        ].
        s cr; nextPutAll:')'
    ].

"
    bosch_dapasx_interactiver_editor autoloadedClassNamesGeneratedString
"

    "Created: / 08-08-2006 / 15:00:17 / fm"
    "Modified: / 08-08-2006 / 19:24:34 / fm"
    "Modified: / 11-08-2006 / 14:01:23 / cg"
!

classNamesGeneratedCodeToCompile
    |classNamesCode|

   classNamesCode := 'compiled_classNames', String lf, '"This method has been automatically generated"'.
   classNamesCode := classNamesCode, String lf, self classNamesGeneratedString. 
   ^classNamesCode

"
    DapasXProject Datenbasis
    DapasX_Datenbasis Datenbasis

"

    "Created: / 08-08-2006 / 15:07:06 / fm"
!

classNamesGeneratedString
    | |

    ^ String streamContents:[:s |
        s nextPutAll:'^#('.
        self searchForClassesWithProject do:[:eachClass |
            (self autoloaded_classNames includes:eachClass name) ifFalse:[ 
                (self excluded_classNames includes:eachClass name) ifFalse:[ 
                    s cr; nextPutAll:eachClass name asString storeString
                 ]
             ]
        ].
        s cr; nextPutAll:')'
    ].

"
    bosch_dapasx_interactiver_editor classNamesGeneratedString
"

    "Created: / 08-08-2006 / 15:00:17 / fm"
    "Modified: / 08-08-2006 / 19:24:34 / fm"
    "Modified: / 11-08-2006 / 14:01:26 / cg"
!

extensionMethodNamesGeneratedCodeToCompile
    |extensionMethodNamesCode|

   extensionMethodNamesCode := 'extensionMethodNames', String lf, '"This method has been automatically generated"'.
   extensionMethodNamesCode := extensionMethodNamesCode, String lf, self extensionMethodNamesGeneratedString. 
   ^extensionMethodNamesCode

"
    DapasXProject extensionMethodNamesGeneratedCodeToCompile
    DapasX_Datenbasis extensionMethodNamesGeneratedCodeToCompile

"

    "Created: / 08-08-2006 / 18:54:42 / fm"
!

extensionMethodNamesGeneratedString
    |generatedString |

    generatedString := self searchForExtensionsWithProject 
            inject: '^#(' 
            into:[:string :each | 
                string, String lf, each mclass name asString storeString, ' #', each name ]. 
    ^generatedString, String lf, ')'

"
    self extensionMethodNamesGeneratedString
"

    "Created: / 08-08-2006 / 18:55:04 / fm"
!

forEachMethodsCodeToCompileDo:aTwoArgBlock
    aTwoArgBlock 
        value:self autoloadedClassNamesGeneratedCodeToCompile
        value:'project description'.

   aTwoArgBlock
        value: self classNamesGeneratedCodeToCompile
        value: 'project description'.

   (self theMetaclass includesSelector:#excluded_classNames) ifFalse:[
       aTwoArgBlock
            value: 'excluded_classNames\^ #()' withCRs
            value: 'project description'.
   ].

   aTwoArgBlock 
        value: self extensionMethodNamesGeneratedCodeToCompile
        value: 'project description'.

"/   aTwoArgBlock 
"/        value: 'description ^''bla bla'''
"/        value: 'project description'

    "Created: / 10-08-2006 / 16:35:47 / cg"
!

inconsistency:message
    Dialog warn:message

"
    self searchForNeverCompiledSuperclasses
    DapasX_Datenbasis searchForNeverCompiledSuperclasses  
"

    "Created: / 09-08-2006 / 16:32:31 / fm"
!

searchForClassesNamesWithProject

    ^self searchForClassesWithProject collect:[:each | each name]. 

"
    self searchForClassesNamesWithProject
"

    "Created: / 07-08-2006 / 21:37:06 / fm"
!

searchForClassesWithProject

    ^self searchForClassesWithProject: self package

"
    self searchForClassesWithProject
"

    "Created: / 07-08-2006 / 20:42:39 / fm"
    "Modified: / 07-08-2006 / 21:56:25 / fm"
!

searchForClassesWithProject: aProjectID

    ^ Smalltalk allClasses select:[:cls | cls package == aProjectID].

"
    self searchForClassesWithProject: #'bosch:dapasx'
    self searchForClassesWithProject: #'bosch:dapasx/datenbasis'
"

    "Created: / 07-08-2006 / 20:42:39 / fm"
    "Modified: / 07-08-2006 / 21:56:25 / fm"
!

searchForExtensionsForProject:aProjectID
    |methods|

    methods := IdentitySet new.
    Smalltalk allClassesDo:[:eachClass |
        |classPackage|

        classPackage := eachClass package.
        eachClass instAndClassMethodsDo:[:mthd |
            mthd package ~= classPackage ifTrue:[ 
                mthd package == aProjectID ifTrue:[
                    methods add:mthd 
                ]
            ].
        ].
    ].
    ^ methods
"
    self searchForExtensionsForProject:#'bosch:dapasx'
"

    "Created: / 07-08-2006 / 22:03:55 / fm"
!

searchForExtensionsWithProject
    ^ self searchForExtensionsForProject:self package

"
    self searchForExtensionsWithProject
    DapasXProject searchForExtensionsWithProject
    DapasX_Datenbasis searchForExtensionsWithProject

"

    "Created: / 07-08-2006 / 21:03:10 / fm"
    "Modified: / 09-08-2006 / 13:01:26 / fm"
!

searchForProjectsWhichProvideHeaderFiles
      |myPackageID requiredPackages|

      requiredPackages := Set new.
      myPackageID := self package.

      self compiled_classesDo:[:includedClass | 
            includedClass allSuperclassesDo:[:eachSuperClass |
                ((eachSuperClass package ~= myPackageID)
                and:[ (self moduleOfClass: eachSuperClass) ~= 'stx' ])
                    ifTrue:[
                        eachSuperClass package == Project noProjectID ifFalse:[
                            requiredPackages add:(eachSuperClass package).
                        ]
                    ]
            ]
      ].
      ^ requiredPackages

"
    self searchForProjectsWhichProvideHeaderFiles
    DapasX_Datenbasis searchForProjectsWhichProvideHeaderFiles  
"

    "Created: / 09-08-2006 / 16:26:37 / fm"
! !

!ProjectDefinition class methodsFor:'xxx'!

try
   ^ 'hhh' , '989898'

    "Created: / 09-08-2006 / 16:50:52 / fm"
!

try2
   ^ 1 + 2

    "Created: / 09-08-2006 / 16:53:16 / fm"
! !

!ProjectDefinition class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/LibraryDefinition.st,v 1.14 2006-08-15 18:06:04 fm Exp $'
! !