File: phony-inputs.ninja

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (68 lines) | stat: -rw-r--r-- 2,393 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Check the handling of inputs that also have phony edges.

# Check that we handle phony rules for actual input files properly, and rebuild
# targets that depend on them if the input actually exists and it changes.

# RUN: rm -rf %t.build
# RUN: mkdir -p %t.build
# RUN: cp %s %t.build/build.ninja
# RUN: ln -s %S/Inputs %t.build/Inputs


# Check that the initial build creates 'output' properly, even though 'input'
# does not exist.
#
# RUN: %{llbuild} ninja build --jobs 1 --chdir %t.build &> %t1.out
# RUN: %{FileCheck} --check-prefix=CHECK-INITIAL < %t1.out %s
# RUN: %{FileCheck} --check-prefix=CHECK-OUTPUT-INITIAL < %t.build/output %s
#
# CHECK-INITIAL: SIZING input TO output
# CHECK-OUTPUT-INITIAL: input does not exist


# Check that a rebuild continues to run the output rule.
#
# RUN: %{llbuild} ninja build --jobs 1 --chdir %t.build &> %t1.out
# RUN: %{FileCheck} --check-prefix=CHECK-NEXT < %t1.out %s
# RUN: %{FileCheck} --check-prefix=CHECK-OUTPUT-NEXT < %t.build/output %s
#
# CHECK-NEXT: SIZING input TO output
# CHECK-OUTPUT-NEXT: input does not exist


# Check that the output rule gets rebuilt when we create 'input'.
#
# RUN: touch %t.build/input
# RUN: %{llbuild} ninja build --strict --jobs 1 --chdir %t.build &> %t1.out
# RUN: %{FileCheck} --check-prefix=CHECK-WITH-INPUT < %t1.out %s
# RUN: %{FileCheck} --check-prefix=CHECK-OUTPUT-WITH-INPUT < %t.build/output %s
#
# CHECK-WITH-INPUT: SIZING input TO output
# CHECK-OUTPUT-WITH-INPUT: input size: 0


# Check that the output rule no longer gets rebuilt ever build.
#
# RUN: %{llbuild} ninja build --jobs 1 --chdir %t.build &> %t1.out
# RUN: %{FileCheck} --check-prefix=CHECK-NEXT-WITH-INPUT < %t1.out %s
#
# CHECK-NEXT-WITH-INPUT: no work to do


# Check that the output rule does get rebuilt if input changes.
#
# RUN: echo -n "X" > %t.build/input
# RUN: %{llbuild} ninja build --strict --jobs 1 --chdir %t.build &> %t1.out
# RUN: %{FileCheck} --check-prefix=CHECK-WITH-NEW-INPUT < %t1.out %s
# RUN: %{FileCheck} --check-prefix=CHECK-OUTPUT-WITH-NEW-INPUT < %t.build/output %s
#
# CHECK-WITH-NEW-INPUT: SIZING input TO output
# CHECK-OUTPUT-WITH-NEW-INPUT: input size: 1

rule GETSIZE
     command = if [ -f $in ]; then echo "input size: $$(Inputs/get-file-size $in)"; else echo "input does not exist"; fi > $out
     description = SIZING $in TO $out

build input: phony
build output: GETSIZE input
default output