Skip to content

Commit bc17387

Browse files
authored
Merge pull request #13293 from Swiftb0y/chore/update-rekordbox-kaitai-definitions
chore: update rekordbox kaitai definitions
2 parents d669562 + 85d95df commit bc17387

18 files changed

Lines changed: 2817 additions & 1371 deletions

CMakeLists.txt

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -939,8 +939,6 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
939939
src/library/recording/dlgrecording.cpp
940940
src/library/recording/dlgrecording.ui
941941
src/library/recording/recordingfeature.cpp
942-
src/library/rekordbox/kaitaistructs/rekordbox_anlz.cpp
943-
src/library/rekordbox/kaitaistructs/rekordbox_pdb.cpp
944942
src/library/rekordbox/rekordboxfeature.cpp
945943
src/library/rhythmbox/rhythmboxfeature.cpp
946944
src/library/scanner/importfilestask.cpp
@@ -1576,26 +1574,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
15761574
message(STATUS "Enabling QML Debugging! This poses a security risk as Mixxx will open a TCP port for debugging")
15771575
endif()
15781576

1579-
# Disable warnings in generated source files
1580-
if(GNU_GCC OR LLVM_CLANG)
1581-
set_property(
1582-
SOURCE src/library/rekordbox/kaitaistructs/rekordbox_anlz.cpp
1583-
APPEND_STRING
1584-
PROPERTY COMPILE_OPTIONS -Wno-unused-parameter
1585-
)
1586-
set_property(
1587-
SOURCE src/library/rekordbox/kaitaistructs/rekordbox_pdb.cpp
1588-
APPEND_STRING
1589-
PROPERTY COMPILE_OPTIONS -Wno-unused-parameter -Wno-switch
1590-
)
1591-
elseif(MSVC)
1592-
set_property(
1593-
SOURCE src/library/rekordbox/kaitaistructs/rekordbox_pdb.cpp
1594-
APPEND_STRING
1595-
PROPERTY COMPILE_OPTIONS /wd4244
1596-
)
1597-
endif()
1598-
15991577
option(WARNINGS_PEDANTIC "Let the compiler show even more warnings" OFF)
16001578
if(MSVC)
16011579
if(WARNINGS_PEDANTIC)
@@ -2508,12 +2486,20 @@ target_link_libraries(mixxx-lib PRIVATE FpClassify)
25082486
find_package(mp3lame REQUIRED)
25092487
target_link_libraries(mixxx-lib PRIVATE mp3lame::mp3lame)
25102488

2489+
add_library(rekordbox_metadata STATIC EXCLUDE_FROM_ALL
2490+
lib/rekordbox-metadata/rekordbox_pdb.cpp
2491+
lib/rekordbox-metadata/rekordbox_anlz.cpp
2492+
)
2493+
target_include_directories(rekordbox_metadata SYSTEM PUBLIC lib/rekordbox-metadata)
2494+
target_link_libraries(mixxx-lib PRIVATE rekordbox_metadata)
2495+
25112496
# Kaitai for reading Rekordbox libraries
25122497
add_library(Kaitai STATIC EXCLUDE_FROM_ALL
2513-
lib/kaitai/kaitaistream.cpp
2498+
lib/kaitai/kaitai/kaitaistream.cpp
25142499
)
25152500
target_include_directories(Kaitai SYSTEM PUBLIC lib/kaitai)
25162501
target_compile_definitions(Kaitai PRIVATE KS_STR_ENCODING_NONE)
2502+
target_link_libraries(rekordbox_metadata PRIVATE Kaitai)
25172503
target_link_libraries(mixxx-lib PRIVATE Kaitai)
25182504

25192505
# For determining MP3 timing offset cases in Rekordbox library feature

lib/kaitai/CMakeLists.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
cmake_minimum_required (VERSION 3.11)
2+
project (kaitai_struct_cpp_stl_runtime CXX)
3+
enable_testing()
4+
5+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
6+
option(BUILD_TESTS "Build tests" ON)
7+
8+
set (CMAKE_INCLUDE_CURRENT_DIR ON)
9+
10+
find_package(ZLIB)
11+
find_package(Iconv)
12+
13+
set (HEADERS
14+
kaitai/kaitaistream.h
15+
kaitai/kaitaistruct.h
16+
kaitai/exceptions.h
17+
)
18+
19+
set (SOURCES
20+
kaitai/kaitaistream.cpp
21+
)
22+
23+
set(STRING_ENCODING_TYPE "ICONV" CACHE STRING "Set the way strings have to be encoded (ICONV|WIN32API|NONE|...)")
24+
25+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
26+
27+
add_library (${PROJECT_NAME} ${HEADERS} ${SOURCES})
28+
set_property(TARGET ${PROJECT_NAME} PROPERTY PUBLIC_HEADER ${HEADERS})
29+
target_include_directories(${PROJECT_NAME} INTERFACE ${PROJECT_SOURCE_DIR})
30+
31+
if (ZLIB_FOUND)
32+
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
33+
target_compile_definitions(${PROJECT_NAME} PRIVATE -DKS_ZLIB)
34+
endif()
35+
36+
if(Iconv_FOUND)
37+
target_link_libraries(${PROJECT_NAME} PRIVATE Iconv::Iconv)
38+
endif()
39+
40+
include(Common.cmake)
41+
42+
install(TARGETS ${PROJECT_NAME}
43+
ARCHIVE DESTINATION lib
44+
LIBRARY DESTINATION lib
45+
RUNTIME DESTINATION bin
46+
PUBLIC_HEADER DESTINATION include/kaitai
47+
)
48+
49+
# Add the tests
50+
if(BUILD_TESTS)
51+
add_subdirectory(tests)
52+
endif()

lib/kaitai/Common.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if (STRING_ENCODING_TYPE STREQUAL "ICONV")
2+
target_compile_definitions(${PROJECT_NAME} PRIVATE -DKS_STR_ENCODING_ICONV)
3+
elseif (STRING_ENCODING_TYPE STREQUAL "WIN32API")
4+
target_compile_definitions(${PROJECT_NAME} PRIVATE -DKS_STR_ENCODING_WIN32API)
5+
elseif (STRING_ENCODING_TYPE STREQUAL "NONE")
6+
target_compile_definitions(${PROJECT_NAME} PRIVATE -DKS_STR_ENCODING_NONE)
7+
else()
8+
# User action requested
9+
endif()
10+
11+
# Maximum warnings emission, treat all warnings as errors
12+
#
13+
# This method was taken from https://www.pragmaticlinux.com/2022/07/enable-compiler-warnings-with-cmake/
14+
target_compile_options(${PROJECT_NAME} PRIVATE
15+
$<$<CXX_COMPILER_ID:MSVC>:/W4 /WX>
16+
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -Wpedantic -Werror>
17+
)

lib/kaitai/LICENSE

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
1-
Copyright 2016-2019 Kaitai Project: MIT license
1+
MIT License
22

3-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3+
Copyright (c) 2016-2022 Kaitai Project
44

5-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
611

7-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

