[Vm-dev] VM Maker: CMakeVMMakerSqueak-tty.124.mcz

commits at source.squeak.org commits at source.squeak.org
Sun Jun 5 20:57:48 UTC 2016


Timothy M uploaded a new version of CMakeVMMakerSqueak to project VM Maker:
http://source.squeak.org/VMMaker/CMakeVMMakerSqueak-tty.124.mcz

==================== Summary ====================

Name: CMakeVMMakerSqueak-tty.124
Author: tty
Time: 5 June 2016, 4:03:32.199266 pm
UUID: c48a30ca-d0c8-40a9-a4a3-9a99358540a3
Ancestors: CMakeVMMakerSqueak-tty.123

Start decoupling from pharo code.
Add class for testing CMakeTemplates.

=============== Diff against CMakeVMMakerSqueak-tty.123 ===============

Item was added:
+ Object subclass: #CMakeGeneratorForSqueak
+ 	instanceVariableNames: 'output'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'CMakeVMMakerSqueak'!
+ 
+ !CMakeGeneratorForSqueak commentStamp: '<historical>' prior: 0!
+ a base class for generating cmake files.
+ Mainly provides a helper methods of cmake commands api.!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addDefinitions: (in category 'cmake commands') -----
+ addDefinitions: aString
+ 	^ self cmd: 'add_definitions' params: aString!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addDependency: (in category 'cmake commands') -----
+ addDependency: aName
+ 
+ 	self cmd: 'list'
+ 		params: 'APPEND ', self moduleName , '_dependencies ' , aName.
+ !

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addExternalLibraries: (in category 'cmake commands') -----
+ addExternalLibraries: libs
+ 
+ 	libs do: [:each | self addExternalLibrary: each ]!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addExternalLibrary: (in category 'cmake commands') -----
+ addExternalLibrary: aLibrary 
+ 	self cmd: 'list'
+ 		params: 'APPEND LINKLIBS ' , aLibrary .
+ 		
+ "	self cmd: 'target_link_libraries' 
+ 		params: self moduleName , ' ' , aLibrary.
+ "	
+ !

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addFrameworks: (in category 'cmake commands') -----
+ addFrameworks: aCollection 
+ 	"for mac only "
+ 	aCollection
+ 		do: [:each | 
+ 			self cmd: 'find_library' params:  each , '_FMWK ', each.
+ 			self addExternalLibrary: '${', each , '_FMWK}' ]!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addProperty:value: (in category 'cmake commands') -----
+ addProperty: propertyString value: valueString 
+ 	self puts: 'set_target_properties(' , self moduleName , ' PROPERTIES ' , propertyString , ' "' , valueString, '")'
+ !

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addSource: (in category 'sources management') -----
+ addSource: aFileName
+ 
+ 	^ self addSources: { aFileName }!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addSources: (in category 'sources management') -----
+ addSources: aFileNames
+ 
+ 	^ self addSources: aFileNames prefixed: ''!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addSources:prefixed: (in category 'sources management') -----
+ addSources: aFileNames prefixed: aPrefix
+ 
+ 	| names |
+ 	names := aFileNames inject: '' into: [:res :each | res , ' "' , aPrefix, each, '"' ].
+ 	
+ 	self puts: 'list(APPEND sources ', names , ')'!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addSubdirectory: (in category 'cmake commands') -----
+ addSubdirectory: aDir
+ 
+ 	^ self cmd: 'add_subdirectory' qparams: aDir. 
+ !

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>addXCodeProperty:value: (in category 'cmake commands') -----
+ addXCodeProperty: propertyString value: valueString 
+ 	self 
+ 		addProperty: 'XCODE_ATTRIBUTE_' , propertyString 
+ 		value: valueString
+ !

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>captureOutputDuring: (in category 'code generation') -----
+ captureOutputDuring: aBlock
+ 	| old result |
+ 	
+ 	old := output.
+ 	output :=  String new writeStream.
+ 	
+ 	aBlock value.
+ 	
+ 	result := output.
+ 	output := old.
+ 	
+ 	^ result contents!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>cmd:params: (in category 'cmake commands') -----
+ cmd: cmdName params: aString
+ 
+ 	output nextPutAll: cmdName;
+ 		nextPut: $(;
+ 		nextPutAll: aString;
+ 		nextPut: $);
+ 		cr
+ !

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>cmd:qparams: (in category 'cmake commands') -----
+ cmd: cmdName qparams: aString
+ 	"quoted params"
+ 	output nextPutAll: cmdName;
+ 		nextPutAll: '("';
+ 		nextPutAll: aString;
+ 		nextPutAll: '")';
+ 		cr
+ !

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>generate (in category 'code generation') -----
+ generate
+ 	self subclassResponsibility.!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>include: (in category 'cmake commands') -----
+ include: aFileName
+ 	^ self cmd: 'include' params: aFileName!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>includeDirectories: (in category 'cmake commands') -----
+ includeDirectories: aString
+ 	^ self cmd: 'include_directories' params: aString!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>linkDirectories: (in category 'cmake commands') -----
+ linkDirectories: aString
+ 	^ self cmd: 'link_directories' params: aString!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>message: (in category 'cmake commands') -----
+ message: aString
+ 	
+ 	self cmd: 'message' qparams: aString.!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>moduleName (in category 'accessing') -----
+ moduleName
+ 	self subclassResponsibility!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>output (in category 'accessing') -----
+ output
+ 	^ output!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>output: (in category 'accessing') -----
+ output: aStream
+ 
+ 	output := aStream!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>outputFileName (in category 'accessing') -----
+ outputFileName
+ 	^ 'CMakeLists.txt'!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>printHeader (in category 'as yet unclassified') -----
+ printHeader
+ 	
+ 	self puts: '# This is automatically generated file using ', self configurationName, ' on ',
+ 		Date current asString, ' ' , Time current asString;
+ 		puts: 'cmake_minimum_required(VERSION 2.6.2)'!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>project: (in category 'cmake commands') -----
+ project: aProjectName
+ 	self cmd: 'project' qparams: aProjectName
+ !

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>puts: (in category 'as yet unclassified') -----
+ puts: aString
+ 	output nextPutAll: aString; cr!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>set:to: (in category 'cmake commands') -----
+ set: variableName to: aValueString
+ 
+ 	self cmd: 'set' params: variableName , ' ' , aValueString!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>set:toString: (in category 'cmake commands') -----
+ set: variableName toString: aValueString
+ 
+ 	^ self set: variableName to: '"', (aValueString copyReplaceAll: '"' with: '\"'), '"'!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>setTargetProperties: (in category 'cmake commands') -----
+ setTargetProperties: properties 
+ 	self cmd: 'set_target_properties' params: self moduleName, ' PROPERTIES ', properties !

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>setTargetProperty:to: (in category 'cmake commands') -----
+ setTargetProperty: propertyString to: aString
+ 	self 
+ 		cmd: 'set_target_properties'
+ 		params: (String streamContents: [ :stream |
+ 			stream 
+ 				nextPutAll: self moduleName;
+ 				nextPutAll: ' PROPERTIES ';
+ 				nextPutAll: propertyString;
+ 				space;  
+ 				nextPutAll: aString ])!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>setTargetProperty:toAll: (in category 'cmake commands') -----
+ setTargetProperty: propertyString toAll: aCollection
+ 	^self 
+ 		setTargetProperty: propertyString 
+ 		to: (String streamContents: [ :stream | 
+ 			aCollection 
+ 				do: [ :each | stream nextPutAll: each ]
+ 				separatedBy: [ stream nextPut: $, ] ])!

