1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-09-15 06:52:34 +02:00

Merge pull request #576 from madebr/enable_rwtools

Enable rwtools on ci
This commit is contained in:
Daniel Evans 2018-08-11 23:56:27 +01:00 committed by GitHub
commit 2827ab63f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 33 additions and 251 deletions

View File

@ -26,13 +26,13 @@ matrix:
- scripts/docker/docker_travis.sh "conan_base.docker"
- os: osx
env: NAME="Apple macOS" NAME_SUFFIX="mac"
osx_image: xcode9.2
osx_image: xcode9.4
install:
- brew update
- /usr/bin/yes | pip2 uninstall numpy # see https://github.com/travis-ci/travis-ci/issues/6688
- brew upgrade python
- brew upgrade
- brew install boost cmake bullet ffmpeg glm openal-soft qt5 sdl2 jack
- brew install boost cmake bullet ffmpeg glm openal-soft qt5 sdl2 jack freetype
- export PATH="/usr/local/opt/qt/bin:$PATH"
script:
- mkdir -p "$TRAVIS_BUILD_DIR/build"

View File

@ -35,6 +35,9 @@ else()
if(BUILD_TESTS)
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
endif()
if(BUILD_TOOLS)
find_package(Freetype REQUIRED)
endif()
# Do not link to SDL2main library
set(SDL2_BUILDING_LIBRARY True)

View File

