LibraryDefinition.st
author Stefan Vogel <sv@exept.de>
Fri, 12 Jan 2007 19:45:10 +0100
changeset 10318 bef855ddbb59
parent 10305 9ddd9fa56303
child 10332 5fe4d84d78fe
permissions -rw-r--r--
bc.def - no longer generated it is now in rules\bc_dll.def or rules\bc_exe.def

"
 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:libbasic' }"

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

!LibraryDefinition 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.
"
! !

!LibraryDefinition class methodsFor:'code generation'!

forEachMethodsCodeToCompileDo:aTwoArgBlock ignoreOldDefinition:ignoreOldDefinition
    super forEachMethodsCodeToCompileDo:aTwoArgBlock ignoreOldDefinition:ignoreOldDefinition.

    "Created: / 10-08-2006 / 16:35:47 / cg"
    "Modified: / 18-08-2006 / 16:22:49 / cg"
! !

!LibraryDefinition class methodsFor:'description - project information'!

description
    "Returns a description string which will appear in nt.def / bc.def"

    self module = 'stx' ifTrue:[
        ^ 'Smalltalk/X Class library'
    ].

    ^ 'Class Library'

    "Created: / 17-08-2006 / 20:52:16 / cg"
    "Modified: / 18-08-2006 / 16:15:53 / cg"
!

fileDescription
    "Return a description string which will appear in nt.def / bc.def"

    ^self description , ' ClassLibrary'

    "Created: / 14-09-2006 / 10:55:23 / cg"
! !

!LibraryDefinition class methodsFor:'file generation'!

basicFileNamesToGenerate
    ^ #( 
          #('Make.proto'        #'generate_make_dot_proto')
          #('Make.spec'         #'generate_make_dot_spec')
          #('libInit.cc'        #'generate_libInit_dot_cc')
          #('bc.mak'            #'generate_bc_dot_mak')
          #('abbrev.stc'        #'generate_abbrev_dot_stc') 
          #('bmake.bat'         #'generate_bmake_dot_mak') 
     ) , (Array
            with:
                (Array 
                    with:self rcFilename
                    with:#'generate_packageName_dot_rc')
         ).

    "Created: / 14-09-2006 / 14:36:14 / cg"
    "Modified: / 14-09-2006 / 21:02:08 / cg"
!

generateFile:filename
    filename = 'libInit.cc' ifTrue:[
        ^ self generate_libInit_dot_cc
    ].
    ((filename = 'lib.rc') or:[filename = self rcFilename]) ifTrue:[
        ^ self generate_packageName_dot_rc
    ].
    ^ super generateFile:filename

    "Created: / 22-08-2006 / 18:36:24 / cg"
    "Modified: / 07-09-2006 / 17:07:46 / cg"
!

generate_libInit_dot_cc
    ^ self replaceMappings: self libInit_dot_cc_mappings 
            in: self libInit_dot_cc

    "
     bosch_dapasx_datenbasis generate_libInit_dot_cc
     bosch_dapasx_application generate_libInit_dot_cc
    "

    "Created: / 08-08-2006 / 12:47:16 / fm"
    "Modified: / 09-08-2006 / 11:30:52 / fm"
    "Modified: / 19-09-2006 / 22:41:40 / cg"
! !

!LibraryDefinition class methodsFor:'file templates'!

bc_dot_def
    "the template code for the bc.def file"

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

    "Created: / 08-08-2006 / 12:26:58 / fm"
    "Modified: / 08-08-2006 / 19:32:27 / fm"
    "Modified: / 18-08-2006 / 17:13:45 / cg"
!

bc_dot_mak
    "answer a template for the bc.mak makefile.
     Any variable definition %(Variable) will be later replaced by the mapping.
     $% characters have to be duplicated"

^
'# $','Header','$
#
# DO NOT EDIT 
# automagically generated from the projectDefinition: ',self name,'.
#
# Warning: once you modify this file, do not rerun
# stmkmp or projectDefinition-build again - otherwise, your changes are lost.
#
# This file contains make rules for the win32 platform (using borland-bcc).
# It shares common definitions with the unix-make in Make.spec.
# The nt.mak supports the following targets:
#    bmake         - compile all st-files to a classLib (dll)
#    bmake clean   - clean all temp files
#    bmake clobber - clean all
#
#
TOP=%(TOP)
INCLUDE_TOP=$(TOP)\..

!!INCLUDE $(TOP)\rules\stdHeader_bc

!!INCLUDE Make.spec

LIBNAME=%(LIBRARY_NAME)
RESFILES=%(RESFILENAME)
LOCALINCLUDES=%(LOCAL_INCLUDES)

STCLOCALOPT=-package=$(PACKAGE) -I. $(LOCALINCLUDES) %(HEADEROUTPUTARG) $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) %(COMMONSYMFLAG) -varPrefix=$(LIBNAME)
LOCALLIBS=%(ADDITIONAL_LINK_LIBRARIES)

