buildserver — Build XATMI server executable
Build server is a binary which generates main() entry point for the server process. Also server processes can be configured at build stage to statically advertise services, passed to command line. Once the main entry point and advertise tables are generate, the C compiler is invoked to which generated and user files are passed.
It is possible to override the functionality of the generated main() function by enabling TMMAINEXIT macro for build. If macro is set, then after generated variable definition "mainexit.h" header is included, which may contain custom code.
The generated server entry point looks like:
/* Buildserver auto-generated code */ /*---------------------------Includes-----------------------------------*/ #include <stdio.h> #include <stdlib.h> #include <ndebug.h> #include <atmi.h> #include <ndrstandard.h> #include <ubf.h> #include <string.h> #include <unistd.h> #include <xa.h> /*---------------------------Externs------------------------------------*/ /* Buildserver auto generated extern service list */ extern void TESTFUNC (TPSVCINFO *); /*---------------------------Macros-------------------------------------*/ /*---------------------------Enums--------------------------------------*/ /*---------------------------Typedefs-----------------------------------*/ /*---------------------------Globals------------------------------------*/ /*---------------------------Statics------------------------------------*/ /* Auto generated system advertise table */ expublic struct tmdsptchtbl_t ndrx_G_tmdsptchtbl[] = { {"TESTSVC","TESTFUNC",(void (*)(TPSVCINFO *)) TESTFUNC, 0, 0 }, { NULL, NULL, NULL, 0, 0 } }; /*---------------------------Prototypes---------------------------------*/ /* Buildserver main */ int main( int argc, char** argv ) { _tmbuilt_with_thread_option=0; struct tmsvrargs_t tmsvrargs = { &tmnull_switch, &ndrx_G_tmdsptchtbl[0], 0, tpsvrinit, tpsvrdone, NULL, NULL, NULL, NULL, NULL }; #ifdef TMMAINEXIT #include "mainexit.h" #endif return( _tmstartserver( argc, argv, &tmsvrargs )); }
The command line template, how C compiler is invoked, is following:
<CC> [$CFLAGS] -o <binary_name> <generated_source>.c [-I<$NDRX_HOME>/include -L<NDRX_HOME>/{lib|lib64}] [<first_files>] [<RM_libs>] -latmisrvinteg -latmi -lubf -lnstd [<last_files>]
All filesystem path related buffers internally are set to 5120 bytes + EOS byte, thus for example if build command is longer than 5120, it will be truncated to 5120.
The file format for service advertise is basically the same as -s parameter. Each line shall contain either SOMESVC[,OTHERSVC]:SOMEFUNC or SOMESVC or :SOMEFUNC. File format ignores lines starting with # or empty (white space filled) lines.
Sample file (advertise_file.txt, included by -s @advertise_file.txt to buildserver):
# # This file exports some functions for test purposes # FI1,FI2:ECHOSV ECHO2SV ECHO2SV :SERV
Resource manager file format accepts # as comments, and parser ignores whitespace/empty lines. The format is <rm_name>:<switch_name>:<libraries>
Sample definitions:
# # This is test file of the switches # nullsw:tmnull_switch: TestSw:ndrxstatsw: -L ../test021_xafull -l xadrv # # Oracle static registration switch: # Oracle_XA:xaosw:-L$(ORACLE_HOME)/lib -lclntsh
There are certain flags which must be passed to the compilers, in order to get binaries successfully linked.
AIX OS - xlC Compiler:
AIX OS - GCC Compiler:
See atmitest/test071_buildtools/run.sh for samples. Some of them:
$ export CC=cc $ export CFLAGS="-g -I../../include -L../../libatmi -L../../libubf -L../../libatmisrv -L../../libnstd" $ buildserver -o atmi.sv71 -rTestSw -a atmisv71_1.c -l atmisv71_2.c -v \ -s A,B,C:TESTSV -sECHOSV -s:TESTSV -sZ:ECHOSV -f atmisv71_3.c -l atmisv71_4.c \ -s @advertise_file.txt
That would result in following compilation unit:
$ cc -g -I../../include -L../../libatmi -L../../libubf -L../../tmsrv -L../../libatmisrv \ -L../../libexuuid -L../../libexthpool -L../../libnstd -o atmi.sv71 ndrx_bs_xw4wIZ.c \ -I./include -L./lib atmisv71_1.c atmisv71_3.c -L ../test021_xafull -l xadrv -latmisrvinteg \ -latmi -lubf -lnstd -lrt -ldl -lm -lc -lpthread atmisv71_2.c atmisv71_4.c