@ -8,6 +8,7 @@ set(_ARGS_BOOL
USE_CONAN
DEBUG
CHECK_INCLUDES
BUILD_TOOLS
BUILD_VIEWER
RUN_TESTS
@ -142,6 +143,7 @@ else()
endif()
set(_CONFIGURE_OPTIONS
"-DBUILD_TOOLS=${BUILD_TOOLS}"
"-DBUILD_VIEWER=${BUILD_VIEWER}"
"-DBUILD_TESTS=TRUE"
"-DTESTS_NODATA=${TESTS_NODATA}"

View File

@ -1,6 +1,7 @@
set(CMAKE_GENERATOR "Xcode")
set(DEBUG FALSE)
set(CONFIGURE_EXTRA_OPTIONS ";")
set(BUILD_TOOLS TRUE)
set(BUILD_VIEWER TRUE)
set(COVERAGE_COMMAND gcov)
set(CHECK_INCLUDES FALSE)

View File

@ -1,6 +1,7 @@
set(CMAKE_GENERATOR "Unix Makefiles")
set(DEBUG FALSE)
set(CONFIGURE_EXTRA_OPTIONS ";")
set(BUILD_TOOLS TRUE)
set(BUILD_VIEWER TRUE)
set(COVERAGE_COMMAND gcov)
set(CHECK_INCLUDES FALSE)

View File

@ -35,6 +35,7 @@ endif()
set(CONAN_PROFILE "${CTEST_SOURCE_DIRECTORY}/scripts/conan/windows")
set(CONAN_ARCH "x86_64")
set(BUILD_TOOLS TRUE)
set(BUILD_VIEWER TRUE)
set(COVERAGE_COMMAND "echo") #FIXME: ENABLE
set(CHECK_INCLUDES FALSE) #FIXME: ENABLE

View File

@ -47,6 +47,9 @@ function(rwdep_wrap_find_packages)
if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
rwdep_wrap_find_package(boost_unit_test_framework "${Boost_INCLUDE_DIRS}" "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
endif()
if(FREETYPE_FOUND)
rwdep_wrap_find_package(freetype "${FREETYPE_INCLUDE_DIRS}" "${FREETYPE_LIBRARIES}")
endif()
endfunction()
function(rwdep_wrap_conan_target TARGET CONAN_NAME)
@ -66,4 +69,7 @@ function(rwdep_wrap_conan_targets)
rwdep_wrap_conan_target(glm glm)
rwdep_wrap_conan_target(ffmpeg ffmpeg)
rwdep_wrap_conan_target(SDL2 sdl2)
if(BUILD_TOOLS)
rwdep_wrap_conan_target(freetype freetype)
endif()
endfunction()

View File

@ -3,11 +3,6 @@
###########################################################
set(RWENGINE_SOURCES
src/BinaryStream.cpp
src/BinaryStream.hpp
src/TextureArchive.cpp
src/TextureArchive.hpp
src/ai/AIGraph.cpp
src/ai/AIGraph.hpp
src/ai/AIGraphNode.cpp

View File

@ -1,91 +0,0 @@
#include "BinaryStream.hpp"
#include <cstring>
#include <fstream>
#include <rw/debug.hpp>
namespace RW {
std::unique_ptr<BinaryStream> BinaryStream::parse(const std::string &filename) {
std::ifstream dfile(filename, std::ios_base::binary);
if (!dfile.is_open()) {
RW_ERROR("Error opening file " << filename);
return nullptr;
}
dfile.seekg(0, std::ios_base::end);
size_t length = dfile.tellg();
dfile.seekg(0);
char *data = new char[length];
dfile.read(data, length);
// RW_MESSAGE("File is " << length << " bytes");
auto BS = std::make_unique<BinaryStream>();
// Set file's ACTUAL length
auto header = reinterpret_cast<nativeSectionHeader_t *>(data);
length = header->size + sizeof(nativeSectionHeader_t);
sectionHeader_t *prevHeader = nullptr;
size_t offset = 0;
while (offset < length) {
nativeSectionHeader_t *sectionHeader =
reinterpret_cast<nativeSectionHeader_t *>(data + offset);
sectionHeader_t *sec = new sectionHeader_t;
sec->ID = sectionHeader->ID;
sec->size = sectionHeader->size;
sec->version = sectionHeader->version;
if (prevHeader == nullptr)
BS->rootHeader = sec;
else
prevHeader->next = sec;
if (sectionHeader->ID == 0) {
RW_ERROR("Section ID is ZERO! Abort!");
break;
}
RW_MESSAGE("Section " << std::hex << sectionHeader->ID << " ("
<< sectionIdString(sectionHeader->ID) << ")"
<< " - " << std::dec << sectionHeader->size << " bytes");
/*
RW_MESSAGE("Offset " << std::hex << offset);
*/
size_t bytesOfData = 0;
switch (sectionHeader->ID) {
case STRUCT:
bytesOfData = sectionHeader->size;
sec->data = new uint8_t[bytesOfData];
memcpy(sec->data, data + offset + sizeof(nativeSectionHeader_t),
bytesOfData);
break;
}
// RW_MESSAGE("It has " << std::dec << bytesOfData
// << " bytes of data!");
offset += sizeof(nativeSectionHeader_t) + bytesOfData;
prevHeader = sec;
}
delete[] data;
return BS;
}
std::string BinaryStream::sectionIdString(uint32_t id) {
switch (id) {
case STRUCT:
return "STRUCT";
case EXTENSION:
return "EXTENSION";
case TEXTURE_NATIVE:
return "TEXTURE_NATIVE";
case TEXTURE_DICTIONARY:
return "TEXTURE_DICTIONARY";
default:
return "UNKNOWN";
}
}
}

View File

@ -1,41 +0,0 @@
#ifndef _RWENGINE_BINARYSTREAM_HPP_
#define _RWENGINE_BINARYSTREAM_HPP_
#include <cstdint>
#include <memory>
#include <string>
namespace RW {
class BinaryStream {
private:
struct nativeSectionHeader_t {
uint32_t ID;
uint32_t size;
uint32_t version;
};
public:
enum {
STRUCT = 0x0001,
EXTENSION = 0x0003,
TEXTURE_NATIVE = 0x0015,
TEXTURE_DICTIONARY = 0x0016,
};
struct sectionHeader_t {
uint32_t ID;
uint32_t size;
uint32_t version;
uint8_t *data = nullptr;
sectionHeader_t *next = nullptr;
} * rootHeader;
static std::unique_ptr<BinaryStream> parse(const std::string &filename);
static std::string sectionIdString(uint32_t id);
};
}
#endif

View File

@ -1,57 +0,0 @@
#include "TextureArchive.hpp"
#include <cstddef>
#include <cstring>
#include <memory>
#include <rw/debug.hpp>
#include "BinaryStream.hpp"
namespace RW {
std::unique_ptr<TextureArchive> TextureArchive::create(
BinaryStream &binaryStream) {
auto textureArchive = std::make_unique<TextureArchive>();
auto section = binaryStream.rootHeader;
RW_ASSERT(section->ID == BinaryStream::TEXTURE_DICTIONARY &&
"BinaryStream passed to this function must be a TEXTURE DICTIONARY");
// Struct
section = section->next;
textureArchive->numTextures =
reinterpret_cast<uint16_t *>(section->data)[0];
for (size_t i = 0; i < textureArchive->numTextures; i++) {
section = section->next; // Texture Native
section = section->next; // Struct
Texture texture = *reinterpret_cast<Texture *>(section->data);
if (texture.header.rasterFormat & 0x2000) {
memcpy(texture.body.palette,
section->data + sizeof(TextureHeader) - 4, 1024);
texture.body.pixels =
new uint8_t[texture.header.width * texture.header.height];
memcpy(texture.body.pixels,
section->data + sizeof(TextureHeader) + 1024,
texture.header.width * texture.header.height);
} else {
size_t bufSize = texture.header.width * texture.header.height *
texture.header.bpp / 8;
texture.body.pixels = new uint8_t[bufSize];
memcpy(texture.body.pixels, section->data + sizeof(TextureHeader),
bufSize);
}
textureArchive->textures.push_back(texture);
section = section->next; // Extension
}
return textureArchive;
}
}

View File

@ -1,48 +0,0 @@
#ifndef _RWENGINE_TEXTUREARCHIVE_HPP_
#define _RWENGINE_TEXTUREARCHIVE_HPP_
#include <cstddef>
#include <cstdint>
#include <memory>
#include <vector>
namespace RW {
class BinaryStream;
class TextureArchive {
public:
struct TextureHeader {
uint32_t platformID;
uint16_t filterFlags;
uint8_t textureWrapV;
uint8_t textureWrapU;
uint8_t diffuseName[32];
uint8_t alphaName[32];
uint32_t rasterFormat;
uint32_t alpha;
uint16_t width;
uint16_t height;
uint8_t bpp;
uint8_t numMipmap;
uint8_t rasterType;
uint8_t compression;
uint32_t dataSize;
};
struct TextureBody {
uint8_t palette[1024];
uint8_t *pixels;
};
struct Texture {
TextureHeader header;
TextureBody body;
};
size_t numTextures;
std::vector<Texture> textures;
static std::unique_ptr<TextureArchive> create(BinaryStream &binaryStream);
};
}
#endif

View File

@ -1,5 +1,4 @@
# fixme: conan support
find_package(Freetype REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Gui)
add_executable(rwfontmap
rwfontmap.cpp
@ -7,8 +6,13 @@ add_executable(rwfontmap
target_link_libraries(rwfontmap
PUBLIC
rwlib
Freetype::Freetype
rwcore
rwdep::freetype
rwdep::boost_program_options
Qt5::Gui
Boost::program_options
)
install(TARGETS rwfontmap
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)

View File

@ -183,9 +183,9 @@ public:
}
void write(const rwfs::path &bitmap_path, const rwfs::path &advance_path) {
QImageWriter writer(bitmap_path.c_str());
QImageWriter writer(QString::fromStdString(bitmap_path.string()));
writer.write(m_texture);
std::ofstream ofs(advance_path.c_str(), std::ios_base::out);
std::ofstream ofs(advance_path.string(), std::ios_base::out);
ofs << m_aspectratio << '\n';
for (auto adv : m_advances) {
ofs << int(adv) << '\n';

View File

@ -1,6 +1,7 @@
include(default)
[options]
openrw:tools=True
openrw:viewer=True
# https://github.com/bincrafters/community/issues/120
ffmpeg:vdpau=False

View File

@ -1,6 +1,7 @@
include(default)
[options]
openrw:tools=True
openrw:viewer=True
sdl2:esd=False
sdl2:wayland=True

View File

@ -1,5 +1,6 @@
include(default)
[options]
openrw:tools=True
openrw:viewer=True
ffmpeg:qsv=False

View File

@ -10,6 +10,7 @@ RUN pacman -Syy --noconfirm \
community/glm \
extra/openal \
extra/sdl2 \
extra/qt5-base
extra/qt5-base \
extra/freetype2
CMD ["/bin/bash"]

View File

@ -17,6 +17,7 @@ RUN dnf update -y \
openal-soft-devel \
SDL2-devel \
qt5-devel \
freetype-devel \
libasan
CMD ["/bin/bash"]

View File

@ -16,6 +16,7 @@ RUN apt-get update \
libsdl2-dev \
libboost-test-dev \
libqt5opengl5-dev \
libfreetype6-dev \
iwyu \
qt5-default