1 #!/bin/bash
     
2 
     3 set -e
     
4 
     5 # First param of script must be path to zig std lib
     
6 # like so:
     
7 #
     
8 #   build.sh /home/dave/zig/lib/std/
     
9 #
    
10 # Second param CAN be wildcard match:
    
11 #
    
12 #   $ ./build.sh /home/dave/zig/lib/std/ queue
    
13 #   atomic/queue.zig
    
14 #   priority_queue.zig
    
15 #   priority_dequeue.zig
    
16 #
    
17 # This script ALWAYS writes to a dir called "output/"
    
18 # in the current working directory!
    
19 #
    
20 lib_dir=$1
    
21 matchy=$2
    
22 
    23 # make output dir if it doesn't exist
    
24 mkdir -p output
    
25 
    26 # copy static files first
    
27 cp styles.css output/
    
28 cp index.html output/
    
29 cp zig-stdlib-book.svg output/
    
30 
    31 for file in $(find $lib_dir -name '*.zig')
    
32 do
    
33     # Only output files matching argument 2
    
34     [[ $matchy && $file != *$matchy* ]] && continue
    
35 
    36     # Skip zig-cache!
    
37     [[ $file == *zig-cache* ]] && continue
    
38 
    39     relative_file=${file#"$lib_dir"}
    
40     output_file="output/$relative_file.html"
    
41 
    42     echo $relative_file
    
43     mkdir -p $(dirname $output_file)
    
44     ruby makepage.rb $file $relative_file > $output_file
    
45 done