Setup Xcode for using external compiler
Asked Answered
F

1

5

I am trying to use Xcode as an editor for microcontroller code. I want to use the Build, Run buttons. How can i use those to trigger a script that compiles the program ? I already have a script that works on the command line. I need to pass some parameters, like filename and maybe a couple of options. I am using SDCC which is an 8501 compiler. Is it possible to create a custom target or something in Xcode so it calls the script and passes the filename or parameters? Any examples on how to do this? Of course i can't use GCC for this.

Fogg answered 27/3, 2013 at 5:12 Comment(0)
M
10

Well, you need to create "External Build System" project:

  • File -> New -> Project -> OS X -> External Build System -> Next
  • Set "/bin/bash" to the "Build Tool" field
  • Set other information and create project
  • Choose your target and on "Info" tab set arguments (your script name and arguments to be passed to the script) and work directory (if needed). You also can change build tool here.

If you want to set a separate script as a run command than:

  • at the bottom click on your current scheme and choose "Edit Scheme..."
  • Choose "Run" in left panel
  • "Info" tab: select "Executable" -> "Other..." -> navigate to /bin directory (Command + Shift + G) -> choose "bash". Set "Debugger" to "None"
  • "Arguments" tab: set arguments (your script and arguments to be passed).
  • "Options" tab: set working directory.

I usually use just one script for all (set as run script). In this case just leave arguments on target's "Info" tab empty.

Edit: for make as a build tool no need to pass any arguments, just set Directory appropriately and make will find Makefile there.

Myasthenia answered 27/3, 2013 at 7:58 Comment(2)
thanks a lot. Some questions: so i am using a makefile as the method to build. So "make" will be my build tool. So when you say script name i am assuming that it will be "make", how do i pass the arguments ?. for example the argument for "make" will be the project name. So i am using $(EXECUTABLE_NAME) in arguments. I get the following error: Command /Applications/Xcode.app/Contents/Developer/usr/bin/make failed with exit code 2Fogg
if you are using make, than Build Tool will be /usr/bin/make and Arguments field (on Info tab) leave unchanged (in my projects $(ACTION) is there). You need only to setup Directory where your Makefile is. You can add your makefile to the project and XCode will show errors in it (at list in my Java projects it does).Myasthenia

© 2022 - 2024 — McMap. All rights reserved.