%(ADDITIONAL_DEFINITIONS)

OBJS= $(COMMON_OBJS) $(WIN32_OBJS)

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

!!INCLUDE $(TOP)\rules\stdRules_bc

%(ADDITIONAL_RULES)

# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
%(DEPENDENCIES)
# ENDMAKEDEPEND --- do not remove this line
'

    "Created: / 09-08-2006 / 11:44:20 / fm"
    "Modified: / 09-08-2006 / 19:59:32 / fm"
    "Modified: / 14-09-2006 / 15:48:18 / cg"
!

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
    "the template code for the libInit.cc file"

^ 
'/*
 * $','Header','$
 *
 * DO NOT EDIT 
 * automagically generated from the projectDefinition: ',self name,'.
 */
#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"
    "Modified: / 18-08-2006 / 12:57:02 / cg"
!

lib_dot_rc

^ 
'/*------------------------------------------------------------------------
 * $','Header','$                                                            
 *
 * DO NOT EDIT 
 * automagically generated from the projectDefinition: ',self name,'.
 *------------------------------------------------------------------------*/

// #if (__BORLANDC__ < 0x0550)
// #include <ver.h>
// #endif

VS_VERSION_INFO VERSIONINFO
  FILEVERSION     %(FILEVERSION)
  PRODUCTVERSION  %(PRODUCTVERSION)
  FILEFLAGSMASK   VS_FF_DEBUG | VS_FF_PRERELEASE
  FILEFLAGS       VS_FF_PRERELEASE | VS_FF_SPECIALBUILD
  FILEOS          VOS_NT_WINDOWS32
  FILETYPE        %(FILETYPE)
  FILESUBTYPE     VS_USER_DEFINED

BEGIN
  BLOCK "StringFileInfo"
  BEGIN
    BLOCK "040904E4"
    BEGIN
      VALUE "CompanyName", %(COMPANYNAME)
      VALUE "FileDescription", "Smalltalk/X Additional Developer Basic Classes Library\0"
      VALUE "FileVersion", "5.2.8.1\0"
      VALUE "InternalName", "libbasic3\0"
      VALUE "LegalCopyright", "Copyright eXept Software AG 1998-2006\0"
      VALUE "ProductName", "Smalltalk/X\0"
      VALUE "ProductVersion", "5.2.8.1\0"
    END

  END

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

    "Created: / 17-08-2006 / 19:37:50 / cg"
    "Modified: / 18-08-2006 / 12:57:09 / cg"
!

make_dot_proto

^ 
'# $','Header','$
#
# DO NOT EDIT 
# automagically generated from the projectDefinition: ',self name,'.
#
# Warning: once you modify this file, do not rerun
# stmkmp or projectDefinition-build 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 clean   - clean all temp files
#    make clobber - clean all
#
# This file contains definitions for Unix based platforms.
# It shares common definitions with the win32-make in Make.spec.

#
# position (of this package) in directory hierarchy:
# (must point to ST/X top directory, for tools and includes)
TOP=%(TOP)
INCLUDE_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)

LIBNAME=%(LIBRARY_NAME)
STCLOCALOPT=''-package=$(PACKAGE)'' -I. $(LOCALINCLUDES) $(STCLOCALOPTIMIZATIONS) $(STCWARNINGS) $(LOCALDEFINES) %(HEADEROUTPUTARG) %(COMMONSYMFLAG) -varPrefix=$(LIBNAME)


# ********** OPTIONAL: MODIFY the next line ***
# additional C-libraries that should be pre-linked with the class-objects
LD_OBJ_LIBS=%(ADDITIONAL_LINK_LIBRARIES)
LOCAL_SHARED_LIBS=%(ADDITIONAL_SHARED_LINK_LIBRARIES)


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

OBJS= $(COMMON_OBJS) $(UNIX_OBJS)

%(ADDITIONAL_DEFINITIONS)

all:: preMake classLibRule postMake

pre_objs:: %(ADDITIONAL_TARGETS)

%(ADDITIONAL_RULES)

# 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::
%(TAB)-rm -f *.o *.H

clobber::
%(TAB)-rm -f *.so *.dll

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

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

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

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

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

$(INSTALLBASE)/packages/$(MODULE)/$(MODULE_DIR):: $(INSTALLBASE)/packages/$(MODULE)
%(TAB)@test -d $@ || mkdir $@
"
'
# BEGINMAKEDEPEND --- do not remove this line; make depend needs it
%(DEPENDENCIES)
# ENDMAKEDEPEND --- do not remove this line

'

    "Created: / 08-08-2006 / 20:45:36 / fm"
    "Modified: / 09-08-2006 / 16:50:23 / fm"
    "Modified: / 14-09-2006 / 15:48:02 / cg"
!

vc_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"
! !

