add corrade resource compile rule (#3101)
* update meshoptimizer * fix magnum sdl2 app * add corrade resource compile rule * fix corrade and magnum * patch corrade * patch magnum * update patch * update corrade to support cross compile * remove cross binarypull/3109/head
parent
195488879b
commit
57b9e335df
9 changed files with 240 additions and 14 deletions
@ -0,0 +1,67 @@ |
||||
diff --git a/src/Corrade/Containers/GrowableArray.h b/src/Corrade/Containers/GrowableArray.h
|
||||
index f866bea..4bb8b12 100644
|
||||
--- a/src/Corrade/Containers/GrowableArray.h
|
||||
+++ b/src/Corrade/Containers/GrowableArray.h
|
||||
@@ -1166,13 +1166,13 @@ template<class T, class Allocator> void arrayResize(Array<T>& array, NoInitT, co
|
||||
template<class T, class Allocator> void arrayResize(Array<T>& array, DefaultInitT, const std::size_t size) {
|
||||
const std::size_t prevSize = array.size();
|
||||
arrayResize<T, Allocator>(array, NoInit, size);
|
||||
- Implementation::arrayConstruct(DefaultInit, array + prevSize, array.end());
|
||||
+ Implementation::arrayConstruct(DefaultInit, array.data() + prevSize, array.end());
|
||||
}
|
||||
|
||||
template<class T, class Allocator> void arrayResize(Array<T>& array, ValueInitT, const std::size_t size) {
|
||||
const std::size_t prevSize = array.size();
|
||||
arrayResize<T, Allocator>(array, NoInit, size);
|
||||
- Implementation::arrayConstruct(ValueInit, array + prevSize, array.end());
|
||||
+ Implementation::arrayConstruct(ValueInit, array.data() + prevSize, array.end());
|
||||
}
|
||||
|
||||
template<class T, class Allocator, class... Args> void arrayResize(Array<T>& array, DirectInitT, const std::size_t size, Args&&... args) {
|
||||
diff --git a/src/Corrade/Utility/Format.cpp b/src/Corrade/Utility/Format.cpp
|
||||
index 1d4c23c..7fe825f 100644
|
||||
--- a/src/Corrade/Utility/Format.cpp
|
||||
+++ b/src/Corrade/Utility/Format.cpp
|
||||
@@ -383,7 +383,7 @@ std::size_t formatInto(const Containers::ArrayView<char>& buffer, const char* co
|
||||
CORRADE_ASSERT(data.size() <= buffer.size(),
|
||||
"Utility::formatInto(): buffer too small, expected at least" << bufferOffset + data.size() << "but got" << bufferOffset + buffer.size(), );
|
||||
/* strncpy() would stop on \0 characters */
|
||||
- std::memcpy(buffer + bufferOffset, data, data.size());
|
||||
+ std::memcpy(buffer.data() + bufferOffset, data, data.size());
|
||||
}
|
||||
bufferOffset += data.size();
|
||||
}, [&buffer, &bufferOffset](BufferFormatter& formatter, int precision, FormatType type) {
|
||||
diff --git a/src/Corrade/Utility/String.cpp b/src/Corrade/Utility/String.cpp
|
||||
index 1b05870..0cdd472 100644
|
||||
--- a/src/Corrade/Utility/String.cpp
|
||||
+++ b/src/Corrade/Utility/String.cpp
|
||||
@@ -129,7 +129,7 @@ bool beginsWith(Containers::ArrayView<const char> string, const Containers::Arra
|
||||
bool endsWith(Containers::ArrayView<const char> string, const Containers::ArrayView<const char> suffix) {
|
||||
if(string.size() < suffix.size()) return false;
|
||||
|
||||
- return std::strncmp(string + string.size() - suffix.size(), suffix, suffix.size()) == 0;
|
||||
+ return std::strncmp(string.data() + string.size() - suffix.size(), suffix, suffix.size()) == 0;
|
||||
}
|
||||
|
||||
std::string stripPrefix(std::string string, const Containers::ArrayView<const char> prefix) {
|
||||
diff --git a/src/Corrade/Utility/TweakableParser.cpp b/src/Corrade/Utility/TweakableParser.cpp
|
||||
index 4991991..993d107 100644
|
||||
--- a/src/Corrade/Utility/TweakableParser.cpp
|
||||
+++ b/src/Corrade/Utility/TweakableParser.cpp
|
||||
@@ -37,12 +37,12 @@ namespace Corrade { namespace Utility {
|
||||
namespace {
|
||||
std::pair<const char*, int> integerBase(Containers::ArrayView<const char> value) {
|
||||
if(String::viewBeginsWith(value, "0x") || String::viewBeginsWith(value, "0X"))
|
||||
- return {value + 2, 16};
|
||||
+ return {value.data() + 2, 16};
|
||||
if(String::viewBeginsWith(value, "0b") || String::viewBeginsWith(value, "0B"))
|
||||
- return {value + 2, 2};
|
||||
+ return {value.data() + 2, 2};
|
||||
if(String::viewBeginsWith(value, "0"))
|
||||
- return {value + 1, 8};
|
||||
- return {value, 10};
|
||||
+ return {value.data() + 1, 8};
|
||||
+ return {value.data(), 10};
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,54 @@ |
||||
-- Compile corrade resource files. Substitution for cmake corrade_add_resource. |
||||
-- |
||||
-- Usage: |
||||
-- |
||||
-- add_rules("@corrade/resource") |
||||
-- add_files("resources.conf", {rule = "@corrade/resource", single = false}) |
||||
|
||||
rule("resource") |
||||
set_extensions(".conf") |
||||
on_buildcmd_file(function (target, batchcmds, sourcefile, opt) |
||||
import("core.base.option") |
||||
import("lib.detect.find_program") |
||||
|
||||
batchcmds:show_progress(opt.progress, "${color.build.object}compiling.corrade %s", sourcefile) |
||||
|
||||
-- get corrade-rc program |
||||
local corrade = find_program("corrade-rc", {check = "-h"}) |
||||
assert(corrade, "corrade-rc not found! please check your corrade installation.") |
||||
|
||||
-- generate source file |
||||
local basename = path.basename(sourcefile) |
||||
local sourcefile_cx = path.join(target:autogendir(), "rules", "autogen", basename .. ".cpp") |
||||
local objectfile = target:objectfile(sourcefile_cx) |
||||
table.insert(target:objectfiles(), objectfile) |
||||
|
||||
-- compile |
||||
batchcmds:mkdir(path.directory(sourcefile_cx)) |
||||
local args = {} |
||||
local fileconf = target:fileconfig(sourcefile) |
||||
if fileconf and fileconf.single then |
||||
table.insert(args, "--single") |
||||
end |
||||
if fileconf and fileconf.name then |
||||
table.insert(args, fileconf.name) |
||||
else |
||||
table.insert(args, basename) |
||||
end |
||||
local workdir = path.directory(sourcefile) |
||||
table.insert(args, path.filename(sourcefile)) |
||||
table.insert(args, path.relative(sourcefile_cx, workdir)) |
||||
if option.get("verbose") then |
||||
batchcmds:show(corrade .. " " .. os.args(args)) |
||||
end |
||||
local currentdir = os.curdir() |
||||
batchcmds:cd(workdir) |
||||
batchcmds:vrunv(corrade, args) |
||||
batchcmds:cd(currentdir) |
||||
batchcmds:compile(sourcefile_cx, objectfile) |
||||
|
||||
-- add dependency |
||||
batchcmds:add_depfiles(sourcefile) |
||||
batchcmds:set_depmtime(os.mtime(objectfile)) |
||||
batchcmds:set_depcache(target:dependfile(objectfile)) |
||||
end) |
@ -0,0 +1,70 @@ |
||||
diff --git a/src/Magnum/GL/Buffer.cpp b/src/Magnum/GL/Buffer.cpp
|
||||
index 5fa02c2..038e001 100644
|
||||
--- a/src/Magnum/GL/Buffer.cpp
|
||||
+++ b/src/Magnum/GL/Buffer.cpp
|
||||
@@ -419,7 +419,7 @@ void Buffer::bindImplementationMulti(const Target target, const GLuint firstInde
|
||||
}
|
||||
}
|
||||
|
||||
- glBindBuffersRange(GLenum(target), firstIndex, buffers.size(), ids, offsetsSizes, offsetsSizes + buffers.size());
|
||||
+ glBindBuffersRange(GLenum(target), firstIndex, buffers.size(), ids, offsetsSizes, offsetsSizes.data() + buffers.size());
|
||||
}
|
||||
#endif
|
||||
|
||||
diff --git a/src/Magnum/Implementation/ImageProperties.h b/src/Magnum/Implementation/ImageProperties.h
|
||||
index d6326cf..6eedae0 100644
|
||||
--- a/src/Magnum/Implementation/ImageProperties.h
|
||||
+++ b/src/Magnum/Implementation/ImageProperties.h
|
||||
@@ -70,7 +70,7 @@ template<UnsignedInt dimensions, class T, class Image, class Data> Containers::S
|
||||
|
||||
static_assert(sizeof(decltype(image.data().front())) == 1,
|
||||
"pointer arithmetic expects image data type to have 1 byte");
|
||||
- return {data.suffix(properties.first[dimensions - 1]), data + properties.first.sum(), size, stride};
|
||||
+ return {data.suffix(properties.first[dimensions - 1]), data.data() + properties.first.sum(), size, stride};
|
||||
}
|
||||
|
||||
}}
|
||||
diff --git a/src/Magnum/MeshTools/Concatenate.cpp b/src/Magnum/MeshTools/Concatenate.cpp
|
||||
index 38a7bc1..c20eeb9 100644
|
||||
--- a/src/Magnum/MeshTools/Concatenate.cpp
|
||||
+++ b/src/Magnum/MeshTools/Concatenate.cpp
|
||||
@@ -73,7 +73,7 @@ Trade::MeshData concatenate(Containers::Array<char>&& indexData, const UnsignedI
|
||||
attribute = Trade::MeshAttributeData{
|
||||
attribute.name(), attribute.format(),
|
||||
Containers::StridedArrayView1D<void>{vertexData,
|
||||
- vertexData + attribute.offset(vertexData),
|
||||
+ vertexData.data() + attribute.offset(vertexData),
|
||||
vertexCount, attribute.stride()},
|
||||
attribute.arraySize()};
|
||||
}
|
||||
@@ -130,7 +130,7 @@ Trade::MeshData concatenate(Containers::Array<char>&& indexData, const UnsignedI
|
||||
/* Otherwise, if we need an index buffer (meaning at least one of the
|
||||
meshes is indexed), generate a trivial index buffer */
|
||||
} else if(!indices.empty()) {
|
||||
- std::iota(indices + indexOffset, indices + indexOffset + mesh.vertexCount(), UnsignedInt(vertexOffset));
|
||||
+ std::iota(indices.data() + indexOffset, indices.data() + indexOffset + mesh.vertexCount(), UnsignedInt(vertexOffset));
|
||||
indexOffset += mesh.vertexCount();
|
||||
}
|
||||
|
||||
diff --git a/src/Magnum/MeshTools/Interleave.cpp b/src/Magnum/MeshTools/Interleave.cpp
|
||||
index b98c589..c16fd74 100644
|
||||
--- a/src/Magnum/MeshTools/Interleave.cpp
|
||||
+++ b/src/Magnum/MeshTools/Interleave.cpp
|
||||
@@ -224,7 +224,7 @@ Trade::MeshData interleavedLayout(Trade::MeshData&& data, const UnsignedInt vert
|
||||
attribute = Trade::MeshAttributeData{
|
||||
attribute.name(), attribute.format(),
|
||||
Containers::StridedArrayView1D<void>{vertexData,
|
||||
- vertexData + attribute.offset(vertexData),
|
||||
+ vertexData.data() + attribute.offset(vertexData),
|
||||
vertexCount, attribute.stride()},
|
||||
attribute.arraySize()};
|
||||
}
|
||||
@@ -261,7 +261,7 @@ Trade::MeshData interleave(Trade::MeshData&& data, const Containers::ArrayView<c
|
||||
indexData = Containers::Array<char>{data.indexData().size()};
|
||||
Utility::copy(data.indexData(), indexData);
|
||||
indices = Trade::MeshIndexData{data.indexType(),
|
||||
- Containers::ArrayView<const void>{indexData + data.indexOffset(), data.indices().size()[0]*data.indices().size()[1]}};
|
||||
+ Containers::ArrayView<const void>{indexData.data() + data.indexOffset(), data.indices().size()[0]*data.indices().size()[1]}};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue