AbstractOperatingSystem.st
branchjv
changeset 24905 716edea8e854
parent 23107 40173e082cbc
child 24914 5428e2b96ef4
--- a/AbstractOperatingSystem.st	Fri Jun 14 12:48:45 2019 +0100
+++ b/AbstractOperatingSystem.st	Fri Jul 19 12:22:40 2019 +0100
@@ -5198,7 +5198,7 @@
     "Return a default packagePath - that's a collection of
      dirnames, where ST/X searches for packages.
 
-     The default package path contains
+     The default package path contains, in this order:
 
         * $STX_PACKAGEPATH (directories specified in environment variable)
         * $HOME/.smalltalk/packages (on Windows %USERPROFILE%\.smalltalk\packages)
@@ -5220,7 +5220,7 @@
             (packagePath includes:each) ifFalse:[
                 packagePath addFirst:each.
             ].
-	].
+        ].
     ].
 
     "/ $HOME/.smalltalk/packages (on Windows %USERPROFILE%\.smalltalk\packages)
@@ -5232,15 +5232,39 @@
     "/
     execPath := self pathOfSTXExecutable.
     execPath notNil ifTrue:[
-        (self isUNIXlike and:[ execPath endsWith: '/stx/projects/smalltalk/stx' ]) ifTrue:[ 
-            packagePath add: (execPath copyTo: execPath size - '/stx/projects/smalltalk/stx' size)
-        ] ifFalse:[
-        	self isMSWINDOWSlike ifTrue:[
-        		((execPath endsWith: '\stx\projects\smalltalk\stx.com') or:[execPath endsWith: '\stx\projects\smalltalk\stx.exe']) ifTrue:[
-        			packagePath add: (execPath copyTo: execPath size - '\stx\projects\smalltalk\stx.exe' size)
-        		]
-        	]
-        ]
+        | startup |
+
+        startup:= Smalltalk startupClass ? (Smalltalk at: #SmalltalkStartup).
+        startup notNil ifTrue:[ 
+            | definition |
+
+            definition := ProjectDefinition definitionClassForPackage: startup package.
+            definition notNil ifTrue:[ 
+                | execPathEndInBuildTree1 execPathEndInBuildTree2 |
+
+                OperatingSystem isUNIXlike ifTrue:[ 
+                    execPathEndInBuildTree1 := 
+                        definition module , '/' , definition directory , '/' , definition applicationName
+                ] ifFalse:[ OperatingSystem isMSWINDOWSlike ifTrue:[ 
+                    execPathEndInBuildTree1 :=
+                        definition module , '/' , definition directory , '/' , definition applicationNameConsole.
+                    execPathEndInBuildTree2 :=
+                        definition module , '/' , definition directory , '/' , definition applicationNameNoConsole.
+                ] ifFalse:[ 
+                    self error:'Operating system not supported'.
+                ]].
+
+                ((execPathEndInBuildTree1 notNil and:[ execPath endsWith: execPathEndInBuildTree1 ]) or:[execPathEndInBuildTree2 notNil and:[ execPath endsWith: execPathEndInBuildTree2 ]]) ifTrue:[
+                    | root top |
+
+                    top := definition pathToTopWithSeparator: Filename separator.
+                    root := execPath asFilename directory / top / '..'.
+                    root exists ifTrue:[ 
+                        packagePath add: root asAbsoluteFilename pathName.
+                    ].
+                ].
+            ].
+        ].
     ].
 
     ^ packagePath
@@ -5250,7 +5274,7 @@
     "
 
     "Modified: / 04-02-2011 / 16:27:15 / cg"
-    "Modified: / 26-06-2016 / 06:26:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 19-07-2019 / 12:08:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 defaultSystemPath