kompo 0.3.1 → 0.4.0
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 +4 -4
- data/CHANGELOG.md +25 -0
- data/Gemfile +7 -7
- data/Gemfile.lock +2 -2
- data/README.md +38 -13
- data/Rakefile +6 -6
- data/exe/kompo +21 -19
- data/lib/kompo/cache.rb +7 -7
- data/lib/kompo/kompo_ignore.rb +2 -2
- data/lib/kompo/tasks/build_native_gem.rb +48 -15
- data/lib/kompo/tasks/bundle_install.rb +42 -42
- data/lib/kompo/tasks/cargo_path.rb +13 -13
- data/lib/kompo/tasks/check_stdlibs.rb +6 -6
- data/lib/kompo/tasks/collect_dependencies.rb +23 -15
- data/lib/kompo/tasks/copy_gemfile.rb +23 -15
- data/lib/kompo/tasks/copy_project_files.rb +4 -4
- data/lib/kompo/tasks/find_native_extensions.rb +80 -17
- data/lib/kompo/tasks/homebrew.rb +15 -15
- data/lib/kompo/tasks/install_deps.rb +36 -36
- data/lib/kompo/tasks/kompo_vfs_path.rb +41 -32
- data/lib/kompo/tasks/kompo_vfs_version_check.rb +6 -4
- data/lib/kompo/tasks/make_fs_c.rb +32 -23
- data/lib/kompo/tasks/make_main_c.rb +6 -6
- data/lib/kompo/tasks/packing.rb +63 -48
- data/lib/kompo/tasks/ruby_build_path.rb +60 -15
- data/lib/kompo/version.rb +2 -2
- data/lib/kompo.rb +28 -24
- metadata +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "English"
|
|
4
4
|
module Kompo
|
|
5
5
|
# Section to handle platform-specific dependencies.
|
|
6
6
|
# Switches implementation based on the current platform.
|
|
@@ -23,9 +23,9 @@ module Kompo
|
|
|
23
23
|
InstallLibyaml.lib_path,
|
|
24
24
|
InstallZlib.lib_path,
|
|
25
25
|
InstallLibffi.lib_path
|
|
26
|
-
].compact.join(
|
|
26
|
+
].compact.join(" ")
|
|
27
27
|
|
|
28
|
-
puts
|
|
28
|
+
puts "All Homebrew dependencies installed"
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# GMP library installation Section
|
|
@@ -37,8 +37,8 @@ module Kompo
|
|
|
37
37
|
system("#{brew} list #{BREW_NAME} > /dev/null 2>&1") ? Installed : Install
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
BREW_NAME =
|
|
41
|
-
MARKER_FILE = File.expand_path(
|
|
40
|
+
BREW_NAME = "gmp"
|
|
41
|
+
MARKER_FILE = File.expand_path("~/.kompo_installed_gmp")
|
|
42
42
|
|
|
43
43
|
class Installed < Taski::Task
|
|
44
44
|
def run
|
|
@@ -54,7 +54,7 @@ module Kompo
|
|
|
54
54
|
brew = HomebrewPath.path
|
|
55
55
|
puts "Installing #{BREW_NAME}..."
|
|
56
56
|
system("#{brew} install #{BREW_NAME}") or raise "Failed to install #{BREW_NAME}"
|
|
57
|
-
File.write(MARKER_FILE,
|
|
57
|
+
File.write(MARKER_FILE, "installed")
|
|
58
58
|
|
|
59
59
|
prefix = `#{brew} --prefix #{BREW_NAME} 2>/dev/null`.chomp
|
|
60
60
|
@lib_path = "-L#{prefix}/lib" if $CHILD_STATUS.success? && !prefix.empty?
|
|
@@ -80,8 +80,8 @@ module Kompo
|
|
|
80
80
|
system("#{brew} list #{BREW_NAME} > /dev/null 2>&1") ? Installed : Install
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
BREW_NAME =
|
|
84
|
-
MARKER_FILE = File.expand_path(
|
|
83
|
+
BREW_NAME = "openssl@3"
|
|
84
|
+
MARKER_FILE = File.expand_path("~/.kompo_installed_openssl")
|
|
85
85
|
|
|
86
86
|
class Installed < Taski::Task
|
|
87
87
|
def run
|
|
@@ -97,7 +97,7 @@ module Kompo
|
|
|
97
97
|
brew = HomebrewPath.path
|
|
98
98
|
puts "Installing #{BREW_NAME}..."
|
|
99
99
|
system("#{brew} install #{BREW_NAME}") or raise "Failed to install #{BREW_NAME}"
|
|
100
|
-
File.write(MARKER_FILE,
|
|
100
|
+
File.write(MARKER_FILE, "installed")
|
|
101
101
|
|
|
102
102
|
prefix = `#{brew} --prefix #{BREW_NAME} 2>/dev/null`.chomp
|
|
103
103
|
@lib_path = "-L#{prefix}/lib" if $CHILD_STATUS.success? && !prefix.empty?
|
|
@@ -123,8 +123,8 @@ module Kompo
|
|
|
123
123
|
system("#{brew} list #{BREW_NAME} > /dev/null 2>&1") ? Installed : Install
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
-
BREW_NAME =
|
|
127
|
-
MARKER_FILE = File.expand_path(
|
|
126
|
+
BREW_NAME = "readline"
|
|
127
|
+
MARKER_FILE = File.expand_path("~/.kompo_installed_readline")
|
|
128
128
|
|
|
129
129
|
class Installed < Taski::Task
|
|
130
130
|
def run
|
|
@@ -140,7 +140,7 @@ module Kompo
|
|
|
140
140
|
brew = HomebrewPath.path
|
|
141
141
|
puts "Installing #{BREW_NAME}..."
|
|
142
142
|
system("#{brew} install #{BREW_NAME}") or raise "Failed to install #{BREW_NAME}"
|
|
143
|
-
File.write(MARKER_FILE,
|
|
143
|
+
File.write(MARKER_FILE, "installed")
|
|
144
144
|
|
|
145
145
|
prefix = `#{brew} --prefix #{BREW_NAME} 2>/dev/null`.chomp
|
|
146
146
|
@lib_path = "-L#{prefix}/lib" if $CHILD_STATUS.success? && !prefix.empty?
|
|
@@ -166,8 +166,8 @@ module Kompo
|
|
|
166
166
|
system("#{brew} list #{BREW_NAME} > /dev/null 2>&1") ? Installed : Install
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
-
BREW_NAME =
|
|
170
|
-
MARKER_FILE = File.expand_path(
|
|
169
|
+
BREW_NAME = "libyaml"
|
|
170
|
+
MARKER_FILE = File.expand_path("~/.kompo_installed_libyaml")
|
|
171
171
|
|
|
172
172
|
class Installed < Taski::Task
|
|
173
173
|
def run
|
|
@@ -183,7 +183,7 @@ module Kompo
|
|
|
183
183
|
brew = HomebrewPath.path
|
|
184
184
|
puts "Installing #{BREW_NAME}..."
|
|
185
185
|
system("#{brew} install #{BREW_NAME}") or raise "Failed to install #{BREW_NAME}"
|
|
186
|
-
File.write(MARKER_FILE,
|
|
186
|
+
File.write(MARKER_FILE, "installed")
|
|
187
187
|
|
|
188
188
|
prefix = `#{brew} --prefix #{BREW_NAME} 2>/dev/null`.chomp
|
|
189
189
|
@lib_path = "-L#{prefix}/lib" if $CHILD_STATUS.success? && !prefix.empty?
|
|
@@ -209,8 +209,8 @@ module Kompo
|
|
|
209
209
|
system("#{brew} list #{BREW_NAME} > /dev/null 2>&1") ? Installed : Install
|
|
210
210
|
end
|
|
211
211
|
|
|
212
|
-
BREW_NAME =
|
|
213
|
-
MARKER_FILE = File.expand_path(
|
|
212
|
+
BREW_NAME = "zlib"
|
|
213
|
+
MARKER_FILE = File.expand_path("~/.kompo_installed_zlib")
|
|
214
214
|
|
|
215
215
|
class Installed < Taski::Task
|
|
216
216
|
def run
|
|
@@ -226,7 +226,7 @@ module Kompo
|
|
|
226
226
|
brew = HomebrewPath.path
|
|
227
227
|
puts "Installing #{BREW_NAME}..."
|
|
228
228
|
system("#{brew} install #{BREW_NAME}") or raise "Failed to install #{BREW_NAME}"
|
|
229
|
-
File.write(MARKER_FILE,
|
|
229
|
+
File.write(MARKER_FILE, "installed")
|
|
230
230
|
|
|
231
231
|
prefix = `#{brew} --prefix #{BREW_NAME} 2>/dev/null`.chomp
|
|
232
232
|
@lib_path = "-L#{prefix}/lib" if $CHILD_STATUS.success? && !prefix.empty?
|
|
@@ -252,8 +252,8 @@ module Kompo
|
|
|
252
252
|
system("#{brew} list #{BREW_NAME} > /dev/null 2>&1") ? Installed : Install
|
|
253
253
|
end
|
|
254
254
|
|
|
255
|
-
BREW_NAME =
|
|
256
|
-
MARKER_FILE = File.expand_path(
|
|
255
|
+
BREW_NAME = "libffi"
|
|
256
|
+
MARKER_FILE = File.expand_path("~/.kompo_installed_libffi")
|
|
257
257
|
|
|
258
258
|
class Installed < Taski::Task
|
|
259
259
|
def run
|
|
@@ -269,7 +269,7 @@ module Kompo
|
|
|
269
269
|
brew = HomebrewPath.path
|
|
270
270
|
puts "Installing #{BREW_NAME}..."
|
|
271
271
|
system("#{brew} install #{BREW_NAME}") or raise "Failed to install #{BREW_NAME}"
|
|
272
|
-
File.write(MARKER_FILE,
|
|
272
|
+
File.write(MARKER_FILE, "installed")
|
|
273
273
|
|
|
274
274
|
prefix = `#{brew} --prefix #{BREW_NAME} 2>/dev/null`.chomp
|
|
275
275
|
@lib_path = "-L#{prefix}/lib" if $CHILD_STATUS.success? && !prefix.empty?
|
|
@@ -291,30 +291,30 @@ module Kompo
|
|
|
291
291
|
class ForLinux < Taski::Task
|
|
292
292
|
def run
|
|
293
293
|
unless pkg_config_available?
|
|
294
|
-
puts
|
|
295
|
-
puts
|
|
296
|
-
@lib_paths =
|
|
294
|
+
puts "[WARNING] pkg-config not found. Skipping dependency check."
|
|
295
|
+
puts "Install pkg-config to enable automatic dependency verification."
|
|
296
|
+
@lib_paths = ""
|
|
297
297
|
return
|
|
298
298
|
end
|
|
299
299
|
|
|
300
300
|
check_dependencies
|
|
301
301
|
@lib_paths = collect_lib_paths
|
|
302
302
|
|
|
303
|
-
puts
|
|
303
|
+
puts "All required development libraries are installed."
|
|
304
304
|
end
|
|
305
305
|
|
|
306
306
|
REQUIRED_LIBS = {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
307
|
+
"openssl" => {pkg_config: "openssl", apt: "libssl-dev", yum: "openssl-devel"},
|
|
308
|
+
"readline" => {pkg_config: "readline", apt: "libreadline-dev", yum: "readline-devel"},
|
|
309
|
+
"zlib" => {pkg_config: "zlib", apt: "zlib1g-dev", yum: "zlib-devel"},
|
|
310
|
+
"libyaml" => {pkg_config: "yaml-0.1", apt: "libyaml-dev", yum: "libyaml-devel"},
|
|
311
|
+
"libffi" => {pkg_config: "libffi", apt: "libffi-dev", yum: "libffi-devel"}
|
|
312
312
|
}.freeze
|
|
313
313
|
|
|
314
314
|
private
|
|
315
315
|
|
|
316
316
|
def pkg_config_available?
|
|
317
|
-
system(
|
|
317
|
+
system("which pkg-config > /dev/null 2>&1")
|
|
318
318
|
end
|
|
319
319
|
|
|
320
320
|
def check_dependencies
|
|
@@ -330,13 +330,13 @@ module Kompo
|
|
|
330
330
|
paths = pkg_names.flat_map do |pkg|
|
|
331
331
|
`pkg-config --libs-only-L #{pkg} 2>/dev/null`.chomp.split
|
|
332
332
|
end
|
|
333
|
-
paths.uniq.join(
|
|
333
|
+
paths.uniq.join(" ")
|
|
334
334
|
end
|
|
335
335
|
|
|
336
336
|
def build_error_message(missing)
|
|
337
|
-
lib_names = missing.keys.join(
|
|
338
|
-
apt_packages = missing.values.map { |info| info[:apt] }.join(
|
|
339
|
-
yum_packages = missing.values.map { |info| info[:yum] }.join(
|
|
337
|
+
lib_names = missing.keys.join(", ")
|
|
338
|
+
apt_packages = missing.values.map { |info| info[:apt] }.join(" ")
|
|
339
|
+
yum_packages = missing.values.map { |info| info[:yum] }.join(" ")
|
|
340
340
|
|
|
341
341
|
<<~MSG
|
|
342
342
|
Missing required development libraries: #{lib_names}
|
|
@@ -359,7 +359,7 @@ module Kompo
|
|
|
359
359
|
private
|
|
360
360
|
|
|
361
361
|
def macos?
|
|
362
|
-
RUBY_PLATFORM.include?(
|
|
362
|
+
RUBY_PLATFORM.include?("darwin")
|
|
363
363
|
end
|
|
364
364
|
end
|
|
365
365
|
end
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
|
|
3
|
+
require "fileutils"
|
|
4
|
+
require "open3"
|
|
5
|
+
require_relative "kompo_vfs_version_check"
|
|
5
6
|
|
|
6
7
|
module Kompo
|
|
7
8
|
# Section to get the kompo-vfs library path.
|
|
8
9
|
# Priority:
|
|
9
10
|
# 1. Local directory (if specified via context[:local_kompo_vfs_path])
|
|
10
|
-
# 2. Homebrew (
|
|
11
|
-
# 3.
|
|
11
|
+
# 2. macOS: Homebrew (required)
|
|
12
|
+
# 3. Linux: Build from source
|
|
12
13
|
class KompoVfsPath < Taski::Section
|
|
13
14
|
interfaces :path
|
|
14
15
|
|
|
@@ -16,10 +17,13 @@ module Kompo
|
|
|
16
17
|
# Priority 1: Local directory if specified
|
|
17
18
|
return FromLocal if Taski.args[:local_kompo_vfs_path]
|
|
18
19
|
|
|
19
|
-
#
|
|
20
|
-
|
|
20
|
+
# macOS: Homebrew is required
|
|
21
|
+
if darwin?
|
|
22
|
+
check_homebrew_available!
|
|
23
|
+
return FromHomebrew
|
|
24
|
+
end
|
|
21
25
|
|
|
22
|
-
#
|
|
26
|
+
# Linux: Build from source
|
|
23
27
|
FromSource
|
|
24
28
|
end
|
|
25
29
|
|
|
@@ -27,15 +31,15 @@ module Kompo
|
|
|
27
31
|
class FromLocal < Taski::Task
|
|
28
32
|
def run
|
|
29
33
|
local_path = Taski.args[:local_kompo_vfs_path]
|
|
30
|
-
raise
|
|
34
|
+
raise "Local kompo-vfs path not specified" unless local_path
|
|
31
35
|
raise "Local kompo-vfs path does not exist: #{local_path}" unless Dir.exist?(local_path)
|
|
32
36
|
|
|
33
37
|
puts "Building kompo-vfs from local directory: #{local_path}"
|
|
34
38
|
cargo = CargoPath.path
|
|
35
39
|
|
|
36
|
-
raise
|
|
40
|
+
raise "Failed to build kompo-vfs" unless system(cargo, "build", "--release", chdir: local_path)
|
|
37
41
|
|
|
38
|
-
@path = File.join(local_path,
|
|
42
|
+
@path = File.join(local_path, "target", "release")
|
|
39
43
|
puts "kompo-vfs library path: #{@path}"
|
|
40
44
|
|
|
41
45
|
KompoVfsVersionCheck.verify!(@path)
|
|
@@ -63,7 +67,7 @@ module Kompo
|
|
|
63
67
|
unless missing_libs.empty?
|
|
64
68
|
installed_version = `#{brew} list --versions kompo-vfs`.chomp.split.last
|
|
65
69
|
raise "kompo-vfs #{installed_version} is outdated. Please run: brew upgrade kompo-vfs\n" \
|
|
66
|
-
"Missing libraries: #{missing_libs.join(
|
|
70
|
+
"Missing libraries: #{missing_libs.join(", ")}"
|
|
67
71
|
end
|
|
68
72
|
|
|
69
73
|
puts "kompo-vfs library path: #{@path}"
|
|
@@ -76,9 +80,9 @@ module Kompo
|
|
|
76
80
|
class Install < Taski::Task
|
|
77
81
|
def run
|
|
78
82
|
brew = HomebrewPath.path
|
|
79
|
-
puts
|
|
80
|
-
system(brew,
|
|
81
|
-
system(brew,
|
|
83
|
+
puts "Installing kompo-vfs via Homebrew..."
|
|
84
|
+
system(brew, "tap", "ahogappa/kompo-vfs", "https://github.com/ahogappa/kompo-vfs.git") or raise "Failed to tap ahogappa/kompo-vfs"
|
|
85
|
+
system(brew, "install", "ahogappa/kompo-vfs/kompo-vfs") or raise "Failed to install kompo-vfs"
|
|
82
86
|
|
|
83
87
|
@path = "#{`#{brew} --prefix kompo-vfs`.chomp}/lib"
|
|
84
88
|
puts "kompo-vfs library path: #{@path}"
|
|
@@ -100,24 +104,24 @@ module Kompo
|
|
|
100
104
|
|
|
101
105
|
# Build from source (requires Cargo)
|
|
102
106
|
class FromSource < Taski::Task
|
|
103
|
-
REPO_URL =
|
|
107
|
+
REPO_URL = "https://github.com/ahogappa/kompo-vfs"
|
|
104
108
|
|
|
105
109
|
def run
|
|
106
|
-
puts
|
|
110
|
+
puts "Building kompo-vfs from source..."
|
|
107
111
|
cargo = CargoPath.path
|
|
108
112
|
|
|
109
|
-
build_dir = File.expand_path(
|
|
113
|
+
build_dir = File.expand_path("~/.kompo/kompo-vfs")
|
|
110
114
|
FileUtils.mkdir_p(File.dirname(build_dir))
|
|
111
115
|
|
|
112
116
|
if Dir.exist?(build_dir)
|
|
113
|
-
system(
|
|
117
|
+
system("git", "-C", build_dir, "pull", "--quiet")
|
|
114
118
|
else
|
|
115
|
-
system(
|
|
119
|
+
system("git", "clone", REPO_URL, build_dir) or raise "Failed to clone kompo-vfs repository"
|
|
116
120
|
end
|
|
117
121
|
|
|
118
|
-
system(cargo,
|
|
122
|
+
system(cargo, "build", "--release", chdir: build_dir) or raise "Failed to build kompo-vfs"
|
|
119
123
|
|
|
120
|
-
@path = File.join(build_dir,
|
|
124
|
+
@path = File.join(build_dir, "target", "release")
|
|
121
125
|
puts "kompo-vfs library path: #{@path}"
|
|
122
126
|
|
|
123
127
|
KompoVfsVersionCheck.verify!(@path)
|
|
@@ -126,19 +130,24 @@ module Kompo
|
|
|
126
130
|
|
|
127
131
|
private
|
|
128
132
|
|
|
129
|
-
def
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
def darwin?
|
|
134
|
+
RUBY_PLATFORM.include?("darwin") || `uname -s`.chomp == "Darwin"
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def check_homebrew_available!
|
|
138
|
+
# Check if brew is in PATH
|
|
139
|
+
brew_in_path, = Open3.capture2("which", "brew", err: File::NULL)
|
|
140
|
+
return unless brew_in_path.chomp.empty?
|
|
141
|
+
|
|
142
|
+
# Check common Homebrew installation paths (including ARM64 at /opt/homebrew)
|
|
143
|
+
return if HomebrewPath::COMMON_BREW_PATHS.any? { |p| File.executable?(p) }
|
|
133
144
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
%w[x86_64 Darwin],
|
|
138
|
-
%w[x86_64 Linux]
|
|
139
|
-
]
|
|
145
|
+
raise <<~ERROR
|
|
146
|
+
Homebrew is required on macOS but not installed.
|
|
147
|
+
Please install Homebrew first: https://brew.sh
|
|
140
148
|
|
|
141
|
-
|
|
149
|
+
For local development, you can use --local-vfs-path option instead.
|
|
150
|
+
ERROR
|
|
142
151
|
end
|
|
143
152
|
end
|
|
144
153
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
3
|
+
require_relative "../version"
|
|
4
4
|
|
|
5
5
|
module Kompo
|
|
6
6
|
# Verifies that the installed kompo-vfs version meets minimum requirements.
|
|
@@ -8,7 +8,7 @@ module Kompo
|
|
|
8
8
|
module KompoVfsVersionCheck
|
|
9
9
|
class IncompatibleVersionError < StandardError; end
|
|
10
10
|
|
|
11
|
-
VERSION_FILE =
|
|
11
|
+
VERSION_FILE = "KOMPO_VFS_VERSION"
|
|
12
12
|
|
|
13
13
|
def self.verify!(lib_path)
|
|
14
14
|
actual_version = get_version(lib_path)
|
|
@@ -37,7 +37,8 @@ module Kompo
|
|
|
37
37
|
Required: >= #{required_version}
|
|
38
38
|
|
|
39
39
|
Please upgrade:
|
|
40
|
-
Homebrew: brew upgrade kompo-vfs
|
|
40
|
+
Homebrew: brew update && brew upgrade kompo-vfs
|
|
41
|
+
(If upgrade fails, try: brew tap --force-auto-update ahogappa/kompo)
|
|
41
42
|
Source: cd ~/.kompo/kompo-vfs && git pull && cargo build --release
|
|
42
43
|
MSG
|
|
43
44
|
end
|
|
@@ -48,7 +49,8 @@ module Kompo
|
|
|
48
49
|
Your kompo-vfs installation may be outdated (< 0.5.0).
|
|
49
50
|
|
|
50
51
|
Please upgrade:
|
|
51
|
-
Homebrew: brew upgrade kompo-vfs
|
|
52
|
+
Homebrew: brew update && brew upgrade kompo-vfs
|
|
53
|
+
(If upgrade fails, try: brew tap --force-auto-update ahogappa/kompo)
|
|
52
54
|
Source: cd ~/.kompo/kompo-vfs && git pull && cargo build --release
|
|
53
55
|
MSG
|
|
54
56
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
3
|
+
require "erb"
|
|
4
|
+
require "fileutils"
|
|
5
|
+
require "find"
|
|
6
6
|
|
|
7
7
|
module Kompo
|
|
8
8
|
# Struct to hold file data for embedding
|
|
@@ -30,7 +30,7 @@ module Kompo
|
|
|
30
30
|
|
|
31
31
|
def run
|
|
32
32
|
@work_dir = WorkDir.path
|
|
33
|
-
@path = File.join(@work_dir,
|
|
33
|
+
@path = File.join(@work_dir, "fs.c")
|
|
34
34
|
|
|
35
35
|
# Get original paths for Ruby standard library cache support
|
|
36
36
|
# When Ruby is restored from cache, standard library paths are from the original build
|
|
@@ -47,8 +47,11 @@ module Kompo
|
|
|
47
47
|
@file_bytes = []
|
|
48
48
|
@paths = []
|
|
49
49
|
@file_sizes = [0]
|
|
50
|
+
@added_paths = Set.new
|
|
51
|
+
@duplicate_count = 0
|
|
52
|
+
@verbose = Taski.args.fetch(:verbose, false)
|
|
50
53
|
|
|
51
|
-
group(
|
|
54
|
+
group("Collecting files") do
|
|
52
55
|
embed_paths = collect_embed_paths
|
|
53
56
|
|
|
54
57
|
embed_paths.each do |embed_path|
|
|
@@ -64,13 +67,14 @@ module Kompo
|
|
|
64
67
|
add_file(expand_path)
|
|
65
68
|
end
|
|
66
69
|
end
|
|
67
|
-
|
|
70
|
+
duplicate_info = @duplicate_count.positive? ? " (#{@duplicate_count} duplicates skipped)" : ""
|
|
71
|
+
puts "Collected #{@file_sizes.size - 1} files#{duplicate_info}"
|
|
68
72
|
end
|
|
69
73
|
|
|
70
|
-
group(
|
|
74
|
+
group("Generating fs.c") do
|
|
71
75
|
context = build_template_context
|
|
72
76
|
|
|
73
|
-
template_path = File.join(__dir__,
|
|
77
|
+
template_path = File.join(__dir__, "..", "..", "fs.c.erb")
|
|
74
78
|
template = ERB.new(File.read(template_path))
|
|
75
79
|
File.write(@path, template.result(binding))
|
|
76
80
|
puts "Generated: fs.c (#{@file_bytes.size} bytes)"
|
|
@@ -81,7 +85,7 @@ module Kompo
|
|
|
81
85
|
return unless @path && File.exist?(@path)
|
|
82
86
|
|
|
83
87
|
FileUtils.rm_f(@path)
|
|
84
|
-
puts
|
|
88
|
+
puts "Cleaned up fs.c"
|
|
85
89
|
end
|
|
86
90
|
|
|
87
91
|
private
|
|
@@ -90,24 +94,21 @@ module Kompo
|
|
|
90
94
|
paths = []
|
|
91
95
|
|
|
92
96
|
# 1. Project files (entrypoint + additional files/directories specified by user)
|
|
93
|
-
# Created by: CopyProjectFiles
|
|
94
97
|
paths << CopyProjectFiles.entrypoint_path
|
|
95
98
|
paths += CopyProjectFiles.additional_paths
|
|
96
99
|
|
|
97
|
-
# 2. Gemfile
|
|
98
|
-
# Created by: CopyGemfile
|
|
100
|
+
# 2. Gemfile, Gemfile.lock, and gemspec files (if exists)
|
|
99
101
|
if CopyGemfile.gemfile_exists
|
|
100
|
-
paths << File.join(@work_dir,
|
|
101
|
-
paths << File.join(@work_dir,
|
|
102
|
+
paths << File.join(@work_dir, "Gemfile")
|
|
103
|
+
paths << File.join(@work_dir, "Gemfile.lock")
|
|
104
|
+
paths += CopyGemfile.gemspec_paths
|
|
102
105
|
|
|
103
106
|
# 3. Bundle directory (.bundle/config and bundle/ruby/X.Y.Z/gems/...)
|
|
104
|
-
# Created by: BundleInstall
|
|
105
107
|
paths << BundleInstall.bundler_config_path
|
|
106
108
|
paths << BundleInstall.bundle_ruby_dir
|
|
107
109
|
end
|
|
108
110
|
|
|
109
111
|
# 4. Ruby standard library
|
|
110
|
-
# Retrieved by: CheckStdlibs
|
|
111
112
|
paths += CheckStdlibs.paths
|
|
112
113
|
|
|
113
114
|
paths.compact
|
|
@@ -136,7 +137,7 @@ module Kompo
|
|
|
136
137
|
|
|
137
138
|
# Skip certain file extensions
|
|
138
139
|
next if SKIP_EXTENSIONS.any? { |ext| path.end_with?(ext) }
|
|
139
|
-
next if path.end_with?(
|
|
140
|
+
next if path.end_with?("selenium-manager")
|
|
140
141
|
|
|
141
142
|
# Skip files matching .kompoignore patterns
|
|
142
143
|
next if should_ignore?(path)
|
|
@@ -154,7 +155,7 @@ module Kompo
|
|
|
154
155
|
# Ruby standard library paths are outside work_dir and should not be filtered
|
|
155
156
|
return false unless absolute_path.start_with?(@work_dir)
|
|
156
157
|
|
|
157
|
-
relative_path = absolute_path.sub("#{@work_dir}/",
|
|
158
|
+
relative_path = absolute_path.sub("#{@work_dir}/", "")
|
|
158
159
|
if @kompo_ignore.ignore?(relative_path)
|
|
159
160
|
puts "Ignoring (via .kompoignore): #{relative_path}"
|
|
160
161
|
true
|
|
@@ -164,15 +165,23 @@ module Kompo
|
|
|
164
165
|
end
|
|
165
166
|
|
|
166
167
|
def add_file(path)
|
|
168
|
+
# Skip duplicate files (same absolute path)
|
|
169
|
+
if @added_paths.include?(path)
|
|
170
|
+
@duplicate_count += 1
|
|
171
|
+
puts "skip: duplicate path #{path}" if @verbose
|
|
172
|
+
return
|
|
173
|
+
end
|
|
174
|
+
@added_paths.add(path)
|
|
175
|
+
|
|
167
176
|
# Keep original paths for VFS - the caching system already ensures
|
|
168
177
|
# the same work_dir path is reused across builds via metadata.json
|
|
169
178
|
# Ruby's $LOAD_PATH uses work_dir paths, so embedded files must match.
|
|
170
179
|
embedded_path = if @current_ruby_install_dir != @original_ruby_install_dir && path.start_with?(@current_ruby_install_dir)
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
180
|
+
# Ruby install dir path replacement for cache compatibility (when paths differ)
|
|
181
|
+
path.sub(@current_ruby_install_dir, @original_ruby_install_dir)
|
|
182
|
+
else
|
|
183
|
+
path
|
|
184
|
+
end
|
|
176
185
|
|
|
177
186
|
puts "#{path} -> #{embedded_path}" if path != embedded_path
|
|
178
187
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "erb"
|
|
4
|
+
require "fileutils"
|
|
5
5
|
|
|
6
6
|
module Kompo
|
|
7
7
|
# Generate main.c from ERB template
|
|
@@ -15,25 +15,25 @@ module Kompo
|
|
|
15
15
|
|
|
16
16
|
def run
|
|
17
17
|
work_dir = WorkDir.path
|
|
18
|
-
@path = File.join(work_dir,
|
|
18
|
+
@path = File.join(work_dir, "main.c")
|
|
19
19
|
|
|
20
20
|
return if File.exist?(@path)
|
|
21
21
|
|
|
22
|
-
template_path = File.join(__dir__,
|
|
22
|
+
template_path = File.join(__dir__, "..", "..", "main.c.erb")
|
|
23
23
|
template = ERB.new(File.read(template_path))
|
|
24
24
|
|
|
25
25
|
# Build context object for ERB template
|
|
26
26
|
context = build_template_context
|
|
27
27
|
|
|
28
28
|
File.write(@path, template.result(binding))
|
|
29
|
-
puts
|
|
29
|
+
puts "Generated: main.c"
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def clean
|
|
33
33
|
return unless @path && File.exist?(@path)
|
|
34
34
|
|
|
35
35
|
FileUtils.rm_f(@path)
|
|
36
|
-
puts
|
|
36
|
+
puts "Cleaned up main.c"
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
private
|