!LibraryDefinition class methodsFor:'mappings'!

bc_dot_mak_mappings
    |d resFileName|

    resFileName := (self package copyFrom:(self package lastIndexOfAny:':/')+1),'.res'.

    d := super bc_dot_mak_mappings.
    d
        at: 'LIBRARY_NAME' put: ( self libraryName );
        at: 'LOCAL_INCLUDES' put: (self generateLocalIncludes_win32);
        at: 'COMMONSYMFLAG' put: (self commonSymbolsFlag);
        at: 'HEADEROUTPUTARG' put: (self headerFileOutputArg);
        at: 'RESFILENAME' put: resFileName;
        at: 'ADDITIONAL_DEFINITIONS' put: (self additionalDefinitions_bc_dot_mak);
        at: 'ADDITIONAL_RULES' put: (self additionalRules_bc_dot_mak);
        at: 'ADDITIONAL_TARGETS' put: (self additionalTargets_bc_dot_mak);
        at: 'DEPENDENCIES' put: (self generateDependencies_win32);
        yourself.
    ^ d.

    "Created: / 09-08-2006 / 11:44:36 / fm"
    "Modified: / 09-08-2006 / 20:00:01 / fm"
    "Modified: / 14-09-2006 / 18:58:15 / cg"
!

extensionLine_libInit_dot_cc_mappings

^Dictionary new                                               
    at: 'LIBRARY_NAME' put: ( self st2c:(self package copy asString replaceAny:':/' with:$_) );
    yourself

    "Created: / 09-08-2006 / 11:19:59 / fm"
    "Modified: / 14-09-2006 / 18:56:26 / cg"
!

libInit_dot_cc_mappings

^Dictionary new
    at: 'LIBRARY_NAME' put: (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"
    "Modified: / 16-08-2006 / 18:19:03 / User"
    "Modified: / 14-09-2006 / 18:56:42 / cg"
!

vc_dot_def_mappings

^Dictionary new
    at: 'LIBRARY_NAME' put: (self libraryName);
    at: 'DESCRIPTION' put: (self description asString storeString);
    at: 'VERSION_NUMBER' put: (self versionNumber);
    yourself

    "Created: / 09-08-2006 / 11:21:21 / fm"
    "Modified: / 14-09-2006 / 18:58:07 / cg"
! !

!LibraryDefinition class methodsFor:'mappings support'!

commonSymbolsFlag
    "some libraries are compiled with COMMONSYMBOLS -
     This saves a lot of space in the generated dll/so files;
     However, it also requires the librun to be rebuilt, whenever one of
     the commonSymbols-libs changes.
     Therefore, NEVER do this for end-user or application libraries;
     ONLY do it for a subset of the predefined, eXept-provided standard stx libraries"

    (
        #(
            'stx:libbasic'        'stx:libview'         'stx:libtool'   
            'stx:libbasic2'       'stx:libview2'        'stx:libtool2'
            'stx:libbasic3'       'stx:libwidg'         'stx:libhtml'
            'stx:libcomp'         'stx:libwidg2'        'stx:libui'
            'stx:libboss'         'stx:libdb'
        )
    includes:self package) ifTrue:[
        ^ '$(COMMONSYMBOLS)'
    ].
    ^ ''

    "Created: / 18-08-2006 / 13:01:52 / cg"
    "Modified: / 23-08-2006 / 09:48:11 / cg"
!

generateExtensionLine_libInit_dot_cc
    |mappings|

    ^self hasExtensionMethods 
        ifFalse:['']
        ifTrue:[ 
            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"
    "Modified: / 14-09-2006 / 14:19:59 / cg"
! !

!LibraryDefinition class methodsFor:'queries'!

canHaveExtensions
    "return true, if this class allows extensions from other packages.
     Private classes, namespaces and projectDefinitions dont allow this"

    ^ self == ApplicationDefinition

    "
     Smalltalk allClasses select:[:each | each canHaveExtensions not]
    "

    "Created: / 30-08-2006 / 15:29:53 / cg"
! !

!LibraryDefinition 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"
! !

!LibraryDefinition class methodsFor:'testing'!

isLibraryDefinition
    ^ self ~~ LibraryDefinition

    "
     stx_libboss isLibraryDefinition
     ProjectDefinition isLibraryDefinition
     LibraryDefinition isLibraryDefinition
    "

    "Created: / 23-08-2006 / 15:17:50 / cg"
!

isProjectDefinition
    ^ self ~~ LibraryDefinition

    "
     stx_libboss isProjectDefinition
     ProjectDefinition isProjectDefinition
    "

    "Created: / 17-08-2006 / 14:11:46 / cg"
    "Modified: / 21-08-2006 / 15:50:13 / cg"
! !

!LibraryDefinition class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libbasic/LibraryDefinition.st,v 1.75 2007-01-12 18:45:10 stefan Exp $'
! !