Fix issue with DLL name in Debug configuration.

This commit is contained in:
Mikaël Capelle
2025-05-27 21:03:01 +02:00
parent e16bca653f
commit 736a69ccab
6 changed files with 145 additions and 122 deletions
+7
View File
@@ -49,6 +49,7 @@ compile_commands.json
CTestTestfile.cmake CTestTestfile.cmake
_deps _deps
### CMake Patch ### ### CMake Patch ###
# External projects # External projects
*-prefix/ *-prefix/
@@ -530,3 +531,9 @@ healthchecksdb
MigrationBackup/ MigrationBackup/
# End of https://www.gitignore.io/api/qt,c++,cmake,delphi,qtcreator,visualstudio # End of https://www.gitignore.io/api/qt,c++,cmake,delphi,qtcreator,visualstudio
install
examples/build
examples/vsbuild
examples/test_ba1
examples/test_ba2
+1 -1
View File
@@ -5,7 +5,7 @@ include(CMakePackageConfigHelpers)
project(libbsarch CXX) project(libbsarch CXX)
find_package(mo2-dds-header CONFIG REQUIRED) find_package(mo2-dds-header CONFIG REQUIRED)
find_package(Qt6 COMPONENTS Core REQUIRED) find_package(Qt6 COMPONENTS Core)
get_target_property(SRCS mo2::dds-header SOURCES) get_target_property(SRCS mo2::dds-header SOURCES)
+1
View File
@@ -6,6 +6,7 @@ target_link_libraries(mo2::libbsarch INTERFACE mo2::libbsarch_OOP)
# libbsarch is usually be build in Debug or Release/RelWithDebInfo, so we need to map # libbsarch is usually be build in Debug or Release/RelWithDebInfo, so we need to map
# missing configurations to avoid issue with CMP0111 # missing configurations to avoid issue with CMP0111
get_target_property(_LIBBSARCH_CONFIGURATIONS mo2::libbsarch IMPORTED_CONFIGURATIONS)
list(FIND _LIBBSARCH_CONFIGURATIONS "RELEASE" _LIBBSARCH_HAS_RELEASE) list(FIND _LIBBSARCH_CONFIGURATIONS "RELEASE" _LIBBSARCH_HAS_RELEASE)
if (_LIBBSARCH_HAS_RELEASE EQUAL -1) if (_LIBBSARCH_HAS_RELEASE EQUAL -1)
set_target_properties(mo2::libbsarch PROPERTIES set_target_properties(mo2::libbsarch PROPERTIES
+135 -119
View File
@@ -1,146 +1,162 @@
#include <iostream> #include <iostream>
#include <windows.h> #include <windows.h>
#include "libbsarch.h" #include <libbsarch/libbsarch.h>
#pragma comment(lib, "libbsarch") // #pragma comment(lib, "libbsarch")
static const std::wstring separators(L"\\/"); static const std::wstring separators(L"\\/");
std::wstring dirname(const std::wstring& path) { std::wstring dirname(const std::wstring &path)
size_t slash_pos = path.find_last_of(separators); {
return path.substr(0, slash_pos); size_t slash_pos = path.find_last_of(separators);
return path.substr(0, slash_pos);
} }
std::wstring basename(const std::wstring& path) { std::wstring basename(const std::wstring &path)
size_t slash_pos = path.find_last_of(separators); {
return path.substr(slash_pos + 1); size_t slash_pos = path.find_last_of(separators);
return path.substr(slash_pos + 1);
} }
bool mkdirp(const std::wstring& directory, bool basedir = true) { bool mkdirp(const std::wstring &directory, bool basedir = true)
DWORD attributes = ::GetFileAttributesW(directory.c_str()); {
if(attributes == INVALID_FILE_ATTRIBUTES) { DWORD attributes = ::GetFileAttributesW(directory.c_str());
std::size_t slash_pos = directory.find_last_of(separators); if (attributes == INVALID_FILE_ATTRIBUTES)
if(slash_pos != std::wstring::npos) { {
mkdirp(directory.substr(0, slash_pos)); std::size_t slash_pos = directory.find_last_of(separators);
if (slash_pos != std::wstring::npos)
{
mkdirp(directory.substr(0, slash_pos));
}
return ::CreateDirectoryW(directory.c_str(), nullptr);
} }
return ::CreateDirectoryW(directory.c_str(), nullptr); else
} else { {
return true; return true;
}
}
void dds_info(bsa_archive_t archive, const wchar_t* file_path, bsa_dds_info_t* dds_info, void* context) {
// Mock result
dds_info->width = 2048;
dds_info->height = 2048;
dds_info->mipmaps = 12;
printf("ba2 dds_info callback file: %ls, context: %s\n", file_path, (char*)context);
}
int main() {
bsa_result_message_t result = { 0 };
bsa_archive_t archive = bsa_create();
{
result = bsa_load_from_file(archive, L"test_read.bsa");
if(result.code < 0)
printf("ba1 %ls\n", result.text);
bsa_entry_list_t entries = bsa_entry_list_create();
bsa_get_resource_list(archive, entries, L"");
for(size_t index = 0; index < bsa_entry_list_count(entries); index++) {
wchar_t filename[2048];
wchar_t dest_filename[2048] = L"test_ba1\\";
bsa_entry_list_get(entries, index, 2048, filename);
wcscat_s(dest_filename, 2048, filename);
printf("ba1 file: %ls %ls\n", filename, dest_filename);
if(mkdirp(dirname(dest_filename))) {
result = bsa_extract_file(archive, filename, dest_filename);
if(result.code < 0)
printf("ba1 %ls\n", result.text);
} else {
printf("ba1 could not create: %ls\n", dirname(dest_filename).c_str());
}
} }
}
bsa_entry_list_free(entries); void dds_info(bsa_archive_t archive, const wchar_t *file_path, bsa_dds_info_t *dds_info, void *context)
{
// Mock result
dds_info->width = 2048;
dds_info->height = 2048;
dds_info->mipmaps = 12;
bsa_close(archive); printf("ba2 dds_info callback file: %ls, context: %s\n", file_path, (char *) context);
} }
{ int main()
bsa_entry_list_t entries = bsa_entry_list_create(); {
bsa_entry_list_add(entries, L"textures\\grass\\test.dds"); bsa_result_message_t result = {0};
bsa_entry_list_add(entries, L"textures\\grass\\test2.dds"); bsa_archive_t archive = bsa_create();
bsa_create_archive(archive, L"test_write.bsa", baSSE, entries); {
bsa_add_file_from_disk_root(archive, L"test_ba1\\", L"test_ba1\\textures\\grass\\test.dds"); result = bsa_load_from_file(archive, L"test_read.bsa");
result = bsa_add_file_from_disk(archive, L"textures\\grass\\test2.dds", L"test_ba1\\textures\\grass\\test.dds");
if (result.code < 0)
printf("ba1 %ls\n", result.text);
bsa_save(archive);
bsa_close(archive);
bsa_entry_list_free(entries);
}
bsa_file_dds_info_callback_set(archive, dds_info, (void*)"I was shared");
{
result = bsa_load_from_file(archive, L"test_read.ba2");
if (result.code < 0)
printf("ba2 %ls\n", result.text);
bsa_entry_list_t entries = bsa_entry_list_create();
bsa_get_resource_list(archive, entries, L"");
for (size_t index = 0; index < bsa_entry_list_count(entries); index++) {
wchar_t filename[2048];
wchar_t dest_filename[2048] = L"test_ba2\\";
bsa_entry_list_get(entries, index, 2048, filename);
wcscat_s(dest_filename, 2048, filename);
printf("ba2 file: %ls %ls\n", filename, dest_filename);
if (mkdirp(dirname(dest_filename))) {
result = bsa_extract_file(archive, filename, dest_filename);
if (result.code < 0) if (result.code < 0)
printf("ba2 %ls\n", result.text); printf("ba1 %ls\n", result.text);
}
else { bsa_entry_list_t entries = bsa_entry_list_create();
printf("ba2 could not create: %ls\n", dirname(dest_filename).c_str()); bsa_get_resource_list(archive, entries, L"");
}
for (size_t index = 0; index < bsa_entry_list_count(entries); index++)
{
wchar_t filename[2048];
wchar_t dest_filename[2048] = L"test_ba1\\";
bsa_entry_list_get(entries, index, 2048, filename);
wcscat_s(dest_filename, 2048, filename);
printf("ba1 file: %ls %ls\n", filename, dest_filename);
if (mkdirp(dirname(dest_filename)))
{
result = bsa_extract_file(archive, filename, dest_filename);
if (result.code < 0)
printf("ba1 %ls\n", result.text);
}
else
{
printf("ba1 could not create: %ls\n", dirname(dest_filename).c_str());
}
}
bsa_entry_list_free(entries);
bsa_close(archive);
} }
bsa_entry_list_free(entries); {
bsa_entry_list_t entries = bsa_entry_list_create();
bsa_entry_list_add(entries, L"textures\\grass\\test.dds");
bsa_entry_list_add(entries, L"textures\\grass\\test2.dds");
bsa_close(archive); bsa_create_archive(archive, L"test_write.bsa", baSSE, entries);
} bsa_add_file_from_disk_root(archive, L"test_ba1\\", L"test_ba1\\textures\\grass\\test.dds");
result = bsa_add_file_from_disk(archive, L"textures\\grass\\test2.dds", L"test_ba1\\textures\\grass\\test.dds");
if (result.code < 0)
printf("ba1 %ls\n", result.text);
bsa_save(archive);
bsa_close(archive);
{ bsa_entry_list_free(entries);
bsa_entry_list_t entries = bsa_entry_list_create(); }
bsa_entry_list_add(entries, L"textures\\grass\\test.dds");
bsa_entry_list_add(entries, L"textures\\grass\\test2.dds");
bsa_create_archive(archive, L"test_write.ba2", baFO4dds, entries); bsa_file_dds_info_callback_set(archive, dds_info, (void *) "I was shared");
bsa_add_file_from_disk_root(archive, L"test_ba2\\", L"test_ba2\\textures\\grass\\test.dds");
result = bsa_add_file_from_disk(archive, L"textures\\grass\\test2.dds", L"test_ba2\\textures\\grass\\test.dds");
if (result.code < 0)
printf("ba2 %ls\n", result.text);
bsa_save(archive);
bsa_close(archive);
bsa_entry_list_free(entries); {
} result = bsa_load_from_file(archive, L"test_read.ba2");
if (result.code < 0)
printf("ba2 %ls\n", result.text);
/* bsa_entry_list_t entries = bsa_entry_list_create();
bsa_get_resource_list(archive, entries, L"");
for (size_t index = 0; index < bsa_entry_list_count(entries); index++)
{
wchar_t filename[2048];
wchar_t dest_filename[2048] = L"test_ba2\\";
bsa_entry_list_get(entries, index, 2048, filename);
wcscat_s(dest_filename, 2048, filename);
printf("ba2 file: %ls %ls\n", filename, dest_filename);
if (mkdirp(dirname(dest_filename)))
{
result = bsa_extract_file(archive, filename, dest_filename);
if (result.code < 0)
printf("ba2 %ls\n", result.text);
}
else
{
printf("ba2 could not create: %ls\n", dirname(dest_filename).c_str());
}
}
bsa_entry_list_free(entries);
bsa_close(archive);
}
{
bsa_entry_list_t entries = bsa_entry_list_create();
bsa_entry_list_add(entries, L"textures\\grass\\test.dds");
bsa_entry_list_add(entries, L"textures\\grass\\test2.dds");
bsa_create_archive(archive, L"test_write.ba2", baFO4dds, entries);
bsa_add_file_from_disk_root(archive, L"test_ba2\\", L"test_ba2\\textures\\grass\\test.dds");
result = bsa_add_file_from_disk(archive, L"textures\\grass\\test2.dds", L"test_ba2\\textures\\grass\\test.dds");
if (result.code < 0)
printf("ba2 %ls\n", result.text);
bsa_save(archive);
bsa_close(archive);
bsa_entry_list_free(entries);
}
/*
{ {
result = bsa_load_from_file(archive, L"test_large.ba2"); result = bsa_load_from_file(archive, L"test_large.ba2");
if (result.code < 0) if (result.code < 0)
@@ -170,5 +186,5 @@ int main() {
} }
*/ */
bsa_free(archive); bsa_free(archive);
} }
-1
View File
@@ -1,4 +1,3 @@
LIBRARY LIBBSARCH
;DESCRIPTION "BSArch DLL" ;DESCRIPTION "BSArch DLL"
EXPORTS EXPORTS
bsa_entry_list_create bsa_entry_list_create
+1 -1
View File
@@ -10,7 +10,7 @@
{ {
"kind": "git", "kind": "git",
"repository": "https://github.com/ModOrganizer2/vcpkg-registry", "repository": "https://github.com/ModOrganizer2/vcpkg-registry",
"baseline": "27d8adbfe9e4ce88a875be3a45fadab69869eb60", "baseline": "69db61b22147b14ad66fd05cf798d855f6d68c12",
"packages": ["mo2-*"] "packages": ["mo2-*"]
} }
] ]