File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1725,6 +1725,23 @@ def host_arch_cc():
17251725 return rtn
17261726
17271727
1728+ def is_rosetta2 ():
1729+ if flavor != 'mac' :
1730+ return False
1731+ try :
1732+ proc = subprocess .Popen (['sysctl' , '-n' , 'sysctl.proc_translated' ],
1733+ stdin = subprocess .PIPE , stderr = subprocess .PIPE ,
1734+ stdout = subprocess .PIPE )
1735+ except OSError :
1736+ warn ('sysctl failed' )
1737+ return False
1738+ with proc :
1739+ out = to_utf8 (proc .communicate ()[0 ]).strip ()
1740+ warn (f'proc_translated: { out } ' )
1741+ # return out == '1'
1742+ return True
1743+
1744+
17281745def host_arch_win ():
17291746 """Host architecture check using environ vars (better way to do this?)"""
17301747
@@ -1855,6 +1872,8 @@ def configure_node(o):
18551872 if flavor == 'win' :
18561873 o ['variables' ]['cargo_rust_target' ] = \
18571874 'aarch64-pc-windows-msvc' if target_arch == 'arm64' else 'x86_64-pc-windows-msvc'
1875+ if target_arch == 'x64' and is_rosetta2 ():
1876+ o ['variables' ]['cargo_rust_target' ] = 'x86_64-apple-darwin'
18581877
18591878 # Allow overriding the compiler - needed by embedders.
18601879 if options .use_clang :
Original file line number Diff line number Diff line change 1111 },
1212 'conditions' : [
1313 ['cargo_rust_target!=""' , {
14+ 'variables' : {
15+ 'cargo_build_flags' : ['--target' , '<(cargo_rust_target)' ],
16+ }
17+ }],
18+ ['OS=="win"' , {
1419 'variables' : {
1520 'node_crates_libpath' : '<(SHARED_INTERMEDIATE_DIR)/$(Platform)/release/node_crates.lib' ,
1621 },
1722 }, {
1823 'variables' : {
19- 'node_crates_libpath' : '<(SHARED_INTERMEDIATE_DIR)/release/<(STATIC_LIB_PREFIX)node_crates<(STATIC_LIB_SUFFIX)' ,
24+ 'node_crates_libpath' : '<(SHARED_INTERMEDIATE_DIR)/<(cargo_rust_target)/ release/<(STATIC_LIB_PREFIX)node_crates<(STATIC_LIB_SUFFIX)' ,
2025 },
2126 }],
2227 ],
2631 },
2732 'conditions' : [
2833 ['cargo_rust_target!=""' , {
34+ 'variables' : {
35+ 'cargo_build_flags' : ['--target' , '$(cargo_rust_target)' ],
36+ }
37+ }],
38+ ['OS=="win"' , {
2939 'variables' : {
3040 'node_crates_libpath' : '<(SHARED_INTERMEDIATE_DIR)/$(Platform)/debug/node_crates.lib' ,
3141 },
3242 }, {
3343 'variables' : {
34- 'node_crates_libpath' : '<(SHARED_INTERMEDIATE_DIR)/debug/<(STATIC_LIB_PREFIX)node_crates<(STATIC_LIB_SUFFIX)' ,
44+ 'node_crates_libpath' : '<(SHARED_INTERMEDIATE_DIR)/<(cargo_rust_target)/ debug/<(STATIC_LIB_PREFIX)node_crates<(STATIC_LIB_SUFFIX)' ,
3545 },
3646 }],
3747 ],
6272 ],
6373 },
6474 'conditions' : [
65- ['cargo_rust_target!=" "' , {
75+ ['OS=="win "' , {
6676 'actions' : [
6777 {
6878 'action_name' : 'cargo_build' ,
You can’t perform that action at this time.
0 commit comments