lib/kaitai/kaitai/exceptions.h

Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
#ifndef KAITAI_EXCEPTIONS_H
2+
#define KAITAI_EXCEPTIONS_H
3+
4+
#include <kaitai/kaitaistream.h>
5+
6+
#include <string>
7+
#include <stdexcept>
8+
9+
// We need to use "noexcept" in virtual destructor of our exceptions
10+
// subclasses. Different compilers have different ideas on how to
11+
// achieve that: C++98 compilers prefer `throw()`, C++11 and later
12+
// use `noexcept`. We define KS_NOEXCEPT macro for that.
13+
14+
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)
15+
#define KS_NOEXCEPT noexcept
16+
#else
17+
#define KS_NOEXCEPT throw()
18+
#endif
19+
20+
namespace kaitai {
21+
22+
/**
23+
* Common ancestor for all errors related to `bytes_to_str` operation. Also used
24+
* to signal misc non-specific `bytes_to_str` failures.
25+
*/
26+
class bytes_to_str_error: public std::runtime_error {
27+
public:
28+
bytes_to_str_error(const std::string what):
29+
std::runtime_error(std::string("bytes_to_str error: ") + what) {}
30+
31+
virtual ~bytes_to_str_error() KS_NOEXCEPT {};
32+
};
33+
34+
/**
35+
* Exception to signal that `bytes_to_str` operation was requested to use some encoding
36+
* that is not available in given runtime environment.
37+
*/
38+
class unknown_encoding: public bytes_to_str_error {
39+
public:
40+
unknown_encoding(const std::string enc_name):
41+
bytes_to_str_error(std::string("unknown encoding: `") + enc_name + std::string("`")) {}
42+
43+
virtual ~unknown_encoding() KS_NOEXCEPT {};
44+
};
45+
46+
/**
47+
* Exception to signal that `bytes_to_str` operation failed to decode given byte sequence.
48+
*/
49+
class illegal_seq_in_encoding: public bytes_to_str_error {
50+
public:
51+
illegal_seq_in_encoding(const std::string what):
52+
bytes_to_str_error("illegal sequence: " + what) {}
53+
54+
virtual ~illegal_seq_in_encoding() KS_NOEXCEPT {};
55+
};
56+
57+
/**
58+
* Common ancestor for all error originating from Kaitai Struct usage.
59+
* Stores KSY source path, pointing to an element supposedly guilty of
60+
* an error.
61+
*/
62+
class kstruct_error: public std::runtime_error {
63+
public:
64+
kstruct_error(const std::string what, const std::string src_path):
65+
std::runtime_error(src_path + ": " + what),
66+
m_src_path(src_path)
67+
{
68+
}
69+
70+
virtual ~kstruct_error() KS_NOEXCEPT {};
71+
72+
protected:
73+
const std::string m_src_path;
74+
};
75+
76+
/**
77+
* Error that occurs when default endianness should be decided with
78+
* a switch, but nothing matches (although using endianness expression
79+
* implies that there should be some positive result).
80+
*/
81+
class undecided_endianness_error: public kstruct_error {
82+
public:
83+
undecided_endianness_error(const std::string src_path):
84+
kstruct_error("unable to decide on endianness for a type", src_path)
85+
{
86+
}
87+
88+
virtual ~undecided_endianness_error() KS_NOEXCEPT {};
89+
};
90+
91+
/**
92+
* Common ancestor for all validation failures. Stores pointer to
93+
* KaitaiStream IO object which was involved in an error.
94+
*/
95+
class validation_failed_error: public kstruct_error {
96+
public:
97+
validation_failed_error(const std::string what, kstream* io, const std::string src_path):
98+
kstruct_error("at pos " + kstream::to_string(io->pos()) + ": validation failed: " + what, src_path),
99+
m_io(io)
100+
{
101+
}
102+
103+
// "at pos #{io.pos}: validation failed: #{msg}"
104+
105+
virtual ~validation_failed_error() KS_NOEXCEPT {};
106+
107+
protected:
108+
kstream* m_io;
109+
};
110+
111+
/**
112+
* Signals validation failure: we required "actual" value to be equal to
113+
* "expected", but it turned out that it's not.
114+
*/
115+
template<typename T>
116+
class validation_not_equal_error: public validation_failed_error {
117+
public:
118+
validation_not_equal_error(const T& expected, const T& actual, kstream* io, const std::string src_path):
119+
validation_failed_error("not equal", io, src_path),
120+
m_expected(expected),
121+
m_actual(actual)
122+
{
123+
}
124+
125+
// "not equal, expected #{expected.inspect}, but got #{actual.inspect}"
126+
127+
virtual ~validation_not_equal_error() KS_NOEXCEPT {};
128+
129+
protected:
130+
const T& m_expected;
131+
const T& m_actual;
132+
};
133+
134+
/**
135+
* Signals validation failure: we required "actual" value to be greater
136+
* than or equal to "min", but it turned out that it's not.
137+
*/
138+
template<typename T>
139+
class validation_less_than_error: public validation_failed_error {
140+
public:
141+
validation_less_than_error(const T& min, const T& actual, kstream* io, const std::string src_path):
142+
validation_failed_error("not in range", io, src_path),
143+
m_min(min),
144+
m_actual(actual)
145+
{
146+
}
147+
148+
// "not in range, min #{min.inspect}, but got #{actual.inspect}"
149+
150+
virtual ~validation_less_than_error() KS_NOEXCEPT {};
151+
152+
protected:
153+
const T& m_min;
154+
const T& m_actual;
155+
};
156+
157+
/**
158+
* Signals validation failure: we required "actual" value to be less
159+
* than or equal to "max", but it turned out that it's not.
160+
*/
161+
template<typename T>
162+
class validation_greater_than_error: public validation_failed_error {
163+
public:
164+
validation_greater_than_error(const T& max, const T& actual, kstream* io, const std::string src_path):
165+
validation_failed_error("not in range", io, src_path),
166+
m_max(max),
167+
m_actual(actual)
168+
{
169+
}
170+
171+
// "not in range, max #{max.inspect}, but got #{actual.inspect}"
172+
173+
virtual ~validation_greater_than_error() KS_NOEXCEPT {};
174+
175+
protected:
176+
const T& m_max;
177+
const T& m_actual;
178+
};
179+
180+
/**
181+
* Signals validation failure: we required "actual" value to be from
182+
* the list, but it turned out that it's not.
183+
*/
184+
template<typename T>
185+
class validation_not_any_of_error: public validation_failed_error {
186+
public:
187+
validation_not_any_of_error(const T& actual, kstream* io, const std::string src_path):
188+
validation_failed_error("not any of the list", io, src_path),
189+
m_actual(actual)
190+
{
191+
}
192+
193+
// "not any of the list, got #{actual.inspect}"
194+
195+
virtual ~validation_not_any_of_error() KS_NOEXCEPT {};
196+
197+
protected:
198+
const T& m_actual;
199+
};
200+
201+
/**
202+
* Signals validation failure: we required "actual" value to match
203+
* the expression, but it turned out that it doesn't.
204+
*/
205+
template<typename T>
206+
class validation_expr_error: public validation_failed_error {
207+
public:
208+
validation_expr_error(const T& actual, kstream* io, const std::string src_path):
209+
validation_failed_error("not matching the expression", io, src_path),
210+
m_actual(actual)
211+
{
212+
}
213+
214+
// "not matching the expression, got #{actual.inspect}"
215+
216+
virtual ~validation_expr_error() KS_NOEXCEPT {};
217+
218+
protected:
219+
const T& m_actual;
220+
};
221+
222+
}
223+
224+
#endif

0 commit comments

Comments
 (0)