1 | """
|
2 | bin/NINJA_subgraph.py
|
3 | """
|
4 | from __future__ import print_function
|
5 |
|
6 | from build import ninja_lib
|
7 | from build.ninja_lib import log
|
8 |
|
9 | _ = log
|
10 |
|
11 | # TODO: should have dependencies with sh_binary
|
12 | RULES_PY = 'build/ninja-rules-py.sh'
|
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 = ninja_lib.globs('_devbuild/help/*')
|
33 | files.extend(ninja_lib.globs('stdlib/*.ysh'))
|
34 |
|
35 | n.build(['_gen/bin/text_files.cc'],
|
36 | 'embedded-file-gen',
|
37 | files,
|
38 | implicit=['_bin/shwrap/embedded_file_gen'])
|
39 | n.newline()
|
40 |
|
41 | ru.cc_library('//bin/text_files', srcs=['_gen/bin/text_files.cc'])
|
42 |
|
43 | #
|
44 | # Main Programs
|
45 | #
|
46 |
|
47 | for main_name in ('osh_eval', 'oils_for_unix'):
|
48 | with open('_build/NINJA/bin.%s/translate.txt' % main_name) as f:
|
49 | deps = [line.strip() for line in f]
|
50 |
|
51 | prefix = '_gen/bin/%s.mycpp' % main_name
|
52 | outputs = [prefix + '.cc', prefix + '.h']
|
53 | n.build(outputs,
|
54 | 'gen-oils-for-unix',
|
55 | deps,
|
56 | implicit=['_bin/shwrap/mycpp_main', RULES_PY],
|
57 | variables=[('out_prefix', prefix), ('main_name', main_name),
|
58 | ('preamble', 'cpp/preamble.h')])
|
59 |
|
60 | if main_name == 'oils_for_unix':
|
61 | # The main program!
|
62 | bin_path = 'oils-for-unix'
|
63 | symlinks = ['osh', 'ysh']
|
64 | else:
|
65 | symlinks = []
|
66 | bin_path = None # use default
|
67 |
|
68 | ru.cc_binary('_gen/bin/%s.mycpp.cc' % main_name,
|
69 | bin_path=bin_path,
|
70 | symlinks=symlinks,
|
71 | preprocessed=True,
|
72 | matrix=ninja_lib.COMPILERS_VARIANTS +
|
73 | ninja_lib.GC_PERF_VARIANTS,
|
74 | deps=[
|
75 | '//bin/text_files',
|
76 | '//cpp/core',
|
77 | '//cpp/data_lang',
|
78 | '//cpp/fanos',
|
79 | '//cpp/libc',
|
80 | '//cpp/osh',
|
81 | '//cpp/pgen2',
|
82 | '//cpp/pylib',
|
83 | '//cpp/stdlib',
|
84 | '//cpp/frontend_flag_spec',
|
85 | '//cpp/frontend_match',
|
86 | '//cpp/frontend_pyreadline',
|
87 | '//data_lang/nil8.asdl',
|
88 | '//data_lang/pretty.asdl',
|
89 | '//frontend/arg_types',
|
90 | '//frontend/consts',
|
91 | '//frontend/help_meta',
|
92 | '//frontend/id_kind.asdl',
|
93 | '//frontend/option.asdl',
|
94 | '//frontend/signal',
|
95 | '//frontend/syntax.asdl',
|
96 | '//frontend/types.asdl',
|
97 | '//core/optview',
|
98 | '//core/runtime.asdl',
|
99 | '//core/value.asdl',
|
100 | '//osh/arith_parse',
|
101 | '//ysh/grammar',
|
102 | '//mycpp/runtime',
|
103 | ])
|