Item was added:
+ ----- Method: CMakeGeneratorForSqueak>>setTargetProperty:toString: (in category 'cmake commands') -----
+ setTargetProperty: propertyString toString: aString
+ 	self 
+ 		cmd: 'set_target_properties'
+ 		params: (String streamContents: [ :stream |
+ 			stream 
+ 				nextPutAll: self moduleName;
+ 				nextPutAll: ' PROPERTIES ';
+ 				nextPutAll: propertyString;
+ 				space;
+ 				nextPut: $";  
+ 				nextPutAll: (aString copyReplaceAll: '"' with: '\"');
+ 				nextPut: $"
+ 				 ])!

Item was changed:
+ CMakeGeneratorForSqueak subclass: #CMakePluginGeneratorForSqueak
- CMakeGenerator subclass: #CMakePluginGeneratorForSqueak
  	instanceVariableNames: 'plugin vmGen internal extraRules doNotGenerate externalDependencies configDotCMake templates'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'CMakeVMMakerSqueak'!
  
  !CMakePluginGeneratorForSqueak commentStamp: 'tty 12/8/2014 11:28' prior: 0!
  A CMakePluginGeneratorForSqueak overides some CMakeVMPluginGenerator methods for squeak compatibility. 
  
  I also add Dictionary for storing a plugins config.cmake file
  
  
  !

Item was added:
+ ----- Method: CMakePluginVm>>initialize (in category 'as yet unclassified') -----
+ initialize
+ 	"initialize to nonsense values to aid in debugging."
+ 	config := 'a config'.
+ 	definitions := 'vm plugin compiler definitions'.
+ 	module := ' vm plugin module'.
+ 	sources := 'vm plugin sources'.
+ 	includedirectories:= 'vm plugin include directories'.
+ 	self content:' Customize a CMakePluginVm(', config, ' ' , ' ' , definitions, ' ' , ' ' ,  module , ' ' ,self sources, ' ' , includedirectories,')'!

Item was changed:
  ----- Method: CMakeSqConfigH>>initialize (in category 'initialize-release') -----
  initialize
