Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Xmake language #7199

Merged
merged 7 commits into from
Jan 14, 2025
Merged

Add Xmake language #7199

merged 7 commits into from
Jan 14, 2025

Conversation

waruqi
Copy link
Contributor

@waruqi waruqi commented Jan 11, 2025

Description

This pull request adds support to Xmake buildsystem programming language. Here are some relevant resources:

Website: https://xmake.io/
GitHub Organization: xmake-io

Checklist:

@waruqi waruqi requested a review from a team as a code owner January 11, 2025 14:56
@waruqi waruqi changed the title Add Xmake Add Xmake language Jan 11, 2025
Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is only really a single file, we only need one sample. Please remove the others.

lib/linguist/languages.yml Outdated Show resolved Hide resolved
lib/linguist/languages.yml Outdated Show resolved Hide resolved
@waruqi
Copy link
Contributor Author

waruqi commented Jan 13, 2025

And I have installed github-linguist, but list-grammars does not work.

ruki-2:linguist ruki$ gem install github-linguist
ruki-2:linguist ruki$ gem --version
3.6.2
ruki-2:linguist ruki$ ./script/list-grammars
Source locally installed gems is ignoring #<Bundler::StubSpecification name=websocket-driver version=0.7.1 platform=ruby> because it is missing extensions
Source locally installed gems is ignoring #<Bundler::StubSpecification name=nokogiri version=1.10.5 platform=ruby> because it is missing extensions
Source locally installed gems is ignoring #<Bundler::StubSpecification name=nio4r version=2.5.2 platform=ruby> because it is missing extensions
Source locally installed gems is ignoring #<Bundler::StubSpecification name=json version=1.8.6 platform=ruby> because it is missing extensions
Source locally installed gems is ignoring #<Bundler::StubSpecification name=gem-wrappers version=1.4.0 platform=ruby> because it is missing extensions
Source locally installed gems is ignoring #<Bundler::StubSpecification name=ffi version=1.11.2 platform=ruby> because it is missing extensions
Source locally installed gems is ignoring #<Bundler::StubSpecification name=ffi version=1.15.5 platform=ruby> because it is missing extensions
Source locally installed gems is ignoring #<Bundler::StubSpecification name=executable-hooks version=1.6.0 platform=ruby> because it is missing extensions
/usr/local/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require': cannot load such file -- linguist/linguist (LoadError)
        from /usr/local/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
        from /Users/ruki/Downloads/linguist/lib/linguist/tokenizer.rb:2:in '<top (required)>'
        from /usr/local/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
        from /usr/local/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
        from /Users/ruki/Downloads/linguist/lib/linguist/classifier.rb:1:in '<top (required)>'
        from /usr/local/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
        from /usr/local/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
        from /Users/ruki/Downloads/linguist/lib/linguist/language.rb:9:in '<top (required)>'
        from /usr/local/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
        from /usr/local/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
        from /Users/ruki/Downloads/linguist/lib/linguist.rb:5:in '<top (required)>'
        from /usr/local/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require'
        from /usr/local/Cellar/ruby/3.4.1/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require'
        from ./script/list-grammars:4:in '<main>'

@lildude
Copy link
Member

lildude commented Jan 13, 2025

And I have installed github-linguist, but list-grammars does not work.

Installing the Linguist gem is not sufficient to setup the dev env. You need to follow the instructions in the CONTRIBUTING.md file.

@waruqi
Copy link
Contributor Author

waruqi commented Jan 13, 2025

And I have installed github-linguist, but list-grammars does not work.

Installing the Linguist gem is not sufficient to setup the dev env. You need to follow the instructions in the CONTRIBUTING.md file.

thanks, all tests are passed now.

Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 why did you remove all of the samples? We need at least one.

@lildude
Copy link
Member

lildude commented Jan 14, 2025

Another question... why do we need a whole new language for this? A quick look suggests the current Lua classification is sufficient.

@waruqi
Copy link
Contributor Author

waruqi commented Jan 14, 2025

🤔 why did you remove all of the samples? We need at least one.

If I add samples/xmake.lua it will be interfered by lua language and lead to wrong detection, because it will prioritize matching .lua extension instead of just matching xmake.lua file name.

  3) Failure:
TestSamples#test_Lua_has_samples [test/test_samples.rb:91]:
Missing samples in "samples/Lua/*.[lL][uU][aA]". See https://github.com/github/linguist/blob/master/CONTRIBUTING.md

  4) Failure:
TestSamples#test_samples_have_parity_with_languages_yml_for_Xmake [test/test_samples.rb:66]:
Xmake has a sample with extension (.lua) that isn't explicitly defined in languages.yml

  5) Failure:
TestSamples#test_Xmake_has_samples [test/test_samples.rb:91]:
Missing samples in "samples/Lua/*.[lL][uU][aA]". See https://github.com/github/linguist/blob/master/CONTRIBUTING.md

we need only match filenames. so I moved samples/Xmake/xmake.lua to samples/Xmake/filenames/xmake.lua.

Therefore, under the samples, there is still an xmake.lua, not none at all.

language.filenames.each do |filename|
# Kludge for an unusual edge-case; see https://bit.ly/41EyUkU
next if ["Hosts File", "INI"].include?(language.name) && filename == "HOSTS"
# Check for samples if more than one language matches the given filename
if Language.find_by_filename(filename).size > 1
sample = "samples/#{language.name}/filenames/#{filename}"
assert File.exist?(sample),
"Missing sample in #{sample.inspect}. See https://github.com/github/linguist/blob/master/CONTRIBUTING.md"
end
end
end
end

Another question... why do we need a whole new language for this? A quick look suggests the current Lua classification is sufficient.

Although xmake.lua is based on lua, it has its own keywords, apis and syntax, and many native lua apis have been removed, so it is very different from lua, except for the most basic if else keywords. There are at least 80% differences.

Therefore, it belongs to a new configuration language for the build system, not just lua.

Just like meson, although based on python, it also has its own configuration language. There are also cmake, scons and ninja, all of which have their own configuration languages.

I think xmake.lua should be regarded as a configuration language belonging to the xmake build system, and it should exist independently.

@lildude
Copy link
Member

lildude commented Jan 14, 2025

Those errors are because you added the .lua extension too to the language.yml file.

As we're only adding a filename, you only need to add a sample to samples/Xmake/filenames which I have now down and pushed to your fork.

@waruqi
Copy link
Contributor Author

waruqi commented Jan 14, 2025

Those errors are because you added the extension too to the file..lua``language.yml

As we're only adding a filename, you only need to add a sample to which I have now down and pushed to your fork.samples/Xmake/filenames

oh, my mistake, I forgot to run git add .

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        samples/Xmake/

Copy link
Member

@lildude lildude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now. Thanks.

Important

The changes in this PR will not appear on GitHub until the next release has been made and deployed. See here for more details.

@lildude lildude added this pull request to the merge queue Jan 14, 2025
Merged via the queue into github-linguist:main with commit be39d09 Jan 14, 2025
5 checks passed
@waruqi waruqi deleted the xmake branch January 14, 2025 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants