ProjectBuilder.st
changeset 2972 7db782e25d01
parent 2971 e10937c35748
child 2974 8cf2b51872fd
equal deleted inserted replaced
2971:e10937c35748 2972:7db782e25d01
    14 "{ NameSpace: Tools }"
    14 "{ NameSpace: Tools }"
    15 
    15 
    16 Object subclass:#ProjectBuilder
    16 Object subclass:#ProjectBuilder
    17 	instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
    17 	instanceVariableNames:'package projectDefinitionClass sourceCodeManager buildDirectory
    18 		myWorkingDirectory mySTXTopDirectory myTopDirectory outputStream
    18 		myWorkingDirectory mySTXTopDirectory myTopDirectory outputStream
    19 		makeExeOnly usedCompiler stdOut stdErr isQuickBuild isLocalBuild'
    19 		makeExeOnly makeQuick usedCompiler stdOut stdErr isQuickBuild
       
    20 		isLocalBuild'
    20 	classVariableNames:'PreviousBuildDirectory'
    21 	classVariableNames:'PreviousBuildDirectory'
    21 	poolDictionaries:''
    22 	poolDictionaries:''
    22 	category:'System-Support-Projects'
    23 	category:'System-Support-Projects'
    23 !
    24 !
    24 
    25 
    98                 'lcc'   "/ experimental, but only free for non-commercial work
    99                 'lcc'   "/ experimental, but only free for non-commercial work
    99                 'tcc'   "/ experimental; limited but free
   100                 'tcc'   "/ experimental; limited but free
   100                 'mingw' "/ experimental; free
   101                 'mingw' "/ experimental; free
   101              )
   102              )
   102         ].
   103         ].
   103         ^ #('bcc' 'vc' "'lcc' 'mingw'" )
   104         ^ #('bcc' 'vc' 'mingw' )
   104     ].
   105     ].
   105     ^ #('gcc')
   106     ^ #('gcc')
   106 
   107 
   107     "Created: / 21-01-2012 / 14:04:15 / cg"
   108     "Created: / 21-01-2012 / 14:04:15 / cg"
   108 !
   109 !
   162      to speedup a build. Use with care."
   163      to speedup a build. Use with care."
   163 
   164 
   164     isQuickBuild := aBoolean.
   165     isQuickBuild := aBoolean.
   165 !
   166 !
   166 
   167 
       
   168 makeExeOnly
       
   169     ^ (makeExeOnly ? false)
       
   170 !
       
   171 
   167 makeExeOnly:aBoolean
   172 makeExeOnly:aBoolean
   168     makeExeOnly := aBoolean.
   173     makeExeOnly := aBoolean.
       
   174 !
       
   175 
       
   176 makeQuick
       
   177     ^ (makeQuick ? false)
       
   178 !
       
   179 
       
   180 makeQuick:aBoolean
       
   181     makeQuick := aBoolean.
   169 !
   182 !
   170 
   183 
   171 package:aPackageIDOrSymbol
   184 package:aPackageIDOrSymbol
   172     package := aPackageIDOrSymbol asPackageId.
   185     package := aPackageIDOrSymbol asPackageId.
   173 !
   186 !
   297         self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
   310         self error:('Cannot figure out my top directory (where stx/include and stx/rules are)')
   298     ].
   311     ].
   299     myTopDirectory := myTopDirectory asFilename.
   312     myTopDirectory := myTopDirectory asFilename.
   300     mySTXTopDirectory := myTopDirectory / 'stx'.
   313     mySTXTopDirectory := myTopDirectory / 'stx'.
   301 
   314 
   302     self setupBuildDirectory.
   315     self makeQuick ifFalse:[
   303     self activityNotification:'Generating stc directory...'.
   316         self setupBuildDirectory.
   304     self copySTCDirectoryForBuild.
   317         self activityNotification:'Generating stc directory...'.
       
   318         self copySTCDirectoryForBuild.
       
   319     ].
   305     self activityNotification:'Generating source files...'.
   320     self activityNotification:'Generating source files...'.
   306     self generateSourceFiles.
   321     self generateSourceFiles.
   307     self activityNotification:'Copying dlls for linkage...'.
   322     self makeQuick ifFalse:[
   308     self copyDLLsForLinkage.
   323         self activityNotification:'Copying dlls for linkage...'.
   309     self activityNotification:'Copying support files for compilation and linkage...'.
   324         self copyDLLsForLinkage.
   310     self copySupportFilesForCompilation.
   325         self activityNotification:'Copying support files for compilation and linkage...'.
   311     self copySupportFilesForLinkage.
   326         self copySupportFilesForCompilation.
   312     self copyStartupFilesFromSmalltalk.
   327         self copySupportFilesForLinkage.
   313 
   328         self copyStartupFilesFromSmalltalk.
       
   329     ].
   314     self activityNotification:'Executing make...'.
   330     self activityNotification:'Executing make...'.
   315     self makeWithOutputTo:stdOut errorTo:stdErr.
   331     self makeWithOutputTo:stdOut errorTo:stdErr.
   316 
   332 
   317     "Modified: / 04-09-2012 / 00:49:52 / cg"
   333     "Modified: / 04-09-2012 / 00:49:52 / cg"
   318 ! !
   334 ! !
   600                         'lib/vc/librun.lib'
   616                         'lib/vc/librun.lib'
   601                     ).
   617                     ).
   602         ].
   618         ].
   603         usedCompiler = 'mingw' ifTrue:[
   619         usedCompiler = 'mingw' ifTrue:[
   604             files := files , #( 
   620             files := files , #( 
   605                         'librun/objvc/librun.dll'   "/ linkage is against vc version!!
   621                         'librun/objmingw/librun.dll'   "/ linkage is against vc version!!
   606                         'lib/vc/librun.lib'
   622                         'lib/mingw/librun.lib'
   607                     ).
   623                     ).
   608         ].
   624         ].
   609     ] ifFalse:[
   625     ] ifFalse:[
   610         files := #(
   626         files := #(
   611                     'librun/main.c'
   627                     'librun/main.c'
   834              and:[ fullPathName contents = fileContents ]) ifFalse:[
   850              and:[ fullPathName contents = fileContents ]) ifFalse:[
   835                 fullPathName contents:fileContents.
   851                 fullPathName contents:fileContents.
   836             ].
   852             ].
   837         ].    
   853         ].    
   838     ].
   854     ].
   839 
   855     self makeQuick ifFalse:[
   840     "/ generate header files in prerequisite packages...
   856         "/ generate header files in prerequisite packages...
   841     (projectDefinitionClass allPreRequisites)
   857         (projectDefinitionClass allPreRequisites)
   842     do:[:eachPackageToFileout |
   858         do:[:eachPackageToFileout |
   843         |packageId packageDef packageModule packageDirectory packageTargetDir|
   859             |packageId packageDef packageModule packageDirectory packageTargetDir|
   844 
   860 
   845         packageId := eachPackageToFileout asPackageId.
   861             packageId := eachPackageToFileout asPackageId.
   846         packageModule := packageId module.
   862             packageModule := packageId module.
   847         packageDirectory := packageId directory.
   863             packageDirectory := packageId directory.
   848         packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   864             packageTargetDir := (buildDirectory / packageModule / packageDirectory) recursiveMakeDirectory.
   849 
   865 
   850         packageDef := packageId projectDefinitionClass.
   866             packageDef := packageId projectDefinitionClass.
   851         (packageDef compiled_classNames_common ,
   867             (packageDef compiled_classNames_common ,
   852         packageDef compiled_classNamesForPlatform) do:[:eachClassName |
   868             packageDef compiled_classNamesForPlatform) do:[:eachClassName |
   853             |cls|
   869                 |cls|
   854 
   870 
   855             cls := Smalltalk classNamed:eachClassName.
   871                 cls := Smalltalk classNamed:eachClassName.
   856             "/ self assert:cls isLoaded.
   872                 "/ self assert:cls isLoaded.
   857             cls isNil ifTrue:[
   873                 cls isNil ifTrue:[
   858                 stdErr nextPutLine:('Missing class: ',eachClassName, ' (not present in system. Warning only:subclasses of it will not be compiled)').
   874                     stdErr nextPutLine:('Missing class: ',eachClassName, ' (not present in system. Warning only:subclasses of it will not be compiled)').
   859             ] ifFalse:[
   875                 ] ifFalse:[
   860                 cls isLoaded ifTrue:[    
   876                     cls isLoaded ifTrue:[    
   861                     self createHeaderFileFor:cls in:packageTargetDir
   877                         self createHeaderFileFor:cls in:packageTargetDir
   862                 ]
   878                     ]
       
   879                 ].
   863             ].
   880             ].
   864         ].
   881             self copyResourcesForPackage:eachPackageToFileout.
   865         self copyResourcesForPackage:eachPackageToFileout.
   882         ].
   866     ].
   883     ].
   867 
   884 
   868 "/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
   885 "/    stx_libbasic2 preRequisitesForBuilding#(#'stx:libbasic')
   869 !
   886 !
   870 
   887 
   927             outputTo:stdOut
   944             outputTo:stdOut
   928             errorTo:stdErr
   945             errorTo:stdErr
   929             inDirectory:(buildDirectory / module / directory)
   946             inDirectory:(buildDirectory / module / directory)
   930             onError:[:status | self error:'make failed'].
   947             onError:[:status | self error:'make failed'].
   931     ] ifFalse:[
   948     ] ifFalse:[
   932         (makeExeOnly ? false) ifTrue:[
   949         (self makeExeOnly) ifTrue:[
   933             self activityNotification:(makeCommand,' exe').
   950             self activityNotification:(makeCommand,' exe').
   934             OperatingSystem
   951             OperatingSystem
   935                 "/ generate the executable
   952                 "/ generate the executable
   936                 executeCommand:(makeCommand,' exe')
   953                 executeCommand:(makeCommand,' exe')
   937                 inputFrom:nil
   954                 inputFrom:nil