Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present
- All source *.st files are now Unicode UTF8 without BOM
Files are in two groups (fileOut works this way in Smalltalk/X):
- containing a unicode character have "{ Encoding: utf8 }" at the header
- ASCII only are without the header
2 COPYRIGHT (c) 2009 by eXept Software AG
5 This software is furnished under a license and may be used
6 only in accordance with the terms of that license and with the
7 inclusion of the above copyright notice. This software may not
8 be provided or otherwise made available to, or used by, any
9 other person. No title to or ownership of the software is
12 "{ Package: 'stx:libtool2' }"
14 "{ NameSpace: Tools }"
16 Object subclass:#ProjectBuilder
17 instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
18 myWorkingDirectory mySTXTopDirectory myTopDirectory outputStream
19 makeExeOnly makeAppOnly makeQuick usedCompiler stdOut stdErr
20 isQuickBuild isLocalBuild'
21 classVariableNames:'PreviousBuildDirectory'
23 category:'System-Support-Projects'
26 !ProjectBuilder class methodsFor:'documentation'!
30 COPYRIGHT (c) 2009 by eXept Software AG
33 This software is furnished under a license and may be used
34 only in accordance with the terms of that license and with the
35 inclusion of the above copyright notice. This software may not
36 be provided or otherwise made available to, or used by, any
37 other person. No title to or ownership of the software is
42 !ProjectBuilder class methodsFor:'accessing'!
44 previousBuildDirectory
45 ^ PreviousBuildDirectory
48 previousBuildDirectory:something
49 PreviousBuildDirectory := something.
52 !ProjectBuilder class methodsFor:'examples'!
55 Smalltalk loadPackage:'stx:projects/helloWorldApp' asAutoloaded:true.
58 package:'stx:projects/helloWorldApp';
65 Smalltalk loadPackage:'stx:clients/Demos/foxCalcApplication' asAutoloaded:true.
69 package:'stx:clients/Demos/foxCalcApplication';
72 UserPreferences fileBrowserClass openOnDirectory:builder packageBuildDirectory.
74 "Modified: / 03-09-2012 / 19:23:53 / cg"
77 !ProjectBuilder class methodsFor:'queries'!
82 (compiler := UserPreferences current usedCompilerForBuild) notNil ifTrue:[
86 ^ ParserFlags usedCompiler
89 listOfPossibleCompilers
90 OperatingSystem isMSWINDOWSlike ifTrue:[
91 OperatingSystem getLoginName = 'cg' ifTrue:[
95 'lcc' "/ experimental, but only free for non-commercial work
96 'tcc' "/ experimental; limited but free
97 'mingw' "/ experimental; free
100 ^ #('bcc' 'vc' 'mingw' )
104 "Created: / 21-01-2012 / 14:04:15 / cg"
107 suiteNameOfCompiler:usedCompiler
108 usedCompiler = 'bcc' ifTrue:[
109 ^ 'Borland C-Compiler'.
111 usedCompiler = 'vc' ifTrue:[
112 ^ 'Microsoft Visual C Compiler'.
114 usedCompiler = 'lcc' ifTrue:[
117 usedCompiler = 'tcc' ifTrue:[
120 usedCompiler = 'gcc' ifTrue:[
123 usedCompiler = 'mingw' ifTrue:[
124 ^ 'MINGW GNU C-Compiler'.
126 self halt:'unknown compiler'.
130 "Created: / 06-09-2012 / 15:58:33 / cg"
133 !ProjectBuilder methodsFor:'accessing'!
136 buildDirectory isNil ifTrue:[
137 self determineBuildDirectory
142 buildDirectory:something
143 buildDirectory := something.
147 ^ isLocalBuild ? false
150 isLocalBuild:aBoolean
151 "create a files without going through the source code manager"
153 isLocalBuild := aBoolean.
157 ^ isQuickBuild ? false
160 isQuickBuild:aBoolean
161 "skips creation of header files, and copying of support files, if possible
162 to speedup a build. Use with care."
164 isQuickBuild := aBoolean.
168 ^ (makeAppOnly ? false)
172 makeAppOnly := aBoolean.
176 ^ (makeExeOnly ? false)
180 makeExeOnly := aBoolean.
184 ^ (makeQuick ? false)
188 makeQuick := aBoolean.
191 package:aPackageIDOrSymbol
192 package := aPackageIDOrSymbol asPackageId.
195 packageBuildDirectory
196 "the directoray, where the deployable binary is created (xxxSetup.exe)"
198 ^ buildDirectory / (package asPackageId module) / (package asPackageId directory)
201 projectDefinitionClass:something
202 projectDefinitionClass := something.
206 ^ OperatingSystem isUNIXlike ifTrue:['.H'] ifFalse:['.STH']
209 usedCompilerForBuild:something
210 usedCompiler := something.
212 "Created: / 22-01-2012 / 10:50:48 / cg"
215 !ProjectBuilder methodsFor:'building'!
218 "/ intermediate - this will move into a commonly used utility class
219 "/ (where all the project code support will be collected).
223 makeOutput := TextStream on:(Text new:10000).
224 self buildWithColorizedOutputTo:makeOutput.
226 TextView openWith:makeOutput contents.
229 buildWithColorizedOutputTo:makeOutput
230 "/ intermediate - this will move into a commonly used utility class
231 "/ (where all the project code support will be collected).
235 lock := Semaphore forMutualExclusion.
237 stdErr := ActorStream new
238 nextPutBlock:[:char |
241 withEmphasis:{#backgroundColor->Color red. #color->Color white.}
242 do:[makeOutput nextPut:char].
245 nextPutAllBlock:[:string |
248 withEmphasis:{#backgroundColor->Color red. #color->Color white.}
249 do:[makeOutput nextPutAll:string].
252 stdOut := ActorStream new
253 nextPutBlock:[:char |
255 makeOutput nextPut:char.
258 nextPutAllBlock:[:string |
260 makeOutput nextPutAll:string.
264 self buildWithOutputTo:stdOut errorTo:stdErr.
266 "Modified: / 06-09-2012 / 16:15:50 / cg"
269 buildWithOutputTo:stdOutArg errorTo:stdErrArg
270 "/ intermediate - this will move into a commonly used utility class
271 "/ (where all the project code support will be collected).
275 usedCompiler isNil ifTrue:[
276 usedCompiler := ParserFlags usedCompiler.
277 usedCompiler isNil ifTrue:[ self error:'no compiler defined (settings)'. ].
280 projectDefinitionClass := ProjectDefinition definitionClassForPackage:package.
281 projectDefinitionClass isNil ifTrue:[
282 self error:('Missing ProjectDefinition class for "',package asString,'"')
285 "/ ensure that everything is loaded...
286 projectDefinitionClass loadAsAutoloaded:false.
287 projectDefinitionClass loadExtensions.
288 projectDefinitionClass loadAllClassesAsAutoloaded:false.
290 module := package module.
291 directory := package directory.
293 buildDirectory isNil ifTrue:[
294 self determineBuildDirectory.
297 "/ self validateBuildDirectoryIsPresent.
299 PreviousBuildDirectory := buildDirectory.
301 "/ UserPreferences current localBuild:true
302 (self isLocalBuild or:[UserPreferences current localBuild]) ifFalse:[
303 SourceCodeManager notNil ifTrue:[
304 sourceCodeManager := SourceCodeManagerUtilities sourceCodeManagerFor:projectDefinitionClass.
307 sourceCodeManager := nil.
310 Smalltalk packagePath
312 (aPath asFilename / 'stx' / 'include') exists
313 and: [ (aPath asFilename / 'stx' / 'rules') exists ]]
315 myTopDirectory isNil ifTrue:[
316 self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
318 myTopDirectory := myTopDirectory asFilename.
319 mySTXTopDirectory := myTopDirectory / 'stx'.
321 self makeQuick ifFalse:[
322 self setupBuildDirectory.
323 self activityNotification:'Generating stc directory...'.
324 self copySTCDirectoryForBuild.
326 self activityNotification:'Generating source files...'.
327 self generateSourceFiles.
328 false "self makeQuick" ifFalse:[
329 self activityNotification:'Copying dlls for linkage...'.
330 self copyDLLsForLinkage.
331 self activityNotification:'Copying support files for compilation and linkage...'.
332 self copySupportFilesForCompilation.
333 self copySupportFilesForLinkage.
334 self copyStartupFilesFromSmalltalk.
336 self makeWithOutputTo:stdOut errorTo:stdErr.
338 "Modified: / 06-06-2016 / 15:16:28 / cg"
341 !ProjectBuilder methodsFor:'building/private'!
344 |targetBuildDir preRequisites dllRelativeSourcePaths dllRelativeDestPaths|
346 targetBuildDir := buildDirectory / package module / package directory.
348 preRequisites := projectDefinitionClass allPreRequisites.
349 OperatingSystem isUNIXlike ifTrue:[
350 "For now: unix Makefiles require some libs implicitely..."
351 preRequisites := preRequisites union:#(
352 #'stx:goodies/refactoryBrowser/parser'
357 preRequisites do:[:eachPackageToFileout |
358 |packageId packageDef packageModule packageDirectory packageTargetDir
359 dllSource dllSourceDir libraryName dllRelativePathSource
360 dllRelativePathDest objDirSource objDirDest alternativeObjDirSource|
362 packageId := eachPackageToFileout asPackageId.
363 packageModule := packageId module.
364 packageDirectory := packageId directory.
365 packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
367 packageDef := packageId projectDefinitionClass.
368 libraryName := packageDef libraryName.
370 "/ mhmh - take them from my tree or from the projects/smalltalk execution directory ??
371 dllSourceDir := myTopDirectory / packageModule / packageDirectory.
373 OperatingSystem isMSWINDOWSlike ifTrue:[
374 objDirDest := self objDirForUsedCompiler:usedCompiler.
375 objDirSource := objDirDest.
376 "/ "/ use visual-c files for tcc linkage
377 "/ usedCompiler = 'tcc' ifTrue:[
378 "/ objDirSource := self objDirForUsedCompiler:'vc'.
380 "/ objDirSource := objDirDest
382 (dllSourceDir / objDirSource / (libraryName, '.dll')) exists ifFalse:[
383 alternativeObjDirSource := self objDirForUsedCompiler:'vc'.
384 (dllSourceDir / alternativeObjDirSource / (libraryName, '.dll')) exists ifTrue:[
385 objDirSource := alternativeObjDirSource.
386 stdErr nextPutLine:(('Warning: using alternative %1 from %2 (%3 version)...'
388 with:alternativeObjDirSource
389 with:(self class suiteNameOfCompiler:'vc'))
390 emphasizeAllWith:(#color -> Color red darkened)).
392 alternativeObjDirSource := self objDirForUsedCompiler:'bcc'.
393 (dllSourceDir / alternativeObjDirSource / (libraryName, '.dll')) exists ifTrue:[
394 objDirSource := alternativeObjDirSource.
395 stdErr nextPutLine:('Warning: using alternative %1 from %2 (%3 version)...'
397 with:alternativeObjDirSource
398 with:(self class suiteNameOfCompiler:'bcc')).
403 "/ dllRelativePath := objDir,'/',(libraryName,'.dll').
404 "/ (dllSourceDir / dllRelativePath) exists
405 dllRelativeSourcePaths := Array with:(objDirSource,'\', libraryName, '.dll').
406 dllRelativeDestPaths := Array with:(objDirDest,'\', libraryName, '.dll').
408 dllRelativeSourcePaths := Array with:(libraryName,'.so').
409 dllRelativeDestPaths := Array with:(libraryName, '.so').
410 (packageModule = 'stx' and:[packageDirectory = 'libview']) ifTrue:[
411 dllRelativeSourcePaths := dllRelativeSourcePaths copyWith:('XWorkstation.so').
412 dllRelativeDestPaths := dllRelativeDestPaths copyWith:'XWorkstation.so'.
413 dllRelativeSourcePaths := dllRelativeSourcePaths copyWith:('GLXWorkstation.so').
414 dllRelativeDestPaths := dllRelativeDestPaths copyWith:'GLXWorkstation.so'.
417 dllRelativeSourcePaths with:dllRelativeDestPaths do:[:dllRelativeSourcePath :dllRelativeDestPath|
420 source := dllSourceDir / dllRelativeSourcePath.
421 source exists ifFalse:[
422 self activityNotification:' skip missing file: ',source pathName.
424 dest := packageTargetDir / dllRelativeDestPath.
426 or:[source fileSize ~= dest fileSize
427 or:[source modificationTime > dest modificationTime
428 "/ or:[ ((dllSourceDir / dllRelativePath) sameContentsAs:(packageTargetDir / dllRelativePath)) not ]
430 Transcript showCR:'updating ',dllRelativeDestPath.
431 dest directory recursiveMakeDirectory.
433 self activityNotification:' ',dest pathName
435 Transcript showCR:'already up-to-date: ',dllRelativeDestPath.
441 "Modified: / 06-09-2012 / 16:19:29 / cg"
444 copyDirectory:relativepath
446 ((Smalltalk projectDirectoryForPackage:'stx') asFilename construct:relativepath)
447 recursiveCopyTo:(buildDirectory construct:'stx').
450 copyDirectoryForBuild:subdir
451 |targetDir targetFile|
453 targetDir := buildDirectory / 'stx' / subdir.
454 targetDir exists ifFalse:[
455 targetDir makeDirectory.
457 self isQuickBuild ifTrue:[^ self]
459 (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
460 eachFile isDirectory ifFalse:[
461 targetFile := targetDir / eachFile baseName.
462 (targetFile exists not
463 or:[ targetFile modificationTime < eachFile modificationTime ]) ifTrue:[
464 self activityNotification:'copying ',eachFile pathName,'...'.
465 eachFile copyTo:(targetDir construct:eachFile baseName)
469 self activityNotification:nil
472 copyResourcesForPackage:aPackage
473 |module directory myPackageDirectory rsrcDir stylesDir|
475 module := aPackage asPackageId module.
476 directory := aPackage asPackageId directory.
478 myPackageDirectory := myTopDirectory / module / directory.
480 (rsrcDir := myPackageDirectory / 'resources' ) exists ifTrue:[
481 rsrcDir recursiveCopyTo:(buildDirectory / module / directory)
483 (stylesDir := myPackageDirectory / 'styles' ) exists ifTrue:[
484 stylesDir recursiveCopyTo:(buildDirectory / module / directory)
488 copySTCDirectoryForBuild
489 "copy stc files to the build directory"
491 |targetDir stc files|
493 targetDir := buildDirectory / 'stx' / 'stc'.
494 targetDir exists ifFalse:[ targetDir makeDirectory ].
496 stc := OperatingSystem isMSWINDOWSlike
500 files := #( ) copyWith:stc.
502 files do:[:eachFile |
503 |sourceFile targetFile|
505 sourceFile := mySTXTopDirectory / 'stc' / eachFile.
506 targetFile := targetDir / eachFile.
507 (targetFile exists not
508 or:[ targetFile modificationTime < sourceFile modificationTime ]) ifTrue:[
509 self activityNotification:'copying ',sourceFile pathName,'...'.
510 sourceFile copyTo:targetFile
514 OperatingSystem isUNIXlike ifTrue:[
515 (targetDir / 'stc') makeExecutableForAll
518 self activityNotification:nil
520 "Modified (comment): / 04-09-2012 / 00:49:19 / cg"
523 copyStartupFilesFromSmalltalk
524 "copy additional smalltalk startup files to the build directory"
526 (buildDirectory / 'stx' / 'projects/smalltalk' ) exists ifFalse:[
527 (buildDirectory / 'stx' / 'projects/smalltalk' ) recursiveMakeDirectory.
540 (myTopDirectory / 'stx' / 'projects/smalltalk' / fn)
541 copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / fn)
544 (myTopDirectory / 'stx' / 'doc/online/english/LICENCE_STX.html')
545 copyTo: (buildDirectory / 'stx' / 'projects/smalltalk' / 'LICENCE_STX.html').
547 "Modified (comment): / 04-09-2012 / 00:48:47 / cg"
550 copySupportFilesForCompilation
551 "copy the tcc compiler to the build directory"
557 OperatingSystem isMSWINDOWSlike ifTrue:[
561 usedCompiler = 'tcc' ifTrue:[
568 "/ 'librun/genDate' -- not needed on unix (done via script)
569 'configurations/myConf'
570 'configurations/vendorConf'
571 'configurations/conf.inc'
572 'configurations/COMMON'
576 files do:[:relativePath |
577 (mySTXTopDirectory / relativePath) exists ifTrue:[
578 ((buildDirectory / 'stx' / relativePath) exists
579 and:[ (mySTXTopDirectory / relativePath) fileSize = (buildDirectory / 'stx' / relativePath) fileSize
580 and:[ (mySTXTopDirectory / relativePath) modificationTime < (buildDirectory / 'stx' / relativePath) modificationTime
581 "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
583 (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
584 (mySTXTopDirectory / relativePath) isDirectory ifTrue:[
585 (mySTXTopDirectory / relativePath) recursiveCopyTo:(buildDirectory / 'stx' / relativePath) directory.
587 (mySTXTopDirectory / relativePath) copyTo:(buildDirectory / 'stx' / relativePath) directory.
591 self error:'Missing file or directory: ',relativePath printString mayProceed:true.
595 "Created: / 04-09-2012 / 00:47:49 / cg"
598 copySupportFilesForLinkage
599 "copy additional files which are req'd for linkage to the build directory"
603 OperatingSystem isMSWINDOWSlike ifTrue:[
607 'projects/smalltalk/stx_16x16.ico'
608 'projects/smalltalk/stx_32x32.ico'
609 'projects/smalltalk/stx_splash.bmp'
612 usedCompiler = 'bcc' ifTrue:[
614 'librun/objbc/librun.dll'
615 'support/win32/borland/cs3245.dll'
616 'support/win32/X11.dll'
617 'support/win32/Xext.dll'
622 usedCompiler = 'vc' ifTrue:[
624 'librun/objvc/librun.dll'
628 usedCompiler = 'tcc' ifTrue:[
630 'librun/objvc/librun.dll' "/ linkage is against vc version!!
634 usedCompiler = 'lcc' ifTrue:[
636 'librun/objvc/librun.dll' "/ linkage is against vc version!!
640 usedCompiler = 'mingw' ifTrue:[
642 'librun/objmingw/librun.dll' "/ linkage is against vc version!!
643 'lib/mingw/librun.lib'
652 files := files asOrderedCollection.
655 OperatingSystem isMSWINDOWSlike ifTrue:[
656 (fn := projectDefinitionClass applicationIconFileNameWindows) notNil ifTrue:[
657 fn asFilename suffix isEmptyOrNil ifTrue:[
660 files add:('projects/smalltalk/',fn)
662 (fn := projectDefinitionClass splashFileName) notNil ifTrue:[
663 files add:('projects/smalltalk/',fn,'.bmp')
666 OperatingSystem isOSXlike ifTrue:[
667 (fn := projectDefinitionClass applicationIconFileNameOSX) notNil ifTrue:[
668 fn asFilename suffix isEmptyOrNil ifTrue:[
671 files add:('projects/smalltalk/',fn)
675 files do:[:relativePath |
676 (mySTXTopDirectory / relativePath) exists ifTrue:[
677 ((buildDirectory / 'stx' / relativePath) exists
678 and:[ (mySTXTopDirectory / relativePath) fileSize = (buildDirectory / 'stx' / relativePath) fileSize
679 and:[ (mySTXTopDirectory / relativePath) modificationTime < (buildDirectory / 'stx' / relativePath) modificationTime
680 "/ and:[ (mySTXTopDirectory / dllRelativePath) sameContentsAs:(targetBuildDir / dllRelativePath) ]
682 (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
683 (mySTXTopDirectory / relativePath) copyTo:(buildDirectory / 'stx' / relativePath).
686 "/ does not really help: objbc/librun.lib does not work with MSVC and vice versa...
687 "/ ((relativePath = 'librun/objvc/librun.dll')
688 "/ and:[ (mySTXTopDirectory / 'librun/objbc/librun.dll') exists ])ifTrue:[
689 "/ stdErr nextPutLine:('Warning: using alternative librun from objbc (Borland version)...').
690 "/ (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
691 "/ (mySTXTopDirectory / 'librun/objbc/librun.dll') copyTo:(buildDirectory / 'stx' / relativePath).
693 "/ ((relativePath = 'librun/objbc/librun.dll')
694 "/ and:[ (mySTXTopDirectory / 'librun/objvc/librun.dll') exists ])ifTrue:[
695 "/ stdErr nextPutLine:('Warning: using alternative librun from objvc (MSVC version)...').
696 "/ (buildDirectory / 'stx' / relativePath) directory recursiveMakeDirectory.
697 "/ (mySTXTopDirectory / 'librun/objvc/librun.dll') copyTo:(buildDirectory / 'stx' / relativePath).
699 self error:'Missing file: ',relativePath printString mayProceed:true.
705 "Modified: / 05-09-2012 / 16:26:25 / cg"
708 createHeaderFileFor:aClass in:packageTargetDir
709 |instVarList classInstVarList classVarList bindings superclassFilename
710 template file newContents oldContents|
712 instVarList := StringCollection new.
713 aClass instVarNames do:[:v |
714 instVarList add:('OBJ %1;' bindWith:v)
716 classInstVarList := StringCollection new.
717 aClass class instVarNames do:[:v |
718 "/ (v includes:$_) ifTrue:[self halt].
719 classInstVarList add:('OBJ %1;' bindWith:v)
721 classVarList := StringCollection new.
722 aClass classVarNames do:[:v |
723 classVarList add:('extern OBJ %1_%2;' bindWith:aClass name with:v)
726 bindings := Dictionary new.
727 bindings at:'ClassName' put:aClass name.
728 aClass superclass isNil ifTrue:[
729 bindings at:'SuperclassName' put:'-'.
730 bindings at:'SuperclassFileInclude' put:''.
732 bindings at:'SuperclassName' put:aClass superclass name.
733 bindings at:'SuperclassFileName' put:(superclassFilename := Smalltalk fileNameForClass:aClass superclass).
734 bindings at:'SuperclassFileInclude' put:('#include "%1.STH"' bindWith:superclassFilename).
736 bindings at:'InstVarList' put:instVarList asString.
737 bindings at:'ClassVarList' put:classVarList asString.
738 bindings at:'ClassInstVarList' put:classInstVarList asString.
741 '/* This file was generated by ProjectBuilder. */
742 /* !!!!!!!! Do not change by hand !!!!!!!! */
744 /* Class: %(ClassName) */
745 /* Superclass: %(SuperclassName) */
747 %(SuperclassFileInclude)
749 /* INDIRECTGLOBALS */
752 #endif /* _HEADER_INST_ */
754 #ifdef _HEADER_CLASS_
756 #endif /* _HEADER_CLASS_ */
758 #ifdef _HEADER_CLASSINST_
760 #endif /* _HEADER_CLASSINST_ */
762 newContents := template bindWithArguments:bindings.
763 file := packageTargetDir asFilename / ((Smalltalk fileNameForClass:aClass),(self suffixForHeaderFiles)).
765 or:[ (oldContents := file contents) ~= newContents ]) ifTrue:[
766 file contents: newContents.
769 "Modified: / 15-08-2011 / 14:58:46 / cg"
772 determineBuildDirectory
773 buildDirectory isNil ifTrue:[
774 buildDirectory := PreviousBuildDirectory ifNil:[ UserPreferences current buildDirectory ].
775 buildDirectory isNil ifTrue:[
776 buildDirectory := Filename tempDirectory construct:'stx_build'.
779 buildDirectory := buildDirectory asFilename.
782 generateBuildSupportFilesByFilingOutIn:packageTargetDir forDefinitionClass:projectDefinitionClass
785 projectDefinitionClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
786 fullPathName := packageTargetDir construct:fileName.
787 fullPathName directory exists ifFalse:[
788 "take care for files like 'autopackage/default.apspec'"
789 fullPathName directory makeDirectory.
792 and:[ fullPathName contents = fileContents ]) ifFalse:[
793 fullPathName contents:fileContents.
799 (self isLocalBuild not and:[ sourceCodeManager notNil ]) ifTrue:[
800 "/ check out / generate files there
801 self generateSourceFilesByCheckingOutUsing:sourceCodeManager
804 "/ fileout the project
805 self generateSourceFilesByFilingOut
809 generateSourceFilesByCheckingOutUsing:aSourceCodeManager
810 "/ will no longer be needed/supported
812 |repository stxRepository module directory|
816 "/ check out / generate files there
817 repository := (aSourceCodeManager repositoryNameForModule:module) ifNil:[aSourceCodeManager repositoryName].
818 stxRepository := aSourceCodeManager repositoryName.
820 (buildDirectory construct:'stx') exists ifFalse:[
821 (module ~= 'stx') ifTrue:[
823 executeCommand:('cvs -d ',stxRepository,' co stx')
827 inDirectory:buildDirectory
828 onError:[:status| self error:'cvs update stx failed'].
832 ((buildDirectory construct:module) construct:'CVS') exists ifFalse:[
834 executeCommand:('cvs -d ',repository,' co -l ',directory)
838 inDirectory:buildDirectory
839 onError:[:status| self error:'cvs update failed'].
842 executeCommand:'cvs upd -d'
846 inDirectory:(buildDirectory construct:module)
847 onError:[:status| self error:'cvs update failed'].
850 "Modified: / 29-12-2011 / 14:02:56 / cg"
853 generateSourceFilesByFilingOut
855 "/ fileout the project
857 (package module ~= 'stx') ifTrue:[
858 (buildDirectory / package module) makeDirectory.
861 "/ file out the package(s) which are to be built
862 ((Array with:package))
863 do:[:eachPackageToFileout |
864 |packageId packageModule packageDirectory packageTargetDir packageDef extSource|
866 packageId := eachPackageToFileout asPackageId.
867 packageModule := packageId module.
868 packageDirectory := packageId directory.
869 packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
871 packageDef := packageId projectDefinitionClass.
872 (packageDef compiled_classNames_common ,
873 packageDef compiled_classNamesForPlatform) do:[:eachClassName |
874 |cls fileName newSource|
876 cls := Smalltalk classNamed:eachClassName.
877 (cls notNil and:[cls isLoaded]) ifFalse:[
878 self error:'missing class: ',eachClassName mayProceed:true
880 fileName := (Smalltalk fileNameForClass:cls),'.st'.
881 fileName := packageTargetDir asFilename construct:fileName.
882 fileName exists ifTrue:[
883 newSource := String streamContents:[:s | cls fileOutOn:s withTimeStamp:false].
884 newSource = fileName contentsAsString ifFalse:[
885 fileName contents:newSource
888 cls fileOutIn:packageTargetDir withTimeStamp:false
892 packageDef hasExtensionMethods ifTrue:[
894 String streamContents:[:s |
895 s nextPutAll:('"{ Package: ''%1'' }" !!\\' bindWith:packageDef package) withCRs.
897 packageDef extensionMethods do:[:eachMethod |
898 eachMethod mclass fileOutMethod:eachMethod on:s
901 extSource isWideString ifTrue:[
902 extSource := ( '"{ Encoding: utf8 }"' , Character cr asString, Character cr asString, extSource).
903 extSource := extSource utf8Encoded.
905 (packageTargetDir asFilename construct:'extensions.st') contents:extSource
908 "/ (Smalltalk allClassesInPackage:eachPackageToFileout) do:[:cls |
909 "/ cls isPrivate ifFalse:[
910 "/ cls isLoaded ifFalse:[
914 "/ cls fileOutIn:packageTargetDir
917 self generateBuildSupportFilesByFilingOutIn:packageTargetDir forDefinitionClass:projectDefinitionClass.
919 self makeQuick ifFalse:[
920 "/ generate header files and build support files
921 "/ in prerequisite packages...
922 (projectDefinitionClass allPreRequisites)
923 do:[:eachPackageToFileout |
924 |packageId packageDef packageModule packageDirectory packageTargetDir|
926 packageId := eachPackageToFileout asPackageId.
927 packageModule := packageId module.
928 packageDirectory := packageId directory.
929 packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
931 packageDef := packageId projectDefinitionClass.
932 (packageDef compiled_classNames_common ,
933 packageDef compiled_classNamesForPlatform) do:[:eachClassName |
936 cls := Smalltalk classNamed:eachClassName.
937 "/ self assert:cls isLoaded.
939 stdErr nextPutLine:('Missing class: ',eachClassName, ' (not present in system. Warning only:subclasses of it will not be compiled)').
941 cls isLoaded ifTrue:[
942 self createHeaderFileFor:cls in:packageTargetDir
946 self copyResourcesForPackage:eachPackageToFileout.
947 self generateBuildSupportFilesByFilingOutIn:packageTargetDir forDefinitionClass:packageDef.
948 (packageTargetDir / '.NOSOURCE') contents:'existence of this file suppresses compilation of st files'.
952 "/ stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
955 makeCommandOfCompiler:usedCompiler
956 usedCompiler notNil ifTrue:[
957 usedCompiler = 'bcc' ifTrue:[
960 usedCompiler = 'vc' ifTrue:[
961 ^ 'vcmake'. "/ compilerFlag := '-DUSEVC'
963 usedCompiler = 'lcc' ifTrue:[
964 ^ 'lccmake'. "/ compilerFlag := '-DUSELCC'
966 usedCompiler = 'tcc' ifTrue:[
967 ^ 'tccmake'. "/ compilerFlag := '-DUSELCC'
969 usedCompiler = 'mingw' ifTrue:[
970 ^ 'mingwmake'. "/ compilerFlag := '-DUSEMINGW'
972 true "usedCompiler = 'gcc'" ifTrue:[
973 ^ 'make'. "/ compilerFlag := '-DUSEGCC'
976 self error:'unknown compiler specified'.
978 "Created: / 03-09-2012 / 19:46:07 / cg"
979 "Modified: / 06-06-2016 / 15:11:54 / cg"
982 makeWithOutputTo:stdOut errorTo:stdErr
983 |module directory makeCommand forceArg makeTarget|
985 module := package module.
986 directory := package directory.
988 "/ makeCommand := ParserFlags makeCommand.
989 usedCompiler isNil ifTrue:[
990 usedCompiler := ParserFlags usedCompiler.
991 usedCompiler isNil ifTrue:[ self error:'no compiler defined (settings)'. ].
993 makeCommand := self makeCommandOfCompiler:usedCompiler.
994 self activityNotification:'Executing make... (',makeCommand,')'.
997 "/ makeCommand := makeCommand, ' TOP=', mySTXTopDirectory pathName.
999 OperatingSystem isUNIXlike ifTrue:[
1000 forceArg := ' FORCE='.
1002 "/ generate the makefile first
1003 self activityNotification:('sh %1/rules/stmkmf (in %2)'
1004 bindWith:mySTXTopDirectory pathName
1005 with:(buildDirectory / module / directory)).
1007 executeCommand:('sh %1/rules/stmkmf' bindWith:mySTXTopDirectory pathName)
1011 inDirectory:(buildDirectory / module / directory)
1012 onError:[:status | self error:'make failed'].
1015 projectDefinitionClass isLibraryDefinition ifTrue:[
1016 "/ generate the library
1017 self activityNotification:(makeCommand,' classLibRule').
1019 executeCommand:(makeCommand,' classLibRule',forceArg)
1023 inDirectory:(buildDirectory / module / directory)
1024 onError:[:status | self error:'make failed'].
1026 (self makeExeOnly) ifTrue:[
1029 (self makeAppOnly) ifTrue:[
1032 makeTarget := 'ALL_NP'
1034 self activityNotification:(makeCommand,' ',makeTarget).
1036 "/ generate the executable
1037 executeCommand:(makeCommand,' ',makeTarget,forceArg)
1041 inDirectory:(buildDirectory / module / directory)
1042 onError:[:status | self error:'make failed'].
1046 "Modified: / 06-06-2016 / 15:17:00 / cg"
1049 objDirForUsedCompiler
1050 ^ self objDirForUsedCompiler:usedCompiler
1052 "Created: / 20-08-2012 / 17:01:13 / cg"
1055 objDirForUsedCompiler:usedCompiler
1056 usedCompiler = 'gcc' ifTrue:[^ 'obj']. "/ unix case
1058 usedCompiler = 'bcc' ifTrue:[^ 'objbc'].
1059 usedCompiler = 'vc' ifTrue:[^ 'objvc'].
1060 usedCompiler = 'tcc' ifTrue:[^ 'objtcc'].
1061 usedCompiler = 'lcc' ifTrue:[^ 'objlcc'].
1062 usedCompiler = 'mingw' ifTrue:[^ 'objmingw'].
1063 self halt:'please add compiler here'.
1066 "Created: / 03-09-2012 / 19:55:34 / cg"
1069 recursiveCopyDirectoryForBuild:subdir
1072 targetDir := buildDirectory / 'stx' / subdir.
1073 targetDir exists ifFalse:[
1074 targetDir makeDirectory.
1076 (mySTXTopDirectory / subdir) directoryContentsAsFilenamesDo:[:eachFile |
1077 eachFile recursiveCopyTo:(targetDir construct:eachFile baseName)
1079 self activityNotification:nil
1083 self activityNotification:('Setting up build directory %1' bindWith:buildDirectory pathName).
1085 buildDirectory exists ifFalse:[
1086 buildDirectory recursiveMakeDirectory.
1088 (buildDirectory / 'stx') exists ifFalse:[
1089 (buildDirectory / 'stx') makeDirectory.
1092 self copyDirectoryForBuild:'include'.
1093 self copyDirectoryForBuild:'rules'.
1095 OperatingSystem isUNIXlike ifTrue:[
1096 self recursiveCopyDirectoryForBuild:'configurations'.
1100 validateBuildDirectoryIsPresent
1105 "/ |default directoryIsOKForMe stc |
1107 "/ default := (buildDirectory ?
1108 "/ PreviousBuildDirectory)
1109 "/ ifNil:[ UserPreferences current buildDirectory].
1111 "/ buildDirectory := Dialog requestDirectoryName:'Temporary Work-ROOT for build:'
1114 "/ buildDirectory isEmptyOrNil ifTrue:[^ self].
1115 "/ buildDirectory := buildDirectory asFilename.
1116 "/ directoryIsOKForMe := true.
1118 "/ buildDirectory exists ifFalse:[
1119 "/ Dialog warn:(self classResources string:'Work directory %1 does not exist.' with:buildDirectory).
1120 "/ directoryIsOKForMe := false.
1122 "/ (buildDirectory construct:'stx') exists ifFalse:[
1123 "/ Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stx subDirectory,\which contains (at least) the stc and include subdirectories.').
1124 "/ directoryIsOKForMe := false.
1126 "/ stc := (OperatingSystem isMSDOSlike) ifTrue:['stc.exe'] ifFalse:['stc'].
1127 "/ (((buildDirectory construct:'stx')construct:'stc')construct:stc) exists ifFalse:[
1128 "/ Dialog warn:(self classResources stringWithCRs:'Work directory must contain an stc compiler in the stx/stc subDirectory.').
1129 "/ directoryIsOKForMe := false.
1131 "/ ((buildDirectory construct:'stx')construct:'include') exists ifFalse:[
1132 "/ Dialog warn:(self classResources stringWithCRs:'Work directory must have had a make run before (for include files to exists).').
1133 "/ directoryIsOKForMe := false.
1137 "/ directoryIsOKForMe
1141 !ProjectBuilder class methodsFor:'documentation'!