#How to ensure that a step is run after some particular step

1 messages · Page 1 of 1 (latest)

near light
#

I am packaging lmdb to use the zig build system for it to be added to the allyourcodebase organization. In my build script I have a test step which builds and installs the test binaries for lmdb into zig-out/test. For the test to run successfully lmdb required a testdb/ directory .ie (zig-out/test/testdb) to exist when the test binaries are run. So I have created a create_testdb sub step which depends on the test step. For create_testdb to work it must be executed after the test binaries have been installed into zig-out/test (I know I can use makePath so that all parent directories are created if they don't already exist but I want to use makeDir for this case and understand how the dependencies of a step are ordered)

So how do I make sure that create_testdb sub step is run only after all the other sub steps (which install the test binaries) of the top level test step are run. Because currently create_testdb sub step is usually run before the test binaries install steps in the top level test step, which leads to a error.FileNotFound because makeDir expects parent directories to already exist.

GitHub

Lmdb using the zig build system. Contribute to Ultra-Code/lmdb development by creating an account on GitHub.

raven linden
#

shouldnt it be create_testdb().dependsOn(test_step)

near light
#

@raven linden create_testdb(b).dependOn(test_step) compiles without error but the testdb/ directory isn't created

soft furnace
#

is it maybe getting istalled in .zig-cache? you might search in your project for a folder named testdb/. not sure, but in make() you might try using step.owner.addInstallDirectory(.{...});

#

another thing you can do to debug is just std.debug.print() from make()

#

to verity its being run

near light
#

Okay let me give it a try

raven linden
near light
#

I didn't create this step using b.step because It isn't supposed to be a dedicated step but a sub step of the zig build test step

near light
#

@soft furnace no testdb/ is created in the cache and using the step.owner.addInstallDirecory approach requires a .source_dir and in this case there is no source directory because all I am trying to do is create a directory in the zig-out/test directory not copy some directory into this location.

#

@soft furnace using the std.debug.print idea with looping through the dependencies of the test step, if I a make it depend on the create_testdb using test_step.dependOn(create_testdb(b)) I see that test indeed depends on create_testdb so my question is are the dependencies run concurrently ? because I assumed it is run one after another and the out put of

for (test_step.dependencies.items) |dep| {
        std.debug.print("dep name is {s}\n", .{dep.name});
}

agrees with me, So if it is running linearly then why is create_testdb executed when the other steps aren't done executing?

raven linden
near light
#

Is there anything I can do to see the order in which the steps (b.addInstallArtifact) are executed ?

#

I have found a work around but it seems like a code smell to me test_step.makeFn = create_testdb.make , I don't understand why all the other approaches aren't working but this?

raven linden
near light
# raven linden could you perhaps share the code for this?

Rereading your comment above, I initially thought the order of the dependencies where for the substep but now that you mentioned it again, I just tried top level steps and that works

    const test_ = b.step("test", "install testdb");
    const create_testdb_step = create_testdb.create_testdb(b);
    test_.dependOn(create_testdb_step);
    create_testdb_step.dependOn(test_step);
#

Thanks a lot @raven linden and @soft furnace

#

how do I mark this thread as answered?

robust galleon
#

you can click the check mark under the first message in the thread