Skip to content

feat: regenerate build.ninja when dub.json or dub.selections.json change - #3134

Merged
thewilsonator merged 15 commits into
dlang:masterfrom
hariprakazz:self-regen-feature
Aug 1, 2026
Merged

feat: regenerate build.ninja when dub.json or dub.selections.json change#3134
thewilsonator merged 15 commits into
dlang:masterfrom
hariprakazz:self-regen-feature

Conversation

@hariprakazz

Copy link
Copy Markdown
Contributor

Adds a regen rule and build.ninja edge so it rebuilds itself
automatically whenever dub.json changes (dub.selections.json too,
if present).

Independent of #3130 (makedeps-v3, still unmerged) - builds cleanly
on current upstream/master with subpkg (#3133) already merged.

Test verifies the actual behavior, not just config text: touches
dub.json, runs ninja, and asserts "Regenerating build.ninja" genuinely
appears in the output. Confirmed the test fails when the regen rule
is removed and passes when restored. Verified via fresh clone build.

Added a regen rule plus a build edge for build.ninja so it rebuilds
itself whenever dub.json or dub.selections.json changes. Only adds
selections.json as a dependency if it actually exists, since packages
with no deps don't have one.

Test checks for the regen rule, the generator attribute, and the
build edge in ninja-generator.sh. Verified it breaks without this and
works with it.

Signed-off-by: Hariprakash V <hariprakash4389285@gmail.com>
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown

✅ PR OK, no changes in deprecations or warnings

Total deprecations: 0

Total warnings: 0

Build statistics:

 statistics (-before, +after)
-executable size=5722856 bin/dub
-rough build time=53s
+executable size=5726952 bin/dub
+rough build time=54s
Full build output
DUB version 1.41.0, built on Mar  1 2026
LDC - the LLVM D compiler (1.42.0):
  based on DMD v2.112.1 and LLVM 21.1.8
  built with LDC - the LLVM D compiler (1.42.0)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: znver4
  https://dlang.org - https://wiki.dlang.org/LDC


  Registered Targets:
    aarch64     - AArch64 (little endian)
    aarch64_32  - AArch64 (little endian ILP32)
    aarch64_be  - AArch64 (big endian)
    amdgcn      - AMD GCN GPUs
    arm         - ARM
    arm64       - ARM64 (little endian)
    arm64_32    - ARM64 (little endian ILP32)
    armeb       - ARM (big endian)
    avr         - Atmel AVR Microcontroller
    bpf         - BPF (host endian)
    bpfeb       - BPF (big endian)
    bpfel       - BPF (little endian)
    hexagon     - Hexagon
    lanai       - Lanai
    loongarch32 - 32-bit LoongArch
    loongarch64 - 64-bit LoongArch
    mips        - MIPS (32-bit big endian)
    mips64      - MIPS (64-bit big endian)
    mips64el    - MIPS (64-bit little endian)
    mipsel      - MIPS (32-bit little endian)
    msp430      - MSP430 [experimental]
    nvptx       - NVIDIA PTX 32-bit
    nvptx64     - NVIDIA PTX 64-bit
    ppc32       - PowerPC 32
    ppc32le     - PowerPC 32 LE
    ppc64       - PowerPC 64
    ppc64le     - PowerPC 64 LE
    r600        - AMD GPUs HD2XXX-HD6XXX
    riscv32     - 32-bit RISC-V
    riscv64     - 64-bit RISC-V
    sparc       - Sparc
    sparcel     - Sparc LE
    sparcv9     - Sparc V9
    spirv       - SPIR-V Logical
    spirv32     - SPIR-V 32-bit
    spirv64     - SPIR-V 64-bit
    systemz     - SystemZ
    thumb       - Thumb
    thumbeb     - Thumb (big endian)
    ve          - VE
    wasm32      - WebAssembly 32-bit
    wasm64      - WebAssembly 64-bit
    x86         - 32-bit X86: Pentium-Pro and above
    x86-64      - 64-bit X86: EM64T and AMD64
    xcore       - XCore
    xtensa      - Xtensa 32
   Upgrading project in /home/runner/work/dub/dub/
    Starting Performing "release" build using /opt/hostedtoolcache/dc/ldc2-1.42.0/x64/ldc2-1.42.0-linux-x86_64/bin/ldc2 for x86_64.
    Building dub 1.42.0-beta.1+commit.28.g296e4d11: building configuration [application]
     Linking dub
STAT:statistics (-before, +after)
STAT:executable size=5726952 bin/dub
STAT:rough build time=54s

Comment thread test/ninja-generator.sh Outdated
Comment thread test/ninja-generator.sh Outdated
Comment thread test/ninja-generator.sh Outdated
@thewilsonator
thewilsonator requested a review from atilaneves July 23, 2026 10:50

@atilaneves atilaneves left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still doesn't handle dub.sdl

Comment thread source/dub/generators/ninja.d Outdated
Comment thread test/ninja-generator.sh Outdated
Comment thread test/ninja-generator.script.d Outdated
Comment thread test/ninja-generator.script.d Outdated
The regen test only checked for the log message and exit status, which
could pass even if build.ninja wasn't actually regenerated. Now it also
mutates the recipe (dub.json/dub.sdl) to add an extra import path and
checks that build.ninja actually reflects the change, per Atila's review.

Also fixes lflags the same way src/regenInputs were already fixed:
escaping paths so Windows drive-letter colons don't break ninja.
@atilaneves
atilaneves enabled auto-merge July 31, 2026 11:03
@hariprakazz

Copy link
Copy Markdown
Contributor Author

Hi Atila, thanks for approving this one. Quick follow up on #3130 (makedeps) too. I asked on the 22nd whether it landed some other way or needs resubmitting, haven't heard back yet. I've got the commit ready to reapply on current master if you'd like a fresh PR, just want your go ahead first since #3129/#3130 already caused mixup once. No rush, just flagging since final GSoC submissions open Aug 17.

@thewilsonator
thewilsonator disabled auto-merge August 1, 2026 08:09
@thewilsonator
thewilsonator merged commit 2c72f43 into dlang:master Aug 1, 2026
26 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants