Skip to content

Commit

Permalink
fix: vue in edit grammars
Browse files Browse the repository at this point in the history
  • Loading branch information
ilevyor committed Mar 12, 2024
1 parent 3655c69 commit be22d92
Show file tree
Hide file tree
Showing 25 changed files with 57 additions and 31 deletions.
28 changes: 27 additions & 1 deletion resources/edit_grammars.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ const allLanguages = [
'sql',
'typescript',
'yaml',
'toml'
'toml',
'vue'
];

// For these languages, copyMvGrammar is optional
Expand Down Expand Up @@ -234,6 +235,31 @@ async function buildLanguage(language) {

await copyWasmParser('typescript', 'tree-sitter-typescript/');
await copyWasmParser('tsx', 'tree-sitter-typescript/');
} else if (language === 'vue') {
// typescript is special
// we edit its package.json to point to our local version of the js grammar
log(`Copying files`);
await fs.copyFile(
`${METAVARIABLE_GRAMMARS}/vue-package.json`,
`${tsLangDir}/package.json`,
);

// typescript defines a typescript and tsx grammar, the grammar we care about is in common/define-grammar.js
await fs.copyFile(
`${METAVARIABLE_GRAMMARS}/vue-metavariable-grammar.js`,
`${tsLangDir}/grammar.js`,
);

await execPromise(
`cd ${tsLangDir} && yarn && yarn prepack && npx tree-sitter build-wasm && echo "Generated grammar for ${language}"`,
);

await copyNodeTypes(language);
await copyWasmParser(language);
await fs.copyFile(
`${METAVARIABLE_GRAMMARS}/cc_build.rs`,
`${tsLangDir}/bindings/rust/build.rs`,
);
} else if (language === 'yaml') {
await copyMvScanner(language);
await buildSimpleLanguage(log, language);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand All @@ -30,7 +30,7 @@ fn main() {
cpp_config.cpp(true);
cpp_config.include(&src_dir);
cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable");
let scanner_path = src_dir.join("scanner.cc");
cpp_config.file(&scanner_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(&src_dir_block);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir_block.join("parser.c");
Expand All @@ -16,7 +16,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(&src_dir_inline);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir_inline.join("parser.c");
Expand All @@ -28,7 +28,7 @@ fn main() {
c_config.cpp(false);
c_config.include(&src_dir_block);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable");
let scanner_path = src_dir_block.join("scanner.c");
c_config.file(&scanner_path);
Expand All @@ -39,7 +39,7 @@ fn main() {
c_config.cpp(false);
c_config.include(&src_dir_inline);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable");
let scanner_path = src_dir_inline.join("scanner.c");
c_config.file(&scanner_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand All @@ -30,7 +30,7 @@ fn main() {
cpp_config.cpp(true);
cpp_config.include(&src_dir);
cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable");
let scanner_path = src_dir.join("scanner.cc");
cpp_config.file(&scanner_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand All @@ -30,7 +30,7 @@ fn main() {
cpp_config.cpp(true);
cpp_config.include(&src_dir);
cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable");
let scanner_path = src_dir.join("scanner.cc");
cpp_config.file(&scanner_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand All @@ -25,7 +25,7 @@ fn main() {
}

cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable");
let scanner_path = src_dir.join("scanner.cc");
cpp_config.file(&scanner_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fn main() {
let mut config = cc::Build::new();
config.include(&src_dir);
config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand All @@ -30,7 +30,7 @@ fn main() {
cpp_config.cpp(true);
cpp_config.include(&src_dir);
cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable");
let scanner_path = src_dir.join("scanner.cc");
cpp_config.file(&scanner_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn main() {
let mut c_config = cc::Build::new();
c_config.include(&src_dir);
c_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable")
.flag_if_supported("-Wno-trigraphs");
let parser_path = src_dir.join("parser.c");
Expand All @@ -30,7 +30,7 @@ fn main() {
cpp_config.cpp(true);
cpp_config.include(&src_dir);
cpp_config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable");
let scanner_path = src_dir.join("scanner.cc");
cpp_config.file(&scanner_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
let mut config = cc::Build::new();
config.include(&typescript_dir);
config
.flag_if_supported("-Wno-unused-parameter")
.flag_if_supported("-w")
.flag_if_supported("-Wno-unused-but-set-variable");

for path in &[
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ endif

quiet_cmd_regen_makefile = ACTION Regenerating $@
cmd_regen_makefile = cd $(srcdir); /Users/itamarlevy-or/.nvm/versions/node/v18.5.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/itamarlevy-or/Library/Caches/node-gyp/18.5.0" "-Dnode_gyp_dir=/Users/itamarlevy-or/.nvm/versions/node/v18.5.0/lib/node_modules/npm/node_modules/node-gyp" "-Dnode_lib_file=/Users/itamarlevy-or/Library/Caches/node-gyp/18.5.0/<(target_arch)/node.lib" "-Dmodule_root_dir=/Users/itamarlevy-or/dev/gritql/resources/language-metavariables/tree-sitter-vue" "-Dnode_engine=v8" "--depth=." "-Goutput_dir=." "--generator-output=build" -I/Users/itamarlevy-or/dev/gritql/resources/language-metavariables/tree-sitter-vue/build/config.gypi -I/Users/itamarlevy-or/.nvm/versions/node/v18.5.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi -I/Users/itamarlevy-or/Library/Caches/node-gyp/18.5.0/include/node/common.gypi "--toplevel-dir=." binding.gyp
Makefile: $(srcdir)/../../../../../.nvm/versions/node/v18.5.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/../../../../../Library/Caches/node-gyp/18.5.0/include/node/common.gypi $(srcdir)/binding.gyp $(srcdir)/build/config.gypi
Makefile: $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../../.nvm/versions/node/v18.5.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi $(srcdir)/../../../../../Library/Caches/node-gyp/18.5.0/include/node/common.gypi
$(call do_cmd,regen_makefile)

# "all" is a concatenation of the "all" targets from all the included
Expand Down
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.

0 comments on commit be22d92

Please sign in to comment.