Skip to content

Commit

Permalink
Merge pull request #829 from MAnyKey/linux-port-7
Browse files Browse the repository at this point in the history
Compile editor
  • Loading branch information
nem0 committed Apr 25, 2016
2 parents 045374f + 9bbb141 commit e0711a2
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions projects/genie.lua
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ project "editor"
linkLib("assimp")
includedirs { "../src", "../external/lua/include", "../external/bgfx/include", "../external/assimp/include", "../external/crnlib/include" }

configuration "not windows"
excludes { "../src/editor/pc/*"}
configuration {}

useLua()
defaultConfigurations()

Expand Down
21 changes: 11 additions & 10 deletions src/editor/studio_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "engine/core/command_line_parser.h"
#include "engine/core/crc32.h"
#include "engine/core/default_allocator.h"
#include "engine/core/fixed_array.h"
#include "engine/core/fs/file_system.h"
#include "engine/core/fs/os_file.h"
#include "engine/core/input_system.h"
Expand Down Expand Up @@ -1253,7 +1254,7 @@ class StudioAppImpl : public StudioApp
Lumix::uint64 offset;
Lumix::uint64 size;

typedef char Path[Lumix::MAX_PATH_LENGTH];
using Path = Lumix::FixedArray<char, Lumix::MAX_PATH_LENGTH>;
};
#pragma pack()

Expand Down Expand Up @@ -1283,16 +1284,16 @@ class StudioAppImpl : public StudioApp
auto& out_path = paths.emplace();
if(dir_path[0] == '.')
{
Lumix::copyString(out_path, Lumix::lengthOf(out_path), normalized_path);
Lumix::copyString(out_path.data(), out_path.size(), normalized_path);
}
else
{
Lumix::copyString(out_path, Lumix::lengthOf(out_path), dir_path);
Lumix::catString(out_path, Lumix::lengthOf(out_path), normalized_path);
Lumix::copyString(out_path.data(), out_path.size(), dir_path);
Lumix::catString(out_path.data(), out_path.size(), normalized_path);
}
auto& out_info = infos.emplace();
out_info.hash = Lumix::crc32(out_path);
out_info.size = PlatformInterface::getFileSize(out_path);
out_info.hash = Lumix::crc32(out_path.data());
out_info.size = PlatformInterface::getFileSize(out_path.data());
out_info.offset = ~0UL;
}
}
Expand Down Expand Up @@ -1339,11 +1340,11 @@ class StudioAppImpl : public StudioApp
for (auto& path : paths)
{
Lumix::FS::OsFile src;
size_t src_size = PlatformInterface::getFileSize(path);
if (!src.open(path, Lumix::FS::Mode::OPEN_AND_READ, m_allocator))
size_t src_size = PlatformInterface::getFileSize(path.data());
if (!src.open(path.data(), Lumix::FS::Mode::OPEN_AND_READ, m_allocator))
{
file.close();
Lumix::g_log_error.log("Editor") << "Could not open " << path;
Lumix::g_log_error.log("Editor") << "Could not open " << path.data();
return;
}
Lumix::uint8 buf[4096];
Expand All @@ -1353,7 +1354,7 @@ class StudioAppImpl : public StudioApp
if (!src.read(buf, batch_size))
{
file.close();
Lumix::g_log_error.log("Editor") << "Could not read " << path;
Lumix::g_log_error.log("Editor") << "Could not read " << path.data();
return;
}
file.write(buf, batch_size);
Expand Down
27 changes: 27 additions & 0 deletions src/engine/core/fixed_array.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

namespace Lumix
{

template <class T, int Size> class FixedArray
{
public:
static_assert(Size > 0, "Size must be positive");

const T& operator[](int index) const { return m_data[index]; }

T& operator[](int index) { return m_data[index]; }

const T* begin() const { return m_data; }

const T* end() const { return m_data + Size; }

T* data() { return m_data; }

int size() const { return Size; }

private:
T m_data[Size];
};

} // ~namespace Lumix

0 comments on commit e0711a2

Please sign in to comment.