extconf_compile_commands_json 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/extconf_compile_commands_json.rb +44 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3c4119e56b170eeb8c7754f47f7735f14f9e2110aec9a55d2627d2be4b96e24d
|
4
|
+
data.tar.gz: 8db262a1e1ceba1e9246fa88914c2cd44b5e36a1b0b80e4ef83be7d159d51f72
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: af7263343f4e56f58c8c49cd40b74bec3865b3bbea54fe32c730f69fd90decb0fbfd6cea29fb373bd319c34099a95c1df22cea09bd1e75132860636adc579f0c
|
7
|
+
data.tar.gz: f547795042f887afd413b52e39310bcd0b3dfe106729c90bb3583ca6b8d8771eb4c8a31b81aac8beaa9592d026e5801d8ad755c05d130a78f24878c01446102a
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mkmf"
|
4
|
+
require "shellwords"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module ExtconfCompileCommandsJson
|
8
|
+
def self.generate_compile_commands_json
|
9
|
+
mkmf_cflags = []
|
10
|
+
# Start by expanding what's in our magic variables
|
11
|
+
[$INCFLAGS, $CPPFLAGS, $CFLAGS, $COUTFLAGS].each do |v|
|
12
|
+
next unless v
|
13
|
+
mkmf_cflags.concat Shellwords.split(v)
|
14
|
+
end
|
15
|
+
# expand that with the contents of the ruby options
|
16
|
+
mkmf_cflags.map! do |flag|
|
17
|
+
flag
|
18
|
+
.gsub("$(arch_hdrdir)", $arch_hdrdir || "")
|
19
|
+
.gsub("$(hdrdir)", $hdrdir || "")
|
20
|
+
.gsub("$(srcdir)", $srcdir || "")
|
21
|
+
.gsub("$(cppflags)", RbConfig::CONFIG["cppflags"] || "")
|
22
|
+
.gsub("$(DEFS)", RbConfig::CONFIG["DEFS"] || "")
|
23
|
+
.gsub("$(cflags)", RbConfig::CONFIG["cflags"] || "")
|
24
|
+
.gsub("$(cxxflags)", RbConfig::CONFIG["cxxflags"] || "")
|
25
|
+
.gsub("$(optflags)", RbConfig::CONFIG["optflags"] || "")
|
26
|
+
.gsub("$(debugflags)", RbConfig::CONFIG["debugflags"] || "")
|
27
|
+
.gsub("$(warnflags)", RbConfig::CONFIG["warnflags"] || "")
|
28
|
+
.gsub("$(empty)", "")
|
29
|
+
end
|
30
|
+
mkmf_cflags.reject! { |f| f.empty? }
|
31
|
+
# This makes sure that #include "extconf.h" works
|
32
|
+
mkmf_cflags = ["-iquote#{File.realpath(Dir.pwd)}"] + mkmf_cflags
|
33
|
+
compile_commands = $srcs.map do |src|
|
34
|
+
{
|
35
|
+
directory: File.realpath(Dir.pwd),
|
36
|
+
# Set the C compiler to "clang", always, since the whole point
|
37
|
+
# of this file is to make clangd work.
|
38
|
+
arguments: ["clang"] + mkmf_cflags + [src],
|
39
|
+
file: src
|
40
|
+
}
|
41
|
+
end
|
42
|
+
File.write("compile_commands.json", compile_commands.to_json)
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: extconf_compile_commands_json
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- KJ Tsanaktsidis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-07-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: standard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
description: |
|
28
|
+
The extconf_compile_commands_json gem allows you to easily generate
|
29
|
+
compatible compile_commands.json files from your extconf.rb file. This
|
30
|
+
makes it easy to use the clangd LSP when working on your gem.
|
31
|
+
email: kj@kjtsanaktsidis.id.au
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- lib/extconf_compile_commands_json.rb
|
37
|
+
homepage: https://github.com/KJTsanaktsidis/extconf_compile_commands_json
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata: {}
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.6.0
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubygems_version: 3.3.7
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Generate clangd compile_commands.json files for gems
|
60
|
+
test_files: []
|