-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRakefile
More file actions
52 lines (42 loc) · 1.69 KB
/
Rakefile
File metadata and controls
52 lines (42 loc) · 1.69 KB
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
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rake/extensiontask'
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test.rb']
end
Rake::ExtensionTask.new('executorch') do |ext|
ext.lib_dir = 'lib/executorch'
end
task default: %i[compile test]
namespace :executorch do
desc 'Build ExecuTorch from source and install to vendor/executorch'
task :build_deps do
source_dir = ENV.fetch('EXECUTORCH_SRC', File.expand_path('../executorch', __dir__))
install_dir = File.expand_path('vendor/executorch', __dir__)
unless File.directory?(source_dir)
abort "ExecuTorch source not found at #{source_dir}. Clone it or set EXECUTORCH_SRC."
end
puts "Building ExecuTorch from #{source_dir}..."
puts "Installing to #{install_dir}..."
Dir.chdir(source_dir) do
system('cmake', '-B', 'cmake-out',
"-DCMAKE_INSTALL_PREFIX=#{install_dir}",
'-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON',
'-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON',
'-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON',
'-DCMAKE_BUILD_TYPE=Release') || abort('CMake configure failed')
system('cmake', '--build', 'cmake-out', "-j#{Etc.nprocessors}") || abort('CMake build failed')
system('cmake', '--install', 'cmake-out') || abort('CMake install failed')
end
puts "ExecuTorch installed to #{install_dir}"
puts "Run: bundle config set --local build.executorch --with-executorch-dir=#{install_dir}"
end
end
desc 'Clean build artifacts'
task :clean do
FileUtils.rm_rf('lib/executorch/executorch.bundle')
FileUtils.rm_rf('lib/executorch/executorch.so')
FileUtils.rm_rf('tmp')
end