NCBI C++ Toolkit Cross Reference

C++/compilers/xCode/ProjBuilder.applescript


  1 (*  $Id: ProjBuilder.applescript 134488 2008-07-18 15:37:50Z lebedev $
  2  * ===========================================================================
  3  *
  4  *                            PUBLIC DOMAIN NOTICE
  5  *               National Center for Biotechnology Information
  6  *
  7  *  This software/database is a "United States Government Work" under the
  8  *  terms of the United States Copyright Act.  It was written as part of
  9  *  the author's official duties as a United States Government employee and
 10  *  thus cannot be copyrighted.  This software/database is freely available
 11  *  to the public for use. The National Library of Medicine and the U.S.
 12  *  Government have not placed any restriction on its use or reproduction.
 13  *
 14  *  Although all reasonable efforts have been taken to ensure the accuracy
 15  *  and reliability of the software and data, the NLM and the U.S.
 16  *  Government do not and cannot warrant the performance or results that
 17  *  may be obtained by using this software or data. The NLM and the U.S.
 18  *  Government disclaim all warranties, express or implied, including
 19  *  warranties of performance, merchantability or fitness for any particular
 20  *  purpose.
 21  *
 22  *  Please cite the author in any work or product based on this material.
 23  *
 24  * ===========================================================================
 25  *
 26  * Author:  Vlad Lebedev
 27  *
 28  * File Description:
 29  * xCode Project Generator Script
 30  *
 31  * Know issues:
 32  * 1) Script build phase should be changed for "gui_project". Use better sed command-line options.
 33  *)
 34 
 35 property upper_alphabet : "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 36 property ret : "
 37 " -- For some reason standard return does not work.
 38 
 39 (* Project starts here *)
 40 global newProject
 41 
 42 (* external globals *)
 43 global TheNCBIPath, TheFLTKPath, TheBDBPath, ThePCREPath, TheOUTPath
 44 global libTypeDLL, cpuOptimization, zeroLink, fixContinue, xcodeVersion, projFile
 45 
 46 (**)
 47 
 48 (* Hold keys and values for object dictionary of the project *)
 49 global objValues
 50 global objKeys
 51 
 52 (* file count: file indexes and references will use this number*)
 53 global refFileCount
 54 
 55 (* all targets go here, as a dependencie for master target: Build All *)
 56 global allDepList, libDepList, appDepList
 57 
 58 (* Build settings: You could target older versions of Mac OS X with this settings*)
 59 property buildSettings10_1 : {|MACOSX_DEPLOYMENT_TARGET|:"10.1", |SDKROOT|:"/Developer/SDKs/MacOSX10.1.5.sdk"}
 60 property buildSettings10_2 : {|MACOSX_DEPLOYMENT_TARGET|:"10.2", |SDKROOT|:"/Developer/SDKs/MacOSX10.2.8.sdk"}
 61 
 62 (* Build settings for the project *)
 63 
 64 property buildSettingsCommon : {|GCC_MODEL_CPU|:"|none|", |GCC_MODEL_TUNING|:"|none|", |FRAMEWORK_SEARCH_PATHS|:"/System/Library/Frameworks/CoreServices.framework/Frameworks", |LIBRARY_SEARCH_PATHS|:"", |GCC_ALTIVEC_EXTENSIONS|:"NO", |PREBINDING|:"NO", |HEADER_SEARCH_PATHS|:"", |ZERO_LINK|:"NO", |GCC_PRECOMPILE_PREFIX_HEADER|:"YES", |OTHER_CPLUSPLUSFLAGS|:"", |GCC_PREFIX_HEADER|:"", |STRIP_INSTALLED_PRODUCT|:"NO", |DEAD_CODE_STRIPPING|:"YES", |OBJROOT|:""}
 65 property buildSettingsDebug : buildSettingsCommon & {|COPY_PHASE_STRIP|:"NO", |DEBUGGING_SYMBOLS|:"YES", |GCC_DYNAMIC_NO_PIC|:"NO", |GCC_ENABLE_FIX_AND_CONTINUE|:"NO", |GCC_GENERATE_DEBUGGING_SYMBOLS|:"YES", |GCC_OPTIMIZATION_LEVEL|:"0", |OPTIMIZATION_CFLAGS|:"-O0", |GCC_PREPROCESSOR_DEFINITIONS|:"NCBI_DLL_BUILD NCBI_XCODE_BUILD _DEBUG _MT"}
 66 property buildSettingsRelease : buildSettingsCommon & {|COPY_PHASE_STRIP|:"YES", |GCC_ENABLE_FIX_AND_CONTINUE|:"NO", |DEPLOYMENT_POSTPROCESSING|:"YES", |GCC_PREPROCESSOR_DEFINITIONS|:"NCBI_DLL_BUILD NCBI_XCODE_BUILD _MT NDEBUG"}
 67 
 68 (* Build styles for the project *)
 69 property buildStyleDebug : {isa:"PBXBuildStyle", |name|:"Debug", |buildRules|:{}, |buildSettings|:buildSettingsDebug}
 70 property buildStyleRelease : {isa:"PBXBuildStyle", |name|:"Release", |buildRules|:{}, |buildSettings|:buildSettingsRelease}
 71 property projectBuildStyles : {"BUILDSTYLE__Development", "BUILDSTYLE__Deployment"}
 72 
 73 
 74 (* Root Objects, project and main group *)
 75 property rootObject : {isa:"PBXProject", |hasScannedForEncodings|:"1", |mainGroup|:"MAINGROUP", |targets|:{}, |buildSettings|:{|name|:"NCBI"}, |buildStyles|:{}}
 76 property mainGroup : {isa:"PBXGroup", children:{"HEADERS", "SOURCES", "FRAMEWORKS"}, |name|:"NCBI C++ Toolkit", |refType|:"4"}
 77 property emptyProject : {|rootObject|:"ROOT_OBJECT", |archiveVersion|:"1", |objectVersion|:"39", objects:{}}
 78 
 79 (* Convinience Groups *)
 80 property headers : {isa:"PBXGroup", children:{}, |name|:"Headers", |refType|:"4"}
 81 property sources : {isa:"PBXGroup", children:{}, |name|:"Sources", |refType|:"4"}
 82 property fworks : {isa:"PBXGroup", children:{}, |name|:"External Frameworks", |refType|:"4"}
 83 
 84 (* Empty templates for the variouse things in the project *)
 85 property toolProduct : {isa:"PBXExecutableFileReference", |explicitFileType|:"compiled.mach-o.executable", |refType|:"3"}
 86 property libProduct : {isa:"PBXLibraryReference", |explicitFileType|:"compiled.mach-o.dylib", |refType|:"3"}
 87 property appProduct : {isa:"PBXFileReference", |explicitFileType|:"wrapper.application", |refType|:"3"}
 88 
 89 
 90 
 91 
 92 script ProjBuilder
 93         on Initialize()
 94                 
 95                 set libraryPath to ""
 96                 set headerPath to TheNCBIPath & "/include/util/regexp" -- for local pcre library
 97                 set headerPath to headerPath & " " & TheNCBIPath & "/include"
 98                 
 99                 set pack to {TheFLTKPath, TheBDBPath, ThePCREPath}
