Create a .bif file with TCL script - sdk

I'm trying create a boot image with TCL script. And i can create if I create fsblTest.bif file via SDK manually. I want to create auto with TCL. How can i create .bif file using TCL ?
My code;
setws /home/nmi/workspace
app create -name fsblTest -template {Zynq FSBL} -hw zc702 -proc ps7_cortexa9_0 -os standalone
app build -name fsblTest
exec bootgen -arch zynq -image /home/nmi/workspace/fsblTest_system/_ide/bootimage/fsblTest_system.bif -w -o /home/nmi/Desktop/bootD/BOOT.bin

I solved.
Last version of my code :
setws /home/nmi/workspace
#app create with hardware,processor..
app create -name fsblTest1 -template {Zynq FSBL} -hw zc702 -proc ps7_cortexa9_0 -os standalone
app build -name fsblTest1
set outputFile [open /home/nmi/workspace/fsblTest1_system/fsblTest1.bif w+]
# .bif file content
puts $outputFile "/* /tmp/bootgen_zynq_fsbl_system16600834677826087177/sd_card_temp/boot.bif */ "
puts $outputFile "/* Command to create bitstream .bin file: */"
puts $outputFile "/* bootgen -image <bif_file> -split bin -w */"
puts $outputFile "/* Command to create BOOT.BIN file: */"
puts $outputFile "/* bootgen -image <bif_file> -w -o i BOOT.BIN */"
puts $outputFile "/*zc702*/"
puts $outputFile "the_ROM_image:"
puts $outputFile "{"
puts $outputFile "\[bootloader] /home/nmi/workspace/zc702/export/zc702/sw/zc702/boot/fsbl.elf"
puts $outputFile "/home/nmi/workspace/fsblTest1/Debug/fsblTest1.elf"
puts $outputFile "}"
close $outputFile
#boot.bin file create
exec bootgen -arch zynq -image /home/nmi/workspace/fsblTest1_system/fsblTest1.bif -w -o /home/nmi/Desktop/bootD/BOOT.bin

Related

Finding bundle identifier in XCode project using shell script

