class: ProjectDefinition
authorStefan Vogel <sv@exept.de>
Fri, 15 Mar 2013 14:40:24 +0100
changeset 14882 24cda9c60389
parent 14881 28ba52b80aa7
child 14883 0580920c8388
class: ProjectDefinition added:6 methods changed: #forEachMethodsCodeToCompileDo:ignoreOldDefinition:
ProjectDefinition.st
--- a/ProjectDefinition.st	Fri Mar 15 12:21:39 2013 +0100
+++ b/ProjectDefinition.st	Fri Mar 15 14:40:24 2013 +0100
@@ -12,11 +12,11 @@
 "{ Package: 'stx:libbasic' }"
 
 Object subclass:#ProjectDefinition
-        instanceVariableNames:''
-        classVariableNames:'LibraryType GUIApplicationType NonGUIApplicationType
-                PackagesBeingLoaded Verbose AbbrevDictionary AccessLock'
-        poolDictionaries:''
-        category:'System-Support-Projects'
+	instanceVariableNames:''
+	classVariableNames:'LibraryType GUIApplicationType NonGUIApplicationType
+		PackagesBeingLoaded Verbose AbbrevDictionary AccessLock'
+	poolDictionaries:''
+	category:'System-Support-Projects'
 !
 
 ProjectDefinition class instanceVariableNames:'safeForOverwrittenMethods extensionOverwriteInfo projectIsLoaded'
@@ -27,10 +27,10 @@
 !
 
 Object subclass:#AbbrevEntry
-        instanceVariableNames:'className fileName category numClassInstVars'
-        classVariableNames:''
-        poolDictionaries:''
-        privateIn:ProjectDefinition
+	instanceVariableNames:'className fileName category numClassInstVars'
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:ProjectDefinition
 !
 
 !ProjectDefinition class methodsFor:'documentation'!
@@ -1488,7 +1488,6 @@
         (companyName companyName_code)
         (legalCopyright legalCopyright_code)
         (applicationIconFileName applicationIconFileName_code)
-        (productInstallDirBaseName productInstallDirBaseName_code)
     ) pairsDo:[:selector :codeMethodSelector |
         (self class includesSelector:selector) ifFalse:[
             aTwoArgBlock
@@ -2317,6 +2316,7 @@
     "Created: / 18-08-2006 / 12:51:38 / cg"
 ! !
 
+
 !ProjectDefinition class methodsFor:'description - project information'!
 
 applicationAdditionalIconFileNames
@@ -4072,6 +4072,59 @@
     "
 !
 
+generateRequiredMakeReferences_bc_dot_mak
+    |myProjectId preRequisites|
+
+    myProjectId := self package.
+    "Note: the trailing blank in 'CFLAGS_LOCAL=$(GLOBALDEFINES) '
+     is required!!
+     Use 'pushd' instead of 'cd', since cd is executed by borland make directly.
+     'popd' is not needed, since each line is executed in
+            an own cmd.exe process.
+     'popd' is not desierable, since it masks a possible
+            error return from the 'bmake'.
+    "
+
+    preRequisites := self allPreRequisitesSorted:#effectivePreRequisites.
+    "these have been already built in preReq"
+    preRequisites removeAllFoundIn:(self allPreRequisites:#mandatoryPreRequisites).
+
+    ^ String streamContents:[:s |
+        preRequisites do:[:eachProjectId |
+            s tab; nextPutAll:'pushd ';
+                   nextPutAll:(self msdosPathToPackage:eachProjectId from:myProjectId);
+                   nextPutLine:' & $(MAKE_BAT) "CFLAGS_LOCAL=$(GLOBALDEFINES) "'.
+        ].
+    ].
+
+    "
+     exept_expecco_application generateRequiredMakeReferences_bc_dot_mak
+     alspa_batch_application generateRequiredMakeReferences_bc_dot_mak
+    "
+!
+
+generateRequiredMakeReferences_make_dot_proto
+    |libPath preRequisites|
+
+    preRequisites := self allPreRequisitesSorted:#effectivePreRequisites.
+    "these have been already built in preReq"
+    preRequisites removeAllFoundIn:(self allPreRequisites:#mandatoryPreRequisites).
+
+    ^ String streamContents:[:s |
+        preRequisites do:[:projectID |
+            libPath := self pathToPackage_unix:projectID.
+            s tab; nextPutAll: 'cd ', libPath; nextPutLine:' && $(MAKE) "CFLAGS_LOCAL=$(GLOBALDEFINES)"'.
+        ].
+
+        s cr.
+    ].
+
+    "
+     exept_expecco_application generateRequiredMakeReferences_make_dot_proto
+     alspa_batch_application generateRequiredMakeReferences_make_dot_proto
+    "
+!
+
 generateSubDirectories
     ^ String streamContents:[:s |
         self subProjects
@@ -6103,6 +6156,100 @@
     "Modified (comment): / 06-09-2011 / 08:26:06 / cg"
 !
 
+allPreRequisites:aSelector
+    "answer all (recursive) prerequisite project ids of myself - in random order."
+
+    |result|
+
+    result := self 
+        allPreRequisites:aSelector withParentDo:[:parent :prereq | 
+            prereq = self package ifTrue:[
+                Transcript showCR:('oops: %1 depends on itself' bindWith:prereq)
+            ].
+        ].
+    result remove:self package ifAbsent:[].
+    ^ result.
+
+    "
+     stx_libbasic allPreRequisites
+     stx_libbasic2 allPreRequisites
+     stx_libview2 allPreRequisites
+     ubs_application allPreRequisites
+     ubs_application allPreRequisitesSorted
+     exept_expecco_application allPreRequisites
+     exept_expeccoNET_application allPreRequisites
+     alspa_batch_application allPreRequisites"
+    "Modified: / 13-04-2011 / 15:30:45 / sr"
+    "Modified (comment): / 06-09-2011 / 08:26:06 / cg"
+!
+
+allPreRequisites:aSelector withParentDo:aBlock
+    "answer all (recursive) prerequisite project ids of myself - in random order.
+     If we exclude a project, but one of our prerequisite projects depends on it,
+     then what ????"
+
+    |setOfAllPreRequisites toAdd|
+
+    setOfAllPreRequisites := Set new.
+    toAdd := Set withAll:(self perform:aSelector).
+
+    "is a subproject really a prerequisite??
+     No, it works the other way: parent projects are prerequisites of sub projects,
+     so the following line has been deleted.
+     Unfortunately the meaning of 'subproject' has never been well defined. SV."
+"/    toAdd addAll:self effectiveSubProjects.
+
+    [toAdd notEmpty] whileTrue:[
+        |aPreRequisiteProjectID def|
+
+        aPreRequisiteProjectID := toAdd removeFirst.
+        (setOfAllPreRequisites includes:aPreRequisiteProjectID) ifFalse:[
+            setOfAllPreRequisites add:aPreRequisiteProjectID.
+
+            def := self definitionClassForPackage:aPreRequisiteProjectID.
+            def isNil ifTrue:[
+                Transcript showCR:'ProjectDefinition ', aPreRequisiteProjectID, ' is missing - cannot find its preRequisites.'.
+            ] ifFalse:[
+                (def perform:aSelector)
+                    select:[:eachSubPreRequisite | (setOfAllPreRequisites includes:eachSubPreRequisite) not]
+                    thenDo:[:eachSubPreRequisite |
+                                Verbose == true ifTrue:[
+                                    Transcript show:'ProjectDefinition preRequisites: '; showCR:(aPreRequisiteProjectID, ' requires ', eachSubPreRequisite).
+                                ].
+                                aBlock value:def value:eachSubPreRequisite.
+                                toAdd add:eachSubPreRequisite
+                           ].
+
+                "but subprojects of our prerequisites are also prerequisites"
+                def effectiveSubProjects
+                    select:[:eachSubSubRequisite | eachSubSubRequisite ~= self package and:[ (setOfAllPreRequisites includes:eachSubSubRequisite) not ]]
+                    thenDo:[:eachSubSubRequisite |
+                                Verbose == true ifTrue:[
+                                    Transcript show:'ProjectDefinition preRequisites: '; showCR:(aPreRequisiteProjectID, ' hasSub ', eachSubSubRequisite).
+                                ].
+                                aBlock value:def value:eachSubSubRequisite.
+                                toAdd add:eachSubSubRequisite
+                           ].
+            ].
+        ]
+    ].
+    ^ setOfAllPreRequisites.
+
+    "
+     stx_libbasic allPreRequisites
+     stx_libbasic2 allPreRequisites
+     stx_libview2 allPreRequisites
+     ubs_application allPreRequisites
+     ubs_application allPreRequisitesSorted
+     exept_expecco_application allPreRequisites
+     exept_expeccoNET_application allPreRequisites
+     alspa_batch_application allPreRequisites
+    "
+
+    "Created: / 13-04-2011 / 15:23:21 / sr"
+    "Modified: / 20-07-2012 / 18:29:31 / cg"
+!
+
 allPreRequisitesSorted
     "answer all the prerequisites of this projects sorted in
      the order they are needed.
@@ -6158,6 +6305,61 @@
     "Modified (comment): / 13-03-2013 / 00:40:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
+allPreRequisitesSorted:aSelector
+    "answer all the prerequisites of this projects sorted in
+     the order they are needed.
+     Use this to e.g. compile packages in the dependency order"
+
+    |allPreRequisites orderedTuples sortedPackages|
+
+    orderedTuples := OrderedCollection new.
+    allPreRequisites := self allPreRequisites:aSelector.
+
+    "/JV@2013-03-13: Added asSortedCollection to make the order of packages
+    "/as stable as possible. Makes merging of makefiles a lot easier.
+    allPreRequisites asSortedCollection do:[:eachPackageID |
+        |def preRequisites|
+
+        self assert:(eachPackageID ~= self package).
+        orderedTuples add:(Array with:eachPackageID with:self package).
+
+        def := self definitionClassForPackage:eachPackageID.
+        def isNil ifTrue:[
+            Transcript showCR:'Warning: no definition class for package: ', eachPackageID.
+            ((self searchForPreRequisites: eachPackageID) 
+                fold:[:d1 :d2| d1 addAll:d2; yourself]) keys
+        ] ifFalse:[
+            preRequisites := def perform:aSelector.
+            preRequisites removeAllFoundIn:def excludedFromPreRequisites.
+            preRequisites do:[:eachPrerequisitePackageID|
+                self assert:(eachPrerequisitePackageID ~= eachPackageID).
+                orderedTuples add:(Array with:eachPrerequisitePackageID with:eachPackageID).
+            ].
+        ].
+    ].
+
+    (orderedTuples includes:[:el | el first = el second]) ifTrue:[
+        self halt
+    ].
+    sortedPackages := orderedTuples topologicalSort.
+
+    "packages which only result from extension methods are used for computing the sort order,
+     but they are not added, if not present in the first place"
+    ^ sortedPackages select:[:eachProject| allPreRequisites includes:eachProject]
+
+    "
+     stx_libbasic allPreRequisitesSorted
+     stx_libbasic2 allPreRequisitesSorted
+     stx_libwidg2 allPreRequisitesSorted
+     exept_expecco allPreRequisitesSorted
+     alspa_batch_application allPreRequisitesSorted
+     ubs_application allPreRequisitesSorted
+    "
+
+    "Modified: / 13-04-2011 / 15:19:13 / sr"
+    "Modified (comment): / 13-03-2013 / 00:40:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 allPreRequisitesWithParentDo:aBlock
     "answer all (recursive) prerequisite project ids of myself - in random order.
      If we exclude a project, but one of our prerequisite projects depends on it,
@@ -6225,6 +6427,32 @@
     "Modified: / 20-07-2012 / 18:29:31 / cg"
 !
 
+allReferences
+    "answer all (recursive) projects to which I refer - in random order."
+
+    |result|
+
+    result := self 
+        allPreRequisites:#referencedPreRequisites withParentDo:[:parent :prereq | 
+            prereq = self package ifTrue:[
+                Transcript showCR:('oops: %1 depends on itself' bindWith:prereq)
+            ].
+        ].
+    result remove:self package ifAbsent:[].
+    ^ result.
+
+    "
+     stx_libbasic allReferences
+     stx_libbasic2 allReferences
+     stx_libview2 allReferences
+     ubs_application allReferences
+     ubs_application allReferences
+     exept_expecco_application allReferences
+     exept_expeccoNET_application allReferences
+     alspa_batch_application allReferences
+    "
+!
+
 effectivePreRequisites
     "get the preRequisites, that are not excluded.
      This method appears to be obsolete, because its functionality
@@ -6985,11 +7213,11 @@
 !ProjectDefinition class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.428 2013-03-15 10:32:13 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.429 2013-03-15 13:40:24 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.428 2013-03-15 10:32:13 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ProjectDefinition.st,v 1.429 2013-03-15 13:40:24 stefan Exp $'
 !
 
 version_SVN