How can I instruct Xcode to use YASM to compile .asm files? I have a Xcode 4.0 project setup to compile C and C++ files just fine, however, Xcode doesn't know what to do with .asm files. I've 开发者_如何学Goalready got the binary tool yasm installed, it's just a matter of instructing Xcode of using Yasm to compile .asm files.
For Visual Studio, I use the Yasm rules, and for Linux I modified the makefile. However, I do not know how to configure Xcode to use yasm.
Any ideas?
Install yasm. (MacPorts or brew or DIY)
Select the project item in the Project Navigator. Select the target from the TARGETS list. Select the "Build Rules" tab item. Click "Add Build Rule" button. Choose "Assembly files (sourcecode.asm) from the "Process" pop-up. Choose "Custom script:" from the "Using" pop-up.
Enter the yasm build command into the script area. For example:
#!/bin/bash /usr/local/bin/yasm -f macho32 -o ${OBJECT_FILE_DIR_normal}/${CURRENT_ARCH}/${INPUT_FILE_BASE}.o ${INPUT_FILE_DIR}/${INPUT_FILE}
Add the output file ("${OBJECT_FILE_DIR_normal}/${CURRENT_ARCH}/${INPUT_FILE_BASE}.o") to the list of output files.
The shell variables are defined by Xcode and added to the shell execution environment. I determined these instructions without any prior familiarity with yasm, so I apologize if there are any errors in my invocation. Seems to be working in my case, though.
精彩评论