文章标签 » gcc

接上一篇

有必要给blogo2加个追加功能。。可以直接把mail追加到最新一篇blog的后面
————————
gcc之预处理js和as,下面的makefile主要处理flash的两个版本,SSL版本要比普通版本大150K。。感谢gcc

FLAGS="-DDEBUG"
 
define make-all
	gcc $(FLAGS) $1 -E -x c src/swfsocket.js -o $2/swfsocket.js 
	gcc $(FLAGS) $1 -E -x c src/swf/SwfSocket.rel.as -o src/swf/SwfSocket.as
	sed -i "/^#/d" $2/swfsocket.js
	sed -i "/^#/d" src/swf/SwfSocket.as
	cd src/swf; \
	mxmlc -static-link-runtime-shared-libraries -output=./SwfSocket.swf SwfSocketMain.as
	mv src/swf/SwfSocket.swf $2 
endef
 
main:
	$(call make-all,,bin)
	$(call make-all,-DSSL,bin_ssl)

———–
post by gmail~

gcc预处理用于其他语言也很好用啊

header.js

function SSL_socket()
{
    alert('SSL');
}
 
function socket()
{
    alert('normal');
}

main.js

#include "header.js"
#ifdef _SSL
var socket = new SSL_socket();
#else
var socket = new socket();
#endif
gcc -E -x c main.js 
# 1 "main.js"
# 1 ""
# 1 ""
# 1 "main.js"
# 1 "header.js" 1
function SSL_socket()
{
    alert('SSL');
}

function socket()
{
    alert('normal');
}
# 2 "main.js" 2



var socket = new socket();
gcc -E -x c -D_SSL main.js 
# 1 "main.js"
# 1 ""
# 1 ""
# 1 "main.js"
# 1 "header.js" 1
function SSL_socket()
{
    alert('SSL');
}

function socket()
{
    alert('normal');
}
# 2 "main.js" 2

var socket = new SSL_socket();

———–
post by gmail~