| 1 | """
|
| 2 | bin/NINJA_subgraph.py
|
| 3 | """
|
| 4 | from __future__ import print_function
|
| 5 |
|
| 6 | from glob import glob
|
| 7 | from fnmatch import fnmatch
|
| 8 |
|
| 9 | from build import ninja_lib
|
| 10 | from build.ninja_lib import mycpp_binary, mycpp_library, main_cc, log
|
| 11 |
|
| 12 | _ = log
|
| 13 |
|
| 14 |
|
| 15 | def NinjaGraph(ru):
|
| 16 | n = ru.n
|
| 17 |
|
| 18 | ru.comment('Generated by %s' % __name__)
|
| 19 |
|
| 20 | #
|
| 21 | # Files embedded in binary
|
| 22 | #
|
| 23 |
|
| 24 | n.rule('embedded-file-gen',
|
| 25 | command='_bin/shwrap/embedded_file_gen $in > $out',
|
| 26 | description='embedded_file_gen $in $out')
|
| 27 |
|
| 28 | # Generated by build/py.sh all -> build/doc.sh all-help
|
| 29 | # I wish Ninja had DIRECTORY-level dependencies? Because this should
|
| 30 | # ultimately depend on doc/ref/*.md
|
| 31 | # We could probably create a _build/ninja-stamp/HELP file and so forth
|
| 32 | files = glob('_devbuild/help/*')
|
| 33 |
|
| 34 | # OSH and YSH stdlib
|
| 35 | tmp = glob('stdlib/ysh/*.ysh') + glob('stdlib/osh/*.sh')
|
| 36 |
|
| 37 | # Remove this?
|
| 38 | tmp.extend(glob('stdlib/*.ysh'))
|
| 39 |
|
| 40 | # exclude test files
|
| 41 | for path in tmp:
|
| 42 | if fnmatch(path, '*-test.ysh'):
|
| 43 | continue
|
| 44 | if fnmatch(path, '*-test.sh'):
|
| 45 | continue
|
| 46 | if fnmatch(path, '*/draft-*'):
|
| 47 | continue
|
| 48 |
|
| 49 | files.append(path)
|
| 50 |
|
| 51 | # Make sure it's DETERMINISTIC
|
| 52 | files.sort()
|
| 53 |
|
| 54 | n.build(['_gen/bin/text_files.cc'],
|
| 55 | 'embedded-file-gen',
|
| 56 | files,
|
| 57 | implicit=['_bin/shwrap/embedded_file_gen'])
|
| 58 | n.newline()
|
| 59 |
|
| 60 | ru.cc_library('//bin/text_files', srcs=['_gen/bin/text_files.cc'])
|
| 61 |
|
| 62 | #
|
| 63 | # Programs
|
| 64 | #
|
| 65 |
|
| 66 | hello_py_inputs = ninja_lib.TryDynamicDeps('bin/hello.py')
|
| 67 |
|
| 68 | # library //bin/hello.mycpp
|
| 69 | mycpp_library(
|
| 70 | ru,
|
| 71 | 'bin/hello.py',
|
| 72 | py_inputs=hello_py_inputs,
|
| 73 | deps=['//mycpp/runtime_pure'],
|
| 74 | )
|
| 75 | mycpp_binary(ru,
|
| 76 | '//bin/hello.mycpp',
|
| 77 | template='win32',
|
| 78 | matrix=ninja_lib.COMPILERS_VARIANTS)
|
| 79 |
|
| 80 | # library //bin/hello.mycpp-souffle
|
| 81 | mycpp_library(
|
| 82 | ru,
|
| 83 | 'bin/hello.py',
|
| 84 | py_inputs=hello_py_inputs,
|
| 85 | translator='mycpp-souffle',
|
| 86 | deps=['//mycpp/runtime_pure'],
|
| 87 | )
|
| 88 | mycpp_binary(ru,
|
| 89 | '//bin/hello.mycpp-souffle',
|
| 90 | template='win32',
|
| 91 | matrix=ninja_lib.COMPILERS_VARIANTS)
|
| 92 |
|
| 93 | # Use the stdlib
|
| 94 | mycpp_library(
|
| 95 | ru,
|
| 96 | 'bin/hello_mylib.py',
|
| 97 | deps=['//mycpp/runtime'],
|
| 98 | )
|
| 99 | mycpp_binary(ru,
|
| 100 | '//bin/hello_mylib.mycpp',
|
| 101 | matrix=ninja_lib.COMPILERS_VARIANTS)
|
| 102 |
|
| 103 | oils_deps = [
|
| 104 | '//bin/text_files',
|
| 105 | '//core/optview',
|
| 106 | '//core/runtime.asdl',
|
| 107 | '//core/value.asdl',
|
| 108 | '//cpp/core',
|
| 109 | '//cpp/data_lang',
|
| 110 | '//cpp/fanos',
|
| 111 | '//cpp/libc',
|
| 112 | '//cpp/osh',
|
| 113 | '//cpp/pgen2',
|
| 114 | '//cpp/pylib',
|
| 115 | '//cpp/stdlib',
|
| 116 | '//cpp/frontend_flag_spec',
|
| 117 | '//cpp/frontend_match',
|
| 118 | '//cpp/frontend_pyreadline',
|
| 119 | '//data_lang/nil8.asdl',
|
| 120 | '//display/pretty.asdl',
|
| 121 | '//frontend/arg_types',
|
| 122 | '//frontend/consts',
|
| 123 | '//frontend/help_meta',
|
| 124 | '//frontend/id_kind.asdl',
|
| 125 | '//frontend/option.asdl',
|
| 126 | '//frontend/signal',
|
| 127 | '//frontend/syntax.asdl',
|
| 128 | '//frontend/types.asdl',
|
| 129 | '//osh/arith_parse',
|
| 130 | '//ysh/grammar',
|
| 131 | '//mycpp/runtime',
|
| 132 | ]
|
| 133 |
|
| 134 | oils_preamble = 'bin/oils_for_unix_preamble.h'
|
| 135 |
|
| 136 | mycpp_library(
|
| 137 | ru,
|
| 138 | 'bin/osh_eval.py',
|
| 139 | py_inputs=ninja_lib.TryDynamicDeps('bin/osh_eval.py'),
|
| 140 | # TODO: use different preamble and deps
|
| 141 | preamble=oils_preamble,
|
| 142 | deps=oils_deps)
|
| 143 |
|
| 144 | mycpp_binary(ru,
|
| 145 | '//bin/osh_eval.mycpp',
|
| 146 | matrix=ninja_lib.COMPILERS_VARIANTS)
|
| 147 |
|
| 148 | mycpp_library(
|
| 149 | ru,
|
| 150 | 'bin/osh_parse.py',
|
| 151 | py_inputs=ninja_lib.TryDynamicDeps('bin/osh_parse.py'),
|
| 152 | # TODO: use different preamble and deps
|
| 153 | preamble='bin/osh_parse_preamble.h',
|
| 154 | deps=oils_deps)
|
| 155 |
|
| 156 | mycpp_binary(ru,
|
| 157 | '//bin/osh_parse.mycpp',
|
| 158 | matrix=ninja_lib.COMPILERS_VARIANTS)
|
| 159 |
|
| 160 | oils_matrix = (ninja_lib.COMPILERS_VARIANTS + ninja_lib.GC_PERF_VARIANTS +
|
| 161 | ninja_lib.OTHER_VARIANTS)
|
| 162 |
|
| 163 | oils_py_inputs = ninja_lib.TryDynamicDeps('bin/oils_for_unix.py')
|
| 164 |
|
| 165 | # Main oils-for-unix binary
|
| 166 | mycpp_library(
|
| 167 | ru,
|
| 168 | 'bin/oils_for_unix.py',
|
| 169 | py_inputs=oils_py_inputs,
|
| 170 | deps=oils_deps,
|
| 171 | )
|
| 172 | mycpp_binary(
|
| 173 | ru,
|
| 174 | '//bin/oils_for_unix.mycpp',
|
| 175 | matrix=oils_matrix,
|
| 176 | symlinks=['oils-for-unix', 'osh', 'ysh'],
|
| 177 | preprocessed=True,
|
| 178 | )
|
| 179 |
|
| 180 | # Faster variant
|
| 181 | mycpp_library(
|
| 182 | ru,
|
| 183 | 'bin/oils_for_unix.py',
|
| 184 | py_inputs=oils_py_inputs,
|
| 185 | translator='mycpp-souffle',
|
| 186 | deps=oils_deps,
|
| 187 | )
|
| 188 | mycpp_binary(
|
| 189 | ru,
|
| 190 | '//bin/oils_for_unix.mycpp-souffle',
|
| 191 | matrix=oils_matrix,
|
| 192 | symlinks=[
|
| 193 | 'mycpp-souffle/oils-for-unix', 'mycpp-souffle/osh',
|
| 194 | 'mycpp-souffle/ysh'
|
| 195 | ],
|
| 196 | )
|
| 197 |
|
| 198 | # Opposite
|
| 199 | mycpp_library(
|
| 200 | ru,
|
| 201 | 'bin/oils_for_unix.py',
|
| 202 | py_inputs=oils_py_inputs,
|
| 203 | translator='mycpp-nosouffle',
|
| 204 | deps=oils_deps,
|
| 205 | )
|
| 206 | mycpp_binary(
|
| 207 | ru,
|
| 208 | '//bin/oils_for_unix.mycpp-nosouffle',
|
| 209 | matrix=oils_matrix,
|
| 210 | symlinks=[
|
| 211 | 'mycpp-nosouffle/oils-for-unix', 'mycpp-nosouffle/osh',
|
| 212 | 'mycpp-nosouffle/ysh'
|
| 213 | ],
|
| 214 | )
|