-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathRakefile
66 lines (52 loc) · 2.05 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
require "yaml"
require_relative 'lib/rsyntaxtree'
require_relative 'lib/rsyntaxtree/utils'
# task default: "test"
Rake::TestTask.new do |task|
task.pattern = "test/*_test.rb"
task.warning = false
end
desc "Generate SVG and PNG example images locally"
task :generate do
require_relative "dev/generate_examples"
end
desc "Docker image Build"
task :docker_build do
`docker build ./ -t rsyntaxtree_devel`
end
desc "Generate SVG and PNG example images using Docker image"
task :docker_generate do
docpath = File.expand_path(File.join(__dir__, "docs"))
`docker build ./ -t rsyntaxtree_devel`
`docker run --rm -v #{docpath}:/rsyntaxtree/hostdocs rsyntaxtree_devel ruby /rsyntaxtree/dev/generate_examples.rb /rsyntaxtree/hostdocs`
`cat #{docpath}/generate_examples.log`
end
# Add new task for macOS environment configuration
desc "Configure Bundler build options for macOS"
task :setup_macos do
require "rbconfig"
host_os = RbConfig::CONFIG['host_os']
# Check if the host OS is macOS (Darwin)
if host_os =~ /darwin/
puts "macOS detected. Setting up build options for native extensions..."
gems_with_options = {
"gobject-introspection" => '--with-ldflags=-Wl,-undefined,dynamic_lookup',
"cairo-gobject" => '--with-ldflags=-Wl,-undefined,dynamic_lookup',
"gio2" => '--with-ldflags=-Wl,-undefined,dynamic_lookup'
}
# Configure each gem with the necessary ldflags option using Bundler config command
gems_with_options.each do |gem_name, flags|
command = "bundle config build.#{gem_name} \"#{flags}\""
puts "Executing: #{command}"
unless system(command)
abort("Failed to execute command: #{command}")
end
end
puts "macOS setup complete. Please run 'bundle install' after this."
else
puts "This setup task is intended for macOS environments. Current OS: #{host_os}"
end
end