| 1 | """
|
| 2 | yaks/NINJA_subgraph.py
|
| 3 | """
|
| 4 | from __future__ import print_function
|
| 5 |
|
| 6 | from build import ninja_lib
|
| 7 | from build.ninja_lib import log, mycpp_binary
|
| 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 | ru.asdl_library('yaks/yaks.asdl')
|
| 21 |
|
| 22 | ru.cc_binary('yaks/yaks_runtime_test.cc',
|
| 23 | deps=['//mycpp/runtime'],
|
| 24 | matrix=ninja_lib.COMPILERS_VARIANTS)
|
| 25 |
|
| 26 | mycpp_binary(
|
| 27 | ru,
|
| 28 | 'yaks/yaks_main.py',
|
| 29 | matrix=ninja_lib.COMPILERS_VARIANTS + ninja_lib.GC_PERF_VARIANTS,
|
| 30 | deps=[
|
| 31 | '//core/optview', # TODO: remove this dep
|
| 32 | '//core/runtime.asdl',
|
| 33 | '//core/value.asdl',
|
| 34 | '//cpp/data_lang',
|
| 35 | '//cpp/frontend_match',
|
| 36 | '//data_lang/nil8.asdl',
|
| 37 | '//frontend/consts',
|
| 38 | '//frontend/syntax.asdl', # TODO: remove this, value.asdl dep
|
| 39 | '//mycpp/runtime',
|
| 40 | '//yaks/yaks.asdl',
|
| 41 | ])
|
| 42 |
|
| 43 | n.newline()
|
| 44 |
|
| 45 | ### CUSTOM translation with the COMPILED yaks binary.
|
| 46 | n.rule('yaks',
|
| 47 | command='_bin/cxx-opt/yaks/yaks_main.mycpp cpp $in > $out',
|
| 48 | description='yaks cpp $in > $out')
|
| 49 | n.newline()
|
| 50 |
|
| 51 | raw_cc = '_gen/yaks/examples/hello_raw.yaks.cc'
|
| 52 | example_cc = '_gen/yaks/examples/hello.yaks.cc'
|
| 53 |
|
| 54 | n.build(
|
| 55 | [raw_cc],
|
| 56 | 'yaks',
|
| 57 | ['yaks/examples/hello.yaks'],
|
| 58 | implicit=['_bin/cxx-opt/yaks/yaks_main.mycpp'],
|
| 59 | )
|
| 60 | n.newline()
|
| 61 |
|
| 62 | n.build([example_cc],
|
| 63 | 'wrap-cc', [raw_cc],
|
| 64 | implicit=[RULES_PY],
|
| 65 | variables=[('main_namespace', 'hello'), ('preamble', '""'),
|
| 66 | ('main_func', 'main-wrapper')])
|
| 67 | n.newline()
|
| 68 |
|
| 69 | ru.cc_binary(
|
| 70 | example_cc,
|
| 71 | matrix=ninja_lib.COMPILERS_VARIANTS + ninja_lib.GC_PERF_VARIANTS,
|
| 72 | deps=['//mycpp/runtime'],
|
| 73 | )
|
| 74 |
|
| 75 |
|
| 76 | # vim: sw=4
|