1
1
import CMake_jll: cmake
2
- using p7zip_jll, Tar
3
2
using Clang. Generators
4
3
5
4
function build_libbitfield_native ()
@@ -14,7 +13,7 @@ function build_libbitfield_native()
14
13
if Sys. iswindows ()
15
14
config_cmd = ` $config_cmd -A win32`
16
15
elseif Sys. islinux ()
17
- config_cmd = ` $config_cmd -D CMAKE_C_FLAGS=-march=native -D CMAKE_CXX_FLAGS=- march=native`
16
+ config_cmd = ` $config_cmd -D CMAKE_C_FLAGS='-m32 - march=native' `
18
17
end
19
18
end
20
19
build_cmd = ` $(cmake ()) --build $build_dir --config Debug`
@@ -30,32 +29,11 @@ function build_libbitfield_native()
30
29
return success
31
30
end
32
31
33
-
34
- function build_libbitfield_binarybuilder ()
35
- @info " Building libbitfield binary with BinaryBuilder."
36
- success = true
37
- try
38
- cd (@__DIR__ ) do
39
- run (` $(Base. julia_cmd ()) --project bitfield/build_tarballs.jl` )
40
- # from Pkg.download_verify_unpack
41
- # Note that we filter out the extra log file that's generated
42
- tarball_path = only (filter (! contains (" -logs.v" ), readdir (" products" )))
43
- dest = " build"
44
- rm (dest; recursive = true )
45
- Tar. extract (` $(p7zip_jll. p7zip ()) x products/$tarball_path -so` , dest)
46
- end
47
- catch e
48
- @warn " Building libbitfield with BinaryBuilder failed" exception= (e, catch_backtrace ())
49
- success = false
50
- end
51
- return success
52
- end
53
-
54
32
function build_libbitfield ()
55
33
success = true
56
34
try
57
35
# Compile binary
58
- if ! build_libbitfield_binarybuilder () && ! build_libbitfield_native ()
36
+ if ! build_libbitfield_native ()
59
37
error (" Could not build libbitfield binary" )
60
38
end
61
39
@@ -77,28 +55,36 @@ function build_libbitfield()
77
55
m = Base. @invokelatest LibBitField. Mirror (10 , 1.5 , 1e6 , - 4 , 7 , 3 )
78
56
Base. @invokelatest LibBitField. toBitfield (Ref (m))
79
57
catch e
80
- @warn " Building libbitfield failed: $e "
81
- success = false
58
+ if haskey (ENV , " CI" )
59
+ rethrow ()
60
+ else
61
+ @warn " Building libbitfield failed: $e "
62
+ success = false
63
+ end
82
64
end
83
65
return success
84
66
end
85
67
86
-
68
+ # The actual tests are in this separate function so it's easier to @invokelatest
69
+ # all of the new functions.
70
+ function test_libbitfield ()
71
+ bf = Ref (LibBitField. BitField (Int8 (10 ), 1.5 , Int32 (1e6 ), Int32 (- 4 ), Int32 (7 ), UInt32 (3 )))
72
+ m = Ref (LibBitField. Mirror (10 , 1.5 , 1e6 , - 4 , 7 , 3 ))
73
+ GC. @preserve bf m begin
74
+ pbf = Ptr {LibBitField.BitField} (pointer_from_objref (bf))
75
+ pm = Ptr {LibBitField.Mirror} (pointer_from_objref (m))
76
+ @test LibBitField. toMirror (bf) == m[]
77
+ @test LibBitField. toBitfield (m). a == bf[]. a
78
+ @test LibBitField. toBitfield (m). b == bf[]. b
79
+ @test LibBitField. toBitfield (m). c == bf[]. c
80
+ @test LibBitField. toBitfield (m). d == bf[]. d
81
+ @test LibBitField. toBitfield (m). e == bf[]. e
82
+ @test LibBitField. toBitfield (m). f == bf[]. f
83
+ end
84
+ end
87
85
88
86
@testset " Bitfield" begin
89
87
if build_libbitfield ()
90
- bf = Ref (LibBitField. BitField (Int8 (10 ), 1.5 , Int32 (1e6 ), Int32 (- 4 ), Int32 (7 ), UInt32 (3 )))
91
- m = Ref (LibBitField. Mirror (10 , 1.5 , 1e6 , - 4 , 7 , 3 ))
92
- GC. @preserve bf m begin
93
- pbf = Ptr {LibBitField.BitField} (pointer_from_objref (bf))
94
- pm = Ptr {LibBitField.Mirror} (pointer_from_objref (m))
95
- @test LibBitField. toMirror (bf) == m[]
96
- @test LibBitField. toBitfield (m). a == bf[]. a
97
- @test LibBitField. toBitfield (m). b == bf[]. b
98
- @test LibBitField. toBitfield (m). c == bf[]. c
99
- @test LibBitField. toBitfield (m). d == bf[]. d
100
- @test LibBitField. toBitfield (m). e == bf[]. e
101
- @test LibBitField. toBitfield (m). f == bf[]. f
102
- end
88
+ Base. @invokelatest test_libbitfield ()
103
89
end
104
90
end
0 commit comments