tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

message_compiler.gni (2756B)


      1 # Copyright 2015 The Chromium Authors
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 assert(is_win, "This only runs on Windows.")
      6 
      7 # Runs mc.exe over a list of sources. The outputs (a header and rc file) are
      8 # placed in the target gen dir, and compiled. Sources without a BOM will be
      9 # processed as if they are UTF-16LE. Generated text files will be written in the
     10 # ANSI codepage.
     11 #
     12 # sources
     13 #   List of message files to process.
     14 #
     15 # user_mode_logging (optional bool)
     16 #   Generates user-mode logging code. Defaults to false (no logging code).
     17 #
     18 # compile_generated_code (optional, deafults = true)
     19 #   If unset or true, the generated code will be compiled and linked into
     20 #   targets that depend on it. If set to false, the .h and .rc files will only
     21 #   be generated.
     22 #
     23 # deps, public_deps, visibility
     24 #   Normal meaning.
     25 template("message_compiler") {
     26   if (defined(invoker.compile_generated_code) &&
     27       !invoker.compile_generated_code) {
     28     compile_generated_code = false
     29     action_name = target_name
     30   } else {
     31     compile_generated_code = true
     32     action_name = "${target_name}_mc"
     33     source_set_name = target_name
     34   }
     35 
     36   action_foreach(action_name) {
     37     if (compile_generated_code) {
     38       visibility = [ ":$source_set_name" ]
     39     } else {
     40       forward_variables_from(invoker, [ "visibility" ])
     41     }
     42 
     43     script = "//chromium/build/win/message_compiler.py"
     44 
     45     outputs = [
     46       "$target_gen_dir/{{source_name_part}}.h",
     47       "$target_gen_dir/{{source_name_part}}.rc",
     48     ]
     49 
     50     args = [
     51       # The first argument is the environment file saved to the build
     52       # directory. This is required because the Windows toolchain setup saves
     53       # the VC paths and such so that running "mc.exe" will work with the
     54       # configured toolchain. This file is in the root build dir.
     55       "environment.$target_cpu",
     56 
     57       # Where to put the header.
     58       "-h",
     59       rebase_path(target_gen_dir, root_build_dir),
     60 
     61       # Where to put the .rc file.
     62       "-r",
     63       rebase_path(target_gen_dir, root_build_dir),
     64 
     65       # Sources without a BOM are UTF-16LE.
     66       "-u",
     67     ]
     68     if (defined(invoker.user_mode_logging) && invoker.user_mode_logging) {
     69       args += [ "-um" ]
     70     }
     71     args += [ "{{source}}" ]
     72 
     73     forward_variables_from(invoker,
     74                            [
     75                              "deps",
     76                              "public_deps",
     77                              "sources",
     78                            ])
     79   }
     80 
     81   if (compile_generated_code) {
     82     # Compile the generated rc file.
     83     source_set(source_set_name) {
     84       forward_variables_from(invoker, [ "visibility" ])
     85       sources = get_target_outputs(":$action_name")
     86       deps = [ ":$action_name" ]
     87     }
     88   }
     89 }