Re: Replacing build rule with copy bundle resource
Re: Replacing build rule with copy bundle resource
- Subject: Re: Replacing build rule with copy bundle resource
- From: Andrew Brownsword <email@hidden>
- Date: Fri, 23 Dec 2011 18:30:40 -0800
For purposes of closure, this is how I fixed my problem:
1. Created a custom build rule "OpenCL source files using Script" by clicking the built-in OpenCL rule's "Copy to Target" button.
2. Wrote the following custom script:
# <com.apple.compilers.opencl>
cp ${INPUT_FILE_PATH} ${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.cls
cp ${INPUT_FILE_PATH} ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/${INPUT_FILE_BASE}.cl
3. Specified this in the output files list:
${DERIVED_FILES_DIR}/${INPUT_FILE_BASE}.cls
And that's it. The .cls output seems to be needed to placate the build system, and second copy actually populates the resources directory. Using the .cl extension means I get the syntax colouring, and could use the clc compiler without renaming files or adding more rules, if I so desire.
Thanks to Aaron for the helpful pointers about how to write build scripts and examine the environment variables needed.
Cheers,
Andrew
On 2011-12-21, at 6:33 AM, Aaron Burghardt wrote:
> Two suggestions:
>
> 1. If the list of files is easy to distinguish and manage, then Create a Run Script phase and write a script to copy the files.
>
> 2. If the files are never compiled and only to be included in your app bundle, rename the files with a custom extension and create a build rule script that copies and renames the file either to the derived outputs directory or directly into the app bundle. The script will have all of the normal Xcode build settings via it's environment that a Run Script phase has. Where ever you put them, make sure it matches the Output Files section of the build rule. A good way to ensure that is use the variable SCRIPT_OUTPUT_FILE_0, which is the expanded version of the first file in the Output Files. The input file is SCRIPT_INPUT_FILE and/or INPUT_FILE_*. To have the output file reflect the input filename, specify the output folder similar to this: "$(DERIVED_FILES_DIR)/$(INPUT_FILE_BASE).processed_ext" (without the quotes).
>
> A couple notes on specifying input and output files to build rules and Run Script phases:
>
> * Refer to variables as $VARIABLE or ${VARIABLE} in the script, but as $(VARIABLE) in the inputs and outputs sections.
>
> * Don't quote paths in the inputs and outputs section. Xcode will pass the quotes as part of the path.
>
> * To see a list of the environment variables, check the box in a Run Script phase or include a printenv in a build rule.
>
>
>> On 2011-12-18, at 3:56 PM, Fritz Anderson wrote:
>>
>>> No need for a special rule. Remove the .cl files from the Compile Sources build phase and add them to the Copy Bundle Resources phase.
>>
>> Yes, I had done that already. It makes no difference. I also tried re-ordering the build phases, to no effect.
>
> I'm not sure if it's documented as the designed behavior, but I will confirm that my build rules get invoked for both Compile and Copy Files phases.
>
> Aaron
>
>
> On Dec 18, 2011, at 4:49 PM, Andrew Brownsword wrote:
>
>> I'm trying to get xcode 4 to simply copy my *.cl files into the application bundle, however it compiles them first and copies the outputs of the compile. I haven't been able to disable this rule, nor figure out how to create a replacement rule that will do this for me -- the documentation on how to write scripts for build rules, specify the output files, etc is abysmal and bordering on non-existant. The couple of books I have on xcode 4 similarly fail to illuminate.
>>
>> Sorry if this has been covered in the archive -- search doesn't seem to work on this mailing list's archives. Advice on any of these topics would be appreciated, thanks.
>>
>>
>> _______________________________________________
>> 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
>
_______________________________________________
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