Skip to content

Commit 2c8ce53

Browse files
committed
AArch64: simplify to_hrl usage with precompiled tests
Signed-off-by: Paul Guyot <[email protected]>
1 parent 3b9ddf3 commit 2c8ce53

File tree

5 files changed

+30
-52
lines changed

5 files changed

+30
-52
lines changed

tests/erlang_tests/CMakeLists.txt

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,37 @@ endfunction()
7070
set(TO_HRL_PATH ${CMAKE_CURRENT_LIST_DIR})
7171

7272
function(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
)
79106
endfunction()

tests/erlang_tests/code_load/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ set(code_load_deps
3737
code_load_pack_data.hrl
3838
)
3939
if(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)
4341
endif()
4442

4543
add_custom_target(code_load_files DEPENDS ${code_load_deps})

tests/erlang_tests/test_add_avm_pack_binary.erl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,10 @@
2222

2323
-export([start/0]).
2424

25-
-ifdef(AVM_DISABLE_JIT).
2625
-include("code_load/code_load_pack_data.hrl").
2726

2827
load_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

4430
start() ->
4531
Bin = load_pack_data(),

tests/erlang_tests/test_close_avm_pack.erl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,10 @@
2222

2323
-export([start/0]).
2424

25-
-ifdef(AVM_DISABLE_JIT).
2625
-include("code_load/code_load_pack_data.hrl").
2726

2827
load_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

4930
start() ->
5031
Bin = load_pack_data(),

tests/erlang_tests/test_code_load_binary.erl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,10 @@
2222

2323
-export([start/0]).
2424

25-
-ifdef(AVM_DISABLE_JIT).
2625
-include("code_load/export_test_module_data.hrl").
2726

2827
export_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

4430
start() ->
4531
Bin = export_test_module_data(),

0 commit comments

Comments
 (0)