Is there a tool to migrate from make to waf?

I want to migrate a large project using make to waf . Are there any tools that can help automate the process to some extent?

+4
source share
1 answer

No, no, but migration is not so complicated.

If you've never used waf before, look at an example from the demos/ folder ( c is typical) and retell the waf book .

Then from make to waf:

  • at the configuration stage implemented by the configure() function, initialize the necessary high-level tools and define relationships with external libraries using high-level tools, if possible (for example, check_cfg() processes pkg-config(1) ) or return to the definition of {DEFINES,INCLUDE,LIB,...}_$LIBNAME , for example:

     def configure(cfg): # I want to do C with any available compiler cfg.load("compiler_c") # will detect MSVC, GCC, or other common compilers # always include cwd cfg.env.INCLUDES += ['.'] # I want to link all my programs with pthread cfg.env.LIB += ['pthread'] # I want to link with static zlib cfg.env.STLIB_Z += ['z'] # I want to use pkg-config to tell me how to link with pjsip # and avoid typing the risky -DPJ_AUTOCONF=1 -pipe -O2 -march=k8-sse3 -mcx16 -msahf -mno-movbe -mno-aes -mno-pclmul -mno-popcnt -mno-abm -mno-lwp -mno-fma -mno-fma4 -mno-xop -mno-bmi -mno-tbm -mno-avx -mno-sse4.2 -mno-sse4.1 --param l1-cache-size=64 l1-cache-line-size=64 l2-cache-size=512 -mtune=k8 -DPJ_IS_BIG_ENDIAN=0 -DPJ_IS_LITTLE_ENDIAN=1 -I/home/portage/tmp/net-libs-pjsip-1.12/image//usr/include -L/home/portage/tmp/net-libs-pjsip-1.12/image//usr/lib -lpjsua -lpjsip-ua -lpjsip-simple -lpjsip -lpjmedia-codec -lpjmedia -lpjmedia-audiodev -lpjnath -lpjlib-util -lresample -lmilenage -lsrtp -lg7221codec -lpj -lm -luuid -lnsl -lrt -lpthread -lasound -lcrypto -lssl -lopencore-amrnb # the *_PJSIP variables will be created cfg.check_cfg( package='libpjproject', uselib_store='PJSIP', args='--libs --cflags', ) 

    avoid using *FLAGS if possible, as they are compiler specific.

  • replace standard makefile rules with high-level rules (using tools created in configure() ), for example.

     bld( target='mylib', features='c', # see note source=['a.c', 'b.c'], use=['Z', 'PJSIP'], ) bld( target='name', features='c cprogram', source=['main.c'], use=['mylib'], ) 
  • Non-standard rules and high-level tools can be created if necessary, see the waf book

In general, build scripts will be shorter and easier to read than make files. They are more linear, and their content is more semantic.

Please note that you do not need to create static libraries unless you plan to export them. waf tools do not use the shell to invoke programs, so limiting the length of the command line (the main reason for creating internal static libraries) is not a problem.

+3
source

Source: https://habr.com/ru/post/1393815/


All Articles