In one of our projects, I have a need to build a library, using waf. The library has multiple steps, like it builds a binary, then executes the binary to generate a few more files, and those files are included in further builds. To run the binary (which got generated in the intermediate step), I need its path - as string, so that I can prefix to the binary. From the Waf book, I saw an example, and some references to bld.path.find_dir() and bld.path.parent.find_dir(). But these functions do not return path as string. And, there is bld.path.abspath() which returns the source path as string.

I want to be able to get the path to the binary file which got generated. Here is a snippet of what I am trying:

    bld.program(
                source              =       my_sources,
                target              =       'my_binary', # <-- path to this
                includes            =       my_includes,
                cflags              =       my_cflags,
                linkflags           =       my_ldflags
            )
    bld.add_group()
    # use the above generated binary file

P.S This might seem fairly trivial, but I come from make background, and new to waf !

Thanks.

--EDIT--

I am able to build the my_binary here, but I want to get its abs path, and reference it in the further steps

有帮助吗?

解决方案

build/${build_target}/${your_binary} - unless you overwrite some default value

Update#1

A cut down thing that should keep you going, especially the derival of build targets, also be sure to check the waf book which includes a lot of examples.

def configure(ctx):
    ctx.load(...)
    ctx.env.appname = APPNAME
    ctx.env.version = VERSION

    ctx.define(...)

    ctx.check_cc(...)


    ctx.setenv('debug', env=ctx.env.derive())
    ctx.env.CFLAGS = ['-ggdb', '-Wall']
    ctx.define('DEBUG',1)

    ctx.setenv('release', env=ctx.env.derive())
    ctx.env.CFLAGS = ['-O2', '-Wall']
    ctx.define('RELEASE',1)


def build(bld):
            ### subdirs :) under build are usually related to build variant or command
            print (">>>>> "+bld.cmd)
            print (">>>>> "+bld.variant)
        bin = bld.program(...)



from waflib.Build import BuildContext

class release(BuildContext):
      cmd = 'release'
      variant = 'release'

class debug(BuildContext):
      cmd = 'debug'
      variant = 'debug'
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top