[Vm-dev] VM Maker: CMakeVMMakerSqueak-tty.50.mcz
commits at source.squeak.org
commits at source.squeak.org
Fri Jun 13 01:28:09 UTC 2014
Timothy M uploaded a new version of CMakeVMMakerSqueak to project VM Maker:
http://source.squeak.org/VMMaker/CMakeVMMakerSqueak-tty.50.mcz
==================== Summary ====================
Name: CMakeVMMakerSqueak-tty.50
Author: tty
Time: 12 June 2014, 9:28:12.792 pm
UUID: 9b62a9a4-f53c-4859-88ab-cf4a25566396
Ancestors: CMakeVMMakerSqueak-tty.49
Added some scratch notes to Help
=============== Diff against CMakeVMMakerSqueak-tty.49 ===============
Item was changed:
----- Method: CMakeVMMakerSqueakDeveloperHelp class>>pages (in category 'pages') -----
pages
+ ^#(overview prerequisites igorStasenkoDesign plugins scratch)!
- ^#(overview prerequisites igorStasenkoDesign)!
Item was added:
+ ----- Method: CMakeVMMakerSqueakDeveloperHelp class>>plugins (in category 'pages') -----
+ plugins
+ ^HelpTopic
+ title:'setting up defaultInternalPlugins and defaultExternalPlugins'
+ contents:
+ '
+ bad mojo with plugins.int plugins.ext in GNU and plugin names in CMakeVMMaker(Squeak)
+
+ |s|
+ Transcript clear.
+ s:=SortedCollection new.
+ InterpreterPlugin allSubclassesDo:[:p|
+ p moduleName = ''SqueakSSL'' "<-------Text from plugins.int or plugins.ext"
+ ifTrue:[Transcript show:p name;cr].
+ s add: (p moduleName)].
+
+
+ '
+
+ !
Item was added:
+ ----- Method: CMakeVMMakerSqueakDeveloperHelp class>>scratch (in category 'pages') -----
+ scratch
+ ^HelpTopic
+ title:'Program Flow'
+ contents:
+ '
+ Create a new configuration
+ add external/internal plugins
+ generateSources
+ verifies Sources file in place
+ prepares CogRTLOpcodes/CogIA32Compiler/StackInterpreter depending on configuration used
+ initializes/prepares VMMaker
+ asks VMMaker to generateEntire while intercepting notifications and deprecation warnings.
+
+ generate
+ a Configuration passes itself to a CMakeVMGeneratorForSqueak
+ an output writeStream is opened
+ ask the config to set global options on the Generator. Stuff like (maker set: ''CMAKE_C_COMPILER'' to: ''/usr/bin/gcc'')
+ "We are setting up a file here"
+ print the header
+ set project name
+ set system specific global options after system is known (all existing implementations are XCode CMAKE_OSX_SYSROOT etc)
+ set up directories.cmake content with all the topDir,srcDir etc in the Generator
+ 9. is troubling. set''s CMAKECONFIGURATIONTYPES to Release
+ set up preferedIncludes. This one is important as it is config specific
+ set up standardIncludes. This one is important as it is config specific
+ add CompilerFlag Definitions. This is where customization among release, debug, assert flags are set.
+ extraVMSettings . more custom stuff for the VM. The generateConfigH issue resides here
+ put this string ''add_executable(Squeak ${coreSources} ${crossVMSources} ${platformVMSources} ${extraSources})''
+ generate and store internally the internal/external plugin CMakePluginGeneratorForSqueak . Each of these has its own Stream etc.for CMake
+ processThirdPartyLibraries This loops through the CMakeVMMaker-Libs that are associated with this config. these libs generate their own spiel
+ libraries can be downloaded here?
+ processPlugins pretty complicated as well.
+ setExtraTargetProperties <---this is important. It is used by "most" configs and sets compile flags, etc. This will be messed up for cut-n-paste I did .
+ self cmd: ''target_link_libraries'' params: self moduleName , '' ${LINKLIBS}''. just puts in doc
+ postBuildActions <--used by Mac configs need to clean this up.
+ saveFile "Writes CMakeLists.txt"
+ generateBuildScript "this is config specific"
+
+
+ ----------------------------------------------------------------------------------
+ SqeuakCogMTBuilder buildUnix32
+ self new buildUnix32
+ >>> SqueakCogMTUnixConfig new. (CPlatformConfig initialize
+ super initialize
+ generateForRelease = true.
+ addExternalPlugins#();
+ addInternalPlugins#();
+ 1. generateSources;
+ 2. generate.
+
+
+
+
+
+
+
+ 1 SqueakCogMTUnixConfig generateSources
+ CPlatformConfig generateSources
+ "Generate whole VM + plugins sources"
+ | maker |
+
+ self validateSourcesPresent.
+ self prepareForGeneration.
+
+ "suppress questions and deprecation warnings during generation "
+ [[
+
+ maker := self prepareVMMaker.
+
+ maker interpreterClass: self interpreterClass.
+ self cogitClass ifNotNil: [:cg |
+ maker cogitClass: cg.
+ cg initializeWithOptions: (maker instVarNamed: ''optionsDictionary'')
+ ].
+
+ maker generateEntire
+
+ ] on: ProvideAnswerNotification do: [:ex | ex resume: true ]]
+ on: Deprecation do: [:ex | ex resume ].
+
+
+
+ 2. generate
+ self generatePluginsList. writes PLUGINS.txt file from pluginsTemplate
+ self generateLicense. writes LICENSE.txt file from licenseTemplate
+ 3.-> ^CMakeVMGeneratorForSqueak generate:self pass myself (a config) to a VMGenerator
+
+ CMakeVMGenerator generate
+ 3. generate
+ | intPlugins extPlugins |
+
+ output := String new writeStream.
+
+ 4. config setGlobalOptions: self.
+
+ self
+ 5 printHeader;
+ 6 project: config executableName.
+
+ 7. config setGlobalOptionsAfterDetermineSystem: self.
+
+ 8. config setupDirectories: self.
+
+ 9. self message: ''${CMAKE_MODULE_PATH}''.
+ self set: ''CMAKE_CONFIGURATION_TYPES'' to: ''Release''.
+
+ 10. config preferredIncludes
+ do: [ :each | self includeDirectories: each ].
+ self includeDirectories: self includeDirs.
+ 11 config standardIncludes
+ do: [:each | self includeDirectories: each ].
+
+ 12 self addDefinitions: config compilerFlags.
+
+ 13. config extraVMSettings: self.
+
+ 14 self puts: ''add_executable('' , config executableName, '' '', config executableType, '' '' , self sources , '')''.
+
+ 15 intPlugins := self generatePluginConfigs: config internalPlugins internal: true. <---this area is complicated, but it generates Plugin files
+ extPlugins := self generatePluginConfigs: config externalPlugins internal: false.
+
+ 16 self processThirdpartyLibraries.
+
+ 17 self processPlugins: intPlugins, extPlugins.
+
+ 18. config setExtraTargetProperties: self. <---this is very important
+
+ self cmd: ''target_link_libraries''
+ params: self moduleName , '' ${LINKLIBS}''.
+
+ 19. config postBuildActions: self.
+
+ 20 self saveFile.
+ self generateBuildScript. build.sh
+
+
+
+
+ 4. setGlobalOptions: maker
+
+ "set any CMake global options, before declaring a project in cmake file"
+
+ maker set: ''CMAKE_C_COMPILER'' to: ''/usr/bin/gcc''.
+ maker set: ''CMAKE_CXX_COMPILER'' to: ''/usr/bin/g++''.
+
+ 5. 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)''
+
+
+
+ 6 project: aProjectName
+ self cmd: ''project'' qparams: aProjectName{
+
+ cmd: cmdName qparams: aString
+ "quoted params"
+ output nextPutAll: cmdName;
+ nextPutAll: ''("'';
+ nextPutAll: aString;
+ nextPutAll: ''")'';
+ cr
+ }
+
+ 7.SqueakIPhoneSqueakStackV3Config setGlobalOptionsAfterDetermineSystem: maker <---here is a representative example
+ self setGlobalOptions: maker.
+ maker
+ set: ''CMAKE_OSX_SYSROOT''
+ to: (''/Applications/Xcode.app/Contents/Developer/Platforms/{1}.platform/Developer/SDKs/{1}{2}.sdk''
+ format: { self targetDevice. self sdkVersion })
+
+ 8. config setupDirectories:self
+ this creates directories.cmake with all the top/build/etc directories
+
+ 9. this is troubling, sets CMAKE_CONFIGURATION_TYPES to ''Release''.
+
+
+
+ 10. preferredIncludes
+ ^ #(
+ ''${buildDir}/''
+ ''${platformsDir}/iOS/vm/iPhone'' "config.h is here. Why???"
+ )
+
+ this gets put int CMakeGenerator{
+
+ includeDirectories: aString
+ ^self cmd: ''include_directories'' params: aString
+
+
+ 11. standardIncludes <---this one is important
+
+
+ 12. addDefinitions:config compilerFlags
+ compilerFlags
+ | releaseFlags |
+
+ releaseFlags := self isGenerateForRelease
+ ifTrue: [ self compilerFlagsRelease ]
+ ifFalse: [ self compilerFlagsDebug ].
+
+ ^ String streamContents: [ :stream |
+ ((self commonCompilerFlags, releaseFlags)
+ asStringOn: stream
+ delimiter: '' '' )]
+
+
+ 13. extraVMSettings: maker very customizable method.
+ | versionC |
+ self generateConfigH. <---the issue Eliot raised.
+
+
+ "output a fake version.c file"
+
+ self write:
+ ''int vm_serial= 1;
+ char *vm_date= "<HERE IS SUPPOSED TO BE THE DATE>";
+ char *cc_version= "<HERE IS SUPPOSED TO BE gcc VERSION>";
+ char *ux_version= "<FAKE FROZEN VERSION FOR DEBUGGING PURPOSES>";
+ ''
+ toFile: ''version.c''.
+
+
+ 14. ''add_executable(Squeak ${coreSources} ${crossVMSources} ${platformVMSources} ${extraSources})''
+
+
+
+ 15. generatePluginConfigs: plugins internal: bool
+ "Answers a collection of CMakePluginGenerator instances"
+
+ ^ plugins collect: [:each | | plugin |
+ plugin := Smalltalk at: each.
+ plugin generateFor: self internal: bool. <---InterpreterPlugin method added by CMakeVMMaker
+ ].
+
+ generateFor: aCMakeVMGenerator internal: aBoolean
+ ^ aCMakeVMGenerator
+ generatePlugin: self
+ internal: aBoolean
+ extraRules: nil
+
+ so, for each plugin in the generator, invoke my generator method generatePlugin: internal:extraRules:
+ THIS invokes CMakePluginGeneratorForSqueak new
+ generate: aPlugin for: aCMakeVMGenerator internal: aBoolean extraRules: aBlock
+ doNotGenerate := false.
+ internal := aBoolean.
+ plugin := aPlugin.
+ vmGen := aCMakeVMGenerator.
+ extraRules := aBlock.
+ ^ self generate{
+
+ | name |
+ output := String new writeStream.
+
+ name := plugin moduleName.
+ #( vmGen config setGlobalOptions: self.
+
+ self
+ printHeader;
+ project: name;
+ "include directories generated for build"
+ include: ''../directories.cmake''.
+
+ self set: ''CMAKE_CONFIGURATION_TYPES'' to: ''Release''.
+ ).
+
+ self message: (internal ifTrue: [ ''Adding internal plugin: ''] ifFalse: [''Adding external plugin: '']) , name.
+
+ self
+ set: #pluginName toString: name;
+ set: #pluginSrc toString: ''${srcPluginsDir}/'', name;
+ set: #pluginCross toString: ''${crossDir}/plugins/'', name;
+ set: #pluginPlatform toString: ''${targetPlatform}/plugins/'', name.
+
+ "clear LINKLIBS variable"
+ self set: #LINKLIBS to: ''.
+
+ internal
+ ifTrue: [ self puts: ''add_definitions(-DSQUEAK_BUILTIN_PLUGIN)''].
+
+ self addSources: { name , ''.c'' } prefixed: ''${pluginSrc}/''.
+
+ " default include directories for plugin "
+ self includeDirectories: ''${pluginSrc} ${pluginCross} ${targetPlatform}/plugins/${pluginName}''.
+
+ "Not needed because there are already there (inherited from main configuration)"
+ "self addDefinitions: vmGen config compilerFlags."
+
+ " perform config''s configureXYZ: message to apply per-plugin custom rules, if any "
+
+ vmGen config configurePlugin: plugin with: self.
+
+ extraRules ifNotNil: [ extraRules value: self ].
+
+ " generate a static lib for internal plugin, or shared for external"
+ internal ifTrue: [
+ self cmd: ''add_library'' params: name , '' STATIC ${sources}''.
+ ] ifFalse: [
+ self cmd: ''add_library'' params: name , '' SHARED ${sources}''.
+
+ " self cmd: ''set_property'' params: ''TARGET '' , name , ''PROPERTY LINK_FLAGS -bundle''"
+ ].
+
+ vmGen config extraPluginSettings: self.
+
+ self isExternal ifTrue: [
+ self cmd: ''target_link_libraries''
+ params: self moduleName , ''${LINKLIBS}''.
+ ].
+
+ " see senders of #linkFlags "
+ self
+ cmd: ''set_property''
+ params: ''TARGET'', name, ''PROPERTY LINK_FLAGS "${linkFlags}''.
+
+ "set dependencies"
+ self puts: ''IF ('',self moduleName , ''_dependencies)''.
+
+ self cmd: ''add_dependencies''
+ params: name , ''${'', self moduleName , ''_dependencies}''.
+
+ self puts: ''ENDIF ('',self moduleName , ''_dependencies)''.
+ self saveFile.
+
+
+ }
+
+
+
+
+
+
+ 16. processThirdpartyLibraries
+
+ config thirdpartyLibs do: [:each |
+ each generateFor: self ]{
+ generateFor: aVMGenerator
+
+ | libDir stream contents |
+
+ vmGen := aVMGenerator.
+
+ gen := CMakeGenerator new
+ output: (String new writeStream).
+
+ libDir := (aVMGenerator thirdpartyDir / self canonicalName) ensureDirectory.
+
+ stream := String new writeStream.
+
+ self generate.
+
+ stream nextPutAll: (vmGen config fixLineEndsOf: gen output contents).
+
+ contents := stream contents.
+
+ (self isFile: (libDir asFileReference / 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 asFileReference / gen outputFileName)) nextPutAll: contents; close.
+ ].
+
+
+ vmGen addSubdirectory: vmGen thirdpartyDirName , ''/'' , self canonicalName.
+ self defineGlobalTargets.
+
+
+ }
+
+
+
+ 17 processPlugins: pluginGenerators
+ | libs libDeps |
+
+ libs := OrderedCollection new.
+ libDeps := Dictionary new.
+ pluginGenerators do: [:gen |
+ gen doNotGenerate ifFalse: [
+ gen isInternal
+ ifTrue: [
+ libs add: gen plugin moduleName ]
+ ifFalse: [
+ "make main module to depend on external plugin, just to make sure it is built
+ before main module built"
+ self
+ cmd: ''add_dependencies''
+ params: config executableName, '' '' , gen plugin moduleName ].
+ gen externalDependencies
+ ifNotEmpty: [ :deps |
+ libDeps
+ at: gen plugin moduleName
+ put: (deps fold: [ :a :b | a, '' '', b ]) ].
+ self addSubdirectory: gen plugin moduleName ] ].
+
+ self cmd: ''target_link_libraries'' params: config executableName , '' '' ,
+ (libs inject: '' into: [:res :ea | res, '' '' , ea ]).
+
+ libDeps keysAndValuesDo: [ :moduleName :dependencies |
+ self
+ cmd: ''add_dependencies''
+ params: moduleName, '' '', dependencies ].
+
+ self generateExportsH: libs.
+
+
+ 18 setExtraTargetProperties: maker
+
+ "maker setTargetProperties: ''LINK_FLAGS ""''."
+
+ maker puts: ''set_source_files_properties( ${srcVMDir}/cogit.c PROPERTIES
+ COMPILE_FLAGS "-O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer")''.
+
+
+ maker
+ cmd: ''set_source_files_properties''
+ params: ''${targetPlatform}/vm/sqUnixHeartbeat.c PROPERTIES
+ COMPILE_FLAGS "-O1 -fno-omit-frame-pointer"''.
+
+ maker linkDirectories: ''${CMAKE_FIND_ROOT_PATH}/usr/lib/arm-linux-gnueabihf/''.
+
+ maker addExternalLibraries:
+ #(
+ ''m'' "math lib"
+ ''dl'' "dynamic loader"
+ ''pthread'' "posix threads"
+ ).
+
+ maker set: ''EXECUTABLE_OUTPUT_PATH'' toString: self outputDir fullName.
+ self addVMDrivers: maker.
+
+
+ 19. postBuildActions: gen
+
+ " override to add custom rules after all targets is defined "
+
+ self write: self fixLibsTemplate toFile: ''fix_libs.cmake''.
+
+
+ gen
+ set: #bundlePath toString: ''${outputDir}/'', self executableName, ''.app'';
+ set: #pluginsRelPath toString: ''@executable_path/Plugins''.
+
+ gen
+ puts: ''
+ INSTALL(CODE "
+ set(externalModulesDir \"${externalModulesDir}\")
+ set(bundlePath \"${bundlePath}\")
+ set(pluginsRelPath \"${pluginsRelPath}\")
+
+ include(fix_libs.cmake)
+ ")''
+
+ " FILE(GLOB_RECURSE bLibs /${externalModulesDir}/*.*)
+ "
+
+
+
+
+ '!
More information about the Vm-dev
mailing list