- " 
- IF (NOT DEFINED __sq_config_h)
- 	
- 	rest of config.cmake here
  
+ " See class comment"
+ 
+       content:='should not get here. writestream is used instead of content. this is a hack for tests to pass.'.
- ENDIF (NOT DEFINED __sq_config_h)"
  	templates := OrderedCollection new.
  	output := String new writeStream.
  	self puts: 'IF (NOT DEFINED __sq_config_h)
  
    SET(__sq_config_h 1)
    CONFIG_DEFINE(__sq_config_h)
  '.   !

Item was changed:
+ CMakeGeneratorForSqueak subclass: #CMakeTemplate
- CMakeGenerator subclass: #CMakeTemplate
  	instanceVariableNames: 'content'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'CMakeVMMakerSqueak-CMakeTemplates'!
  
  !CMakeTemplate commentStamp: 'tty 12/8/2014 11:08' prior: 0!
  A CMakeTemplate  is a wrapper for CMake commands, variables and definitions.
  Generators output my contents into their files.
  
  N.B. The motivations for this approach are:
  
  1. I found the Pharo methods  in CMakeGenerator 's (cmake commands protocol) difficult to parse and debug.
  2, As I developed it bacame apparent that the key to making this project work is to "THINK IN CMake". 
  3. I find the Seaside approach of using Components to generate a web-page is a useful idiom for generating CMake files.
  4. Using wrappers for the CMake commands eases re-use and consistency that radically sped up development. 
  5. It is easy to add new templates. Just find the CMake construct you want, subclass me, and model it such that its output generates the correct CMake "thing" 
  
  cmake   --help-commands
  cmake   --help-command
  cmake   --help-command-list
  cmake   --help-commands 
  cmake   --help-module
  cmake   --help-module-list
  cmake   --help-modules 
  cmake   --help-policy 
  cmake   --help-policy-list 
  cmake   --help-policies 
  cmake   --help-property 
  cmake   --help-property-list 
  cmake   --help-properties
  cmake   --help-variable var
  cmake   --help-variable-list 
  cmake   --help-variables
  
  
  
  
  If you need a custom version of my subclasses, just set 'content: your custom content here' on the appropriate subclass (or on me)	
  
  !

Item was changed:
+ CMakeGeneratorForSqueak subclass: #CMakeVMGeneratorForSqueak
- CMakeGenerator subclass: #CMakeVMGeneratorForSqueak
  	instanceVariableNames: 'internalPlugins externalPlugins config'
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'CMakeVMMakerSqueak'!
  
  !CMakeVMGeneratorForSqueak commentStamp: 'tty 5/16/2014 15:52' prior: 0!
  A CMakeVMGeneratorForSqueak overides some CMakeVMGenerator methos for squeak compatibility. 
  
  !

Item was added:
+ TestCase subclass: #CMakeVMMakerSqueakCMakeTemplatesTest
+ 	instanceVariableNames: ''
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'CMakeVMMakerSqueak-Tests'!

Item was added:
+ ----- Method: CMakeVMMakerSqueakCMakeTemplatesTest>>testCMakeTemplateContent (in category 'as yet unclassified') -----
+ testCMakeTemplateContent
+ 	"a template encapsulates CMake content and should have default content on instantiation"
+ 	CMakeTemplate
+ 		subclassesDo:[:c | |template| 
+ 				template := c new.
+ 				template initialize.
+ "				template content inspect."
+ 				self assert: ((template content) isString)]
+ 
+ !

Item was changed:
  ----- Method: SqueakCMThirdpartyLibrary>>generateFor: (in category 'as yet unclassified') -----
  generateFor: aVMGenerator
  
  	| libDir stream contents |
  	self flag:'tty'. "This l must be transformed to generateByTemplateFor: and the output converted to CMakeTemplates"
  	self break.
  	vmGen := aVMGenerator.
  	
+ 	gen := CMakeGeneratorForSqueak new
- 	gen := CMakeGenerator new
  		output: (String new writeStream).
  	
  	libDir := (aVMGenerator thirdpartyDir / self canonicalName) assureExistence.
  
  	stream := String new writeStream.
  	
  	self generate.
  
  	stream nextPutAll: (vmGen config fixLineEndsOf: gen output contents).
  
  	contents := stream contents. 
  	
  	(self isFile: (libDir  / gen outputFileName) fullName hasContents: contents) ifFalse: [
  		"contents changed, update the file. Because fucking cmake will force rebuild everything if we change its modification date
  		without changing its contents"
  		(FileStream forceNewFileNamed: (libDir  / gen outputFileName) pathName) nextPutAll: contents; close.
  		].
  	
  
  	vmGen addSubdirectory:  vmGen thirdpartyDirName , '/' , self canonicalName.
  	self defineGlobalTargets.
  	!



More information about the Vm-dev mailing list