extconf_compile_commands_json 0.0.1 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/extconf_compile_commands_json/autoload.rb +28 -0
- data/lib/extconf_compile_commands_json.rb +15 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92e4b4fbb8bb8e86e7039716f5ea508d2384890760e5eac2b4e0aa2d4e7acc5a
|
4
|
+
data.tar.gz: a9a7564118dba73159f3888a84cc1d5177561480005584b6a538e5ee7d2ec207
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 549e9d2def77550934c972edca5c86d0edab4211d5175099f312d6319eaf9ce03aba745863a8097e7d64d3825f4e509596a49798e653a44e23b020e7abcf492f
|
7
|
+
data.tar.gz: 6ae64693bf58886d3670d3bc7032520d0db565d4eeabb7ae90ab376deb357db0e4cd330619cec29dad0d192b6223e5b4f2623c3b201934cbc84b6b1b207c1b95
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Requiring this file will patch MkMf to auto-magically generate compile_commands.json.
|
4
|
+
# Handy to add to a RUBYOPT env var or such, so you can work on a project not using
|
5
|
+
# this gem but benefit from it yourself, without having to modify the existing build
|
6
|
+
# scripts.
|
7
|
+
|
8
|
+
require "mkmf"
|
9
|
+
# the require_relative looks stupid, but it ensures that you can load this patch
|
10
|
+
# simply by running adding -r/path/to/autoload.rb to your Ruby invocation without
|
11
|
+
# needing to muck about with $LOAD_PATH or Bundler.
|
12
|
+
require_relative "../extconf_compile_commands_json"
|
13
|
+
|
14
|
+
module ExtconfCompileCommandsJson
|
15
|
+
module AutoloadPatch
|
16
|
+
def create_makefile(*args)
|
17
|
+
super
|
18
|
+
ExtconfCompileCommandsJson.generate!
|
19
|
+
ExtconfCompileCommandsJson.symlink!
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
MakeMakefile.prepend ExtconfCompileCommandsJson::AutoloadPatch
|
25
|
+
# We have to patch the toplevel binding directly as well, because requiring
|
26
|
+
# mkmf includes it into main straight away. So, prepending to MakeMakefile
|
27
|
+
# will be ignored if someone calls "create_makefile" in their extconf.rb
|
28
|
+
prepend ExtconfCompileCommandsJson::AutoloadPatch
|
@@ -3,9 +3,10 @@
|
|
3
3
|
require "mkmf"
|
4
4
|
require "shellwords"
|
5
5
|
require "json"
|
6
|
+
require "fileutils"
|
6
7
|
|
7
8
|
module ExtconfCompileCommandsJson
|
8
|
-
def self.
|
9
|
+
def self.generate!
|
9
10
|
mkmf_cflags = []
|
10
11
|
# Start by expanding what's in our magic variables
|
11
12
|
[$INCFLAGS, $CPPFLAGS, $CFLAGS, $COUTFLAGS].each do |v|
|
@@ -41,4 +42,17 @@ module ExtconfCompileCommandsJson
|
|
41
42
|
end
|
42
43
|
File.write("compile_commands.json", compile_commands.to_json)
|
43
44
|
end
|
45
|
+
|
46
|
+
# generate will put the compile_commands.json in the same folder as the
|
47
|
+
# compiled output (and Makefile); symlink will create a symlink in the
|
48
|
+
# same folder as the extconf.rb, so that clangd can find it.
|
49
|
+
def self.symlink!
|
50
|
+
# This is the same check mkmf does for deciding whether to spew errors onto your
|
51
|
+
# terminal, so I figure it'll do for spewing symlinks into your directory too.
|
52
|
+
return unless !$extmk && (/\A(extconf|makefile).rb\z/ =~ File.basename($0))
|
53
|
+
extconf_dir = File.dirname $0
|
54
|
+
compile_commands_file = File.realpath("./compile_commands.json")
|
55
|
+
return unless File.exist? compile_commands_file
|
56
|
+
FileUtils.ln_sf compile_commands_file, File.join(extconf_dir, "compile_commands.json")
|
57
|
+
end
|
44
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extconf_compile_commands_json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- KJ Tsanaktsidis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -34,6 +34,7 @@ extensions: []
|
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
36
|
- lib/extconf_compile_commands_json.rb
|
37
|
+
- lib/extconf_compile_commands_json/autoload.rb
|
37
38
|
homepage: https://github.com/KJTsanaktsidis/extconf_compile_commands_json
|
38
39
|
licenses:
|
39
40
|
- MIT
|