100                 
101                 repeat with p in pack -- add all paths to headers
102                         set headerPath to headerPath & " " & p & "/include"
103                         set libraryPath to libraryPath & " " & p & "/lib"
104                 end repeat
105                 
106                 set libraryPath to libraryPath & " " & TheOUTPath & "/lib"
107                 
108                 set |HEADER_SEARCH_PATHS| of buildSettingsDebug to headerPath
109                 set |HEADER_SEARCH_PATHS| of buildSettingsRelease to headerPath
110                 
111                 set |LIBRARY_SEARCH_PATHS| of buildSettingsDebug to libraryPath
112                 set |LIBRARY_SEARCH_PATHS| of buildSettingsRelease to libraryPath
113                 
114                 set PCH to x_Replace(TheNCBIPath, ":", "/") & "/include/ncbi_pch.hpp"
115                 set |GCC_PREFIX_HEADER| of buildSettingsDebug to PCH
116                 set |GCC_PREFIX_HEADER| of buildSettingsRelease to PCH
117                 
118                 (* no-permissive flag for GCC *)
119                 set |OTHER_CPLUSPLUSFLAGS| of buildSettingsDebug to "-fno-permissive"
120                 set |OTHER_CPLUSPLUSFLAGS| of buildSettingsDebug to "-fno-permissive"
121                 
122                 (* Output directories and intermidiate files (works staring xCode 1.5) *)
123                 set |OBJROOT| of buildSettingsDebug to TheOUTPath
124                 set |OBJROOT| of buildSettingsRelease to TheOUTPath
125                 
126                 (* Set other options *)
127                 if zeroLink then
128                         set |ZERO_LINK| of buildSettingsDebug to "YES"
129                 end if
130                 
131                 if fixContinue then
132                         set |GCC_ENABLE_FIX_AND_CONTINUE| of buildSettingsDebug to "YES"
133                 end if
134                 
135                 if cpuOptimization then
136                         log "Getting CPU type"
137                         set cpuType to do shell script "/usr/sbin/ioreg | grep PowerPC | awk '{print $3}'| cut -c 9-10"
138                         
139                         if cpuType contains "G5" then
140                                 set |GCC_MODEL_TUNING| of buildSettingsDebug to "G5"
141                                 set |GCC_MODEL_CPU| of buildSettingsDebug to "G5"
142                                 set |GCC_ALTIVEC_EXTENSIONS| of buildSettingsDebug to "YES"
143                                 set |GCC_MODEL_TUNING| of buildSettingsRelease to "G5"
144                                 set |GCC_MODEL_CPU| of buildSettingsRelease to "G5"
145                                 set |GCC_ALTIVEC_EXTENSIONS| of buildSettingsRelease to "YES"
146                         else if cpuType contains "G4" then
147                                 set |GCC_MODEL_TUNING| of buildSettingsDebug to "G4"
148                                 set |GCC_MODEL_CPU| of buildSettingsDebug to "G4"
149                                 set |GCC_ALTIVEC_EXTENSIONS| of buildSettingsDebug to "YES"
150                                 set |GCC_MODEL_TUNING| of buildSettingsRelease to "G4"
151                                 set |GCC_MODEL_CPU| of buildSettingsRelease to "G4"
152                                 set |GCC_ALTIVEC_EXTENSIONS| of buildSettingsRelease to "YES"
153                         else
154                                 set |GCC_MODEL_TUNING| of buildSettingsDebug to "G3"
155                                 set |GCC_MODEL_CPU| of buildSettingsDebug to "G3"
156                                 set |GCC_MODEL_TUNING| of buildSettingsRelease to "G3"
157                                 set |GCC_MODEL_CPU| of buildSettingsRelease to "G3"
158                         end if
159                         log cpuType
160                 end if
161                 
162                 set newProject to emptyProject
163                 set objValues to {}
164                 set objKeys to {}
165                 
166                 set refFileCount to 1
167                 set allDepList to {}
168                 set libDepList to {}
169                 set appDepList to {}
170                 
171                 set |buildStyles| of rootObject to projectBuildStyles
172                 
173                 addPair(mainGroup, "MAINGROUP")
174                 addPair(buildStyleDebug, "BUILDSTYLE__Development")
175                 addPair(buildStyleRelease, "BUILDSTYLE__Deployment")
176                 
177                 if xcodeVersion is 1 then
178                         set |objectVersion| of newProject to "39"
179                 else if xcodeVersion is 2 then
180                         set |objectVersion| of newProject to "42"
181                 end if
182                 log "Done initialize ProjBuilder"
183         end Initialize
184         
185         
186         on MakeNewTarget(target_info, src_files, hdr_files, aTarget, aProduct, aType)
187                 set tgName to name of target_info
188                 set fullTargetName to tgName
189                 if aType is equal to 0 then set fullTargetName to "lib" & tgName -- Library
190                 set targetName to "TARGET__" & tgName
191                 set targetProxy to "PROXY__" & tgName
192                 set buildPhaseName to "BUILDPHASE__" & tgName
193                 set prodRefName to "PRODUCT__" & tgName
194                 set depName to "DEPENDENCE__" & tgName
195                 set tgNameH to tgName & "H"
196                 
197                 set targetDepList to {} -- dependencies for this target
198                 try -- set dependencies (if any)
199                         set depString to dep of target_info
200                         set depList to x_Str2List(depString)
201                         
202                         repeat with d in depList
203                                 if d is "datatool" then copy "DEPENDENCE__" & d to the end of targetDepList
204                         end repeat
205                 end try
206                 
207                 copy depName to the end of allDepList -- store a dependency for use in master target: Build All
208                 if aType is equal to 0 then copy depName to the end of libDepList -- Library
209                 if aType is equal to 1 then copy depName to the end of appDepList -- Application
210                 --if aType equals 2 then copy depName to the end of testDepList -- Tests
211                 
212                 -- Add to proper lists
213                 copy targetName to the end of |targets| of rootObject
214                 copy tgName to the end of children of sources
215                 copy tgNameH to the end of children of headers
216                 
217                 set libDepend to {isa:"PBXTargetDependency", |target|:targetName} --, |targetProxy|:targetProxy}
218                 --set aProxy to {isa:"PBXContainerItemProxy", |proxyType|:"1", |containerPortal|:"ROOT_OBJECT", |remoteInfo|:fullTargetName} --|remoteGlobalIDString|:targetName}
219                 
220                 set buildFileRefs to {}
221                 set libFileRefs to {}
222                 -- Add Source Files
223                 repeat with F in src_files
224                         set nameRef to "FILE" & refFileCount
225                         set nameBuild to "REF_FILE" & refFileCount
226                         
227                         set filePath to F --"/" & x_Replace(f, ":", "/") -- f will contain something like "users:vlad:c++:src:corelib:ncbicore.cpp"
228                         set fileName to x_FileNameFromPath(F)
229                         
230                         --set first_char to first character of fileName
231                         --considering case
232                         --set valid_idx to offset of first_char in upper_alphabet
233                         --end considering
234                         
235                         --if valid_idx is 0 then -- no capital first letters!
236                         if fileName ends with ".cpp" then
237                                 set fileType to "sourcecode.cpp.cpp"
238                         else
239                                 set fileType to "sourcecode.c.c"
240                         end if
241                         
242                         set fileRef to {isa:"PBXFileReference", |lastKnownFileType|:fileType, |name|:fileName, |path|:filePath, |sourceTree|:"<absolute>"}
243                         set fileBuild to {isa:"PBXBuildFile", |fileRef|:nameRef}
244                         
245                         addPair(fileRef, nameRef)
246                         addPair(fileBuild, nameBuild)
247                         copy nameBuild to the end of buildFileRefs
248                         copy nameRef to the end of libFileRefs
249                         
250                         set refFileCount to refFileCount + 1
251                         --end if
252                         --if refFileCount = 3 then exit repeat
253                         --log f
254                 end repeat
255                 
256                 
257                 -- Add Header Files
258                 set hdrFileRefs to {}
259                 repeat with F in hdr_files
260                         set nameRef to "FILE" & refFileCount
261                         set filePath to F
262                         set fileName to x_FileNameFromPath(F)
263                         if fileName ends with ".hpp" then
264                                 set fileType to "sourcecode.hpp.hpp"
265                         else
266                                 set fileType to "sourcecode.h.h"
267                         end if
268                         
269                         set fileRef to {isa:"PBXFileReference", |lastKnownFileType|:fileType, |name|:fileName, |path|:filePath, |sourceTree|:"<absolute>"}
270                         addPair(fileRef, nameRef)
271                         copy nameRef to the end of hdrFileRefs
272                         set refFileCount to refFileCount + 1
273                 end repeat
274                 
275                 set libGroup to {isa:"PBXGroup", |name|:tgName, children:libFileRefs, |refType|:"4"}
276                 set hdrGroup to {isa:"PBXGroup", |name|:tgName, children:hdrFileRefs, |refType|:"4"}
277                 
278                 set aBuildPhase to {isa:"PBXSourcesBuildPhase", |files|:buildFileRefs}
279                 
280                 set |productReference| of aTarget to prodRefName
281                 set dependencies of aTarget to targetDepList
282                 
283                 -- Go through the lis of libraries and chech ASN1 dependency. Add a script phase and generate a datatool dep for each one of it.
284                 try -- generated from ASN?
285                         set subLibs to the libs of target_info
286                         set needDatatoolDep to false
287                         set ASNPaths to {}
288                         set ASNNames to {}
289                         
290                         repeat with theSubLib in subLibs
291                                 try
292                                         set asn1 to asn1 of theSubLib
293                                         set needDatatoolDep to true
294                                         set oneAsnPath to path of theSubLib
295                                         --set oneAsnName to last word of oneAsnPath
296                                         set oneAsnName to do shell script "ruby -e \"s='" & oneAsnPath & "'; puts s.split(':')[1]\""
297                                         try
298                                                 set oneAsnName to asn1Name of theSubLib -- have a special ASN name?
299                                         end try
300                                         
301                                         copy oneAsnPath to the end of ASNPaths -- store all paths to asn files
302                                         copy oneAsnName to the end of ASNNames -- store all names of asn files; Use either folder name or ASN1Name if provided
303                                 end try
304                         end repeat
305                         
306                         if needDatatoolDep then -- add dependency to a data tool (when asn1 is true for at least sublibrary)
307                                 copy "DEPENDENCE__datatool" to the end of dependencies of aTarget
308                                 
309                                 set shellScript to x_GenerateDatatoolScript(ASNPaths, ASNNames)
310                                 --log shellScript
311                                 
312                                 -- Now add a new script build phase to regenerate dataobjects
313                                 set scriptPhaseName to "SCRIPTPHASE__" & tgName
314                                 set aScriptPhase to {isa:"PBXShellScriptBuildPhase", |files|:{}, |inputPaths|:{}, |outputPaths|:{}, |shellPath|:"/bin/sh", |shellScript|:shellScript}
315                                 
316                                 copy scriptPhaseName to the beginning of |buildPhases| of aTarget -- shell script phase goes first (before compiling)
317                                 addPair(aScriptPhase, scriptPhaseName)
318                         end if
319                 end try
320                 
321                 
322                 (* Create a shell script phase to copy GBENCH Resources here *)
323                 try
324                         set tmp to gbench of target_info
325                         set shellScript to x_CopyGBENCHResourses()
326                         set scriptPhaseName to "SCRIPTPHASE__" & tgName
327                         set aScriptPhase to {isa:"PBXShellScriptBuildPhase", |files|:{}, |inputPaths|:{}, |outputPaths|:{}, |shellPath|:"/bin/sh", |shellScript|:shellScript}
328                         
329                         copy scriptPhaseName to the end of |buildPhases| of aTarget -- shell script phase goes first (before compiling)
330                         addPair(aScriptPhase, scriptPhaseName)
331                 end try -- Create a GBENCH Resources
332                 
333                 
334                 (* Create a shell script phase to add resource fork for gbench_feedback app *)
335                 if tgName is "gbench_feedback_agent" then
336                         set shellScript to "cd \"$TARGET_BUILD_DIR\"" & ret & "$SYSTEM_DEVELOPER_TOOLS/Rez -t APPL " & TheFLTKPath & "/include/FL/mac.r -o $EXECUTABLE_NAME"
337                         set scriptPhaseName to "SCRIPTPHASE__" & tgName
338                         set aScriptPhase to {isa:"PBXShellScriptBuildPhase", |files|:{}, |inputPaths|:{}, |outputPaths|:{}, |shellPath|:"/bin/sh", |shellScript|:shellScript}
339                         copy scriptPhaseName to the end of |buildPhases| of aTarget -- shell script phase goes first (before compiling)
340                         addPair(aScriptPhase, scriptPhaseName)
341                 end if -- Create a Resources Fork
342                 
343                 
344                 -- add to main object list
345                 addPair(aTarget, targetName)
346                 --addPair(aProxy, targetProxy)
347                 addPair(libDepend, depName)
348                 addPair(aProduct, prodRefName)
349                 addPair(aBuildPhase, buildPhaseName)
350                 
351                 addPair(libGroup, tgName)
352                 addPair(hdrGroup, tgNameH)
353         end MakeNewTarget
354         
355         
356         on MakeNewLibraryTarget(lib_info, src_files, hdr_files)
357                 set libName to name of lib_info
358                 set targetName to "TARGET__" & libName
359                 set buildPhaseName to "BUILDPHASE__" & libName
360                 
361                 set installPath to TheOUTPath & "/lib" --"/Users/lebedev/Projects/tmp3"
362                 set linkerFlags to "" --  -flat_namespace -undefined suppress" -- warning -- additional liker flags (like -lxncbi)
363                 set symRoot to TheOUTPath & "/lib"
364                 
365                 -- build DLLs by default
366                 set libraryStyle to "DYNAMIC"
367                 set fullLibName to "lib" & libName
368                 set libProdType to "com.apple.product-type.library.dynamic"
369                 
370                 set isBundle to false
371                 try -- are we building a loadable module?
372                         if bundle of lib_info then set libraryStyle to "DYNAMIC" --"BUNDLE"
373                         set linkerFlags to "" -- do not suppress undefined symbols. Bundles should be fully resolved
374                         --set linkerFlags to "-framework Carbon -framework AGL -framework OpenGL"
375                         set symRoot to TheOUTPath & "/bin/$(CONFIGURATION)/Genome Workbench.app/Contents/MacOS/plugins"
376                         set isBundle to true
377                 end try
378                 
379                 if libTypeDLL is false and isBundle is false then -- build as static                    
380                         set libraryStyle to "STATIC"
381                         set fullLibName to libName
382                         set libProdType to "com.apple.product-type.library.static"
383                 end if
384                 
385                 
386                 set linkerFlags to linkerFlags & x_CreateLinkerFlags(lib_info) -- additional liker flags (like -lxncbi)
387                 
388                 set buildSettings to {|LIB_COMPATIBILITY_VERSION|:"1", |DYLIB_CURRENT_VERSION|:"1", |INSTALL_PATH|:installPath, |LIBRARY_STYLE|:libraryStyle, |PRODUCT_NAME|:fullLibName, |OTHER_LDFLAGS|:linkerFlags, |SYMROOT|:symRoot, |TARGET_BUILD_DIR|:symRoot}
389                 set libTarget to {isa:"PBXNativeTarget", |buildPhases|:{buildPhaseName}, |buildSettings|:buildSettings, |name|:fullLibName, |productReference|:"", |productType|:libProdType, dependencies:{}}
390                 
391                 my MakeNewTarget(lib_info, src_files, hdr_files, libTarget, libProduct, 0) -- 0 is library
392         end MakeNewLibraryTarget
393         
394         
395         on MakeNewToolTarget(tool_info, src_files, hdr_files)
396                 set toolName to name of tool_info
397                 set targetName to "TARGET__" & toolName
398                 set buildPhaseName to "BUILDPHASE__" & toolName
399                 set fullToolName to toolName -- "app_" & toolName
400                 
401                 set linkerFlags to x_CreateLinkerFlags(tool_info) -- additional liker flags (like -lxncbi)
402                 
403                 set symRoot to TheOUTPath & "/bin"
404                 set buildSettings to {|PRODUCT_NAME|:fullToolName, |OTHER_LDFLAGS|:linkerFlags, |SYMROOT|:symRoot}
405                 if toolName is "gbench_plugin_scan" or toolName is "gbench_monitor" or toolName is "gbench_feedback_agent" or toolName is "gbench_cache_agent" then
406                         set symRoot to TheOUTPath & "/bin/$(CONFIGURATION)/Genome Workbench.app/Contents/MacOS"
407                         set |SYMROOT| of buildSettings to symRoot
408                         set buildSettings to buildSettings & {|TARGET_BUILD_DIR|:symRoot}
409                 end if
410                 set toolTarget to {isa:"PBXNativeTarget", |buildPhases|:{buildPhaseName}, |buildSettings|:buildSettings, |name|:fullToolName, |productReference|:"", |productType|:"com.apple.product-type.tool", dependencies:{}}
411                 
412                 my MakeNewTarget(tool_info, src_files, hdr_files, toolTarget, toolProduct, 2) -- is a tool
413         end MakeNewToolTarget
414         
415         
416         
417         on MakeNewAppTarget(app_info, src_files, hdr_files)
418                 set appName to name of app_info
419                 set targetName to "TARGET__" & appName
420                 set buildPhaseName to "BUILDPHASE__" & appName
421                 --set fullAppName to "app_" & appName
422                 
423                 set linkerFlags to x_CreateLinkerFlags(app_info) -- additional liker flags (like -lxncbi)
424                 
425                 set symRoot to TheOUTPath & "/bin"
426                 set buildSettings to {|PRODUCT_NAME|:appName, |OTHER_LDFLAGS|:linkerFlags, |REZ_EXECUTABLE|:"YES", |INFOPLIST_FILE|:"", |SYMROOT|:symRoot, |KEEP_PRIVATE_EXTERNS|:"YES", |GENERATE_MASTER_OBJECT_FILE|:"YES"}
427                 set appTarget to {isa:"PBXNativeTarget", |buildPhases|:{buildPhaseName}, |buildSettings|:buildSettings, |name|:appName, |productReference|:"", |productType|:"com.apple.product-type.application", dependencies:{}}
428                 
429                 my MakeNewTarget(app_info, src_files, hdr_files, appTarget, appProduct, 1) -- 1 is application
430         end MakeNewAppTarget
431         
432         
433         
434         
435         (* Save everything *)
436         on SaveProjectFile()
437                 (* Genome Workbench Disk Image *)
438                 (* Add a shell script only target to create a standalone disk image for distribution *)
439                 set shellScript to do shell script "cat " & TheNCBIPath & "/compilers/xCode/diskimage.tmpl"
440                 
441                 copy "TARGET__GBENCH_DISK" to the end of |targets| of rootObject
442                 set aScriptPhase to {isa:"PBXShellScriptBuildPhase", |files|:{}, |inputPaths|:{}, |outputPaths|:{}, |runOnlyForDeploymentPostprocessing|:1, |shellPath|:"/bin/sh", |shellScript|:shellScript}
443                 
444                 set theTarget to {isa:"PBXAggregateTarget", |buildPhases|:{}, |buildSettings|:{|PRODUCT_NAME|:"Genome Workbench Disk Image", |none|:""}, dependencies:{}, |name|:"Genome Workbench Disk Image"}
445                 copy "SCRIPTPHASE__GBENCH_DISK" to the beginning of |buildPhases| of theTarget
446                 addPair(aScriptPhase, "SCRIPTPHASE__GBENCH_DISK")
447                 addPair(theTarget, "TARGET__GBENCH_DISK")
448                 addPair({isa:"PBXTargetDependency", |target|:"TARGET__GBENCH_DISK"}, "DEPENDENCE__GBENCH_DISK")
449                 copy "DEPENDENCE__GBENCH_DISK" to the end of allDepList
450                 
451                 
452                 (* Target: Build Everything *)
453                 copy "TARGET__BUILD_APP" to the beginning of |targets| of rootObject
454                 addPair({isa:"PBXAggregateTarget", |buildPhases|:{}, |buildSettings|:{|PRODUCT_NAME|:"Build All Applications", |none|:""}, dependencies:appDepList, |name|:"Build All Applications"}, "TARGET__BUILD_APP")
455                 copy "TARGET__BUILD_LIB" to the beginning of |targets| of rootObject
456                 addPair({isa:"PBXAggregateTarget", |buildPhases|:{}, |buildSettings|:{|PRODUCT_NAME|:"Build All Libraries", |none|:""}, dependencies:libDepList, |name|:"Build All Libraries"}, "TARGET__BUILD_LIB")
457                 copy "TARGET__BUILD_ALL" to the beginning of |targets| of rootObject
458                 addPair({isa:"PBXAggregateTarget", |buildPhases|:{}, |buildSettings|:{|PRODUCT_NAME|:"Build All", |none|:""}, dependencies:allDepList, |name|:"Build All"}, "TARGET__BUILD_ALL")
459                 
460                 
461                 (* add frameworks*)
462                 -- Carbon
463                 copy "FW_CARBON" to the end of children of fworks
464                 addPair({isa:"PBXFileReference", |lastKnownFileType|:"wrapper.framework", |name|:"Carbon.framework", |path|:"/System/Library/Frameworks/Carbon.framework", |refType|:"0", |sourceTree|:"<absolute>"}, "FW_CARBON")
465                 -- OpenGL
466                 copy "FW_OpenGL" to the end of children of fworks
467                 addPair({isa:"PBXFileReference", |lastKnownFileType|:"wrapper.framework", |name|:"OpenGL.framework", |path|:"/System/Library/Frameworks/OpenGL.framework", |refType|:"0", |sourceTree|:"<absolute>"}, "FW_OpenGL")
468                 copy "FW_CORESERVICES" to the end of children of fworks
469                 addPair({isa:"PBXFileReference", |lastKnownFileType|:"wrapper.framework", |name|:"CoreServices.framework", |path|:"/System/Library/Frameworks/CoreServices.framework", |refType|:"0", |sourceTree|:"<absolute>"}, "FW_CORESERVICES")
470                 
471                 (* Add ROOT objects and groups *)
472                 addPair(rootObject, "ROOT_OBJECT")
473                 addPair(headers, "HEADERS")
474                 addPair(sources, "SOURCES")
475                 addPair(fworks, "FRAMEWORKS")
476                 
477                 
478                 (* Create a record from two lists *)
479                 set objects of newProject to CreateRecordFromList(objValues, objKeys)
480                 
481                 
482                 
483                 try -- create some folders
484                         set shScript to "if test ! -d " & TheOUTPath & "/" & projFile & " ; then mkdir " & TheOUTPath & "/" & projFile & " ; fi"
485                         do shell script shScript
486                 end try
487                 
488                 set fullProjName to (TheOUTPath & "/" & projFile & "/project.pbxproj") as string
489                 (* Call NSDictionary method to save data as XML property list *)
490                 --call method "writeToFile:atomically:" of newProject with parameters {"/Users/lebedev/111.txt", "YES"}
491                 --call method "writeToFile:atomically:" of newProject with parameters {"/Users/lebedev/!test.xcode/project.pbxproj", "YES"}
492                 
493                 call method "writeToFile:atomically:" of newProject with parameters {fullProjName, "YES"}
494                 (*set the_file to open for access "users:lebedev:111.txt"
495                 set hhh to read the_file as string
496                 log hhh
497                 close access the_file*)
498         end SaveProjectFile
499         
500         
501         (* Convinience method *)
502         on addPair(aObj, aKey)
503                 copy aObj to the end of objValues
504                 copy aKey to the end of objKeys
505         end addPair
506         
507         (* Workaround the AppleScript lack of variable property labels *)
508         on CreateRecordFromList(objs, keys)
509                 return call method "dictionaryWithObjects:forKeys:" of class "NSDictionary" with parameters {objs, keys}
510         end CreateRecordFromList
511         
512         (*  Replace all occurances of "old" in the aString with "new" *)
513         on x_Replace(aString, old, new)
514                 set OldDelims to AppleScript's text item delimiters
515                 set AppleScript's text item delimiters to old
516                 set newText to text items of aString
517                 set AppleScript's text item delimiters to new
518                 set finalText to newText as text
519                 set AppleScript's text item delimiters to OldDelims
520                 
521                 return finalText
522         end x_Replace
523         
524         
525         (* convert a space-separated "aString" to a list *)
526         on x_Str2List(aString)
527                 set OldDelims to AppleScript's text item delimiters
528                 set AppleScript's text item delimiters to " "
529                 set aList to every text item in aString
530                 set AppleScript's text item delimiters to OldDelims
531                 return aList
532         end x_Str2List
533         
534         
535         (* Get file name and extension from the full file path *)
536         on x_FileNameFromPath(fileNameWithPath)
537                 set OldDelims to AppleScript's text item delimiters
538                 set AppleScript's text item delimiters to "/"
539                 set partsList to text items of fileNameWithPath
540                 set AppleScript's text item delimiters to OldDelims
541                 return the last item of partsList as string
542         end x_FileNameFromPath
543         
544         
545         (* Create a linker flags string based on dependencies and libs to link *)
546         on x_CreateLinkerFlags(info)
547                 set linkFlags to ""
548                 try -- set dependencies (if any)
549                         set depString to dep of info
550                         set depList to x_Str2List(depString)
551                         
552                         repeat with d in depList
553                                 set linkFlags to linkFlags & " -l" & d
554                         end repeat
555                 end try
556                 
557                 try -- set libraries to link (if any)
558                         set libList to lib2link of info
559                         repeat with d in libList
560                                 set linkFlags to linkFlags & " -l" & d
561                         end repeat
562                 end try
563                 
564                 try -- set frameworks
565                         set fwString to fworks of info
566                         set fwList to x_Str2List(fwString)
567                         repeat with d in fwList
568                                 set linkFlags to linkFlags & " -framework " & d
569                         end repeat
570                 end try
571                 return linkFlags
572         end x_CreateLinkerFlags
573         
574         
575         (* Creates a shell script to regenerate ASN files *)
576         on x_GenerateDatatoolScript(thePaths, theNames)
577                 set theScript to "echo Updating $PRODUCT_NAME" & ret
578                 set theScript to theScript & "" & ret
579                 set idx to 1
580                 repeat with aPath in thePaths
581                         set asnName to item idx of theNames
582                         set posixPath to x_Replace(aPath, ":", "/")
583                         
584                         set fullPath to TheNCBIPath & "/src/" & posixPath
585                         
586                         set theScript to theScript & "echo Working in: " & fullPath & ret
587                         set theScript to theScript & "cd " & fullPath & ret
588                         
589                         set theScript to theScript & "if ! test -e " & asnName & ".files || find . -newer " & asnName & ".files | grep '.asn'; then" & ret
590                         set theScript to theScript & "  m=\"" & asnName & "\"" & ret
591                         
592                         set theScript to theScript & "  echo Running Datatool" & ret
593                         if asnName is "gui_project" or asnName is "data_handle" or asnName is "plugin" or asnName is "gbench_svc" or asnName is "seqalign_ext" then -- Should use sed properly here (but how?)
594                                 set theScript to theScript & "  M=\"$(grep ^MODULE_IMPORT $m.module | sed 's/^.*= *//' | sed 's/\\([/a-z0-9_]*\\)/\\1.asn/g')\"" & ret
595                         else
596                                 set theScript to theScript & "  M=\"\"" & ret
597                                 set theScript to theScript & "  if test -e $m.module; then" & ret
598                                 set theScript to theScript & "    M=\"$(grep ^MODULE_IMPORT $m.module | sed 's/^.*= *//' | sed 's/\\(objects[/a-z0-9]*\\)/\\1.asn/g')\"" & ret
599                                 set theScript to theScript & "  fi" & ret
600                         end if
601                         
602                         set theScript to theScript & "  " & TheOUTPath & "/bin/$CONFIGURATION/datatool -oR " & TheNCBIPath
603                         
604                         set theScript to theScript & " -opm " & TheNCBIPath & "/src  -m \"$m.asn\" -M \"$M\" -oA -of \"$m.files\" -or \"" & posixPath & "\" -oc \"$m\" -oex '' -ocvs -odi -od \"$m.def\"" & ret
605                         set theScript to theScript & "else" & ret
606                         set theScript to theScript & "  echo ASN files are up to date" & ret
607                         set theScript to theScript & "fi" & ret & ret
608                         
609                         set idx to idx + 1
610                 end repeat
611                 
612                 return theScript
613         end x_GenerateDatatoolScript
614         
615         
616         (* Creates a shell script to copy some additional files into GBENCH package *)
617         (* Can be replaced with Copy Files Build phase *)
618         on x_CopyGBENCHResourses()
619                 set theScript to ""
620                 set theScript to theScript & "echo Running GBench Plugin Scan" & ret
621                 set theScript to theScript & "if test ! -e " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/plugins/plugin-cache ; then" & ret
622                 set theScript to theScript & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/gbench_plugin_scan " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/plugins" & ret
623                 set theScript to theScript & "fi" & ret
624                 
625                 set theScript to theScript & "echo Copying GBench resources" & ret
626                 
627                 -- Create etc directory
628                 set theScript to theScript & "if test ! -d " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/etc ; then" & ret
629                 set theScript to theScript & "  mkdir " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/etc" & ret
630                 set theScript to theScript & "fi" & ret
631                 
632                 -- Create Resources directory
633                 set theScript to theScript & "if test ! -d " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/Resources ; then" & ret
634                 set theScript to theScript & "  mkdir " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/Resources" & ret
635                 set theScript to theScript & "fi" & ret
636                 
637                 -- Create share directory
638                 set theScript to theScript & "if test ! -d " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/share/gbench ; then" & ret
639                 set theScript to theScript & "  mkdir " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/share" & ret
640                 set theScript to theScript & "  mkdir " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/share/gbench" & ret
641                 set theScript to theScript & "fi" & ret
642                 
643                 -- Create executables directory
644                 --set theScript to theScript & "if test ! -d " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/executables ; then" & ret
645                 --set theScript to theScript & "  mkdir " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/executables" & ret
646                 --set theScript to theScript & "fi" & ret
647                 
648                 --set theScript to theScript & "cp " & TheNCBIPath & "/src/gui/plugins/algo/executables/* " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/executables" & ret
649                 
650                 -- copy png images
651                 set theScript to theScript & "cp " & TheNCBIPath & "/src/gui/res/share/gbench/* " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/share/gbench" & ret
652                 
653                 -- copy Info.plist file
654                 set theScript to theScript & "cp " & TheNCBIPath & "/src/gui/res/share/gbench/Info.plist " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents" & ret
655                 
656                 -- copy Icon file
657                 set theScript to theScript & "cp " & TheNCBIPath & "/src/gui/res/share/gbench/gbench.icns " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/Resources/Genome\\ Workbench.icns" & ret
658                 
659                 set theScript to theScript & "cp " & TheNCBIPath & "/src/gui/res/share/gbench/gbench_workspace.icns " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/Resources/gbench_workspace.icns" & ret
660                 set theScript to theScript & "cp " & TheNCBIPath & "/src/gui/res/share/gbench/gbench_project.icns " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/Resources/gbench_project.icns" & ret
661                 
662                 ----set theScript to theScript & "cp -r " & TheNCBIPath & "/src/gui/plugins/algo/executables " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/executables" & ret
663                 set theScript to theScript & "rm -rf " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/etc/*" & ret
664                 set theScript to theScript & "cp -r " & TheNCBIPath & "/src/gui/res/etc/* " & TheOUTPath & "/bin/$CONFIGURATION/Genome\\ Workbench.app/Contents/MacOS/etc" & ret
665                 --set theScript to theScript & "cp -r " & TheNCBIPath & "/src/gui/gbench/patterns/ " & TheOUTPath & "/bin/Genome\\ Workbench.app/Contents/MacOS/etc/patterns" & ret
666                 --set theScript to theScript & "cp " & TheNCBIPath & "/src/gui/gbench/news.ini " & TheOUTPath & "/bin/Genome\\ Workbench.app/Contents/MacOS/etc" & ret
667                 --set theScript to theScript & "cp " & TheNCBIPath & "/src/gui/gbench/gbench.ini " & TheOUTPath & "/bin/Genome\\ Workbench.app/Contents/MacOS/etc" & ret
668                 --set theScript to theScript & "cp " & TheNCBIPath & "/src/gui/gbench/algo_urls " & TheOUTPath & "/bin/Genome\\ Workbench.app/Contents/MacOS/etc" & ret
669                 
670                 return theScript
671         end x_CopyGBENCHResourses
672 end script

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.