Re: Applescripting XCode Project setup
Re: Applescripting XCode Project setup
- Subject: Re: Applescripting XCode Project setup
- From: Dmitry Markman <email@hidden>
- Date: Sun, 15 Jan 2006 14:44:15 -0500
I have almost empty simulink_T.xcodeproj (like template)
set matlab_path to "/sandbox/dmarkman/Aslrtw/matlab"
set posix_project_t_path to "/sandbox/dmarkman/Projects/Simulink/
XCode/simulink/simulink_T.xcodeproj"
set posix_project_new_path to "/sandbox/dmarkman/Projects/Simulink/
XCode/simulink/simulink.xcodeproj"
set posix_src_path to matlab_path & "/src"
set posix_global_include_path to posix_src_path & "/include"
set posix_simulink_path to posix_src_path & "/simulink"
set simulink_path to POSIX file posix_simulink_path
set global_include_path to POSIX file posix_global_include_path
set project_t_path to POSIX file posix_project_t_path
set project_new_path to POSIX file posix_project_new_path
set sources_simulink_folders to {"sl_bde", "sl_blks", "sl_cmds",
"sl_engin", "sl_glee", "sl_intg", "sl_obj", ¬
"sl_uix", "sl_util", "sl_sfcn", "sl_uiutil", "sl_log",
"sl_hardcopy", "modver"}
set headers_simulink_folders to {"sl_bde", "sl_blks", "sl_cmds",
"sl_engin", "sl_glee", "sl_intg", "sl_obj", ¬
"sl_uix", "sl_util", "sl_sfcn", "sl_uiutil", "sl_log",
"sl_hardcopy", "modver", "messages", "include"}
set msg_simulink_folders to {"messages"}
on CVSFolder(f)
if class of f is folder then
if name of f is "CVS" then return true
end if
return false
end CVSFolder
tell application "Xcode"
quit
end tell
delay 1
-- DUPLICATE TEMPLATE
tell application "Finder"
set project_t_item to item project_t_path
try
delete project_new_path
empty trash
end try
set new_project to duplicate project_t_item with replace
set name of new_project to "simulink.xcodeproj"
set new_project to item project_new_path
end tell
-- END OF DUPLICATE TEMPLATE
tell application "Xcode"
open new_project
set my_project to project of active project document
set simulink_target to item 1 of (targets of my_project)
set project_groups to groups of root group of my_project
repeat with g in project_groups
if name of g is "Sources" then
set project_sources_group to g
else if name of g is "Headers" then
set project_headers_group to g
else if name of g is "Messages" then
set project_messages_group to g
else if name of g is "External Frameworks and Libraries" then
set project_external_group to item 1 of groups of g
end if
end repeat
-- SETTING MATLAB GROUP PATH
if class of project_sources_group is group then
set src_matlab_group to item 1 of groups of project_sources_group
set path of src_matlab_group to matlab_path
end if
if class of project_headers_group is group then
set headers_matlab_group to item 1 of groups of project_headers_group
set path of headers_matlab_group to matlab_path
end if
if class of project_messages_group is group then
set msg_matlab_group to item 1 of groups of project_messages_group
set path of msg_matlab_group to matlab_path
end if
if class of project_external_group is group then
set lib_matlab_group to item 1 of groups of project_external_group
set path of lib_matlab_group to matlab_path
end if
-- END SETTING MATLAB GROUP PATH
-- SETTING TARGET SETTINGS
set bcs to build configurations of simulink_target
set dev_bc to item 1 of bcs
set build_settings to build settings of dev_bc
set lib_paths to matlab_path & "/sys/os/mac"
set lib_paths to lib_paths & " /usr/X11R6/lib "
set lib_paths to lib_paths & matlab_path & "/bin/mac"
set headers_paths to "/System/Library/Frameworks/JavaVM.framework/
Headers "
set headers_paths to headers_paths & matlab_path & "/src/simulink/
include "
set headers_paths to headers_paths & matlab_path & "/src/include "
set need_to_set to 2
repeat with bs in build_settings
if name of bs is "HEADER_SEARCH_PATHS" then
set value of bs to headers_paths
set need_to_set to need_to_set - 1
end if
if name of bs is "LIBRARY_SEARCH_PATHS" then
set value of bs to lib_paths
set need_to_set to need_to_set - 1
end if
if need_to_set < 1 then
exit repeat
end if
end repeat
set copy_phases to copy files phases of simulink_target
if length of copy_phases > 0 then
set first_copy_phase to item 1 of copy_phases
set path of first_copy_phase to (matlab_path & "/bin/mac/")
end if
-- ENDSETTING TARGET SETTINGS
-- SETTING EXECUTABLE
set exec_name to "matlab_exec"
tell my_project
set exec to make new executable with properties {name:exec_name,
path:(matlab_path & "/bin/mac/MATLAB")}
set active executable to exec
end tell
set dylib_path to matlab_path & "/sys/os/mac:" & matlab_path & "/bin/
mac:" & matlab_path & "/extern/lib/mac"
set xfilesearch to "/System/Library/Frameworks/JavaVM.framework/lib/
locale/%L/%T/%N%S:"
tell exec
make new launch argument with properties {active:true, name:"-nojvm"}
make new launch argument with properties {active:true, name:"-
display :0.0"}
make new environment variable with properties {active:true,
name:"ARCH", value:"mac"}
make new environment variable with properties {active:true,
name:"TOOLBOX", value:(matlab_path & "/toolbox")}
make new environment variable with properties {active:true,
name:"XAPPLRESDIR", value:(matlab_path & "/X11/app-defaults")}
make new environment variable with properties {active:true,
name:"XKEYSYMDB", value:(matlab_path & "/X11/app-defaults/XKeysymDB")}
make new environment variable with properties {active:true,
name:"MATLABPATH", value:(matlab_path & "/toolbox/local")}
make new environment variable with properties {active:true,
name:"DYLD_LIBRARY_PATH", value:dylib_path}
make new environment variable with properties {active:true,
name:"DISPLAY", value:":0.0"}
make new environment variable with properties {active:true,
name:"MATLAB", value:matlab_path}
make new environment variable with properties {active:true,
name:"XFILESEARCHPATH", value:xfilesearch}
make new source directory with properties {path:(matlab_path & "/
src/simulink")}
end tell
-- END SETTING EXECUTABLE
tell application "Finder"
set simulink_folder to item simulink_path
set global_include_folder to item global_include_path
if class of simulink_folder is not folder then
return
end if
if class of global_include_folder is not folder then
return
end if
set fs_simulink_folders to folders of simulink_folder
set include_files to files of global_include_folder
end tell
-- POPULATING Sources group
tell application "Finder"
set current_list to {}
repeat with g in fs_simulink_folders
if (sources_simulink_folders contains name of g) then
set end of current_list to g
end if
end repeat
end tell
set src_matlab_src_group to item 1 of groups of src_matlab_group
set src_matlab_simulink_group to item 1 of groups of
src_matlab_src_group
repeat with sim_folder in current_list
tell src_matlab_simulink_group
set new_group to make new group with properties ¬
{name:name of sim_folder, path type:group relative, path:name of
sim_folder}
end tell
tell application "Finder"
set sub_files to files of sim_folder
end tell
repeat with f in sub_files
set file_name to name of f
if file_name ends with ".c" or file_name ends with ".cpp" then
if file_name ends with ".c" then
set file_type to "sourcecode.c.c"
else
set file_type to "sourcecode.cpp.cpp"
end if
tell new_group
set new_file to make new file reference with properties {file
kind:file_type, name:file_name, file encoding:macos roman, path
type:group relative, path:file_name}
end tell
end if
end repeat
end repeat
-- END POPULATING Sources group
-- POPULATING Headers group
tell application "Finder"
set current_list to {}
repeat with g in fs_simulink_folders
if (headers_simulink_folders contains name of g) then
set end of current_list to g
end if
end repeat
end tell
set headers_matlab_src_group to item 1 of groups of
headers_matlab_group
set headers_matlab_simulink_group to {}
set headers_matlab_include_group to {}
repeat with g in groups of headers_matlab_src_group
if name of g is "simulink" then
set headers_matlab_simulink_group to g
else if name of g is "include" then
set headers_matlab_include_group to g
end if
end repeat
if class of headers_matlab_simulink_group is not group then
return
end if
if class of headers_matlab_include_group is not group then
return
end if
repeat with f in include_files
set file_name to name of f
if file_name ends with ".h" then
set file_type to "sourcecode.cpp.h"
set full_path to posix_global_include_path & "/" & name of f
tell headers_matlab_include_group
-- set new_file to make new file reference with properties ¬
--{file kind:file_type, name:file_name, file encoding:macos
roman, path type:group relative, full path:full_path}
set new_file to make new file reference with properties ¬
{file kind:file_type, name:file_name, file encoding:macos roman,
path type:group relative, path:file_name}
end tell
end if
end repeat
repeat with sim_folder in current_list
tell headers_matlab_simulink_group
set new_group to make new group with properties ¬
{name:name of sim_folder, path type:group relative, path:name of
sim_folder}
end tell
tell application "Finder"
set sub_files to files of sim_folder
end tell
repeat with f in sub_files
set file_name to name of f
if file_name ends with ".h" then
set file_type to "sourcecode.cpp.h"
tell new_group
set new_file to make new file reference with properties {file
kind:file_type, name:file_name, file encoding:macos roman, path
type:group relative, path:file_name}
end tell
end if
end repeat
end repeat
-- END POPULATING Headers group
close every project document
delay 1
set project_src_group to {}
open new_project
--ADDING ITEMS TO THE TARGET
repeat with gr in groups of src_matlab_simulink_group
repeat with single_file in file references of gr
add single_file to simulink_target
end repeat
end repeat
repeat with single_file in file references of
headers_matlab_include_group
add single_file to simulink_target
end repeat
repeat with gr in groups of headers_matlab_simulink_group
repeat with single_file in file references of gr
add single_file to simulink_target
end repeat
end repeat
--END ADDING ITEMS TO THE TARGET
quit
end tell
On Jan 15, 2006, at 2:18 PM, Thomas Engelmeier wrote:
Hi,
is there any sample how to set up a complete project in XCode via
AppleScript?
create a new project based on a template
while (some groups)
make a new group
while (files for that group)
add a file reference in the group
TIA,
Tom_E_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Dmitry Markman
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden