2222OptionParser . new do |opts |
2323 opts . on '--genvm'
2424 opts . on '--rust'
25+ opts . on '--cross-linux-aarch64'
26+ opts . on '--zig'
2527 opts . on '--rust-det'
2628 opts . on '--os'
2729 opts . on '--wasi'
@@ -90,6 +92,7 @@ def find_executable(name)
9092end . call ( )
9193
9294logger . info ( "detected target is #{ TARGET_TRIPLE } " )
95+ $logger = logger
9396
9497OS = ( Proc . new {
9598 re = {
@@ -127,6 +130,7 @@ def find_executable(name)
127130
128131download_dir = root . join ( 'tools' , 'downloaded' )
129132download_dir . mkpath ( )
133+ $download_dir = download_dir
130134
131135logger . debug ( "download dir is #{ download_dir } " )
132136
@@ -148,6 +152,9 @@ def load_packages_from_lists(dir)
148152
149153if options [ :os ]
150154 load_packages_from_lists 'os'
155+ #if options[:'cross-linux-aarch64']
156+ # load_packages_from_lists 'os-linux-aarch64'
157+ #end
151158end
152159
153160if not RUBY_VERSION =~ /^3\. /
@@ -166,6 +173,27 @@ def load_packages_from_lists(dir)
166173 raise "rustup not found" if rustup . nil?
167174end
168175
176+ if options [ :'cross-linux-aarch64' ]
177+ # ZIG
178+ # FIXME(kp2pml30) check platform
179+ require_relative './src/webget.rb'
180+ download_to = download_dir . join ( 'zig.tar.xz' )
181+ read_file (
182+ uri : URI ( "https://ziglang.org/builds/zig-linux-x86_64-0.14.0-dev.2238+1db8cade5.tar.xz" ) ,
183+ path : download_to
184+ )
185+ extract_tar ( download_dir . join ( 'zig' ) , download_to )
186+
187+ # openssl
188+ download_to = download_dir . join ( 'openssl-aarch.tar.xz' )
189+ read_file (
190+ uri : URI ( "http://mirror.archlinuxarm.org/aarch64/core/openssl-3.4.0-1-aarch64.pkg.tar.xz" ) ,
191+ path : download_to ,
192+ use_ssl : false ,
193+ )
194+ extract_tar ( download_dir . join ( 'cross-aarch64-libs' ) , download_to , trim_first : false )
195+ end
196+
169197if options [ :rust ]
170198 puts `cd "#{ root } " && #{ rustup } show active-toolchain || #{ rustup } toolchain install`
171199 run_command ( rustup , 'component' , 'add' , 'rustfmt' , chdir : root )
@@ -181,10 +209,19 @@ def load_packages_from_lists(dir)
181209 run_command ( rustup , 'component' , 'add' , '--toolchain' , cur_toolchain , 'rust-std' , chdir : ext_path )
182210end
183211
212+ if options [ :rust ] and options [ :'cross-linux-aarch64' ]
213+ ext_path = root . join ( 'executor' )
214+ cur_toolchain = run_command ( rustup , 'show' , 'active-toolchain' , chdir : ext_path )
215+ cur_toolchain = cur_toolchain . lines . map { |l | l . strip } . filter { |l | l . size != 0 } . last
216+ cur_toolchain = /^([a-zA-Z0-9\- _]+)/ . match ( cur_toolchain ) [ 1 ]
217+ logger . debug ( "installing for toolchain #{ cur_toolchain } " )
218+ run_command ( rustup , 'target' , 'add' , '--toolchain' , cur_toolchain , 'aarch64-unknown-linux-gnu' , chdir : ext_path )
219+ run_command ( rustup , 'component' , 'add' , '--toolchain' , cur_toolchain , 'rust-std' , chdir : ext_path )
220+ end
221+
184222if options [ :wasi ]
185223 logger . debug ( "downloading runners dependencies" )
186- src = Pathname . new ( __FILE__ ) . parent . join ( 'src' , 'wasi-sdk.rb' ) . read
187- eval ( src , binding )
224+ require_relative './src/wasi-sdk.rb'
188225
189226 if find_executable ( 'docker' ) . nil?
190227 logger . error ( "docker is required" )
0 commit comments