设置 Xcode 以使用外部编译器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15652316/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:04:15  来源:igfitidea点击:

Setup Xcode for using external compiler

xcode8051sdcc

提问by jelipito

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.

我正在尝试使用 Xcode 作为微控制器代码的编辑器。我想使用构建、运行按钮。我如何使用这些来触发编译程序的脚本?我已经有一个可以在命令行上运行的脚本。我需要传递一些参数,比如文件名和几个选项。我正在使用 SDCC,它是一个 8501 编译器。是否可以在 Xcode 中创建自定义目标或其他内容,以便它调用脚本并传递文件名或参数?关于如何做到这一点的任何例子?当然,我不能为此使用 GCC。

回答by cody

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.
  • 文件 -> 新建 -> 项目 -> OS X -> 外部构建系统 -> 下一步
  • 将“/bin/bash”设置为“构建工具”字段
  • 设置其他信息并创建项目
  • 选择您的目标并在“信息”选项卡上设置参数(您的脚本名称和要传递给脚本的参数)和工作目录(如果需要)。您也可以在此处更改构建工具。

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.
  • 在底部单击您当前的方案并选择“编辑方案...”
  • 在左侧面板中选择“运行”
  • “信息”选项卡:选择“可执行文件”->“其他...”-> 导航到 /bin 目录(Command + Shift + G)-> 选择“bash”。将“调试器”设置为“无”
  • “参数”选项卡:设置参数(您的脚本和要传递的参数)。
  • “选项”选项卡:设置工作目录。

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.

我通常只使用一个脚本(设置为运行脚本)。在这种情况下,只需将目标的“信息”选项卡上的参数留空。

编辑:对于作为构建工具的 make 不需要传递任何参数,只需适当地设置目录,make 就会在那里找到 Makefile。