FB AS3 中,使用条件编译,实现debug、release的代码分离编译。

本文介绍了一种在Flex中利用条件编译进行代码管理和测试的方法。通过实例演示了如何使用CONFIG宏定义区分debug与release版本,使测试代码更加灵活可控。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

如题:


FB AS3 中,使用条件编译,效果类似:VS的#if DEBUG与#if RELEASE,相比之下,FB中的宏定义更灵活


这样做,我们测试代码就可以更灵活的管理了。


在网上搜查了一下相关资料,得出DEMO:以下是我的个人测试:







源码:


package
{
	import flash.display.Sprite;
	
	/**
	 *  Create By Jave.Lin(afeng)<br/>
	 *  2012-7-9 上午9:49:18<br/>
	 *  <b/>
	 *  [description]
	 **/
	public class TestConfigDebug extends Sprite
	{
		public function TestConfigDebug()
		{
			super();
			
			
			CONFIG::debug{
				function test():void
				{
					trace("debug test function");
				}
				trace("[debug trace : 1111111]");
			};
			
			trace("normal trace : 11111111");
			
			CONFIG::release{
				function test():void
				{
					trace("release test function");
				}
				trace("release trace : 2323112314");
			}
			
			trace("normal trace : [2222222]");
			test();
			
			trace("CONFIG::TEST_DEFINE_CONST's value : ",CONFIG::TEST_DEFINE_CONST);
			trace("TEST::FLAG's value : ",TEST::FLAG);
		}
	}
}

交叉编译 Qt 5.14.2 源码,需要先安装交叉编译工具链和对应的库文件,然后使用 Qt 的 configure 工具进行配置,最后进行编译。 以下是一个简单的步骤: 1. 安装交叉编译工具链和库文件,例如 arm-linux-gnueabihf-gcc 和 libssl-dev。可以参考交叉编译工具链的文档或者咨询厂商的技术支持。 2. 下载 Qt 5.14.2 源码包,解压后进入源码目录。 3. 配置 Qt 的编译选项,使用 configure 工具。可以使用以下命令: ``` ./configure -prefix /opt/qt5 \ -release -opensource -confirm-license \ -no-icu -no-opengl -no-xcb -no-glib -no-pulseaudio \ -no-feature-bearermanagement -no-feature-ftp \ -no-feature-socks5 -no-feature-xmlstream -no-feature-xml \ -no-feature-qml-debug -no-feature-process -no-feature-sharedmemory \ -no-feature-animation -no-feature-printer -no-feature-qml-network \ -no-feature-qml -no-feature-qml-debug -no-feature-qml-designer \ -no-feature-qml-filesystem -no-feature-qml-debugger -no-feature-qml-workerscript \ -no-feature-qml-xmlhttprequest -no-feature-qml-workercontext \ -no-feature-qml-websockets -no-feature-qml-webchannel \ -no-feature-qml-mirroring -no-feature-qml-live-reload \ -no-feature-qml-context2d \ -opensource -confirm-license \ -no-sql-sqlite -no-sql-sqlite2 -no-sql-odbc -no-sql-psql \ -no-sql-mysql -no-sql-ibase -no-sql-tds -no-sql-tds \ -no-ssl -no-openssl \ -no-feature-geoservices -no-feature-geoservices-mapboxgl \ -no-feature-geoservices-nokia -no-feature-geoservices-google \ -no-feature-geoservices-here -no-feature-geoservices-mapbox \ -no-feature-geoservices-osm \ -no-feature-testlib \ -no-qml-debug \ -no-widgets \ -no-gui \ -no-iconv \ -no-compile-examples \ -no-cups \ -no-dbus \ -no-fontconfig \ -no-freetype \ -no-harfbuzz \ -no-journald \ -no-kms \ -no-linuxfb \ -no-mirclient \ -no-mtdev \ -no-pcre \ -no-pulseaudio \ -no-rpath \ -no-sm \ -no-syslog \ -no-tslib \ -no-xcb-xinput \ -no-xkbcommon \ -no-xinerama \ -no-xinput \ -no-xkb \ -no-xcursor \ -no-xfixes \ -no-xrandr \ -no-xrender \ -no-xshape \ -no-xsync \ -no-xvideo \ -no-zlib \ -no-eglfs \ -no-gbm \ -no-directfb \ -no-linuxfb \ -no-mirclient \ -no-wayland \ -no-icu \ -no-opengl \ -no-glib \ -platform linux-g++-32 \ -xplatform linux-arm-gnueabi-g++ \ -device-option CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- \ -device-option SYSROOT=/path/to/sysroot ``` 其中,-prefix 指定 Qt 的安装路径,-xplatform 指定交叉编译的平台,-device-option 指定交叉编译工具链的前缀和 sysroot 路径。 4. 执行 make 命令进行编译。 5. 执行 make install 命令进行安装。 完成以上步骤后,就能在指定的安装路径下找到交叉编译后的 Qt 库和工具了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值