Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions gem/lib/triangulum/validation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class BunNotFound < Triangulum::Error
Gem::Platform.match_gem?(platform, Gem::Platform.local.to_s)
end

IS_RUBY_PLATFORM_GEM = Dir.glob(File.expand_path('../../exe/*/bun', __dir__)).empty?

attr_reader :flow, :runtime_function_definitions, :data_types

def initialize(flow, runtime_function_definitions, data_types)
Expand All @@ -38,10 +40,8 @@ def validate
private

def run_ts_triangulum(input)
raise BunNotFound, "No bundled bun binary found for #{Gem::Platform.local}" if BUN_EXE.nil?

stdout_s, stderr_s, status = Open3.capture3(
BUN_EXE, 'run', ENTRYPOINT,
bun, 'run', ENTRYPOINT,
stdin_data: input
)

Expand Down Expand Up @@ -88,5 +88,15 @@ def parse_output(output)
end
)
end

def bun
if IS_RUBY_PLATFORM_GEM
'bun'
else
raise BunNotFound, "No bundled bun binary found for #{Gem::Platform.local}" if BUN_EXE.nil?

BUN_EXE
end
end
end
end
5 changes: 5 additions & 0 deletions gem/rakelib/package.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ exepaths = []

TRIANGULUM_GEMSPEC = Bundler.load_gemspec('triangulum.gemspec')

ruby_gem_path = Gem::PackageTask.new(TRIANGULUM_GEMSPEC).define

desc 'Build the ruby (platform-independent) gem'
task 'gem:ruby' => [ruby_gem_path]

BUN_PLATFORMS.each do |platform, (zip_filename, expected_checksum)|
TRIANGULUM_GEMSPEC.dup.tap do |gemspec|
exedir = File.join('exe', platform)
Expand Down
Loading