Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a tool to help migrate from make to waf?

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

like image 321
fredley Avatar asked Oct 09 '22 21:10

fredley


1 Answers

No, there isn't, but the migration isn't that complex.

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

Then, from make to waf:

  • in the configure step, materialized by the configure() function, instanciate the needed high-level tools and define the relations to external libraries using high-level tools if possible (eg. check_cfg() handles pkg-config(1)) or fall back in defining {DEFINES,INCLUDE,LIB,...}_$LIBNAME, eg:
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 by high level rules (using tools instanciated in configure()), eg.
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 needed, see waf book

Overall, the build scripts will be shorter and easier to read than makefiles. They are more linear, and their content is more semantical.

Note that you don't need to create static libraries if you don't plan to export them. waf tools does not use the shell to call programs, so the command-line length limit (main reason to create internal static libs) is not a problem.

like image 169
cJ Zougloub Avatar answered Oct 13 '22 11:10

cJ Zougloub