A Bundle identifier in Info.plist of an Xcode project could have various forms, for e.g.
com.company.$(PRODUCT_NAME:rfc1034identifier)
$(PRODUCT_BUNDLE_IDENTIFIER)
Someone could design their own product bundle identifier for debug, release etc types of build and write a variable against Bundle identifier, e.g. com.company.$(PRODUCT_NAME:rfc1034identifier).$(someRandomVariable)
I want to write a shell script that just reads the bundle identifier properly.
However, if you only know shell script - I know, how to figure out values of variables in $(), but want a shell script that should give me all such variables in the string and then I will have code to figure out their values, post which I will create string back with the variables replaced with values.
function getBundleIdentifier
{
cfBundleIdentifier=${PRODUCT_BUNDLE_IDENTIFIER}
if [ ${#cfBundleIdentifier} -lt 1 ]; then
SOURCE="rfc1034identifier"
cfBundleIdentifier=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "${PROJECT_DIR}/${INFOPLIST_FILE}")
if echo "$cfBundleIdentifier" | grep -q "$SOURCE"; then
echo `eval echo $cfBundleIdentifier``eval echo ${PRODUCT_NAME:rfc1034identifier}`
else
echo `eval echo $cfBundleIdentifier`
fi
else
echo $cfBundleIdentifier
fi
}
This is what I have written, but it does not cover all the cases.
It's very easy, just run this command:
BUNDLE_ID=`xcodebuild -showBuildSettings | grep PRODUCT_BUNDLE_IDENTIFIER`
echo $BUNDLE_ID
you can use this
xcodebuild -project Myproject.xcodeproj \-showBuildSettings | grep PRODUCT_BUNDLE_IDENTIFIER | awk -F ' = ' '{print $2}'
or just consolidated the non-xcode portion into :
xcodebuild……. |
{m,g}awk '$!NF = $(NF=2*/PRODUCT_BUNDLE_IDENTIFIER/)' FS=' = '
To get get the bundle identifier in a shell script, I found this to be the simplest way:
xcodebuild -showBuildSettings | awk -F ' = ' '/PRODUCT_BUNDLE_IDENTIFIER/ { print $2 }'
If your script works currently in a different path, use -project option:
xcodebuild -project Myproject.xcodeproj -showBuildSettings | awk -F ' = ' '/PRODUCT_BUNDLE_IDENTIFIER/ { print $2 }'

Running iOS UIAutomation as a post-action build script is return as a posix spawn error

I'm entirely new to using bash and Xcode build scripts and so my code is probably a jungle full of errors.
The idea here is to trigger the script below which will scrape the directory that it is saved in for any .js automation scripts. It will then send these scripts to instruments to be run one at a time. I found some nifty code that created time stamped files and so I used that to create a more meaningful storage system.
#!/bin/bash
# This script should run all (currently only one) tests, independently from
# where it is called from (terminal, or Xcode Run Script).
# REQUIREMENTS: This script has to be located in the same folder as all the
# UIAutomation tests. Additionally, a *.tracetemplate file has to be present
# in the same folder. This can be created with Instruments (Save as template...)
# The following variables have to be configured:
#EXECUTABLE="Plans.app"
# Find the test folder (this script has to be located in the same folder).
ROOT="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Prepare all the required args for instruments.
TEMPLATE=`find $ROOT -name '*.tracetemplate'`
#EXECUTABLE=`find ~/Library/Application\ Support/iPhone\ Simulator | grep "${EXECUTABLE}$"`
echo "$BUILT_PRODUCTS_DIR"
echo "$PRODUCT_NAME"
EXECUTABLE="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/"
SCRIPTS=`find $ROOT -name '*.js'`
# Prepare traces folder
TRACES="${ROOT}/Traces/`date +%Y-%m-%d_%H-%M-%S`"
mkdir -p "$TRACES"
printf "\n" >> "$ROOT/results.log"
echo `date +%Y-%m-%d_%H-%M-%S` >> "$ROOT/results.log"
# Get the name of the user we should use to run Instruments.
# Currently this is done, by getting the owner of the folder containing this script.
USERNAME=`ls -l "${ROOT}/.." | grep \`basename "$ROOT"\` | awk '{print $3}'`
# Bring simulator window to front. Depending on the localization, the name is different.
osascript -e 'try
tell application "iPhone Simulator" to activate
on error
tell application "iOS Simulator" to activate
end try'
# Prepare an Apple Script that promts for the password.
PASS_SCRIPT="tell application \"System Events\"
activate
display dialog \"Password for user $USER:\" default answer \"\" with hidden answer
text returned of the result
end tell"
# Run all the tests.
for SCRIPT in $SCRIPTS; do
echo -e "\nRunning test script $SCRIPT"
TESTC="sudo -u ${USER} xcrun instruments -l -c -t ${TEMPLATE} ${EXECUTABLE} -e UIARESULTSPATH ${TRACES}/${TRACENAME} -e UIASCRIPT ${SCRIPT} >> ${ROOT}/results.log"
#echo "$COMMAND"
echo "Executing command $TESTC" >> "$ROOT/results.log"
echo "here $TESTC" >> "$ROOT/results.log"
OUTPUT=$(TESTC)
echo $OUTPUT >> "$ROOT/results.log"
echo "Finished logging" >> "$ROOT/results.log"
SCRIPTNAME=`basename "$SCRIPT"`
TRACENAME=`echo "$SCRIPTNAME" | sed 's_\.js$_.trace_g'`
for i in $(ls -A1t $PWD | grep -m 1 '.trace')
do
TRACEFILE="$PWD/$i"
done
if [ -e $TRACEFILE ]; then
mv "$TRACEFILE" "${TRACES}/${TRACENAME}"
fi
if [ `grep " Fail: " results.log | wc -l` -gt 0 ]; then
echo "Test ${SCRIPTNAME} failed. See trace for details."
open "${TRACES}/${TRACENAME}"
exit 1
break
fi
done
rm results.log
A good portion of this was taken from another Stack Overflow answer but because of the repository setup that I'm working with I needed to keep the paths abstract and separate from the root folder of the script. Everything seems to work (although probably not incredibly efficiently) except for the actual xcrun command to launch instruments.
TESTC="sudo -u ${USER} xcrun instruments -l -c -t ${TEMPLATE} ${EXECUTABLE} -e UIARESULTSPATH ${TRACES}/${TRACENAME} -e UIASCRIPT ${SCRIPT} >> ${ROOT}/results.log"
echo "Executing command $TESTC" >> "$ROOT/results.log"
OUTPUT=$(TESTC)
This is turned into the following by whatever black magic Bash runs on:
sudo -u Braains xcrun instruments -l -c -t
/Users/Braains/Documents/Automation/AppName/TestCases/UIAutomationTemplate.tracetemplate
/Users/Braains/Library/Developer/Xcode/DerivedData/AppName-
ekqevowxyipndychtscxwgqkaxdk/Build/Products/Debug-iphoneos/AppName.app/ -e UIARESULTSPATH
/Users/Braains/Documents/Automation/AppName/TestCases/Traces/2014-07-17_16-31-49/ -e
UIASCRIPT /Users/Braains/Documents/Automation/AppName/TestCases/Test-Case_1js
(^ Has inserted line breaks for clarity of the question ^)
The resulting error that I am seeing is:
posix spawn failure; aborting launch (binary ==
/Users/Braains/Library/Developer/Xcode/DerivedData/AppName-
ekqevowxyipndychtscxwgqkaxdk/Build/Products/Debug-iphoneos/AppName.app/AppName).
I have looked all over for a solution to this but I can't find anything because Appium has a similar issue. Unfortunately I don't understand the systems well enough to know how to translate the fixes to Appium to my own code but I imagine it's a similar issue.
I do know that the posix spawn failure is related to threading, but I don't know enough about xcrun to say what's causing the threading issue.
Related info:
- I'm building for the simulator but it'd be great to work on real devices too
- I'm using xCode 5.1.1 and iOS Simulator 7.1
- This script is meant to be run as a build post action script in xCode
- I did get it briefly working once before I broke it and couldn't get it back to the working state. So I think that means all of my permissions are set correctly.
UPDATE: So I've gotten to the root of this problem although I have not found a fix yet. First of all I have no idea what xcrun is for and so I dropped it. Then after playing around I found that my Xcode environment variables are returning the wrong path, probably because of some project setting somewhere. If you copy the Bash command from above but replace Debug-iphoneos with Debug-iphonesimulator the script can be run from the command line and will work as expected.
So for anyone who happens across this the only solution I could find was to hardcode the script for the simulator.
I changed EXECUTABLE="${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/" to be EXECUTABLE="${SYMROOT}/Debug-iphonesimulator/${EXECUTABLE_PATH}". This is obviously not a great solution but it works for now.

clang: Remove comments in preprocessed files?

is there a way to tell clang to remove comment lines when generating preprocessed output?
Apparently, this is a difference between gcc and clang, and I have not found an option to do so
Thanks
Alex
To be more precise: It seems that I have an issue with input from file, please see this sample:
CONTENT="// \$REMOVE BEFORE FLIGHT\$\r\nprintf(\"HelloWorld!\");"
echo "Original:\n$CONTENT"
echo "-------------------------"
echo "From stdin"
echo $CONTENT | cpp -P -E -nostdinc -xc++ -
echo "-------------------------"
echo "From file"
echo $CONTENT > foo.sample
cpp -P -E -nostdinc -xc++ foo.sample
echo "\n What gives?"
Addition: It appears, that the -x Argument is changed. Using -v, I can see that on the command line, actually -x c++ is passed, whereas when using a file as input, it is changed to -x c.
Any idea why?

Unused Images in XCode Project

I have created small bash script which finds the unused images(*.jpg and *.png) in iOS project. And here is the code for the same.
//For removing space and replace '\n' in file and folder names
`IFS=$'\n'`
//Find all files with extension *.png and *.jpg
`for i in `find . -name "*.png" -o -name "*.jpg"``; do`
//Get the base name of found file
file=``basename -s .jpg "$i" | xargs basename -s .png``
//Replace "\n" with original space so that ack can search exact file name in all files
filenameWithSpace="${file//$'\n'/ }"
//Merge both basename and extension for ack command
//Add this "</dev/null" to ack command for it to work on jenkins setup
`extension="${i##*.}"`
`filename="$filenameWithSpace.$extension"`
result=`ack -i --ignore-file=match:/.\.pbxproj/ "$filename" </dev/null`
//result=ack -i "$filename" </dev/null
//If result is NULL then ack did not find any occurrence of the filename in any file
`if [ -z "$result" ];`
`then `
`echo "$i" `
`fi `
`done`
Should ".pbxproj" be included in my search? I ask this question since including and excluding ".pbxproj" provides me different results.
Thanks in advance.
Don't include the .pbxproj. It will have the image references.
FYI : http://jeffhodnett.github.io/Unused/ to find the unused images.

Capsitrano deploy recipe : after deploy file listing and modifications

I'm currently working on a multi-stage recipe for Capistrano that would, ideally, after deploy, make wise use of the yui compressor for all css and js.
Here's what I currently came up to :
after "deploy", "deploy:cleanup", "minifier:compress"
# Task to minify via Yui-compressor
# Uses compressor bundled with application in #{application}/lib/yuicompressor
namespace :minifier do
def minify(files)
files.each do |file|
cmd = "java -jar lib/yuicompressor/build/yuicompressor-2.4.6.jar #{file} -o #{file}"
puts cmd
ret = system(cmd)
raise "Minification failed for #{file}" if !ret
end
end
desc "minify"
task :compress do
minify_js
minify_css
end
desc "minify javascript"
task :minify_js do
minify(Filelist['public/js/**/*.js'])
end
desc "minify css"
task :minify_css do
minify(Filelist['public/css/**/*.css'])
end
end
What's really puzzling me is the
uninitialized constant Capistrano::Configuration::Filelist (NameError)
I get as soon as Capistrano gets to the point.
As a total newbie to Ruby, Rails, and Capistrano, I understand for some reason FileList isn't a common Capistrano method, but can't figure out what to replace it with.
Thanks for the help.
Your task is conceptually wrong, it will run on local system (the one from which you're deploying), because you're call system, you should use the run method which run commands remotely.
def minify(files)
files.each do |file|
cmd = "java -jar lib/yuicompressor/build/yuicompressor-2.4.6.jar #{file} -o #{file}"
puts cmd
ret = system(cmd) # *** SYSTEM RUN LOCAL COMMANDS ***
raise "Minification failed for #{file}" if !ret
end
end
That said, I will change that code with shell scripting, something like (untested)
task :minify
cmd = "java -jar lib/yuicompressor/build/yuicompressor-2.4.6.jar"
run "find #{current_path}/public/css/ -name '*.css' -print0 | xargs -0 -I file #{cmd} file -o file"
run "find #{current_path}/public/js/ -name '*.js' -print0 | xargs -0 -I file #{cmd} file -o file"
end
or if you prefer to use ruby to program it, you should move the code into a rake task (which you can try and debug locally) and then invoke it with Capistrano: How do I run a rake task from Capistrano?

Resources