-
Notifications
You must be signed in to change notification settings - Fork 1
/
gn.js
103 lines (94 loc) · 2.72 KB
/
gn.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* highlight.js GN syntax highlighting definition
*
* @see https://github.com/highlightjs/highlight.js
*
* @package: highlightjs-GN
* @author: Petr Hosek <[email protected]>
* @since: 2019-05-28
*
* Description: GN is a meta-build system that generates build files for Ninja.
* Category: common
*/
var module = module ? module : {}; // shim for browser use
function hljsDefineGN(hljs) {
var SUBST = {
className: 'subst', relevance: 2,
variants: [
{
begin: '\\$[A-Za-z0-9_]+'
},
{
begin: '\\${', end: '}',
contains: [{
className: 'variable',
begin: hljs.UNDERSCORE_IDENT_RE,
relevance: 0
}]
}
],
};
var LINK = {
className: 'link', relevance: 5,
begin: ':\\w+',
}
var NUMBER = {
className: 'number', relevance: 0,
begin: hljs.NUMBER_RE
};
var STRING = {
className: 'string', relevance: 0,
begin: '"',
end: '"',
illegal: '\\n',
contains: [hljs.BACKSLASH_ESCAPE, SUBST, LINK],
};
var KEYWORDS = {
keyword:
'if else',
literal:
'true false ' +
'current_cpu current_os current_toolchain ' +
'default_toolchain host_cpu host_os ' +
'root_build_dir root_gen_dir root_out_dir ' +
'target_cpu target_gen_dir target_out_dir ' +
'target_os target_name invoker',
type:
'action action_foreach copy executable group ' +
'shared_library source_set static_library ' +
'loadable_module generated_file',
built_in:
'assert config declare_args defined exec_script ' +
'foreach get_label_info get_path_info ' +
'get_target_outputs getenv import print ' +
'process_file_template read_file rebase_path ' +
'set_default_toolchain set_defaults ' +
'set_sources_assignment_filter template tool ' +
'toolchain toolchain_args propagates_configs ' +
'write_file forward_variables_from target ' +
'get_name_info not_needed',
symbol:
'all_dependent_configs allow_circular_includes_from ' +
'args asmflags cflags cflags_c cflags_cc cflags_objc ' +
'cflags_objcc check_includes complete_static_lib ' +
'configs data data_deps defines depfile deps ' +
'include_dirs inputs ldflags lib_dirs libs ' +
'output_extension output_name outputs public ' +
'public_configs public_deps script sources testonly ' +
'visibility contents output_conversion rebase ' +
'data_keys walk_keys',
};
return {
aliases: ['gn', 'gni'],
keywords: KEYWORDS,
contains: [
NUMBER,
STRING,
hljs.HASH_COMMENT_MODE,
]
};
}
module.exports = function(hljs) {
hljs.registerLanguage('GN', hljsDefineGN);
};
module.exports.definer = hljsDefineGN;