上周末参加了上海开源软件的活动,认识了RT-Thread的发起者,为身边有那么多技术的狂热者感到高兴。
他们在几年的时间把RT-Thread做的这么优秀真的很辛苦,在这里支持他们一下。
会议中讨论到了RTOS的配制性,觉得这个问题可以讨论的更清晰些,这里针对eCos可配置性的实现稍作介绍。
cdl_component CYGBLD_MICROWINDOWS_NANOX_SERVER { display "Nano-X Server/Client" default_value 1 implements CYGBLD_MICROWINDOWS_NANOX_SETUP # NANO X compile \ nanox/srvmain.c \ nanox/srvfunc.c \ nanox/srvutil.c \ nanox/srvevent.c \ nanox/srvclip.c \ nanox/srvnet.c \ nanox/clientfb.c \ nanox/client.c \ nanox/error.c \ nanox/nxdraw.c \ nanox/nxproto.c \ nanox/nxutil.c
我所提到的预编译主要是指我们通常所说的预编译宏,我们可以在代码中根据这些宏定义决定在程序中编译那部分代码。
图形配置界面
实现配置的脚本
description "Touch screen driver for the MINI2440" cdl_option CYGPKG_DEVS_TOUCH_BLOCKREAD { display "touch driver is blockread method" flavor bool default_value 0 description " This option modifies the touch driver read method to blockread or not." }
代码中是如何根据配置来编译的
static Cyg_ErrNo ts_lookup(struct cyg_devtab_entry **tab, struct cyg_devtab_entry *st, const char *name) { if (!_is_open) { _is_open = true; #if CYGPKG_DEVS_TOUCH_BLOCKREAD cyg_drv_mutex_init(&res_lock); cyg_drv_cond_init(&res_wait,&res_lock); #endif cyg_drv_interrupt_create(CYGNUM_HAL_INTERRUPT_ADC, 0, (CYG_ADDRWORD)0, cyg_mini2440_ts_isr, cyg_mini2440_ts_dsr, &ts_thread_handle, &ts_thread_data); cyg_drv_interrupt_attach(ts_thread_handle); cyg_drv_interrupt_unmask(CYGNUM_HAL_INTERRUPT_ADC); } return ENOERR; }
有时候为了提高运行效率或者打开编译器的某些调试选项,我们常常要为编译器加入特定的参数。
比如 -O2 为GCC加入2级优化, -g 开启调试选项,在编译好的可执行文件中加入更多的调试信息。
配置界面
实现配置脚本
cdl_component CYGPKG_MICROWINDOWS_OPTIONS { display "Build options" flavor none no_define description " Package specific build options including control over compiler flags used only in building this package, and details of which tests are built." cdl_option CYGPKG_MICROWINDOWS_CFLAGS_ADD { display "Additional compiler flags" flavor data no_define default_value { "-I$(PREFIX)/include/microwin -D__ECOS=1 -DMSDOS=0 -DELKS=0 -D__rtems__=0 -D_MINIX=0 -DNOTYET=0 -DUNIX=1 -DHAVE_FILEIO -DHAVE_BMP_SUPPORT=1 -DHAVE_PNM_SUPPORT=1 -DHAVE_XPM_SUPPORT=1 -DxHAVE_JPEG_SUPPORT=1 -DHAVESELECT=1" } description " This option modifies the set of compiler flags for building the MicroWindows package. These flags are used in addition to the set of global flags." } cdl_option CYGPKG_MICROWINDOWS_CFLAGS_REMOVE { display "Suppressed compiler flags" flavor data no_define default_value { "" } description " This option modifies the set of compiler flags for building the MicroWindows package. These flags are removed from the set of global flags if present." } }