ionide / tree-sitter-fsharp

F# grammar for treesitter
MIT License
81 stars 19 forks source link

npm install fails with "The subcommand '../generate' wasn't recognized" #21

Closed gsuuon closed 7 months ago

gsuuon commented 1 year ago

npm install is failing for me on windows

gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
  generated parser
CUSTOMBUILD : error : The subcommand '../generate' wasn't recognized [C:\Users\gsuuon\code\gsuuon\forks\tree-si
tter-fsharp\build\tree_sitter_fsharp_binding.vcxproj]
        Did you mean 'generate'?

  If you believe you received this message in error, try re-running with 'tree-sitter.exe -- ../generate'

      tree-sitter.exe <SUBCOMMAND>

  For more information try --help
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.tar
gets(241,5): error MSB8066: Custom build for '..\grammar.js' exited with code 1. [C:\Users\gsuuon\code\gsuuon\f
orks\tree-sitter-fsharp\build\tree_sitter_fsharp_binding.vcxproj]

If I remove the generate on install:

diff --git a/binding.gyp b/binding.gyp
index 20c4fe5..99bb1cb 100644
--- a/binding.gyp
+++ b/binding.gyp
@@ -14,15 +14,6 @@
       "cflags_c": [
         "-std=c99",
       ],
-      'actions': [
-        {
-          'action_name': 'generate parser',
-          'inputs': ['grammar.js'],
-          'outputs': ['src'],
-          'action': ['tree-sitter', 'generate'],
-          'message': 'generated parser'
-        }
-      ],
     }
   ]
 }

I get error LNK2001: unresolved external symbol tree_sitter_YOUR_LANGUAGE_NAME:

gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
  binding.cc
  parser.c
  scanner.cc
  win_delay_load_hook.cc
     Creating library C:\Users\gsuuon\code\gsuuon\forks\tree-sitter-fsharp\build\Release\tree_sitter_fsharp_bin
  ding.exp
binding.obj : error LNK2001: unresolved external symbol tree_sitter_YOUR_LANGUAGE_NAME [C:\Users\gsuuon\code\gs
uuon\forks\tree-sitter-fsharp\build\tree_sitter_fsharp_binding.vcxproj]
C:\Users\gsuuon\code\gsuuon\forks\tree-sitter-fsharp\build\Release\tree_sitter_fsharp_binding.node : fatal erro
r LNK1120: 1 unresolved externals [C:\Users\gsuuon\code\gsuuon\forks\tree-sitter-fsharp\build\tree_sitter_fshar
p_binding.vcxproj]
Nsidorenco commented 1 year ago

Unfortunately this seems like a windows issue, where it parses the generate command in the build step wrong. Maybe it was fixed by changing the naming in the binding files? Otherwise, there is not currently much to do about this, other than to add the pre-generated files to another branch

gsuuon commented 1 year ago

Not sure if you saw this comment but it doesn't look like the pre-built parsers are necessary for using with nvim-treesitter. I'm not sure if they're included for another use-case, but simply removing the build step would unblock using this with nvim on windows

Nsidorenco commented 1 year ago

Hi @gsuuon, when I originally experimented with this I could not get the :TSGenerateFromGrammar command to work, since this grammar also requires that the external scanner src/scanner.cc is compiled along with the grammar. Maybe there is a way around this, but imo the nicest solution would be to setup a ci pipeline generating the parser files on a different branch