mac os x

Auto increment build number by run script. (Xcode)

Posted on

1. to add key in your Project-info.plist
CFBuildNumber, CFBuildDate
2. add scripts to your run script (in Xcode)
myPlist=$PROJECT_DIR/$PROJECT_NAME/$PROJECT_NAME-info.plist
CFBuildNumber=$(/usr/libexec/PlistBuddy -c “Print CFBuildNumber" $myPlist)
CFBuildNumber=$(($CFBuildNumber + 1))
/usr/libexec/PlistBuddy -c “Set :CFBuildNumber $CFBuildNumber" $myPlist
CFBuildDate=$(date)
/usr/libexec/PlistBuddy -c “Set :CFBuildDate $CFBuildDate" $myPlist
echo “build number: " $CFBuildNumber

3. get info from Project-info.plist and show on somewhere.
NSString * version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
NSString * buildNo = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildNumber"];
NSString * buildDate = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildDate"];

install ldid

Posted on

get binary from
http://svn.telesphoreo.org/trunk/data/ldid/ldid-1.0.610.tgz
% tar -zxf ldid-1.0.610.tgz
% cd ldid-1.0.610
% g++ -I . -o util/ldid{,.cpp} -x c util/{lookup2,sha1}.c
% sudo cp -a util/ldid /usr/bin

How to: build open source by libtool

Posted on

use libjpeg for example:
% tar zxvf jpegsrc.v6b.tar.gz
% cd jpeg-6b
% cp /usr/share/libtool/config.sub .
% cp /usr/share/libtool/config.guess .
% ./configure –enable-shared –enable-static
% make
% sudo make install
% sudo ranlib /usr/local/lib/libjpeg.a

受保護的文章:setitimer performance

Posted on

該內容受密碼保護。如欲檢視請在下方輸入你的密碼:

hitkey use select

Posted on

set millisecond to 1 cost cpu 98% on
Model Name: MacBook
Model Identifier: MacBook1,1
Processor Name: Intel Core Duo
Processor Speed: 1.83 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache: 2 MB
Memory: 1 GB
Bus Speed: 667 MHz


#include <stdlib.h>
#include <string.h>
#include <sys/select.h>
#include <termios.h>
#include <stdio.h>

static struct termios orig_termios;

static void reset_terminal_mode()
{
tcsetattr(0, TCSANOW, &orig_termios);
}

static void set_conio_terminal_mode()
{
struct termios new_termios;

/* take two copies - one for now, one for later */
tcgetattr(0, &orig_termios);
memcpy(&new_termios, &orig_termios, sizeof(new_termios));

/* register cleanup handler, and set the new terminal mode */
atexit(reset_terminal_mode);
cfmakeraw(&new_termios);
tcsetattr(0, TCSANOW, &new_termios);
}

static int getch()
{
static int r;
static unsigned char c;
if ((r = read(0, &c, sizeof(c))) < 0) {
return r;
} else {
return c;
}
}

int kbhit(unsigned int millisecond)
{
static int r = 0;
static struct timeval tv = { 0L, 0L };
fd_set fds;
FD_SET(0, &fds);
tv.tv_sec = millisecond / 1000000 ;
tv.tv_usec = millisecond % 1000000;
if ( select(1, &fds, NULL, NULL, &tv) )
return getch();
return 0;
}

int main(int argc, char *argv[])
{
int count = 0;
unsigned int millisecond =0;
if ( argc == 2 )
millisecond = atoi(argv[1]);
printf("time:%u\n",millisecond);
set_conio_terminal_mode();

while (!kbhit(millisecond)) {
/* do some work */
//printf("count:%d\n",count++);
}
//(void)getch(); /* consume the character */
}