File tree Expand file tree Collapse file tree 5 files changed +30
-52
lines changed Expand file tree Collapse file tree 5 files changed +30
-52
lines changed Original file line number Diff line number Diff line change @@ -70,10 +70,37 @@ endfunction()
7070set (TO_HRL_PATH ${CMAKE_CURRENT_LIST_DIR} )
7171
7272function (generate_hrl out_file def_name in_file)
73+ if (AVM_DISABLE_JIT)
74+ # For non-JIT builds, use the base file
75+ set (selected_file ${in_file} )
76+ else ()
77+ # For JIT builds, determine the architecture-specific file
78+ get_filename_component (base_name ${in_file} NAME_WE )
79+ get_filename_component (base_ext ${in_file} EXT )
80+ get_filename_component (base_dir ${in_file} DIRECTORY )
81+
82+ # Check if it's a .avm file (pack) or .beam file
83+ if (base_ext STREQUAL ".avm" )
84+ # For .avm files: name.avm -> name-arch.avm
85+ if (base_dir)
86+ set (selected_file ${base_dir} /${base_name} -${AVM_JIT_TARGET_ARCH}${base_ext} )
87+ else ()
88+ set (selected_file ${base_name} -${AVM_JIT_TARGET_ARCH}${base_ext} )
89+ endif ()
90+ else ()
91+ # For .beam files: name.beam -> arch/name.beam
92+ if (base_dir)
93+ set (selected_file ${base_dir} /${AVM_JIT_TARGET_ARCH} /${base_name}${base_ext} )
94+ else ()
95+ set (selected_file ${AVM_JIT_TARGET_ARCH} /${base_name}${base_ext} )
96+ endif ()
97+ endif ()
98+ endif ()
99+
73100 add_custom_command (
74101 OUTPUT ${out_file}
75- COMMAND escript ${TO_HRL_PATH} /to_hrl.erl ${in_file } ${def_name} ${out_file}
76- DEPENDS ${in_file }
102+ COMMAND escript ${TO_HRL_PATH} /to_hrl.erl ${selected_file } ${def_name} ${out_file}
103+ DEPENDS ${selected_file }
77104 COMMENT "Generating ${out_file} "
78105 )
79106endfunction ()
Original file line number Diff line number Diff line change @@ -37,9 +37,7 @@ set(code_load_deps
3737 code_load_pack_data.hrl
3838)
3939if (NOT AVM_DISABLE_JIT)
40- generate_hrl(export_test_module_data_${AVM_JIT_TARGET_ARCH} .hrl EXPORT_TEST_MODULE_DATA_${AVM_JIT_TARGET_ARCH} ${AVM_JIT_TARGET_ARCH} /export_test_module.beam)
41- generate_hrl(code_load_pack_data_${AVM_JIT_TARGET_ARCH} .hrl CODE_LOAD_PACK_DATA_${AVM_JIT_TARGET_ARCH} code_load_pack-${AVM_JIT_TARGET_ARCH} .avm)
42- set (code_load_deps ${code_load_deps} export_test_module_data_${AVM_JIT_TARGET_ARCH} .hrl code_load_pack_data_${AVM_JIT_TARGET_ARCH} .hrl jit)
40+ set (code_load_deps ${code_load_deps} jit)
4341endif ()
4442
4543add_custom_target (code_load_files DEPENDS ${code_load_deps} )
Original file line number Diff line number Diff line change 2222
2323-export ([start /0 ]).
2424
25- -ifdef (AVM_DISABLE_JIT ).
2625-include (" code_load/code_load_pack_data.hrl" ).
2726
2827load_pack_data () ->
2928 ? CODE_LOAD_PACK_DATA .
30- -else .
31- -if (? AVM_JIT_TARGET_ARCH == aarch64 ).
32- -include (" code_load/code_load_pack_data_aarch64.hrl" ).
33-
34- load_pack_data () ->
35- ? CODE_LOAD_PACK_DATA_aarch64 .
36- -elif (? AVM_JIT_TARGET_ARCH == x86_64 ).
37- -include (" code_load/code_load_pack_data_x86_64.hrl" ).
38-
39- load_pack_data () ->
40- ? CODE_LOAD_PACK_DATA_x86_64 .
41- -endif .
42- -endif .
4329
4430start () ->
4531 Bin = load_pack_data (),
Original file line number Diff line number Diff line change 2222
2323-export ([start /0 ]).
2424
25- -ifdef (AVM_DISABLE_JIT ).
2625-include (" code_load/code_load_pack_data.hrl" ).
2726
2827load_pack_data () ->
2928 ? CODE_LOAD_PACK_DATA .
30- -else .
31- -if (? AVM_JIT_TARGET_ARCH == aarch64 ).
32- -include (" code_load/code_load_pack_data_aarch64.hrl" ).
33-
34- load_pack_data () ->
35- ? CODE_LOAD_PACK_DATA_aarch64 .
36- -elif (? AVM_JIT_TARGET_ARCH == x86_64 ).
37- -include (" code_load/code_load_pack_data_x86_64.hrl" ).
38-
39- load_pack_data () ->
40- ? CODE_LOAD_PACK_DATA_x86_64 .
41- -else .
42- -include (" code_load/code_load_pack_data_x86_64.hrl" ).
43-
44- load_pack_data () ->
45- ? CODE_LOAD_PACK_DATA_x86_64 .
46- -endif .
47- -endif .
4829
4930start () ->
5031 Bin = load_pack_data (),
Original file line number Diff line number Diff line change 2222
2323-export ([start /0 ]).
2424
25- -ifdef (AVM_DISABLE_JIT ).
2625-include (" code_load/export_test_module_data.hrl" ).
2726
2827export_test_module_data () ->
2928 ? EXPORT_TEST_MODULE_DATA .
30- -else .
31- -if (? AVM_JIT_TARGET_ARCH == aarch64 ).
32- -include (" code_load/export_test_module_data_aarch64.hrl" ).
33-
34- export_test_module_data () ->
35- ? EXPORT_TEST_MODULE_DATA_aarch64 .
36- -elif (? AVM_JIT_TARGET_ARCH == x86_64 ).
37- -include (" code_load/export_test_module_data_x86_64.hrl" ).
38-
39- export_test_module_data () ->
40- ? EXPORT_TEST_MODULE_DATA_x86_64 .
41- -endif .
42- -endif .
4329
4430start () ->
4531 Bin = export_test_module_data (),
You can’t perform that action at this time.
0 commit comments