gitout

A static git page generator
git clone https://git.bracken.jp/gitout.git
Log | Files | Refs | Submodules | README | LICENSE

BUILD.gn (5002B)


      1 # Each toolchain must define "stamp" and "copy" tools,
      2 # but they are always the same in every toolchain.
      3 stamp_command = "touch {{output}}"
      4 stamp_description = "STAMP {{output}}"
      5 
      6 # We use link instead of copy; the way "copy" tool is being used is
      7 # compatible with links since Ninja is tracking changes to the source.
      8 copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
      9 copy_description = "COPY {{source}} {{output}}"
     10 
     11 toolchain("clang") {
     12   cc = "clang"
     13   cxx = "clang++"
     14   ld = cxx
     15   ar = "ar"
     16 
     17   tool("cc") {
     18     depfile = "{{output}}.d"
     19     command = "$cc -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
     20     depsformat = "gcc"
     21     description = "CC {{output}}"
     22     outputs =
     23         [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
     24   }
     25 
     26   tool("cxx") {
     27     depfile = "{{output}}.d"
     28     command = "$cxx -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
     29     depsformat = "gcc"
     30     description = "CXX {{output}}"
     31     outputs =
     32         [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
     33   }
     34 
     35   tool("asm") {
     36     depfile = "{{output}}.d"
     37     command = "$cc -MD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
     38     depsformat = "gcc"
     39     description = "ASM {{output}}"
     40     outputs =
     41         [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
     42   }
     43 
     44   tool("objc") {
     45     depfile = "{{output}}.d"
     46     command = "$cc -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objc}} -c {{source}} -o {{output}}"
     47     depsformat = "gcc"
     48     description = "OBJC {{output}}"
     49     outputs =
     50         [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
     51   }
     52 
     53   tool("objcxx") {
     54     depfile = "{{output}}.d"
     55     command = "$cxx -MD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} {{cflags_objcc}} -c {{source}} -o {{output}}"
     56     depsformat = "gcc"
     57     description = "OBJCXX {{output}}"
     58     outputs =
     59         [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
     60   }
     61 
     62   tool("alink") {
     63     rspfile = "{{output}}.rsp"
     64     command = "rm -f {{output}} && $ar rcs {{output}} {{inputs}}"
     65     description = "AR {{output}}"
     66     rspfile_content = "{{inputs}}"
     67     outputs = [ "{{output_dir}}/{{target_output_name}}{{output_extension}}" ]
     68     default_output_dir = "{{target_out_dir}}"
     69     default_output_extension = ".a"
     70     output_prefix = "lib"
     71   }
     72 
     73   tool("solink") {
     74     outname = "{{target_output_name}}{{output_extension}}"
     75     outfile = "{{output_dir}}/$outname"
     76     rspfile = "$outfile.rsp"
     77     unstripped_outfile = outfile
     78     if (use_strip) {
     79       unstripped_outfile = "{{output_dir}}/lib.unstripped/{{target_output_name}}{{output_extension}}"
     80     }
     81     if (target_os == "mac") {
     82       command = "$ld -shared {{ldflags}} -Wl,-install_name,@rpath/\"{{target_output_name}}{{output_extension}}\" -o \"$unstripped_outfile\" -Wl,-filelist,\"$rspfile\" {{libs}} {{solibs}}"
     83       rspfile_content = "{{inputs_newline}}"
     84       default_output_extension = ".dylib"
     85     } else {
     86       command = "$ld -shared {{ldflags}} -o \"$unstripped_outfile\" -Wl,--Map=\"$unstripped_outfile.map\" -Wl,-soname=\"$outname\" @\"$rspfile\""
     87       rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}"
     88       default_output_extension = ".so"
     89     }
     90     if (use_strip) {
     91       command += " && strip --strip-all \"$unstripped_outfile\" \"$outfile\""
     92     }
     93     description = "SOLINK $outfile"
     94     default_output_dir = "{{root_out_dir}}"
     95     output_prefix = "lib"
     96     outputs = [ outfile ]
     97     if (outfile != unstripped_outfile) {
     98       outputs += [ unstripped_outfile ]
     99     }
    100   }
    101 
    102   tool("link") {
    103     outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
    104     rspfile = "$outfile.rsp"
    105     unstripped_outfile = outfile
    106     if (use_strip) {
    107       unstripped_outfile = "{{root_out_dir}}/exe.unstripped/{{target_output_name}}{{output_extension}}"
    108     }
    109     if (target_os == "mac") {
    110       command = "$ld {{ldflags}} -o \"$unstripped_outfile\" -Wl,-filelist,\"$rspfile\" {{frameworks}} {{solibs}} {{libs}}"
    111       rspfile_content = "{{inputs_newline}}"
    112     } else {
    113       command = "$ld {{ldflags}} -o \"$unstripped_outfile\" -Wl,--Map=\"$unstripped_outfile.map\" -Wl,--start-group @\"$rspfile\" {{solibs}} -Wl,--end-group {{libs}}"
    114       rspfile_content = "{{inputs}}"
    115     }
    116     if (use_strip) {
    117       command +=
    118           " && cp \"$unstripped_outfile\" \"$outfile\" && strip \"$outfile\""
    119     }
    120     description = "LINK $outfile"
    121     default_output_dir = "{{root_out_dir}}"
    122     outputs = [ outfile ]
    123     if (outfile != unstripped_outfile) {
    124       outputs += [ unstripped_outfile ]
    125     }
    126   }
    127 
    128   tool("stamp") {
    129     command = stamp_command
    130     description = stamp_description
    131   }
    132 
    133   tool("copy") {
    134     command = copy_command
    135     description = copy_description
    136   }
    137 }