Compare commits
2 Commits
master
...
appveyor-c
| Author | SHA1 | Date |
|---|---|---|
|
|
64cecd92f9 | 7 years ago |
|
|
bc50a55a3e | 7 years ago |
179 changed files with 3076 additions and 29255 deletions
@ -1,40 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
.. py:class:: corrade.pluginmanager.AbstractManager |
||||
:data VERSION: Plugin ABI version |
||||
|
||||
.. py:function:: corrade.pluginmanager.AbstractManager.load |
||||
:raise RuntimeError: When loading fails |
||||
:return: :ref:`LoadState.LOADED`, possibly combined with other flags such |
||||
as :ref:`LoadState.STATIC` |
||||
|
||||
.. py:function:: corrade.pluginmanager.AbstractManager.unload |
||||
:raise RuntimeError: When unloading fails |
||||
:return: Either :ref:`LoadState.NOT_LOADED` or :ref:`LoadState.STATIC` |
||||
|
||||
.. py:function:: corrade.pluginmanager.AbstractManager.set_preferred_plugins |
||||
:raise KeyError: If the alias doesn't exist |
||||
@ -1,50 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
.. roles used for all other docs |
||||
|
||||
.. role:: cpp(code) |
||||
:language: c++ |
||||
.. role:: py(code) |
||||
:language: py |
||||
.. role:: sh(code) |
||||
:language: sh |
||||
|
||||
.. doctest setup |
||||
>>> from corrade import * |
||||
|
||||
.. py:module:: corrade |
||||
:data BUILD_DEPRECATED: Build with deprecated features enabled |
||||
:data BUILD_STATIC: Static library build |
||||
:data BUILD_MULTITHREADED: Multi-threaded build |
||||
:data TARGET_UNIX: Unix target |
||||
:data TARGET_APPLE: Apple target |
||||
:data TARGET_IOS: iOS target |
||||
:data TARGET_IOS_SIMULATOR: iOS simulator target |
||||
:data TARGET_WINDOWS: Windows target |
||||
:data TARGET_WINDOWS_RT: Windows RT target |
||||
:data TARGET_EMSCRIPTEN: Emscripten target |
||||
:data TARGET_ANDROID: Android target |
||||
@ -1,37 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
.. py:function:: corrade.utility.copy |
||||
:raise AssertionError: If :p:`src` and :p:`dst` sizes, type sizes or types are different |
||||
|
||||
.. py:function:: corrade.utility.ConfigurationGroup.group |
||||
:raise KeyError: If group :p:`name` doesn't exist |
||||
|
||||
.. py:function:: corrade.utility.Configuration.__init__(self, filename: str) |
||||
:raise IOError: If :p:`filename` contains a parse error |
||||
|
||||
.. py:function:: corrade.utility.Configuration.save |
||||
:raise IOError: If the file can't be saved |
||||
@ -1,43 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
.. py:function:: magnum.materialtools.filter_attributes |
||||
:raise AssertionError: If size of :p:`attributes_to_keep` is different than |
||||
:ref:`trade.MaterialData.attribute_data_offset()` for |
||||
:ref:`trade.MaterialData.layer_count` |
||||
.. py:function:: magnum.materialtools.filter_layers |
||||
:raise AssertionError: If size of :p:`layers_to_keep` is different than |
||||
:ref:`trade.MaterialData.layer_count` |
||||
.. py:function:: magnum.materialtools.filter_attributes_layers |
||||
:raise AssertionError: If size of :p:`attributes_to_keep` is different than |
||||
:ref:`trade.MaterialData.attribute_data_offset()` for |
||||
:ref:`trade.MaterialData.layer_count` |
||||
:raise AssertionError: If size of :p:`layers_to_keep` is different than |
||||
:ref:`trade.MaterialData.layer_count` |
||||
.. py:function:: magnum.materialtools.merge |
||||
:raise RuntimeError: If merge failed due to a conflict |
||||
.. py:function:: magnum.materialtools.phong_to_pbr_metallic_roughness |
||||
:raise RuntimeError: If conversion failed |
||||
@ -1,97 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
.. py:function:: magnum.meshtools.compress_indices |
||||
:raise AssertionError: If :p:`mesh` is not indexed |
||||
|
||||
.. py:function:: magnum.meshtools.concatenate |
||||
:raise AssertionError: If :p:`meshes` is empty |
||||
:raise AssertionError: If any of the :p:`meshes` is |
||||
:ref:`MeshPrimitive.LINE_STRIP`, :ref:`MeshPrimitive.LINE_LOOP`, |
||||
:ref:`MeshPrimitive.TRIANGLE_STRIP` or |
||||
:ref:`MeshPrimitive.TRIANGLE_FAN` |
||||
:raise AssertionError: If all :p:`meshes` don't have the same |
||||
:ref:`MeshPrimitive` |
||||
|
||||
.. py:function:: magnum.meshtools.duplicate |
||||
:raise AssertionError: If :p:`mesh` is not indexed |
||||
|
||||
.. py:function:: magnum.meshtools.filter_attributes |
||||
:raise AssertionError: If size of :p:`attributes_to_keep` is different than |
||||
:p:`mesh` attribute count |
||||
|
||||
.. py:function:: magnum.meshtools.generate_indices |
||||
:raise AssertionError: If :p:`mesh` is not :ref:`MeshPrimitive.LINE_STRIP`, |
||||
:ref:`MeshPrimitive.LINE_LOOP`, :ref:`MeshPrimitive.TRIANGLE_STRIP` or |
||||
:ref:`MeshPrimitive.TRIANGLE_FAN` |
||||
|
||||
.. py:function:: magnum.meshtools.interleave |
||||
:raise AssertionError: If any attribute in :p:`extra` has the data size |
||||
different from :p:`mesh` vertex count |
||||
|
||||
.. py:function:: magnum.meshtools.transform2d |
||||
:raise KeyError: If :p:`mesh` doesn't have |
||||
:ref:`trade.MeshAttribute.POSITION` of index :p:`id` (and in morph |
||||
target :p:`morph_target_id` if not :py:`-1`) |
||||
:raise AssertionError: If :ref:`trade.MeshAttribute.POSITION` are not 2D |
||||
|
||||
.. py:function:: magnum.meshtools.transform2d_in_place |
||||
:raise AssertionError: If :p:`mesh` vertex data aren't |
||||
:ref:`trade.DataFlags.MUTABLE` |
||||
:raise KeyError: If :p:`mesh` doesn't have |
||||
:ref:`trade.MeshAttribute.POSITION` of index :p:`id` (and in morph |
||||
target :p:`morph_target_id` if not :py:`-1`) |
||||
:raise AssertionError: If :ref:`trade.MeshAttribute.POSITION` are not |
||||
:ref:`VertexFormat.VECTOR2` |
||||
|
||||
.. py:function:: magnum.meshtools.transform3d |
||||
:raise KeyError: If :p:`mesh` doesn't have |
||||
:ref:`trade.MeshAttribute.POSITION` of index :p:`id` (and in morph |
||||
target :p:`morph_target_id` if not :py:`-1`) |
||||
:raise AssertionError: If :ref:`trade.MeshAttribute.POSITION` are not 3D |
||||
|
||||
.. py:function:: magnum.meshtools.transform3d_in_place |
||||
:raise AssertionError: If :p:`mesh` vertex data aren't |
||||
:ref:`trade.DataFlags.MUTABLE` |
||||
:raise KeyError: If :p:`mesh` doesn't have |
||||
:ref:`trade.MeshAttribute.POSITION` of index :p:`id` (and in morph |
||||
target :p:`morph_target_id` if not :py:`-1`) |
||||
:raise AssertionError: If :ref:`trade.MeshAttribute.POSITION` are not |
||||
:ref:`VertexFormat.VECTOR3` |
||||
|
||||
.. py:function:: magnum.meshtools.transform_texture_coordinates2d |
||||
:raise KeyError: If :p:`mesh` doesn't have |
||||
:ref:`trade.MeshAttribute.TEXTURE_COORDINATES` of index :p:`id` (and in |
||||
morph target :p:`morph_target_id` if not :py:`-1`) |
||||
|
||||
.. py:function:: magnum.meshtools.transform_texture_coordinates2d_in_place |
||||
:raise AssertionError: If :p:`mesh` vertex data aren't |
||||
:ref:`trade.DataFlags.MUTABLE` |
||||
:raise KeyError: If :p:`mesh` doesn't have |
||||
:ref:`trade.MeshAttribute.TEXTURE_COORDINATES` of index :p:`id` (and in |
||||
morph target :p:`morph_target_id` if not :py:`-1`) |
||||
:raise AssertionError: If :ref:`trade.MeshAttribute.TEXTURE_COORDINATES` |
||||
are not :ref:`VertexFormat.VECTOR2` |
||||
@ -1,70 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
.. py:function:: magnum.primitives.capsule2d_wireframe |
||||
:raise AssertionError: If :p:`hemisphere_rings` is less than :py:`1` |
||||
:raise AssertionError: If :p:`cylinder_rings` is less than :py:`1` |
||||
.. py:function:: magnum.primitives.capsule3d_solid |
||||
:raise AssertionError: If :p:`hemisphere_rings` is less than :py:`1` |
||||
:raise AssertionError: If :p:`cylinder_rings` is less than :py:`1` |
||||
:raise AssertionError: If :p:`segments` is less than :py:`3` |
||||
.. py:function:: magnum.primitives.capsule3d_wireframe |
||||
:raise AssertionError: If :p:`hemisphere_rings` is less than :py:`1` |
||||
:raise AssertionError: If :p:`cylinder_rings` is less than :py:`1` |
||||
:raise AssertionError: If :p:`segments` is zero or not a multiple of |
||||
:py:`4` |
||||
|
||||
.. py:function:: magnum.primitives.circle2d_solid |
||||
:raise AssertionError: If :p:`segments` is less than :py:`3` |
||||
.. py:function:: magnum.primitives.circle2d_wireframe |
||||
:raise AssertionError: If :p:`segments` is less than :py:`3` |
||||
.. py:function:: magnum.primitives.circle3d_solid |
||||
:raise AssertionError: If :p:`segments` is less than :py:`3` |
||||
.. py:function:: magnum.primitives.circle3d_wireframe |
||||
:raise AssertionError: If :p:`segments` is less than :py:`3` |
||||
|
||||
.. py:function:: magnum.primitives.cone_solid |
||||
:raise AssertionError: If :p:`rings` is less than :py:`1` |
||||
:raise AssertionError: If :p:`segments` is less than :py:`3` |
||||
.. py:function:: magnum.primitives.cone_wireframe |
||||
:raise AssertionError: If :p:`segments` is zero or not a multiple of |
||||
:py:`4` |
||||
|
||||
.. py:function:: magnum.primitives.cylinder_solid |
||||
:raise AssertionError: If :p:`rings` is less than :py:`1` |
||||
:raise AssertionError: If :p:`segments` is less than :py:`3` |
||||
.. py:function:: magnum.primitives.cylinder_wireframe |
||||
:raise AssertionError: If :p:`rings` is less than :py:`1` |
||||
:raise AssertionError: If :p:`segments` is zero or not a multiple of |
||||
:py:`4` |
||||
|
||||
.. py:function:: magnum.primitives.uv_sphere_solid |
||||
:raise AssertionError: If :p:`rings` is less than :py:`2` |
||||
:raise AssertionError: If :p:`segments` is less than :py:`3` |
||||
.. py:function:: magnum.primitives.uv_sphere_wireframe |
||||
:raise AssertionError: If :p:`rings` is zero or not a multiple of :py:`2` |
||||
:raise AssertionError: If :p:`segments` is zero or not a multiple of |
||||
:py:`4` |
||||
@ -1,75 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
.. py:function:: magnum.scenetools.filter_fields |
||||
:raise AssertionError: If size of :p:`fields_to_keep` is different than |
||||
:ref:`trade.SceneData.field_count` |
||||
|
||||
.. py:function:: magnum.scenetools.filter_field_entries |
||||
:raise AssertionError: If any field in :p:`entries_to_keep` does not exist |
||||
in :p:`scene` |
||||
:raise AssertionError: If any field in :p:`entries_to_keep` is listed more |
||||
than once |
||||
:raise AssertionError: If size of any array in :p:`entries_to_keep` does |
||||
not match :ref:`trade.SceneData.field_size()` for given field |
||||
|
||||
.. py:function:: magnum.scenetools.filter_objects |
||||
:raise AssertionError: If size of :p:`objects_to_keep` is different than |
||||
:ref:`trade.SceneData.mapping_bound` |
||||
|
||||
.. py:function:: magnum.scenetools.parents_breadth_first |
||||
:raise AssertionError: If :p:`scene` does not have |
||||
:ref:`trade.SceneField.PARENT` |
||||
|
||||
.. py:function:: magnum.scenetools.children_depth_first |
||||
:raise AssertionError: If :p:`scene` does not have |
||||
:ref:`trade.SceneField.PARENT` |
||||
|
||||
.. py:function:: magnum.scenetools.absolute_field_transformations2d(scene: magnum.trade.SceneData, field: magnum.trade.SceneField, global_transformation: magnum.Matrix3) |
||||
:raise KeyError: If :p:`field` does not exist in :p:`scene` |
||||
:raise AssertionError: If :p:`scene` is not 2D |
||||
:raise AssertionError: If :p:`scene` does not have |
||||
:ref:`trade.SceneField.PARENT` |
||||
|
||||
.. py:function:: magnum.scenetools.absolute_field_transformations2d(scene: magnum.trade.SceneData, field_id: int, global_transformation: magnum.Matrix3) |
||||
:raise IndexError: If :p:`field_id` negative or not less than |
||||
:ref:`trade.SceneData.field_count` |
||||
:raise AssertionError: If :p:`scene` is not 2D |
||||
:raise AssertionError: If :p:`scene` does not have |
||||
:ref:`trade.SceneField.PARENT` |
||||
|
||||
.. py:function:: magnum.scenetools.absolute_field_transformations3d(scene: magnum.trade.SceneData, field: magnum.trade.SceneField, global_transformation: magnum.Matrix4) |
||||
:raise KeyError: If :p:`field` does not exist in :p:`scene` |
||||
:raise AssertionError: If :p:`scene` is not 2D |
||||
:raise AssertionError: If :p:`scene` does not have |
||||
:ref:`trade.SceneField.PARENT` |
||||
|
||||
.. py:function:: magnum.scenetools.absolute_field_transformations3d(scene: magnum.trade.SceneData, field_id: int, global_transformation: magnum.Matrix4) |
||||
:raise IndexError: If :p:`field_id` negative or not less than |
||||
:ref:`trade.SceneData.field_count` |
||||
:raise AssertionError: If :p:`scene` is not 2D |
||||
:raise AssertionError: If :p:`scene` does not have |
||||
:ref:`trade.SceneField.PARENT` |
||||
@ -1,169 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
.. py:class:: magnum.text.FontManager |
||||
:summary: Manager for :ref:`AbstractFont` plugin instances |
||||
|
||||
Each plugin returned by :ref:`instantiate()` or :ref:`load_and_instantiate()` |
||||
references its owning :ref:`FontManager` through |
||||
:ref:`AbstractFont.manager`, ensuring the manager is not deleted before the |
||||
plugin instances are. |
||||
|
||||
.. TODO couldn't the plugin_interface etc. docs be parsed from pybind's docs? |
||||
repeating them for every plugin is annoying |
||||
|
||||
.. py:class:: magnum.text.AbstractFont |
||||
:data plugin_interface: Plugin interface string |
||||
:data plugin_search_paths: Plugin search paths |
||||
:data plugin_suffix: Plugin suffix |
||||
:data plugin_metadata_suffix: Plugin metadata suffix |
||||
|
||||
Similarly to C++, font plugins are loaded through :ref:`FontManager`: |
||||
|
||||
.. |
||||
>>> from magnum import text |
||||
|
||||
.. code:: py |
||||
|
||||
>>> manager = text.FontManager() |
||||
>>> font = manager.load_and_instantiate('StbTrueTypeFont') |
||||
|
||||
Unlike C++, errors in both API usage and file parsing are reported by |
||||
raising an exception. See particular function documentation for detailed |
||||
behavior. |
||||
|
||||
.. py:function:: magnum.text.AbstractFont.open_data |
||||
:raise RuntimeError: If file opening fails |
||||
|
||||
.. py:function:: magnum.text.AbstractFont.open_file |
||||
:raise RuntimeError: If file opening fails |
||||
|
||||
For compatibility with :ref:`os.path`, on Windows this function converts |
||||
all backslashes in :p:`filename` to forward slashes before passing it to |
||||
:dox:`Text::AbstractFont::openFile()`, which expects forward slashes as |
||||
directory separators on all platforms. |
||||
|
||||
.. py:property:: magnum.text.AbstractFont.size |
||||
:raise AssertionError: If no file is opened |
||||
.. py:property:: magnum.text.AbstractFont.ascent |
||||
:raise AssertionError: If no file is opened |
||||
.. py:property:: magnum.text.AbstractFont.descent |
||||
:raise AssertionError: If no file is opened |
||||
.. py:property:: magnum.text.AbstractFont.line_height |
||||
:raise AssertionError: If no file is opened |
||||
.. py:property:: magnum.text.AbstractFont.glyph_count |
||||
:raise AssertionError: If no file is opened |
||||
.. py:function:: magnum.text.AbstractFont.glyph_id |
||||
:raise AssertionError: If no file is opened |
||||
.. py:function:: magnum.text.AbstractFont.glyph_size |
||||
:raise AssertionError: If no file is opened |
||||
:raise IndexError: If :p:`glyph` is negative or not less than |
||||
:ref:`glyph_count` |
||||
.. py:function:: magnum.text.AbstractFont.glyph_advance |
||||
:raise AssertionError: If no file is opened |
||||
:raise IndexError: If :p:`glyph` is negative or not less than |
||||
:ref:`glyph_count` |
||||
.. py:function:: magnum.text.AbstractFont.fill_glyph_cache |
||||
:raise AssertionError: If no file is opened |
||||
.. py:function:: magnum.text.AbstractFont.create_shaper |
||||
:raise AssertionError: If no file is opened |
||||
|
||||
.. TODO remove the copies once the base class methods don't leak to subclasses |
||||
.. py:property:: magnum.text.RendererCore.cursor |
||||
:raise AssertionError: If setting this property while rendering is in |
||||
progress |
||||
.. py:property:: magnum.text.Renderer.cursor |
||||
:raise AssertionError: If setting this property while rendering is in |
||||
progress |
||||
.. py:property:: magnum.text.RendererGL.cursor |
||||
:raise AssertionError: If setting this property while rendering is in |
||||
progress |
||||
|
||||
.. py:property:: magnum.text.RendererCore.alignment |
||||
:raise AssertionError: If setting this property while rendering is in |
||||
progress |
||||
.. py:property:: magnum.text.Renderer.alignment |
||||
:raise AssertionError: If setting this property while rendering is in |
||||
progress |
||||
.. py:property:: magnum.text.RendererGL.alignment |
||||
:raise AssertionError: If setting this property while rendering is in |
||||
progress |
||||
|
||||
.. py:property:: magnum.text.RendererCore.line_advance |
||||
:raise AssertionError: If setting this property while rendering is in |
||||
progress |
||||
.. py:property:: magnum.text.Renderer.line_advance |
||||
:raise AssertionError: If setting this property while rendering is in |
||||
progress |
||||
.. py:property:: magnum.text.RendererGL.line_advance |
||||
:raise AssertionError: If setting this property while rendering is in |
||||
progress |
||||
|
||||
.. py:property:: magnum.text.RendererGL.index_type |
||||
:raise AssertionError: If setting this property while rendering is in |
||||
progress |
||||
|
||||
.. py:function:: magnum.text.RendererCore.add |
||||
:raise AssertionError: If :p:`shaper` font isn't present in |
||||
:ref:`glyph_cache` |
||||
.. py:function:: magnum.text.Renderer.add |
||||
:raise AssertionError: If :p:`shaper` font isn't present in |
||||
:ref:`glyph_cache` |
||||
.. py:function:: magnum.text.RendererGL.add |
||||
:raise AssertionError: If :p:`shaper` font isn't present in |
||||
:ref:`glyph_cache` |
||||
|
||||
.. py:function:: magnum.text.RendererGL.render(self, shaper: magnum.text.AbstractShaper, size: float, text: str, features: list[magnum.text.FeatureRange]) |
||||
:raise AssertionError: If :p:`shaper` font isn't present in |
||||
:ref:`glyph_cache` |
||||
|
||||
.. py:enum:: magnum.text.Feature |
||||
|
||||
The equivalent to C++ :dox:`Text::feature()` is passing the four-character |
||||
code to the constructor: |
||||
|
||||
.. |
||||
>>> from magnum import text |
||||
|
||||
.. code:: pycon |
||||
|
||||
>>> feature = text.Feature('kern') |
||||
>>> feature.name |
||||
'KERNING' |
||||
|
||||
.. py:enum:: magnum.text.Script |
||||
|
||||
The equivalent to C++ :dox:`Text::script()` is passing the four-character |
||||
code to the constructor: |
||||
|
||||
.. |
||||
>>> from magnum import text |
||||
|
||||
.. code:: pycon |
||||
|
||||
>>> script = text.Script('Latn') |
||||
>>> script.name |
||||
'LATIN' |
||||
Binary file not shown.
@ -1,238 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
Changelog |
||||
######### |
||||
|
||||
:ref-prefix: |
||||
corrade |
||||
magnum |
||||
:some_directive: TODO: why can't the title below "just work" and I have to |
||||
add some bogus content before? |
||||
|
||||
`Changes since 2020.06`_ |
||||
======================== |
||||
|
||||
- Minimal supported CMake version is now 3.5, changed from 3.4, since CMake |
||||
3.27+ warns if a compatibility with CMake below 3.5 is requested. Older |
||||
versions are not supported anymore and all workarounds for them were |
||||
removed. This is a conservative change, as there are no known supported |
||||
distributions which would have anything older than 3.5. |
||||
- Exposed the :ref:`corrade.BUILD_DEPRECATED` and |
||||
:ref:`magnum.BUILD_DEPRECATED` constants, as some features may work |
||||
differently depending on these being enabled or not and it's useful to be |
||||
able to query this |
||||
- Exposed the new :ref:`containers.BitArray`, :ref:`containers.BitArrayView`, |
||||
:ref:`containers.StridedBitArrayView1D` containers, their mutable and |
||||
multi-dimensional counterparts as well as the |
||||
:ref:`containers.StridedArrayView*D.slice_bit() <containers.StridedArrayView1D.slice_bit()>` |
||||
utility |
||||
- Exposed missing :ref:`Vector4` constructor from a :ref:`Vector3` and a |
||||
W component and :ref:`Vector3` from :ref:`Vector2` and a Z component |
||||
- Renamed :py:`Matrix3.from()` / :py:`Matrix4.from()` to :ref:`Matrix3.from_()` |
||||
/ :ref:`Matrix4.from_()` because :py:`from` is a Python keyword and it |
||||
would be silly to have to write :py:`getattr(Matrix4, 'from')` just to use |
||||
these APIs |
||||
- Exposed newly added off-center variants of |
||||
:ref:`Matrix4.orthographic_projection()` and |
||||
:ref:`Matrix3.projection()` |
||||
- Exposed remaining vector/scalar, exponential and other functions in the |
||||
:ref:`math <magnum.math>` library |
||||
- Exposed the :ref:`CompressedPixelFormat` enum, various pixel-format-related |
||||
helper APIs are now properties on :ref:`PixelFormat` and |
||||
:ref:`CompressedPixelFormat` |
||||
- Exposed :ref:`CompressedImage2D`, :ref:`CompressedImageView2D`, |
||||
:ref:`MutableCompressedImageView2D` and their 1D and 3D counterparts |
||||
- Exposed :ref:`Color3.from_xyz()`, :ref:`Color3.from_linear_rgb_int()`, |
||||
:ref:`Color3.to_xyz()`, :ref:`Color3.to_linear_rgb_int()` and equivalent |
||||
APIs on :ref:`Color4` |
||||
- Exposed unsigned :ref:`Range1Dui`, :ref:`Range2Dui` and :ref:`Range3Dui` |
||||
types in addition to the signed variants |
||||
- Exposed new :ref:`Quaternion.rotation()`, :ref:`Quaternion.reflection()`, |
||||
:ref:`Quaternion.reflect_vector()`, :ref:`Quaternion.xyzw` and |
||||
:ref:`Quaternion.wxyz` APIs |
||||
- Exposed :ref:`gl.Context` and its platform-specific subclasses for EGL, WGL |
||||
and GLX |
||||
- Exposed :ref:`gl.Framebuffer.attach_texture()` and missing sRGB, depth |
||||
and stencil :ref:`gl.TextureFormat` values (see :gh:`mosra/magnum-bindings#14`) |
||||
- Exposed :ref:`gl.Renderer.set_blend_function()`, |
||||
:ref:`gl.Renderer.set_blend_equation()` and related enums (see :gh:`mosra/magnum-bindings#9`) |
||||
- Exposed :ref:`gl.Renderer.Feature.CLIP_DISTANCEn <gl.Renderer.Feature.CLIP_DISTANCE0>` |
||||
values that are new since 2020.06 |
||||
- Exposed new instancing, texture transformation, normal-mapping-related and |
||||
lighting features in :ref:`shaders.PhongGL` |
||||
- Exposed new instancing and texture transformation features in |
||||
:ref:`shaders.FlatGL2D` and :ref:`shaders.FlatGL3D` |
||||
- Exposed :ref:`shaders.DistanceFieldVectorGL2D`, |
||||
:ref:`shaders.DistanceFieldVectorGL3D`, :ref:`shaders.VectorGL2D` and |
||||
:ref:`shaders.VectorGL3D` shaders |
||||
- Renamed all helper ``Python.h`` headers to ``PythonBindings.h`` to avoid |
||||
issues with shitty IDE indexers such as Eclipse, confusing these with |
||||
Python's ``<Python.h>`` |
||||
- Minor performance fixes (see :gh:`mosra/magnum-bindings#10`, |
||||
:gh:`mosra/magnum-bindings#15`, |
||||
:gh:`mosra/magnum-bindings#16`, |
||||
:gh:`mosra/magnum-bindings#17`, |
||||
:gh:`mosra/magnum-bindings#19`, |
||||
:gh:`mosra/magnum-bindings#20`) |
||||
Travis banned everyone from using their CI and so all Linux and macOS |
||||
builds were migrated from Travis to Circle CI. See also |
||||
:gh:`mosra/magnum#350` and :gh:`mosra/magnum#523`. |
||||
- It's now possible to use ``<PackageName>_ROOT`` to point to install |
||||
locations of dependencies such as Corrade on CMake 3.12+, in addition to |
||||
putting them all together inside ``CMAKE_PREFIX_PATH``. See also |
||||
:gh:`mosra/magnum#614`. |
||||
- On CMake 3.16 and newer, ``FindMagnumBindings.cmake`` can provide |
||||
additional details if some component is not found |
||||
- The Homebrew package now uses ``std_cmake_args`` instead of hardcoded build |
||||
type and install prefix, which resolves certain build issues (see |
||||
:gh:`mosra/homebrew-magnum#6`) |
||||
- Added a caster for :dox:`Containers::Optional`, allowing it to be used |
||||
directly in function signatures and showing up on the Python side as either |
||||
:py:`None` or the actual value |
||||
- Various documentation fixes (see :gh:`mosra/magnum-bindings#11`) |
||||
- Fixed copypaste errors in bindings for :ref:`Range2D.center_x()` / |
||||
:ref:`Range2D.center_y()`, :ref:`Range3D.z()`, :ref:`Range3D.center_x()` / |
||||
:ref:`Range3D.center_y()` / :ref:`Range3D.center_z()` |
||||
- Fixed a copypaste error in |
||||
:ref:`platform.sdl2.Application.PointerMoveEvent.relative_position` and |
||||
:ref:`platform.glfw.Application.PointerMoveEvent.relative_position` |
||||
- Fixed :ref:`platform.sdl2.Application.Modifier` and |
||||
:ref:`platform.glfw.Application.Modifier` to behave properly |
||||
as flags and not just as an enum |
||||
- Exposed :ref:`meshtools.compress_indices()`, :ref:`meshtools.concatenate()`, |
||||
:ref:`meshtools.copy()`, :ref:`meshtools.duplicate()`, |
||||
:ref:`meshtools.filter_attributes()`, |
||||
:ref:`meshtools.filter_except_attributes()`, |
||||
:ref:`meshtools.filter_only_attributes()`, |
||||
:ref:`meshtools.generate_indices()`, :ref:`meshtools.interleave()`, |
||||
:ref:`meshtools.remove_duplicates()`, |
||||
:ref:`meshtools.remove_duplicates_fuzzy()`, :ref:`meshtools.transform2d()`, |
||||
:ref:`meshtools.transform2d_in_place()`, :ref:`meshtools.transform3d()`, |
||||
:ref:`meshtools.transform3d_in_place()`, |
||||
:ref:`meshtools.transform_texture_coordinates2d()` and |
||||
:ref:`meshtools.transform_texture_coordinates2d_in_place()` |
||||
- Exposed :ref:`platform.sdl2.Application.viewport_event` and |
||||
:ref:`platform.glfw.Application.viewport_event` and a possibility |
||||
to make the window resizable on startup |
||||
- Exposed :ref:`platform.sdl2.Application.exit_event` and |
||||
:ref:`platform.glfw.Application.exit_event` |
||||
- Exposed :ref:`platform.sdl2.Application.dpi_scaling` and |
||||
:ref:`platform.glfw.Application.dpi_scaling` |
||||
- Exposed :ref:`platform.glfw.Application.swap_interval` and |
||||
:ref:`platform.glfw.Application.main_loop_iteration` |
||||
- Exposed :ref:`platform.sdl2.Application.cursor` and |
||||
:ref:`platform.sdl2.Application.warp_cursor`, same for GLFW |
||||
- Exposed :ref:`platform.sdl2.Application.is_key_pressed()` and |
||||
:ref:`platform.glfw.Application.is_key_pressed()` |
||||
- Exposed all :ref:`platform.sdl2.Application.Configuration.WindowFlags` and |
||||
:ref:`platform.glfw.Application.Configuration.WindowFlags` |
||||
- Exposed the new :ref:`primitives.CubeFlags` |
||||
- Exposed the new :ref:`text.AbstractShaper`, :ref:`text.RendererCore`, |
||||
:ref:`text.Renderer`, :ref:`text.RendererGL` classes as well as the new |
||||
:ref:`text.Feature`, :ref:`text.Script` enums and the |
||||
:ref:`text.FeatureRange` helper, plus more :ref:`text.Alignment` options |
||||
- Exposed :ref:`trade.AbstractImporter.features` and |
||||
:ref:`trade.AbstractImporter.flags` and corresponding enums |
||||
- Exposed a basic interface of :ref:`trade.AbstractImageConverter` and |
||||
:ref:`trade.AbstractSceneConverter` |
||||
- Exposed the whole interface of :ref:`trade.MeshData` and |
||||
:ref:`trade.MeshAttributeData` including typed access to index and |
||||
attribute data, together with :ref:`VertexFormat`, :ref:`trade.DataFlags`, |
||||
:ref:`trade.AbstractImporter.mesh_attribute_name()` and |
||||
:ref:`trade.AbstractImporter.mesh_attribute_for_name()` |
||||
- Exposed the whole interface of :ref:`trade.MaterialData` including typed |
||||
access to attribute data, together with |
||||
:ref:`trade.AbstractImporter.material()` and related importer APIs |
||||
- Exposed the whole interface of :ref:`trade.SceneData` and |
||||
:ref:`trade.SceneFieldData` including typed access to mapping and field |
||||
data, together with :ref:`trade.AbstractImporter.scene()` and related |
||||
importer APIs |
||||
- Exposed :ref:`Color3.red()` and other convenience constructors (see |
||||
:gh:`mosra/magnum-bindings#12`) |
||||
- Exposed the :ref:`materialtools`, :ref:`scenetools` and :ref:`text` |
||||
libraries |
||||
- Exposed :ref:`utility.copy()` for convenient, fast and safe copying of |
||||
multi-dimensional strided arrays |
||||
- Exposed the minimal interface of :ref:`utility.ConfigurationGroup` and |
||||
:ref:`utility.Configuration` |
||||
- Exposed :ref:`pluginmanager.AbstractManager.set_preferred_plugins()`, |
||||
:ref:`pluginmanager.AbstractManager.register_external_manager()`, the base |
||||
:ref:`pluginmanager.AbstractPlugin` class and |
||||
:ref:`pluginmanager.PluginMetadata` |
||||
- Fixed issues with an in-source build (see :gh:`mosra/magnum-bindings#13`) |
||||
- All CMake build options are now prefixed with ``MAGNUM_``. For backwards |
||||
compatibility, unless ``MAGNUM_BUILD_DEPRECATED`` is disabled and unless a |
||||
prefixed option is already set during the initial run, the unprefixed |
||||
options are still recognized with a warning. See also :gh:`mosra/corrade#139`. |
||||
- Added a ``MAGNUM_PYTHON_BINDINGS_STATIC_PLUGINS`` CMake option for linking |
||||
static plugins to the Python bindings module. See the |
||||
:ref:`building documentation <std:doc:building>` for more information. |
||||
- Added a ``MAGNUM_BUILD_PYTHON_BINDINGS_RTLD_GLOBAL`` CMake option to make |
||||
the Python bindings module loaded into the global namespace instead of |
||||
isolated in order to attempt to solve problems with duplicated globals when |
||||
static builds of Corrade and Magnum are linked into multiple dynamic |
||||
modules. See the :ref:`building documentation <std:doc:building>` for more |
||||
information. |
||||
|
||||
`2020.06`_ |
||||
========== |
||||
|
||||
Released 2020-06-27, tagged as |
||||
:gh:`v2020.06 <mosra/magnum-bindings/releases/tag/v2020.06>`. |
||||
|
||||
- Exposed :ref:`Matrix4.cofactor()`, :ref:`Matrix4.comatrix()`, |
||||
:ref:`Matrix4.adjugate()` (and equivalents in other matrix sizes), and |
||||
:ref:`Matrix4.normal_matrix()` |
||||
- Exposed :ref:`gl.AbstractFramebuffer.blit()` functions and related enums |
||||
- Exposed more keys in :ref:`platform.sdl2.Application` and |
||||
:ref:`platform.glfw.Application` |
||||
- Exposed :ref:`gl.AbstractTexture.unbind()` |
||||
- Exposed :ref:`trade.AbstractImporter.image2d_level_count()` and related |
||||
APIs for 1D and 3D |
||||
- Exposed :ref:`trade.MeshData` and related APIs, the previous |
||||
``trade.MeshData3D`` APIs are removed |
||||
- Exposed new APIs and tangent support in the :ref:`primitives` library |
||||
- :ref:`platform.sdl2.Application` and :ref:`platform.glfw.Application` now |
||||
provide a clear error instead of "pure virtual method call" in case |
||||
``draw_event()`` is not implemented |
||||
- Library version is now exposed through ``MAGNUMBINDINGS_VERSION_YEAR``, |
||||
``MAGNUMBINDINGS_VERSION_MONTH``, ``MAGNUMBINDINGS_VERSION_COMMIT``, |
||||
``MAGNUMBINDINGS_VERSION_HASH`` and ``MAGNUMBINDINGS_VERSION_STRING`` |
||||
preprocessor defines in a new ``Magnum/versionBindings.h`` header. This |
||||
header is not included by any other header to avoid trigerring a full |
||||
rebuild when Git commit changes. If Git is not found, only the first two |
||||
defines are present. |
||||
|
||||
`2019.10`_ |
||||
========== |
||||
|
||||
Released 2019-10-24, tagged as |
||||
:gh:`v2019.10 <mosra/magnum-bindings/releases/tag/v2019.10>`. |
||||
|
||||
Initial version. See :gh:`mosra/magnum#228`, :gh:`mosra/magnum-bindings#1`, |
||||
:gh:`mosra/magnum-bindings#2` and :gh:`mosra/magnum-bindings#6` for more |
||||
information. |
||||
@ -1,81 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
Credits |
||||
####### |
||||
|
||||
:ref-prefix: |
||||
corrade |
||||
magnum |
||||
:summary: Third-party dependencies and their corresponding license information; |
||||
people and organizations that contributed to Magnum Python Bindings. |
||||
|
||||
`Third-party components`_ |
||||
========================= |
||||
|
||||
.. TODO: ffs doxygen SORT YOUR SHIT OUT, why can't I link to |
||||
credits-third-party?! |
||||
.. role:: doxygen-you-fool(link) |
||||
:class: m-doc-external |
||||
|
||||
While Magnum Python Bindings themselves don't depend on much, a lot of |
||||
third-party components is used transitively from the Magnum C++ implementation. |
||||
Please see the :ref:`main page <std:doc:index#license>` for license of Magnum |
||||
Python Bindings themselves and the |
||||
:doxygen-you-fool:`Third-party components <https://doc.magnum.graphics/magnum/credits-third-party.html>` |
||||
page of C++ docs for a detailed overview of all used components. The list below |
||||
uses the same color-coding scheme for easier overview: |
||||
|
||||
:ref:`Magnum Python Bindings <std:doc:index>` |
||||
Bindings generated with :gh:`pybind11 <pybind/pybind11>`, released under a |
||||
:label-success:`BSD-style license` |
||||
(`license text <https://github.com/pybind/pybind11/blob/master/LICENSE>`_, |
||||
`choosealicense.com <https://choosealicense.com/licenses/bsd-3-clause/>`_). |
||||
It requires attribution for public use. |
||||
|
||||
`Contributors`_ |
||||
=============== |
||||
|
||||
Listing only people with code contributions or other significant work, because |
||||
otherwise there's too many :) There's also a |
||||
:dox:`similar list for Corrade <corrade-credits-contributors>` and |
||||
:dox:`Magnum <credits-contributors>` themselves. Big thanks to everyone |
||||
involved! |
||||
|
||||
.. class:: m-text-center m-text m-dim |
||||
|
||||
Are the below lists missing your name or something's wrong? |
||||
`Let us know! <https://magnum.graphics/contact/>`_ |
||||
|
||||
- **Aaron Gokaslan** (:gh:`Skylion007`) --- minor performance and |
||||
documentation fixes, expanding :ref:`Color3` / :ref:`Color4` bindings |
||||
- **Cameron Egbert** (:gh:`cegbertOculus`) --- initial Windows port |
||||
- **James Murphy** (:gh:`mCodingLLC`) --- buildsystem fixes, expanding |
||||
:ref:`gl.Framebuffer` bindings |
||||
- **John Laxson** (:gh:`jlaxson`) --- Homebrew package improvements |
||||
- **Stanislaw Halik** (:gh:`sthalik`) --- build fixes |
||||
- **Vladimir Gamalyan** (:gh:`vladimirgamalyan`) --- expanding |
||||
:ref:`gl.Renderer` bindings |
||||
@ -1,80 +0,0 @@
|
||||
.. |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
.. |
||||
|
||||
Developers Guide |
||||
################ |
||||
|
||||
:ref-prefix: |
||||
corrade |
||||
magnum |
||||
:summary: Checklists for developing new things in Magnum Python bindings |
||||
themselves. |
||||
|
||||
.. role:: cmake(code) |
||||
:language: cmake |
||||
.. role:: cpp(code) |
||||
:language: c++ |
||||
.. role:: py(code) |
||||
:language: py |
||||
|
||||
`Checklist for adding / removing bindings for a library`_ |
||||
========================================================= |
||||
|
||||
1. Add a corresponding ``Foo`` Magnum dependency to the :cmake:`find_package()` |
||||
call in ``src/python/magnum/CMakeLists.txt``, create a ``magnum_foo_SRCS`` |
||||
variable with its source file(s). |
||||
2. Add a :cmake:`if(Magnum_Foo_FOUND)` branch to the |
||||
:cmake:`if(NOT MAGNUM_BUILD_STATIC)` condition, adding a new ``magnum_foo`` |
||||
module from ``magnum_foo_SRCS``, linking to ``Magnum::Foo`` and setting |
||||
``OUTPUT_NAME`` to ``foo``. |
||||
3. Add a :cmake:`if(Magnum_Foo_FOUND)` branch to the :cmake:`else()` |
||||
condition, ``APPEND``\ ing ``magnum_foo_SRCS`` to ``magnum_SRCS`` and |
||||
``Magnum::Foo`` to ``magnum_LIBS``. |
||||
4. Add :cpp:`void foo(py::module_& m);` forward declaration to |
||||
``magnum/bootstrap.h``, and :cpp:`#cmakdefeine Magnum_Foo_FOUND` to |
||||
``magnum/staticconfigure.h.cmake``. |
||||
5. Implement ``void foo(py::module_& m)`` in ``src/python/magnum/foo.cpp``, |
||||
add a :cpp:`PYBIND11_MODULE()` calling it. |
||||
6. Add :cpp:`m.def_submodule("foo");` and a call to :cpp:`magnum:foo()` |
||||
wrapped in :cpp:`#ifdef Magnum_Foo_FOUND` to the |
||||
:cpp:`#ifdef MAGNUM_BUILD_STATIC` section of :cpp:`PYBIND11_MODULE()` in |
||||
``magnum/magnum.cpp``. |
||||
7. Add the new module name to the list in ``magnum/__init__.py``. |
||||
8. Add a line with ``magnum_foo`` to the :cmake:`foreach()` in |
||||
``src/python/CMakeLists.txt``, and then a corresponding :py:`'magnum.foo'` |
||||
entry in ``src/python/setup.py.cmake`` |
||||
9. Add a ``magnum/test/test_foo.py`` test file, and potentially also |
||||
``magnum/test/test_foo_gl.py`` where is |
||||
:py:`from . import GLTestCase, setUpModule` to skip the test if GL context |
||||
doesn't exist, and the test cases derive from :py:`GLTestCase` instead of |
||||
:py:`unittest.TestCase`. |
||||
10. Add the new module into the :py:`magnum.__all__` list in |
||||
``doc/python/conf.py``. |
||||
11. Add a ``doc/python/magnum.foo.rst`` documentation file for more detailed |
||||
docs, if needed, and reference it from ``INPUT_DOCS``. |
||||
12. Add a ``doc/python/pages/changelog.rst`` entry. |
||||
|
||||
For Corrade bindings it's similar. |
||||
Binary file not shown.
@ -0,0 +1,86 @@
|
||||
#.rst: |
||||
# Find EGL |
||||
# -------- |
||||
# |
||||
# Finds the EGL library. This module defines: |
||||
# |
||||
# EGL_FOUND - True if EGL library is found |
||||
# EGL::EGL - EGL imported target |
||||
# |
||||
# Additionally these variables are defined for internal usage: |
||||
# |
||||
# EGL_LIBRARY - EGL library |
||||
# EGL_INCLUDE_DIR - Include dir |
||||
# |
||||
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# 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: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
# Under Emscripten, GL is linked implicitly. With MINIMAL_RUNTIME you need to |
||||
# specify -lGL. Simply set the library name to that. |
||||
if(CORRADE_TARGET_EMSCRIPTEN) |
||||
set(EGL_LIBRARY GL CACHE STRING "Path to a library." FORCE) |
||||
else() |
||||
find_library(EGL_LIBRARY NAMES |
||||
EGL |
||||
|
||||
# ANGLE (CMake doesn't search for lib prefix on Windows) |
||||
libEGL |
||||
|
||||
# On iOS a part of OpenGLES |
||||
OpenGLES) |
||||
endif() |
||||
|
||||
# Include dir |
||||
find_path(EGL_INCLUDE_DIR NAMES |
||||
EGL/egl.h |
||||
|
||||
# iOS |
||||
EAGL.h) |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args(EGL DEFAULT_MSG |
||||
EGL_LIBRARY |
||||
EGL_INCLUDE_DIR) |
||||
|
||||
if(NOT TARGET EGL::EGL) |
||||
# Work around BUGGY framework support on macOS. Do this also in case of |
||||
# Emscripten, since there we don't have a location either. |
||||
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html |
||||
if((APPLE AND ${EGL_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN) |
||||
add_library(EGL::EGL INTERFACE IMPORTED) |
||||
set_property(TARGET EGL::EGL APPEND PROPERTY |
||||
INTERFACE_LINK_LIBRARIES ${EGL_LIBRARY}) |
||||
else() |
||||
add_library(EGL::EGL UNKNOWN IMPORTED) |
||||
set_property(TARGET EGL::EGL PROPERTY |
||||
IMPORTED_LOCATION ${EGL_LIBRARY}) |
||||
endif() |
||||
|
||||
set_target_properties(EGL::EGL PROPERTIES |
||||
INTERFACE_INCLUDE_DIRECTORIES ${EGL_INCLUDE_DIR}) |
||||
endif() |
||||
|
||||
mark_as_advanced(EGL_LIBRARY EGL_INCLUDE_DIR) |
||||
@ -0,0 +1,94 @@
|
||||
#.rst: |
||||
# Find GLFW |
||||
# --------- |
||||
# |
||||
# Finds the GLFW library using its cmake config if that exists, otherwise |
||||
# falls back to finding it manually. This module defines: |
||||
# |
||||
# GLFW_FOUND - True if GLFW library is found |
||||
# GLFW::GLFW - GLFW imported target |
||||
# |
||||
# Additionally, in case the config was not found, these variables are defined |
||||
# for internal usage: |
||||
# |
||||
# GLFW_LIBRARY - GLFW library |
||||
# GLFW_INCLUDE_DIR - Root include dir |
||||
# |
||||
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# Copyright © 2016 Jonathan Hale <squareys@googlemail.com> |
||||
# |
||||
# 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: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
# GLFW installs cmake package config files to shared/ folder which handles |
||||
# dependencies in case GLFW is built statically. Try to find first, quietly, so |
||||
# it doesn't print loud messages when it's not found, since that's okay. |
||||
find_package(glfw3 CONFIG QUIET) |
||||
|
||||
if(TARGET glfw) |
||||
if(NOT TARGET GLFW::GLFW) |
||||
# Aliases of (global) targets are only supported in CMake 3.11, so we |
||||
# work around it by this. This is easier than fetching all possible |
||||
# properties (which are impossible to track of) and then attempting to |
||||
# rebuild them into a new target. |
||||
add_library(GLFW::GLFW INTERFACE IMPORTED) |
||||
set_target_properties(GLFW::GLFW PROPERTIES INTERFACE_LINK_LIBRARIES glfw) |
||||
endif() |
||||
|
||||
# Just to make FPHSA print some meaningful location, nothing else |
||||
get_target_property(_GLFW_INTERFACE_INCLUDE_DIRECTORIES glfw INTERFACE_INCLUDE_DIRECTORIES) |
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args("GLFW" DEFAULT_MSG |
||||
_GLFW_INTERFACE_INCLUDE_DIRECTORIES) |
||||
return() |
||||
endif() |
||||
|
||||
# In case no config file was found, try manually finding the library. |
||||
find_library(GLFW_LIBRARY NAMES glfw glfw3) |
||||
|
||||
# Include dir |
||||
find_path(GLFW_INCLUDE_DIR |
||||
NAMES GLFW/glfw3.h) |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args("GLFW" DEFAULT_MSG |
||||
GLFW_LIBRARY |
||||
GLFW_INCLUDE_DIR) |
||||
|
||||
if(NOT TARGET GLFW::GLFW) |
||||
add_library(GLFW::GLFW UNKNOWN IMPORTED) |
||||
|
||||
# Work around BUGGY framework support on macOS |
||||
# https://cmake.org/Bug/view.php?id=14105 |
||||
if(CORRADE_TARGET_APPLE AND ${GLFW_LIBRARY} MATCHES "\\.framework$") |
||||
set_property(TARGET GLFW::GLFW PROPERTY IMPORTED_LOCATION ${GLFW_LIBRARY}/GLFW) |
||||
else() |
||||
set_property(TARGET GLFW::GLFW PROPERTY IMPORTED_LOCATION ${GLFW_LIBRARY}) |
||||
endif() |
||||
|
||||
set_property(TARGET GLFW::GLFW PROPERTY |
||||
INTERFACE_INCLUDE_DIRECTORIES ${GLFW_INCLUDE_DIR}) |
||||
endif() |
||||
|
||||
mark_as_advanced(GLFW_LIBRARY GLFW_INCLUDE_DIR) |
||||
@ -0,0 +1,78 @@
|
||||
#.rst: |
||||
# Find OpenGL ES 2 |
||||
# ---------------- |
||||
# |
||||
# Finds the OpenGL ES 2 library. This module defines: |
||||
# |
||||
# OpenGLES2_FOUND - True if OpenGL ES 2 library is found |
||||
# OpenGLES2::OpenGLES2 - OpenGL ES 2 imported target |
||||
# |
||||
# Additionally these variables are defined for internal usage: |
||||
# |
||||
# OPENGLES2_LIBRARY - OpenGL ES 2 library |
||||
# |
||||
# Please note this find module is tailored especially for the needs of Magnum. |
||||
# In particular, it depends on its platform definitions and doesn't look for |
||||
# OpenGL ES includes as Magnum has its own, generated using flextGL. |
||||
# |
||||
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# 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: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
# Under Emscripten, GL is linked implicitly. With MINIMAL_RUNTIME you need to |
||||
# specify -lGL. Simply set the library name to that. |
||||
if(CORRADE_TARGET_EMSCRIPTEN) |
||||
set(OPENGLES2_LIBRARY GL CACHE STRING "Path to a library." FORCE) |
||||
else() |
||||
find_library(OPENGLES2_LIBRARY NAMES |
||||
GLESv2 |
||||
|
||||
# ANGLE (CMake doesn't search for lib prefix on Windows) |
||||
libGLESv2 |
||||
|
||||
# iOS |
||||
OpenGLES) |
||||
endif() |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args(OpenGLES2 DEFAULT_MSG |
||||
OPENGLES2_LIBRARY) |
||||
|
||||
if(NOT TARGET OpenGLES2::OpenGLES2) |
||||
# Work around BUGGY framework support on macOS. Do this also in case of |
||||
# Emscripten, since there we don't have a location either. |
||||
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html |
||||
if((CORRADE_TARGET_APPLE AND ${OPENGLES2_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN) |
||||
add_library(OpenGLES2::OpenGLES2 INTERFACE IMPORTED) |
||||
set_property(TARGET OpenGLES2::OpenGLES2 APPEND PROPERTY |
||||
INTERFACE_LINK_LIBRARIES ${OPENGLES2_LIBRARY}) |
||||
else() |
||||
add_library(OpenGLES2::OpenGLES2 UNKNOWN IMPORTED) |
||||
set_property(TARGET OpenGLES2::OpenGLES2 PROPERTY |
||||
IMPORTED_LOCATION ${OPENGLES2_LIBRARY}) |
||||
endif() |
||||
endif() |
||||
|
||||
mark_as_advanced(OPENGLES2_LIBRARY) |
||||
@ -0,0 +1,92 @@
|
||||
#.rst: |
||||
# Find OpenGL ES 3 |
||||
# ---------------- |
||||
# |
||||
# Finds the OpenGL ES 3 library. This module defines: |
||||
# |
||||
# OpenGLES3_FOUND - True if OpenGL ES 3 library is found |
||||
# OpenGLES3::OpenGLES3 - OpenGL ES 3 imported target |
||||
# |
||||
# Additionally these variables are defined for internal usage: |
||||
# |
||||
# OPENGLES3_LIBRARY - OpenGL ES 3 library |
||||
# |
||||
# Please note this find module is tailored especially for the needs of Magnum. |
||||
# In particular, it depends on its platform definitions and doesn't look for |
||||
# OpenGL ES includes as Magnum has its own, generated using flextGL. |
||||
# |
||||
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# 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: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
# Under Emscripten, GL is linked implicitly. With MINIMAL_RUNTIME you need to |
||||
# specify -lGL. Simply set the library name to that. |
||||
if(CORRADE_TARGET_EMSCRIPTEN) |
||||
set(OPENGLES3_LIBRARY GL CACHE STRING "Path to a library." FORCE) |
||||
else() |
||||
find_library(OPENGLES3_LIBRARY NAMES |
||||
GLESv3 |
||||
|
||||
# On some platforms (e.g. desktop emulation with Mesa or NVidia) ES3 |
||||
# support is provided in ES2 lib |
||||
GLESv2 |
||||
|
||||
# ANGLE (CMake doesn't search for lib prefix on Windows) |
||||
libGLESv2 |
||||
|
||||
# iOS |
||||
OpenGLES) |
||||
endif() |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args("OpenGLES3" DEFAULT_MSG |
||||
OPENGLES3_LIBRARY) |
||||
|
||||
if(NOT TARGET OpenGLES3::OpenGLES3) |
||||
# Work around BUGGY framework support on macOS. Do this also in case of |
||||
# Emscripten, since there we don't have a location either. |
||||
# http://public.kitware.com/pipermail/cmake/2016-April/063179.html |
||||
if((CORRADE_TARGET_APPLE AND ${OPENGLES3_LIBRARY} MATCHES "\\.framework$") OR CORRADE_TARGET_EMSCRIPTEN) |
||||
add_library(OpenGLES3::OpenGLES3 INTERFACE IMPORTED) |
||||
set_property(TARGET OpenGLES3::OpenGLES3 APPEND PROPERTY |
||||
INTERFACE_LINK_LIBRARIES ${OPENGLES3_LIBRARY}) |
||||
else() |
||||
add_library(OpenGLES3::OpenGLES3 UNKNOWN IMPORTED) |
||||
set_property(TARGET OpenGLES3::OpenGLES3 PROPERTY |
||||
IMPORTED_LOCATION ${OPENGLES3_LIBRARY}) |
||||
endif() |
||||
|
||||
# Emscripten needs a special flag to use WebGL 2. CMake 3.13 allows to set |
||||
# this via INTERFACE_LINK_OPTIONS, for older versions we modify the global |
||||
# CMAKE_EXE_LINKER_FLAGS inside FindMagnum.cmake. |
||||
if(CORRADE_TARGET_EMSCRIPTEN AND NOT CMAKE_VERSION VERSION_LESS 3.13) |
||||
# I could probably use target_link_options() here, but let's be |
||||
# consistent with the rest |
||||
set_property(TARGET OpenGLES3::OpenGLES3 APPEND PROPERTY |
||||
INTERFACE_LINK_OPTIONS "SHELL:-s USE_WEBGL2=1") |
||||
endif() |
||||
endif() |
||||
|
||||
mark_as_advanced(OPENGLES3_LIBRARY) |
||||
@ -0,0 +1,173 @@
|
||||
#.rst: |
||||
# Find SDL2 |
||||
# --------- |
||||
# |
||||
# Finds the SDL2 library. This module defines: |
||||
# |
||||
# SDL2_FOUND - True if SDL2 library is found |
||||
# SDL2::SDL2 - SDL2 imported target |
||||
# |
||||
# Additionally these variables are defined for internal usage: |
||||
# |
||||
# SDL2_LIBRARY_DEBUG - SDL2 debug library, if found |
||||
# SDL2_LIBRARY_RELEASE - SDL2 release library, if found |
||||
# SDL2_INCLUDE_DIR - Root include dir |
||||
# |
||||
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# Copyright © 2018 Jonathan Hale <squareys@googlemail.com> |
||||
# |
||||
# 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: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
# In Emscripten SDL is linked automatically, thus no need to find the library. |
||||
# Also the includes are in SDL subdirectory, not SDL2. |
||||
if(CORRADE_TARGET_EMSCRIPTEN) |
||||
set(_SDL2_PATH_SUFFIXES SDL) |
||||
else() |
||||
set(_SDL2_PATH_SUFFIXES SDL2) |
||||
if(WIN32) |
||||
# Precompiled libraries for MSVC are in x86/x64 subdirectories |
||||
if(MSVC) |
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
||||
set(_SDL2_LIBRARY_PATH_SUFFIX lib/x64) |
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) |
||||
set(_SDL2_LIBRARY_PATH_SUFFIX lib/x86) |
||||
endif() |
||||
|
||||
# Both includes and libraries for MinGW are in some directory deep |
||||
# inside. There's also a CMake config file but it has HARDCODED path |
||||
# to /opt/local/i686-w64-mingw32, which doesn't make ANY SENSE, |
||||
# especially on Windows. |
||||
elseif(MINGW) |
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
||||
set(_SDL2_LIBRARY_PATH_SUFFIX x86_64-w64-mingw32/lib) |
||||
list(APPEND _SDL2_PATH_SUFFIXES x86_64-w64-mingw32/include/SDL2) |
||||
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) |
||||
set(_SDL2_LIBRARY_PATH_SUFFIX i686-w64-mingw32/lib) |
||||
list(APPEND _SDL2_PATH_SUFFIXES i686-w64-mingw32/include/SDL2) |
||||
endif() |
||||
endif() |
||||
endif() |
||||
|
||||
find_library(SDL2_LIBRARY_RELEASE |
||||
# Compiling SDL2 from scratch on macOS creates dead libSDL2.so symlink |
||||
# which CMake somehow prefers before the SDL2-2.0.dylib file. Making |
||||
# the dylib first so it is preferred. Not sure how this maps to debug |
||||
# config though :/ |
||||
NAMES SDL2-2.0 SDL2 |
||||
PATH_SUFFIXES ${_SDL2_LIBRARY_PATH_SUFFIX}) |
||||
find_library(SDL2_LIBRARY_DEBUG |
||||
NAMES SDL2d |
||||
PATH_SUFFIXES ${_SDL2_LIBRARY_PATH_SUFFIX}) |
||||
# FPHSA needs one of the _DEBUG/_RELEASE variables to check that the |
||||
# library was found -- using SDL_LIBRARY, which will get populated by |
||||
# select_library_configurations() below. |
||||
set(SDL2_LIBRARY_NEEDED SDL2_LIBRARY) |
||||
endif() |
||||
|
||||
include(SelectLibraryConfigurations) |
||||
select_library_configurations(SDL2) |
||||
|
||||
# Include dir |
||||
find_path(SDL2_INCLUDE_DIR |
||||
# We must search file which is present only in SDL2 and not in SDL1. |
||||
# Apparently when both SDL.h and SDL_scancode.h are specified, CMake is |
||||
# happy enough that it found SDL.h and doesn't bother about the other. |
||||
# |
||||
# On macOS, where the includes are not in SDL2/SDL.h form (which would |
||||
# solve this issue), but rather SDL2.framework/Headers/SDL.h, CMake might |
||||
# find SDL.framework/Headers/SDL.h if SDL1 is installed, which is wrong. |
||||
NAMES SDL_scancode.h |
||||
PATH_SUFFIXES ${_SDL2_PATH_SUFFIXES}) |
||||
|
||||
# iOS dependencies |
||||
if(CORRADE_TARGET_IOS) |
||||
set(_SDL2_FRAMEWORKS |
||||
AudioToolbox |
||||
AVFoundation |
||||
CoreGraphics |
||||
CoreMotion |
||||
Foundation |
||||
GameController |
||||
QuartzCore |
||||
UIKit) |
||||
set(_SDL2_FRAMEWORK_LIBRARIES ) |
||||
foreach(framework ${_SDL2_FRAMEWORKS}) |
||||
find_library(_SDL2_${framework}_LIBRARY ${framework}) |
||||
mark_as_advanced(_SDL2_${framework}_LIBRARY) |
||||
list(APPEND _SDL2_FRAMEWORK_LIBRARIES ${_SDL2_${framework}_LIBRARY}) |
||||
list(APPEND _SDL2_FRAMEWORK_LIBRARY_NAMES _SDL2_${framework}_LIBRARY) |
||||
endforeach() |
||||
endif() |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args("SDL2" DEFAULT_MSG |
||||
${SDL2_LIBRARY_NEEDED} |
||||
${_SDL2_FRAMEWORK_LIBRARY_NAMES} |
||||
SDL2_INCLUDE_DIR) |
||||
|
||||
if(NOT TARGET SDL2::SDL2) |
||||
if(SDL2_LIBRARY_NEEDED) |
||||
add_library(SDL2::SDL2 UNKNOWN IMPORTED) |
||||
|
||||
# Work around BUGGY framework support on macOS |
||||
# https://cmake.org/Bug/view.php?id=14105 |
||||
if(CORRADE_TARGET_APPLE AND SDL2_LIBRARY_RELEASE MATCHES "\\.framework$") |
||||
set_property(TARGET SDL2::SDL2 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) |
||||
set_property(TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_RELEASE ${SDL2_LIBRARY_RELEASE}/SDL2) |
||||
else() |
||||
if(SDL2_LIBRARY_RELEASE) |
||||
set_property(TARGET SDL2::SDL2 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) |
||||
set_property(TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_RELEASE ${SDL2_LIBRARY_RELEASE}) |
||||
endif() |
||||
|
||||
if(SDL2_LIBRARY_DEBUG) |
||||
set_property(TARGET SDL2::SDL2 APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) |
||||
set_property(TARGET SDL2::SDL2 PROPERTY IMPORTED_LOCATION_DEBUG ${SDL2_LIBRARY_DEBUG}) |
||||
endif() |
||||
endif() |
||||
|
||||
# Link additional `dl` and `pthread` libraries required by a static |
||||
# build of SDL on Unixy platforms (except Apple, where it is most |
||||
# probably some frameworks instead) |
||||
if(CORRADE_TARGET_UNIX AND NOT CORRADE_TARGET_APPLE AND SDL2_LIBRARY MATCHES "${CMAKE_STATIC_LIBRARY_SUFFIX}$") |
||||
find_package(Threads) |
||||
set_property(TARGET SDL2::SDL2 APPEND PROPERTY |
||||
INTERFACE_LINK_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) |
||||
endif() |
||||
|
||||
# Link frameworks on iOS |
||||
if(CORRADE_TARGET_IOS) |
||||
set_property(TARGET SDL2::SDL2 APPEND PROPERTY |
||||
INTERFACE_LINK_LIBRARIES ${_SDL2_FRAMEWORK_LIBRARIES}) |
||||
endif() |
||||
else() |
||||
add_library(SDL2::SDL2 INTERFACE IMPORTED) |
||||
endif() |
||||
|
||||
set_property(TARGET SDL2::SDL2 PROPERTY |
||||
INTERFACE_INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}) |
||||
endif() |
||||
|
||||
mark_as_advanced(SDL2_INCLUDE_DIR) |
||||
@ -1,3 +1,3 @@
|
||||
pkg/ |
||||
src/ |
||||
*pkg.tar.zst |
||||
*pkg.tar.xz |
||||
|
||||
@ -1,41 +0,0 @@
|
||||
# Author: mosra <mosra@centrum.cz> |
||||
pkgname=magnum-bindings-git |
||||
pkgver=2020.06.r116.g62a07c3 |
||||
pkgrel=1 |
||||
pkgdesc="Bindings for the Magnum C++11/C++14 graphics engine (Git version)" |
||||
arch=('i686' 'x86_64') |
||||
url="https://magnum.graphics" |
||||
license=('MIT') |
||||
depends=('magnum-git' 'python') |
||||
makedepends=('cmake' 'git' 'ninja' 'pybind11') |
||||
provides=('magnum-bindings') |
||||
conflicts=('magnum-bindings') |
||||
source=("git+https://github.com/mosra/magnum-bindings.git") |
||||
sha1sums=('SKIP') |
||||
|
||||
pkgver() { |
||||
cd "$srcdir/${pkgname%-git}" |
||||
git describe --long | sed -r 's/([^-]*-g)/r\1/;s/-/./g;s/v//g' |
||||
} |
||||
|
||||
build() { |
||||
mkdir -p "$srcdir/build" |
||||
cd "$srcdir/build" |
||||
|
||||
cmake "$srcdir/${pkgname%-git}" \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
-DCMAKE_INSTALL_PREFIX=/usr \ |
||||
-DMAGNUM_WITH_PYTHON=ON \ |
||||
-G Ninja |
||||
ninja |
||||
} |
||||
|
||||
package() { |
||||
# Helper headers |
||||
cd "$srcdir/build" |
||||
DESTDIR="$pkgdir/" ninja install |
||||
|
||||
# Native and python packages |
||||
cd "$srcdir/build/src/python" |
||||
python setup.py install --root="$pkgdir" --prefix=/usr |
||||
} |
||||
@ -1,499 +0,0 @@
|
||||
version: 2.1 |
||||
|
||||
orbs: |
||||
# Version 3.2.4 is the "new" uploader, but it's a 50 MB Node.js *binary* and |
||||
# doesn't work on ARM64 Linux (or ARM Macs, or FreeBSD for that matter) and |
||||
# nobody seems to care. Issues opened since Septembe 2021: |
||||
# https://github.com/codecov/uploader/issues/347 |
||||
# https://github.com/codecov/uploader/issues/523 |
||||
# https://github.com/codecov/uploader/issues/849 |
||||
# The old 1.1.1 still seems to work even though codecov got removed from pip |
||||
# on 2023-04-14. |
||||
codecov: codecov/codecov@1.1.1 |
||||
|
||||
executors: |
||||
ubuntu-18_04: |
||||
docker: |
||||
- image: ubuntu:bionic-20220427 |
||||
# As of November 7, 2025, M4 is the default, and the oldest version there is |
||||
# 14.3.1. |
||||
xcode-14_3: |
||||
macos: |
||||
xcode: 14.3.1 |
||||
arm64: |
||||
machine: |
||||
image: ubuntu-2004:2023.07.1 |
||||
resource_class: arm.medium |
||||
|
||||
commands: |
||||
install-base-linux: |
||||
parameters: |
||||
extra: |
||||
type: string |
||||
default: "" |
||||
sudo: |
||||
type: string |
||||
default: "" |
||||
steps: |
||||
- run: |
||||
name: Update apt and install base packages |
||||
# Git is needed always for cloning Corrade etc |
||||
command: | |
||||
<< parameters.sudo >> apt update |
||||
if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then export LCOV_PACKAGES="lcov curl"; fi |
||||
<< parameters.sudo >> apt install -y git ninja-build $LCOV_PACKAGES << parameters.extra >> |
||||
|
||||
install-base-macos: |
||||
parameters: |
||||
extra: |
||||
type: string |
||||
default: "" |
||||
steps: |
||||
- run: |
||||
name: Install base packages |
||||
# As usual, homebrew takes five minutes to update and then explodes in |
||||
# a spectacular way. How is this acceptable?! |
||||
command: | |
||||
if [[ "$CMAKE_CXX_FLAGS" == *"--coverage"* ]]; then export LCOV_PACKAGES="lcov"; fi |
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake ninja $LCOV_PACKAGES << parameters.extra >> |
||||
- run: |
||||
name: Uninstall the pyenv crap and install plain python instead |
||||
# Otherwise the numpy installed by homebrew is unreachable by actual |
||||
# user-side python. THIS ALL USED TO WORK BUT NOT ANYMORE. They |
||||
# subsequently added `brew pyenv-sync` in an attempt to fix this trash |
||||
# fire, but that damn thing doesn't work at all either. Fuck it, then. |
||||
# https://github.com/orgs/Homebrew/discussions/4664 |
||||
# https://github.com/Homebrew/brew/issues/17563 |
||||
command: | |
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew remove pyenv |
||||
HOMEBREW_NO_AUTO_UPDATE=1 brew install python |
||||
rm -r ~/.pyenv |
||||
|
||||
install-gcc-4_8: |
||||
steps: |
||||
- run: |
||||
name: Install GCC 4.8 |
||||
# For some reason, CMake needs a working C compiler, so provice CC as |
||||
# well for the case when default gcc isn't installed. |
||||
command: | |
||||
apt install -y g++-4.8 |
||||
echo 'export CC=gcc-4.8' >> $BASH_ENV |
||||
echo 'export CXX=g++-4.8' >> $BASH_ENV |
||||
|
||||
install-cmake: |
||||
parameters: |
||||
version: |
||||
type: string |
||||
sudo: |
||||
type: string |
||||
default: "" |
||||
steps: |
||||
- run: |
||||
name: Install CMake << parameters.version >> |
||||
command: | |
||||
version_short=<< parameters.version >> |
||||
version_short="${version_short%.*}" |
||||
<< parameters.sudo >> apt install -y wget |
||||
mkdir -p $HOME/cmake && cd $HOME/cmake |
||||
wget -nc --no-check-certificate https://cmake.org/files/v$version_short/cmake-<< parameters.version >>-Linux-x86_64.tar.gz |
||||
tar --strip-components=1 -xzf cmake-<< parameters.version >>-Linux-x86_64.tar.gz |
||||
echo 'export PATH=$HOME/cmake/bin:$PATH' >> $BASH_ENV |
||||
source $BASH_ENV |
||||
cmake --version | grep << parameters.version >> |
||||
ctest --version | grep << parameters.version >> |
||||
|
||||
install-python-3_6: |
||||
# Can't use the python3.6 docker image because there I can't install GCC |
||||
# 4.8. Loosely based on https://gist.github.com/monkut/c4c07059444fd06f3f8661e13ccac619 |
||||
# The deadsnakes PPA no longer supports 16.04, so this repo builds against |
||||
# 18.04. |
||||
steps: |
||||
- run: |
||||
name: Install Python 3.6 and numpy |
||||
# The software-properties-common need to be installed in order to have |
||||
# apt-add-repository. Sigh, adding a repository should be a core |
||||
# feature ffs! |
||||
# |
||||
# Also, "Press ENTER to continue." Are we still in the DOS days?! |
||||
# |
||||
# Setting up 3.6 as the default is OF COURSE one command more than |
||||
# would be acceptable, but am I surprised on this distro?! |
||||
command: | |
||||
apt install -y software-properties-common |
||||
echo -e "\n" | add-apt-repository ppa:deadsnakes/ppa |
||||
apt update |
||||
apt install -y python3.6 python3.6-dev python3-pip |
||||
|
||||
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 10 |
||||
|
||||
python3 --version | grep 3.6 |
||||
|
||||
python3 -m pip install pip --upgrade |
||||
python3 -m pip install wheel |
||||
|
||||
pip3 install numpy |
||||
|
||||
install-pybind11: |
||||
parameters: |
||||
version: |
||||
type: string |
||||
default: "2.3.0" |
||||
steps: |
||||
- run: |
||||
name: Install Pybind11 << parameters.version >> |
||||
command: | |
||||
cd $HOME |
||||
wget --no-clobber https://github.com/pybind/pybind11/archive/v<< parameters.version >>.tar.gz |
||||
tar -xzf v<< parameters.version >>.tar.gz |
||||
cd pybind11-<< parameters.version >> |
||||
mkdir -p build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/pybind11 \ |
||||
-DPYBIND11_PYTHON_VERSION=3.6 \ |
||||
-DPYBIND11_TEST=OFF \ |
||||
-G Ninja |
||||
ninja install |
||||
|
||||
install-swiftshader-gles: |
||||
parameters: |
||||
build: |
||||
type: string |
||||
steps: |
||||
- run: |
||||
name: Install SwiftShader GLES |
||||
# Zip from https://github.com/mosra/magnum-ci/tree/swiftshader and |
||||
# self-hosted because GH Actions would make it too simple for people if |
||||
# you could just download the artifacts directly, right? RIGHT? |
||||
command: | |
||||
mkdir -p $HOME/swiftshader && cd $HOME/swiftshader |
||||
wget https://ci.magnum.graphics/swiftshader-gles-r5904.14dcbed947-<< parameters.build >>.zip |
||||
unzip swiftshader-gles-r5904.14dcbed947-<< parameters.build >>.zip |
||||
|
||||
install-meshoptimizer: |
||||
steps: |
||||
- run: |
||||
name: Install meshoptimizer |
||||
# few commits after 0.14 with a fix for old Apple Clang |
||||
command: | |
||||
export MESHOPTIMIZER_VERSION=97c52415c6d29f297a76482ddde22f739292446d |
||||
mkdir -p $HOME/meshoptimizer && cd $HOME/meshoptimizer |
||||
wget -nc --no-check-certificate https://github.com/zeux/meshoptimizer/archive/$MESHOPTIMIZER_VERSION.tar.gz |
||||
tar --strip-components=1 -xzf $MESHOPTIMIZER_VERSION.tar.gz |
||||
mkdir build && cd build |
||||
cmake .. -DCMAKE_BUILD_TYPE=Debug \ |
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-G Ninja |
||||
ninja install |
||||
|
||||
build: |
||||
parameters: |
||||
script: |
||||
type: string |
||||
steps: |
||||
- run: |
||||
name: Install coverage |
||||
command: pip3 install coverage |
||||
- checkout |
||||
- run: |
||||
name: Build & test |
||||
command: | |
||||
if [ "$BUILD_STATIC" != "ON" ]; then export BUILD_STATIC=OFF; fi |
||||
if [ "$BUILD_DEPRECATED" != "OFF" ]; then export BUILD_DEPRECATED=ON; fi |
||||
./package/ci/<< parameters.script >> |
||||
|
||||
# Official docs say "token not needed for public repos", in reality not using |
||||
# the token is "extremely flakey". What's best is that if the upload fails, |
||||
# the damn thing exits with a success error code, and nobody cares: |
||||
# https://github.com/codecov/codecov-circleci-orb/issues/139 |
||||
upload-codecov: |
||||
parameters: |
||||
file: |
||||
type: string |
||||
steps: |
||||
# Second best thing is that the codecov/upload helper takes a `token` |
||||
# parameter. But the token parameter is an ENVIRONMENT VARIABLE NAME!! So |
||||
# one just *can't* pass the token there. It got changed arbitrarily in |
||||
# https://github.com/codecov/codecov-circleci-orb/pull/93 "because |
||||
# CircleCI docs suggested so", yet all codecov docs suggest just |
||||
# commiting that token directly to the YML files because "it's fine". So |
||||
# if it's fine, why do I have to suffer like this?! |
||||
- run: |
||||
name: Set codecov upload token because everything is a dumpster fire |
||||
# An icing on the cake is that CircleCI commands don't allow setting |
||||
# `environment` for `commands`, only for `jobs`, so I have to do that |
||||
# via bash, and because the environment isn't passsed from a run to |
||||
# run, use the BASH_ENV hack. Mmm. Technology. |
||||
command: | |
||||
echo 'export CODECOV_TOKEN=ade9e2f1-d6d7-45cb-a292-c5bb1ad45be9' >> "$BASH_ENV" |
||||
- codecov/upload: |
||||
file: << parameters.file >> |
||||
|
||||
lcov: |
||||
parameters: |
||||
extra: |
||||
type: string |
||||
default: "" |
||||
steps: |
||||
- run: |
||||
name: Collect code coverage |
||||
# Keep in sync with PKBUILD-coverage, please |
||||
command: | |
||||
lcov << parameters.extra >> --directory . --capture --output-file coverage.info > /dev/null |
||||
lcov << parameters.extra >> --extract coverage.info "*/src/python/*" "*/src/Corrade/*" "*/src/Magnum/*" --output-file coverage.info > /dev/null |
||||
cd src/python && coverage combine |
||||
- upload-codecov: |
||||
file: coverage.info |
||||
|
||||
jobs: |
||||
linux-gl: |
||||
executor: ubuntu-18_04 |
||||
environment: |
||||
CMAKE_CXX_FLAGS: --coverage |
||||
PLATFORM_GL_API: GLX |
||||
# It crashes (OOM, probably) with the default setting |
||||
NINJA_JOBS: -j2 |
||||
steps: |
||||
# libidn11 needed by CMake |
||||
- install-base-linux: |
||||
extra: libidn11 libgl1-mesa-dev libsdl2-dev libglfw3-dev |
||||
- install-gcc-4_8 |
||||
- install-cmake: |
||||
version: "3.5.2" |
||||
- install-python-3_6 |
||||
- install-pybind11 |
||||
- install-meshoptimizer |
||||
- build: |
||||
script: unix-desktop.sh |
||||
- lcov: |
||||
extra: --gcov-tool /usr/bin/gcov-4.8 |
||||
|
||||
linux-arm64: |
||||
executor: arm64 |
||||
environment: |
||||
CMAKE_CXX_FLAGS: --coverage |
||||
PLATFORM_GL_API: GLX |
||||
steps: |
||||
# Not installing the old GCC 4.8 and CMake 3.5 to speed up. These are |
||||
# tested more than enough on other jobs. Machine executors need sudo. |
||||
- install-base-linux: |
||||
extra: gcc cmake libgl1-mesa-dev libsdl2-dev libglfw3-dev libpython3-dev |
||||
sudo: sudo |
||||
# 2.3.0 doesn't work with Python 3.11, this one should |
||||
- install-pybind11: |
||||
version: "2.11.1" |
||||
- run: |
||||
name: Install numpy |
||||
command: pip3 install numpy |
||||
- install-meshoptimizer |
||||
- build: |
||||
script: unix-desktop.sh |
||||
- lcov |
||||
|
||||
linux-gles2: |
||||
executor: ubuntu-18_04 |
||||
environment: |
||||
CMAKE_CXX_FLAGS: --coverage |
||||
PLATFORM_GL_API: EGL |
||||
# STUPID yml interprets unquoted ON as a boolean |
||||
TARGET_GLES2: "ON" |
||||
# It crashes (OOM, probably) with the default setting |
||||
NINJA_JOBS: -j2 |
||||
steps: |
||||
# libidn11 needed by CMake |
||||
- install-base-linux: |
||||
extra: libidn11 libsdl2-dev libglfw3-dev wget unzip |
||||
- install-gcc-4_8 |
||||
- install-cmake: |
||||
version: "3.5.2" |
||||
- install-python-3_6 |
||||
- install-pybind11 |
||||
- install-meshoptimizer |
||||
- install-swiftshader-gles: |
||||
build: ubuntu-18.04 |
||||
- build: |
||||
script: unix-desktop-gles.sh |
||||
- lcov: |
||||
extra: --gcov-tool /usr/bin/gcov-4.8 |
||||
|
||||
linux-gles3: |
||||
executor: ubuntu-18_04 |
||||
environment: |
||||
CMAKE_CXX_FLAGS: --coverage |
||||
PLATFORM_GL_API: EGL |
||||
# STUPID yml interprets unquoted OFF as a boolean |
||||
TARGET_GLES2: "OFF" |
||||
# It crashes (OOM, probably) with the default setting |
||||
NINJA_JOBS: -j2 |
||||
steps: |
||||
# libidn11 needed by CMake |
||||
- install-base-linux: |
||||
extra: libidn11 libsdl2-dev libglfw3-dev wget unzip |
||||
- install-gcc-4_8 |
||||
- install-cmake: |
||||
version: "3.5.2" |
||||
- install-python-3_6 |
||||
- install-pybind11 |
||||
- install-meshoptimizer |
||||
- install-swiftshader-gles: |
||||
build: ubuntu-18.04 |
||||
- build: |
||||
script: unix-desktop-gles.sh |
||||
- lcov: |
||||
extra: --gcov-tool /usr/bin/gcov-4.8 |
||||
|
||||
linux-static: |
||||
executor: ubuntu-18_04 |
||||
environment: |
||||
# STUPID yml interprets unquoted ON as a boolean |
||||
# https://stackoverflow.com/questions/53648244/specifying-the-string-value-yes-in-a-yaml-property |
||||
BUILD_STATIC: "ON" |
||||
CMAKE_CXX_FLAGS: --coverage |
||||
PLATFORM_GL_API: GLX |
||||
# It crashes (OOM, probably) with the default setting |
||||
NINJA_JOBS: -j2 |
||||
steps: |
||||
# libidn11 needed by CMake |
||||
- install-base-linux: |
||||
extra: libidn11 libsdl2-dev libglfw3-dev |
||||
- install-gcc-4_8 |
||||
- install-cmake: |
||||
version: "3.5.2" |
||||
- install-python-3_6 |
||||
- install-pybind11 |
||||
- install-meshoptimizer |
||||
- build: |
||||
script: unix-desktop.sh |
||||
- lcov: |
||||
extra: --gcov-tool /usr/bin/gcov-4.8 |
||||
|
||||
linux-nondeprecated: |
||||
executor: ubuntu-18_04 |
||||
environment: |
||||
# STUPID yml interprets unquoted OFF as a boolean |
||||
BUILD_DEPRECATED: "OFF" |
||||
CMAKE_CXX_FLAGS: --coverage |
||||
PLATFORM_GL_API: GLX |
||||
# It crashes (OOM, probably) with the default setting |
||||
NINJA_JOBS: -j2 |
||||
steps: |
||||
# libidn11 needed by CMake |
||||
- install-base-linux: |
||||
extra: libidn11 libgl1-mesa-dev libsdl2-dev libglfw3-dev |
||||
- install-gcc-4_8 |
||||
- install-cmake: |
||||
version: "3.5.2" |
||||
- install-python-3_6 |
||||
- install-pybind11 |
||||
- install-meshoptimizer |
||||
- build: |
||||
script: unix-desktop.sh |
||||
- lcov: |
||||
extra: --gcov-tool /usr/bin/gcov-4.8 |
||||
|
||||
macos-gl: |
||||
executor: xcode-14_3 |
||||
environment: |
||||
# Make libc++ remove transitive includes, both for faster build times and |
||||
# to detect if we're missing a transitive include. Works with libc++ 16+, |
||||
# which is used by Xcode 15 (i.e., will get used on the next CircleCI |
||||
# executor update). |
||||
CMAKE_CXX_FLAGS: --coverage -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES |
||||
PLATFORM_GL_API: CGL |
||||
steps: |
||||
- install-base-macos: |
||||
extra: sdl2 glfw wget numpy pybind11 |
||||
- install-meshoptimizer |
||||
- build: |
||||
script: unix-desktop.sh |
||||
# The 14.3 image seems to have the new lcov, which is very picky and throws |
||||
# errors about a ton of little things, 14.0.1 and older didn't |
||||
- lcov: |
||||
extra: --ignore-errors inconsistent |
||||
|
||||
macos-gles3: |
||||
executor: xcode-14_3 |
||||
environment: |
||||
# Make libc++ remove transitive includes, both for faster build times and |
||||
# to detect if we're missing a transitive include. Works with libc++ 16+, |
||||
# which is used by Xcode 15 (i.e., will get used on the next CircleCI |
||||
# executor update). |
||||
CMAKE_CXX_FLAGS: --coverage -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES |
||||
PLATFORM_GL_API: EGL |
||||
# STUPID yml interprets unquoted OFF as a boolean |
||||
TARGET_GLES2: "OFF" |
||||
steps: |
||||
- install-base-macos: |
||||
extra: sdl2 glfw wget numpy pybind11 |
||||
- install-swiftshader-gles: |
||||
build: macos12-arm64 |
||||
- install-meshoptimizer |
||||
- build: |
||||
script: unix-desktop-gles.sh |
||||
# The 14.3 image seems to have the new lcov, which is very picky and throws |
||||
# errors about a ton of little things, 14.0.1 and older didn't |
||||
- lcov: |
||||
extra: --ignore-errors inconsistent |
||||
|
||||
macos-static: |
||||
executor: xcode-14_3 |
||||
environment: |
||||
# STUPID yml interprets unquoted ON as a boolean |
||||
BUILD_STATIC: "ON" |
||||
# Make libc++ remove transitive includes, both for faster build times and |
||||
# to detect if we're missing a transitive include. Works with libc++ 16+, |
||||
# which is used by Xcode 15 (i.e., will get used on the next CircleCI |
||||
# executor update). |
||||
CMAKE_CXX_FLAGS: --coverage -D_LIBCPP_REMOVE_TRANSITIVE_INCLUDES |
||||
PLATFORM_GL_API: CGL |
||||
steps: |
||||
- install-base-macos: |
||||
extra: sdl2 glfw wget numpy pybind11 |
||||
- install-meshoptimizer |
||||
- build: |
||||
script: unix-desktop.sh |
||||
# The 14.3 image seems to have the new lcov, which is very picky and throws |
||||
# errors about a ton of little things, 14.0.1 and older didn't |
||||
- lcov: |
||||
extra: --ignore-errors inconsistent |
||||
|
||||
workflows: |
||||
version: 2 |
||||
build: |
||||
# While there's no actual execution or data dependency between the jobs, |
||||
# this is done in order to reduce unnecessary credit usage. The GL and |
||||
# non-deprecated Linux builds are taken as the main sanity checks. Only if |
||||
# they pass, the rest of the jobs gets gradually executed, with further |
||||
# dependencies especially for the macOS jobs that take the most credits. |
||||
jobs: |
||||
- linux-gl |
||||
- linux-nondeprecated |
||||
- linux-arm64: |
||||
requires: |
||||
- linux-gl |
||||
- linux-nondeprecated |
||||
- linux-gles2: |
||||
requires: |
||||
- linux-gl |
||||
- linux-nondeprecated |
||||
- linux-gles3: |
||||
requires: |
||||
- linux-gl |
||||
- linux-nondeprecated |
||||
- linux-static: |
||||
requires: |
||||
- linux-gl |
||||
- linux-nondeprecated |
||||
- macos-gl: |
||||
requires: |
||||
- linux-arm64 |
||||
- linux-gl |
||||
- linux-nondeprecated |
||||
- macos-gles3: |
||||
requires: |
||||
- linux-gles3 |
||||
- macos-gl |
||||
- macos-static: |
||||
requires: |
||||
- linux-static |
||||
- macos-gl |
||||
@ -1,9 +1,9 @@
|
||||
fixes: |
||||
# The src/python/magnum/__init__.py is copied to cmake's build dir together |
||||
# with setup.py next to the C++ binaries and the test is done from here. |
||||
# with # setup.py next to the C++ binaries and the test is done from here. |
||||
# Python's coverage.py reports an absolute path to it, which means a simple |
||||
# "build/src/python/::src/python/" won't suffice. This is hardcoded to CircleCI |
||||
# "build/src/python/::src/python/" won't suffice. This is hardcoded to Travis |
||||
# Linux / macOS and AppVeyor build paths so let's hope these won't change. |
||||
- "/root/project/build/src/python/::src/python/" |
||||
- "/Users/distiller/project/build/src/python/::src/python/" |
||||
- "/home/travis/build/mosra/magnum-bindings/build/src/python/::src/python/" |
||||
- "/Users/travis/build/mosra/magnum-bindings/build/src/python/::src/python/" |
||||
- "C:/projects/magnum-bindings/build/src/python/::src/python/" |
||||
|
||||
@ -0,0 +1,13 @@
|
||||
set -e |
||||
|
||||
wget --no-clobber https://github.com/pybind/pybind11/archive/v2.3.0.tar.gz && tar -xzf v2.3.0.tar.gz |
||||
|
||||
cd pybind11-2.3.0 |
||||
|
||||
mkdir -p build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/pybind11 \ |
||||
-DPYBIND11_PYTHON_VERSION=3.6 \ |
||||
-DPYBIND11_TEST=OFF \ |
||||
-G Ninja |
||||
ninja install |
||||
@ -0,0 +1,80 @@
|
||||
#!/bin/bash |
||||
set -ev |
||||
|
||||
# Corrade |
||||
git clone --depth 1 git://github.com/mosra/corrade.git |
||||
cd corrade |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_INSTALL_RPATH=$HOME/deps/lib \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
-DBUILD_DEPRECATED=$BUILD_DEPRECATED \ |
||||
-DWITH_INTERCONNECT=OFF \ |
||||
-DWITH_PLUGINMANAGER=ON \ |
||||
-DWITH_TESTSUITE=OFF \ |
||||
-G Ninja |
||||
ninja install |
||||
cd ../.. |
||||
|
||||
# Magnum |
||||
git clone --depth 1 git://github.com/mosra/magnum.git |
||||
cd magnum |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_INSTALL_RPATH=$HOME/deps/lib \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
-DEGL_LIBRARY=$HOME/swiftshader/libEGL.so \ |
||||
-DOPENGLES2_LIBRARY=$HOME/swiftshader/libGLESv2.so \ |
||||
-DOPENGLES3_LIBRARY=$HOME/swiftshader/libGLESv2.so \ |
||||
-DCMAKE_INSTALL_RPATH=$HOME/swiftshader \ |
||||
-DTARGET_GLES=ON \ |
||||
-DTARGET_GLES2=$TARGET_GLES2 \ |
||||
-DWITH_AUDIO=OFF \ |
||||
-DWITH_DEBUGTOOLS=OFF \ |
||||
-DWITH_GL=ON \ |
||||
-DWITH_MESHTOOLS=ON \ |
||||
-DWITH_PRIMITIVES=ON \ |
||||
-DWITH_SCENEGRAPH=ON \ |
||||
-DWITH_SHADERS=ON \ |
||||
-DWITH_TEXT=OFF \ |
||||
-DWITH_TEXTURETOOLS=OFF \ |
||||
-DWITH_TRADE=ON \ |
||||
-DWITH_VK=OFF \ |
||||
-DWITH_WINDOWLESSEGLAPPLICATION=ON \ |
||||
-DBUILD_DEPRECATED=OFF \ |
||||
-G Ninja |
||||
ninja install |
||||
cd ../.. |
||||
|
||||
# Build the thing |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_CXX_FLAGS="--coverage" \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_BUILD_TYPE=Debug \ |
||||
-DCMAKE_PREFIX_PATH=$HOME/pybind11 \ |
||||
-DEGL_LIBRARY=$HOME/swiftshader/libEGL.so \ |
||||
-DOPENGLES2_LIBRARY=$HOME/swiftshader/libGLESv2.so \ |
||||
-DOPENGLES3_LIBRARY=$HOME/swiftshader/libGLESv2.so \ |
||||
-DCMAKE_INSTALL_RPATH=$HOME/swiftshader \ |
||||
-DPYBIND11_PYTHON_VERSION=3.6 \ |
||||
-DWITH_PYTHON=ON \ |
||||
-G Ninja |
||||
ninja |
||||
|
||||
# Verify the setuptools install |
||||
cd src/python |
||||
python3 setup.py install --root="$TRAVIS_BUILD_DIR/install" --prefix=/usr |
||||
|
||||
# Run tests & gather coverage |
||||
cd ../../../src/python/corrade |
||||
coverage run -m unittest -v && cp .coverage ../.coverage.corrade |
||||
|
||||
cd ../magnum |
||||
coverage run -m unittest -v && cp .coverage ../.coverage.magnum |
||||
|
||||
# Test docstring validity |
||||
cd ../../../doc/python |
||||
PYTHONPATH="$TRAVIS_BUILD_DIR/build/src/python" python3 -m doctest -v *.rst |
||||
@ -0,0 +1,74 @@
|
||||
#!/bin/bash |
||||
set -ev |
||||
|
||||
# Corrade |
||||
git clone --depth 1 git://github.com/mosra/corrade.git |
||||
cd corrade |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_INSTALL_RPATH=$HOME/deps/lib \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
-DBUILD_DEPRECATED=OFF \ |
||||
-DBUILD_STATIC=$BUILD_STATIC \ |
||||
-DWITH_INTERCONNECT=OFF \ |
||||
-DWITH_PLUGINMANAGER=ON \ |
||||
-DWITH_TESTSUITE=OFF \ |
||||
-G Ninja |
||||
ninja install |
||||
cd ../.. |
||||
|
||||
# Magnum |
||||
git clone --depth 1 git://github.com/mosra/magnum.git |
||||
cd magnum |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_INSTALL_RPATH=$HOME/deps/lib \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
-DBUILD_DEPRECATED=OFF \ |
||||
-DBUILD_STATIC=$BUILD_STATIC \ |
||||
-DWITH_AUDIO=OFF \ |
||||
-DWITH_DEBUGTOOLS=OFF \ |
||||
-DWITH_GL=ON \ |
||||
-DWITH_MESHTOOLS=ON \ |
||||
-DWITH_PRIMITIVES=ON \ |
||||
-DWITH_SCENEGRAPH=ON \ |
||||
-DWITH_SHADERS=ON \ |
||||
-DWITH_TEXT=OFF \ |
||||
-DWITH_TEXTURETOOLS=OFF \ |
||||
-DWITH_TRADE=ON \ |
||||
-DWITH_VK=OFF \ |
||||
-DWITH_GLFWAPPLICATION=ON \ |
||||
-DWITH_SDL2APPLICATION=ON \ |
||||
-DWITH_WINDOWLESS${PLATFORM_GL_API}APPLICATION=ON \ |
||||
-G Ninja |
||||
ninja install |
||||
cd ../.. |
||||
|
||||
# Build the thing |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_CXX_FLAGS="--coverage" \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_BUILD_TYPE=Debug \ |
||||
-DCMAKE_PREFIX_PATH=$HOME/pybind11 \ |
||||
-DPYBIND11_PYTHON_VERSION=3.6 \ |
||||
-DWITH_PYTHON=ON \ |
||||
-G Ninja |
||||
ninja |
||||
|
||||
# Verify the setuptools install |
||||
cd src/python |
||||
python3 setup.py install --root="$TRAVIS_BUILD_DIR/install" --prefix=/usr |
||||
|
||||
# Run tests & gather coverage |
||||
cd ../../../src/python/corrade |
||||
coverage run -m unittest -v && cp .coverage ../.coverage.corrade |
||||
|
||||
cd ../magnum |
||||
MAGNUM_SKIP_GL_TESTS=ON coverage run -m unittest -v && cp .coverage ../.coverage.magnum |
||||
|
||||
# Test docstring validity |
||||
cd ../../../doc/python |
||||
PYTHONPATH="$TRAVIS_BUILD_DIR/build/src/python" python3 -m doctest -v *.rst |
||||
@ -0,0 +1,146 @@
|
||||
addons: |
||||
apt: |
||||
packages: |
||||
- g++-4.8 |
||||
- libgl1-mesa-dev |
||||
- ninja-build |
||||
- lcov |
||||
- libsdl2-dev |
||||
- libglfw3-dev |
||||
|
||||
matrix: |
||||
include: |
||||
- language: python |
||||
python: 3.6 |
||||
os: linux |
||||
dist: xenial |
||||
compiler: gcc |
||||
env: |
||||
- JOBID=linux-gl |
||||
- TARGET=desktop |
||||
- LCOV_EXTRA_OPTS="--gcov-tool /usr/bin/gcov-4.8" |
||||
- language: python |
||||
python: 3.6 |
||||
os: linux |
||||
dist: xenial |
||||
compiler: gcc |
||||
env: |
||||
- JOBID=linux-gles2 |
||||
- TARGET=desktop-gles |
||||
- TARGET_GLES2=ON |
||||
- CMAKE_CXX_FLAGS="--coverage" |
||||
- LCOV_EXTRA_OPTS="--gcov-tool /usr/bin/gcov-4.8" |
||||
addons: |
||||
apt: |
||||
packages: |
||||
- g++-4.8 |
||||
- ninja-build |
||||
- lcov |
||||
- libsdl2-dev |
||||
- libglfw3-dev |
||||
- language: python |
||||
python: 3.6 |
||||
os: linux |
||||
dist: xenial |
||||
compiler: gcc |
||||
env: |
||||
- JOBID=linux-gles3 |
||||
- TARGET=desktop-gles |
||||
- TARGET_GLES2=OFF |
||||
- CMAKE_CXX_FLAGS="--coverage" |
||||
- LCOV_EXTRA_OPTS="--gcov-tool /usr/bin/gcov-4.8" |
||||
addons: |
||||
apt: |
||||
packages: |
||||
- g++-4.8 |
||||
- ninja-build |
||||
- lcov |
||||
- libsdl2-dev |
||||
- libglfw3-dev |
||||
- language: python |
||||
python: 3.6 |
||||
os: linux |
||||
dist: xenial |
||||
compiler: gcc |
||||
env: |
||||
- JOBID=linux-static |
||||
- TARGET=desktop |
||||
- BUILD_STATIC=ON |
||||
- LCOV_EXTRA_OPTS="--gcov-tool /usr/bin/gcov-4.8" |
||||
- language: cpp |
||||
os: osx |
||||
compiler: clang |
||||
env: |
||||
- JOBID=macos-gl |
||||
- TARGET=desktop |
||||
- language: cpp |
||||
os: osx |
||||
compiler: clang |
||||
env: |
||||
- JOBID=macos-static |
||||
- TARGET=desktop |
||||
- BUILD_STATIC=ON |
||||
|
||||
notifications: |
||||
webhooks: |
||||
urls: |
||||
- https://webhooks.gitter.im/e/00ec7a9066bb0fec98f3 |
||||
on_success: change |
||||
on_failure: always |
||||
on_start: never |
||||
|
||||
cache: |
||||
directories: |
||||
- $HOME/swiftshader |
||||
- $HOME/cmake |
||||
- $HOME/pybind11 |
||||
|
||||
install: |
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export CXX=g++-4.8; fi |
||||
- if [ "$BUILD_STATIC" != "ON" ]; then export BUILD_STATIC=OFF; fi |
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ] && ( [ "$TARGET" == "desktop" ] || [ "$TARGET" == "desktop-sanitizers" ] ); then export PLATFORM_GL_API=GLX; fi |
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ] && [ "$TARGET" == "desktop-gles" ]; then export PLATFORM_GL_API=EGL; fi |
||||
# Download CMake 3.1.3 to ensure we're still compatible with it (Travis has |
||||
# 3.9 since December 2017). Also, the PATH setting can't be cached, so it's |
||||
# separate (bit me two times already). Android needs CMake 3.7, but |
||||
# https://gitlab.kitware.com/cmake/cmake/issues/17253 is fixed in 3.9.2, so |
||||
# grab that. FindVulkan is since 3.7, in that case just use the system package. |
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ] && [ ! -e "$HOME/cmake/bin" ]; then cd $HOME ; wget -nc --no-check-certificate https://cmake.org/files/v3.1/cmake-3.1.3-Linux-x86_64.tar.gz && mkdir -p cmake && cd cmake && tar --strip-components=1 -xzf ../cmake-3.1.3-Linux-x86_64.tar.gz && cd $TRAVIS_BUILD_DIR ; fi |
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export PATH=$HOME/cmake/bin:$PATH && cmake --version; fi |
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install ninja; fi |
||||
|
||||
# Code coverage of python bindings |
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ] || [ "$TRAVIS_OS_NAME" == "osx" ]; then pip3 install coverage codecov; fi |
||||
|
||||
# pybind11 (cached). On macOS the version 2.3.0 needs a brew update, the stale |
||||
# Travis image has just 2.2.4. |
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ] && [ ! -e "$HOME/pybind11/bin" ]; then $TRAVIS_BUILD_DIR/package/ci/setup-pybind11.sh; fi |
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew install pybind11; fi |
||||
|
||||
# SDL and GLFW on macOS |
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ] && [ "$TARGET" == "desktop" ]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install sdl2 glfw; fi |
||||
|
||||
# numpy on macOS -- probably because we updated Homebrew to install new pybind |
||||
# (and thus python as well, apparently), the preinstalled numpy is no longer |
||||
# visible. |
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then brew upgrade numpy; fi |
||||
|
||||
# SwiftShader on Linux (cached). Taken from Chromium snapshot 587878 |
||||
# (swiftshader-bin Arch package). |
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ] && [ "$TARGET" == "desktop-gles" ] && [ ! -e "$HOME/swiftshader/libEGL.so" ]; then cd $HOME ; wget https://ci.magnum.graphics/swiftshader-chromium-587878.tar.gz && mkdir -p swiftshader && cd swiftshader && tar -xzf ../swiftshader-chromium-587878.tar.gz && cd $TRAVIS_BUILD_DIR ; fi |
||||
|
||||
# lcov on macOS |
||||
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install lcov; fi |
||||
|
||||
script: |
||||
- if [ "$TARGET" == "desktop" ] && ( [ "$TRAVIS_OS_NAME" == "linux" ] || [ "$TRAVIS_OS_NAME" == "osx" ] ); then ./package/ci/travis-desktop.sh; fi |
||||
- if [ "$TARGET" == "desktop-gles" ] && ( [ "$TRAVIS_OS_NAME" == "linux" ] || [ "$TRAVIS_OS_NAME" == "osx" ] ); then ./package/ci/travis-desktop-gles.sh; fi |
||||
# Travis somehow is not able to gather all output, try to force it using this |
||||
- sync |
||||
|
||||
after_success: |
||||
# Keep in sync with package/archlinux/PKGBUILD-coverage, please |
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ] || [ "$TRAVIS_OS_NAME" == "osx" ]; then lcov $LCOV_EXTRA_OPTS --directory . --capture --output-file coverage.info > /dev/null; fi |
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ] || [ "$TRAVIS_OS_NAME" == "osx" ]; then lcov $LCOV_EXTRA_OPTS --extract coverage.info "*/src/python/*" "*/src/Corrade/*" "*/src/Magnum/*" --output-file coverage.info; fi |
||||
|
||||
- if [ "$TRAVIS_OS_NAME" == "linux" ] || [ "$TRAVIS_OS_NAME" == "osx" ]; then cd src/python && coverage combine && codecov -X gcov; fi |
||||
@ -1,117 +0,0 @@
|
||||
#!/bin/bash |
||||
set -ev |
||||
|
||||
# Corrade |
||||
git clone --depth 1 https://github.com/mosra/corrade.git |
||||
cd corrade |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_INSTALL_RPATH=$HOME/deps/lib \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
-DCORRADE_WITH_INTERCONNECT=OFF \ |
||||
-DCORRADE_WITH_PLUGINMANAGER=ON \ |
||||
-DCORRADE_WITH_TESTSUITE=ON \ |
||||
-G Ninja |
||||
ninja install |
||||
cd ../.. |
||||
|
||||
# Magnum |
||||
git clone --depth 1 https://github.com/mosra/magnum.git |
||||
cd magnum |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
-DCMAKE_PREFIX_PATH="$HOME/swiftshader;$HOME/pybind11" \ |
||||
-DCMAKE_INSTALL_RPATH="$HOME/deps/lib;$HOME/swiftshader/lib" \ |
||||
-DMAGNUM_TARGET_GLES=ON \ |
||||
-DMAGNUM_TARGET_GLES2=$TARGET_GLES2 \ |
||||
-DMAGNUM_WITH_AUDIO=OFF \ |
||||
-DMAGNUM_WITH_DEBUGTOOLS=OFF \ |
||||
-DMAGNUM_WITH_GL=ON \ |
||||
-DMAGNUM_WITH_MATERIALTOOLS=ON \ |
||||
-DMAGNUM_WITH_MESHTOOLS=ON \ |
||||
-DMAGNUM_WITH_PRIMITIVES=ON \ |
||||
-DMAGNUM_WITH_SCENEGRAPH=ON \ |
||||
-DMAGNUM_WITH_SCENETOOLS=ON \ |
||||
-DMAGNUM_WITH_SHADERS=ON \ |
||||
-DMAGNUM_WITH_SHADERTOOLS=OFF \ |
||||
-DMAGNUM_WITH_TEXT=ON \ |
||||
-DMAGNUM_WITH_TEXTURETOOLS=OFF \ |
||||
-DMAGNUM_WITH_TRADE=ON \ |
||||
-DMAGNUM_WITH_VK=OFF \ |
||||
-DMAGNUM_WITH_WINDOWLESSEGLAPPLICATION=ON \ |
||||
-DMAGNUM_WITH_ANYIMAGEIMPORTER=ON \ |
||||
-DMAGNUM_WITH_ANYSCENECONVERTER=ON \ |
||||
-DMAGNUM_WITH_ANYSCENEIMPORTER=ON \ |
||||
-DMAGNUM_WITH_TGAIMPORTER=ON \ |
||||
-G Ninja |
||||
ninja install |
||||
cd ../.. |
||||
|
||||
# Magnum Plugins |
||||
git clone --depth 1 https://github.com/mosra/magnum-plugins.git |
||||
cd magnum-plugins |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
`# StanfordSceneConverter uses MeshTools which rely on GL which looks` \ |
||||
`# for OpenGLES. And the RPATH entry needs to be there as well,` \ |
||||
`# otherwise it won't load.` \ |
||||
-DCMAKE_PREFIX_PATH=$HOME/swiftshader \ |
||||
-DCMAKE_INSTALL_RPATH="$HOME/deps/lib;$HOME/swiftshader/lib" \ |
||||
-DMAGNUM_BUILD_STATIC=$BUILD_STATIC \ |
||||
-DMAGNUM_WITH_BCDECIMAGECONVERTER=ON \ |
||||
-DMAGNUM_WITH_DDSIMPORTER=ON \ |
||||
-DMAGNUM_WITH_ETCDECIMAGECONVERTER=ON \ |
||||
-DMAGNUM_WITH_GLTFIMPORTER=ON \ |
||||
-DMAGNUM_WITH_GLTFSCENECONVERTER=ON \ |
||||
-DMAGNUM_WITH_KTXIMAGECONVERTER=ON \ |
||||
-DMAGNUM_WITH_MESHOPTIMIZERSCENECONVERTER=ON \ |
||||
-DMAGNUM_WITH_PRIMITIVEIMPORTER=ON \ |
||||
-DMAGNUM_WITH_STANFORDSCENECONVERTER=ON \ |
||||
-DMAGNUM_WITH_STBIMAGECONVERTER=ON \ |
||||
-DMAGNUM_WITH_STBIMAGEIMPORTER=ON \ |
||||
-DMAGNUM_WITH_STBRESIZEIMAGECONVERTER=ON \ |
||||
-DMAGNUM_WITH_STBTRUETYPEFONT=ON \ |
||||
-G Ninja |
||||
ninja install |
||||
cd ../.. |
||||
|
||||
# Build the thing |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_CXX_FLAGS="--coverage" \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_BUILD_TYPE=Debug \ |
||||
-DCMAKE_PREFIX_PATH="$HOME/swiftshader;$HOME/pybind11" \ |
||||
-DCMAKE_INSTALL_RPATH="$HOME/deps/lib;$HOME/swiftshader/lib" \ |
||||
-DPYBIND11_PYTHON_VERSION=3.6 \ |
||||
-DMAGNUM_WITH_PYTHON=ON \ |
||||
-DMAGNUM_BUILD_TESTS=ON \ |
||||
-G Ninja |
||||
ninja $NINJA_JOBS |
||||
|
||||
CORRADE_TEST_COLOR=ON ctest -V |
||||
|
||||
# Verify the setuptools install. Not using $CIRCLE_WORKING_DIRECTORY because |
||||
# it's ~ and that's not correctly expanded always. |
||||
cd src/python |
||||
python3 setup.py install --root="$(pwd)/../../install" --prefix=/usr |
||||
|
||||
# Run tests & gather coverage |
||||
cd ../../../src/python/corrade |
||||
coverage run -m unittest -v |
||||
cp .coverage ../.coverage.corrade |
||||
|
||||
cd ../magnum |
||||
coverage run -m unittest -v |
||||
cp .coverage ../.coverage.magnum |
||||
|
||||
# Test docstring validity |
||||
cd ../../../doc/python |
||||
# I would use $CIRCLE_WORKING_DIRECTORY, but that's ~ and that's not expanded |
||||
# here for some reason |
||||
PYTHONPATH="$(pwd)/../../build/src/python" python3 -m doctest -v *.rst |
||||
@ -1,122 +0,0 @@
|
||||
#!/bin/bash |
||||
set -ev |
||||
|
||||
# Corrade |
||||
git clone --depth 1 https://github.com/mosra/corrade.git |
||||
cd corrade |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_INSTALL_RPATH=$HOME/deps/lib \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
-DMAGNUM_BUILD_DEPRECATED=$BUILD_DEPRECATED \ |
||||
-DCORRADE_BUILD_STATIC=$BUILD_STATIC \ |
||||
-DCORRADE_WITH_INTERCONNECT=OFF \ |
||||
-DCORRADE_WITH_PLUGINMANAGER=ON \ |
||||
-DCORRADE_WITH_TESTSUITE=ON \ |
||||
-G Ninja |
||||
ninja install |
||||
cd ../.. |
||||
|
||||
# Magnum |
||||
git clone --depth 1 https://github.com/mosra/magnum.git |
||||
cd magnum |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_INSTALL_RPATH=$HOME/deps/lib \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
-DMAGNUM_BUILD_DEPRECATED=$BUILD_DEPRECATED \ |
||||
-DMAGNUM_BUILD_STATIC=$BUILD_STATIC \ |
||||
-DMAGNUM_WITH_AUDIO=OFF \ |
||||
-DMAGNUM_WITH_DEBUGTOOLS=OFF \ |
||||
-DMAGNUM_WITH_GL=ON \ |
||||
-DMAGNUM_WITH_MATERIALTOOLS=ON \ |
||||
-DMAGNUM_WITH_MESHTOOLS=ON \ |
||||
-DMAGNUM_WITH_PRIMITIVES=ON \ |
||||
-DMAGNUM_WITH_SCENEGRAPH=ON \ |
||||
-DMAGNUM_WITH_SCENETOOLS=ON \ |
||||
-DMAGNUM_WITH_SHADERS=ON \ |
||||
-DMAGNUM_WITH_SHADERTOOLS=OFF \ |
||||
-DMAGNUM_WITH_TEXT=ON \ |
||||
-DMAGNUM_WITH_TEXTURETOOLS=OFF \ |
||||
-DMAGNUM_WITH_TRADE=ON \ |
||||
-DMAGNUM_WITH_VK=OFF \ |
||||
-DMAGNUM_WITH_GLFWAPPLICATION=ON \ |
||||
-DMAGNUM_WITH_SDL2APPLICATION=ON \ |
||||
-DMAGNUM_WITH_WINDOWLESS${PLATFORM_GL_API}APPLICATION=ON \ |
||||
-DMAGNUM_WITH_ANYIMAGEIMPORTER=ON \ |
||||
-DMAGNUM_WITH_ANYSCENECONVERTER=ON \ |
||||
-DMAGNUM_WITH_ANYSCENEIMPORTER=ON \ |
||||
-DMAGNUM_WITH_TGAIMPORTER=ON \ |
||||
-G Ninja |
||||
|
||||
# In case of a static build there's no way for the test to know the plugin |
||||
# install directory so we have to hardcode it |
||||
if [ "$BUILD_STATIC" == "ON" ]; then |
||||
cmake . -DMAGNUM_PLUGINS_DIR=$HOME/deps/lib/magnum |
||||
fi |
||||
|
||||
ninja install |
||||
cd ../.. |
||||
|
||||
# Magnum Plugins |
||||
git clone --depth 1 https://github.com/mosra/magnum-plugins.git |
||||
cd magnum-plugins |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_INSTALL_RPATH=$HOME/deps/lib \ |
||||
-DCMAKE_BUILD_TYPE=Release \ |
||||
-DMAGNUM_BUILD_STATIC=$BUILD_STATIC \ |
||||
-DMAGNUM_WITH_BCDECIMAGECONVERTER=ON \ |
||||
-DMAGNUM_WITH_DDSIMPORTER=ON \ |
||||
-DMAGNUM_WITH_ETCDECIMAGECONVERTER=ON \ |
||||
-DMAGNUM_WITH_GLTFIMPORTER=ON \ |
||||
-DMAGNUM_WITH_GLTFSCENECONVERTER=ON \ |
||||
-DMAGNUM_WITH_KTXIMAGECONVERTER=ON \ |
||||
-DMAGNUM_WITH_MESHOPTIMIZERSCENECONVERTER=ON \ |
||||
-DMAGNUM_WITH_PRIMITIVEIMPORTER=ON \ |
||||
-DMAGNUM_WITH_STANFORDSCENECONVERTER=ON \ |
||||
-DMAGNUM_WITH_STBIMAGECONVERTER=ON \ |
||||
-DMAGNUM_WITH_STBIMAGEIMPORTER=ON \ |
||||
-DMAGNUM_WITH_STBRESIZEIMAGECONVERTER=ON \ |
||||
-DMAGNUM_WITH_STBTRUETYPEFONT=ON \ |
||||
-G Ninja |
||||
ninja install |
||||
cd ../.. |
||||
|
||||
# Build the thing |
||||
mkdir build && cd build |
||||
cmake .. \ |
||||
-DCMAKE_CXX_FLAGS="--coverage" \ |
||||
-DCMAKE_INSTALL_PREFIX=$HOME/deps \ |
||||
-DCMAKE_BUILD_TYPE=Debug \ |
||||
-DCMAKE_PREFIX_PATH=$HOME/pybind11 \ |
||||
-DPYBIND11_PYTHON_VERSION=3.6 \ |
||||
-DMAGNUM_WITH_PYTHON=ON \ |
||||
-DMAGNUM_BUILD_TESTS=ON \ |
||||
-G Ninja |
||||
ninja $NINJA_JOBS |
||||
|
||||
CORRADE_TEST_COLOR=ON ctest -V |
||||
|
||||
# Verify the setuptools install. Not using $CIRCLE_WORKING_DIRECTORY because |
||||
# it's ~ and that's not correctly expanded always. |
||||
cd src/python |
||||
python3 setup.py install --root="$(pwd)/../../install" --prefix=/usr |
||||
|
||||
# Run tests & gather coverage |
||||
cd ../../../src/python/corrade |
||||
coverage run -m unittest -v |
||||
cp .coverage ../.coverage.corrade |
||||
|
||||
cd ../magnum |
||||
MAGNUM_SKIP_GL_TESTS=ON coverage run -m unittest -v |
||||
cp .coverage ../.coverage.magnum |
||||
|
||||
# Test docstring validity |
||||
cd ../../../doc/python |
||||
# I would use $CIRCLE_WORKING_DIRECTORY, but that's ~ and that's not expanded |
||||
# here for some reason |
||||
PYTHONPATH="$(pwd)/../../build/src/python" python3 -m doctest -v *.rst |
||||
@ -1,12 +0,0 @@
|
||||
This dir is used by `src/*/CMakeLists.txt` to run `git describe --match "v*"`. |
||||
Because, if it would be run in that directory, on Windows the `--match "v*"` |
||||
would get expanded to the `version.h.cmake` file there, causing Git to |
||||
obviously not find any such tag. The reason is probably that on Windows the |
||||
wildcard expansion is done on the application side and not by the shell, thus |
||||
being performed even though CMake docs say `execute_process()` doesn't involve |
||||
a shell. This directory is thus dedicated for that operation, *guaranteed* to |
||||
never contain any file starting with `v` (or `V` for that matter because, |
||||
again, HELLO WINDOWS). |
||||
|
||||
No matter what you do, DON'T put any files starting with `v` or `V` here, or |
||||
hell breaks loose again. |
||||
@ -1,7 +0,0 @@
|
||||
#!/bin/bash |
||||
|
||||
set -e |
||||
|
||||
dir=$(dirname "$0") |
||||
cp $dir/../../corrade/modules/FindCorrade.cmake $dir/../modules/ |
||||
cp $dir/../../magnum/modules/FindMagnum.cmake $dir/../modules/ |
||||
@ -1,63 +0,0 @@
|
||||
#ifndef Corrade_Containers_OptionalPythonBindings_h |
||||
#define Corrade_Containers_OptionalPythonBindings_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#include <pybind11/pybind11.h> |
||||
#include <Corrade/Containers/Optional.h> |
||||
|
||||
namespace pybind11 { namespace detail { |
||||
|
||||
/* pybind11/stl.h has optional_caster for this, but that relies on a value_type
|
||||
typedef that Optional doesn't have, so adapting a copy of it, also without |
||||
std::is_lvalue_reference<T>::value, which is not a thing here */ |
||||
template<class T> struct type_caster<Corrade::Containers::Optional<T>> { |
||||
using value_conv = make_caster<T>; |
||||
|
||||
template<class T_> static handle cast(T_&& src, const return_value_policy policy, const handle parent) { |
||||
if(!src) return none{}.release(); |
||||
return value_conv::cast(*std::forward<T_>(src), return_value_policy_override<T>::policy(policy), parent); |
||||
} |
||||
|
||||
bool load(const handle src, bool convert) { |
||||
if(!src) return false; |
||||
|
||||
/* default-constructed value is already empty */ |
||||
if(src.is_none()) return true; |
||||
|
||||
value_conv inner_caster; |
||||
if(!inner_caster.load(src, convert)) return false; |
||||
|
||||
value.emplace(cast_op<T&&>(std::move(inner_caster))); |
||||
return true; |
||||
} |
||||
|
||||
PYBIND11_TYPE_CASTER(Corrade::Containers::Optional<T>, _("Optional[") + value_conv::name + _("]")); |
||||
}; |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -1,203 +0,0 @@
|
||||
#ifndef Corrade_Containers_StridedArrayViewPythonBindings_h |
||||
#define Corrade_Containers_StridedArrayViewPythonBindings_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#include <pybind11/pybind11.h> |
||||
#include <Corrade/Containers/StridedArrayView.h> |
||||
#include <Corrade/Containers/String.h> |
||||
|
||||
namespace Corrade { namespace Containers { |
||||
|
||||
namespace Implementation { |
||||
|
||||
/* For maintainability please keep in the same order as
|
||||
https://docs.python.org/3/library/struct.html#format-characters. Each of
|
||||
these has also a corresponding entry in accessorsForFormat() in |
||||
containers.cpp in the same order. */ |
||||
template<class T> constexpr const char* pythonFormatString() { |
||||
static_assert(sizeof(T) == 0, "format string unknown for this type, supply it explicitly"); |
||||
return {}; |
||||
} |
||||
/* Treating bytes as unsigned 8-bit integers and not as chars for consistency
|
||||
with bytes/bytearray, where you have to use ord(a[0]) to get a character |
||||
value. Same done for PyStridedArrayViewItem and PyStridedArrayViewSetItem |
||||
below. To further emphasize that this is "general data", a null format |
||||
string is returned, which should be treated the same as B: |
||||
https://docs.python.org/3/c-api/buffer.html#c.Py_buffer.format */
|
||||
template<> constexpr const char* pythonFormatString<char>() { return nullptr; } |
||||
template<> constexpr const char* pythonFormatString<std::int8_t>() { return "b"; } |
||||
template<> constexpr const char* pythonFormatString<std::uint8_t>() { return "B"; } |
||||
template<> constexpr const char* pythonFormatString<std::int16_t>() { return "h"; } |
||||
template<> constexpr const char* pythonFormatString<std::uint16_t>() { return "H"; } |
||||
template<> constexpr const char* pythonFormatString<std::int32_t>() { return "i"; } |
||||
template<> constexpr const char* pythonFormatString<std::uint32_t>() { return "I"; } |
||||
/* *not* l / L, that's 4 bytes in Python */ |
||||
template<> constexpr const char* pythonFormatString<std::int64_t>() { return "q"; } |
||||
template<> constexpr const char* pythonFormatString<std::uint64_t>() { return "Q"; } |
||||
/** @todo how to represent std::size_t? conflicts with uint32_t/uint64_t above */ |
||||
template<> constexpr const char* pythonFormatString<float>() { return "f"; } |
||||
template<> constexpr const char* pythonFormatString<double>() { return "d"; } |
||||
|
||||
template<class U> struct PyStridedArrayViewItem { |
||||
static pybind11::object get(const char* item) { |
||||
return pybind11::cast(*reinterpret_cast<const U*>(item)); |
||||
} |
||||
}; |
||||
/* Treating bytes as unsigned 8-bit integers and not as chars for consistency
|
||||
with bytes/bytearray, where you have to use ord(a[0]) to get a character |
||||
value. Same done for pythonFormatString<char>() above and |
||||
PyStridedArrayViewSetItem below. */ |
||||
template<> struct PyStridedArrayViewItem<const char> { |
||||
static pybind11::object get(const char* item) { |
||||
return pybind11::cast(*reinterpret_cast<const std::uint8_t*>(item)); |
||||
} |
||||
}; |
||||
|
||||
template<class T, class U> struct PyStridedArrayViewSetItem; |
||||
template<class U> struct PyStridedArrayViewSetItem<const char, U> { |
||||
/* __setitem__ is not even exposed for immutable views so this is fine */ |
||||
constexpr static std::nullptr_t set = nullptr; |
||||
}; |
||||
template<class U> struct PyStridedArrayViewSetItem<char, U> { |
||||
static void set(char* item, pybind11::handle object) { |
||||
*reinterpret_cast<U*>(item) = pybind11::cast<U>(object); |
||||
} |
||||
}; |
||||
/* Treating bytes as unsigned 8-bit integers and not as chars for consistency
|
||||
with bytes/bytearray, where you have to use a[0] = ord('A') to set a |
||||
character value. Same done for pythonFormatString<char>() and |
||||
PyStridedArrayViewItem above. */ |
||||
template<> struct PyStridedArrayViewSetItem<char, char> { |
||||
static void set(char* item, pybind11::handle object) { |
||||
*reinterpret_cast<std::uint8_t*>(item) = pybind11::cast<std::uint8_t>(object); |
||||
} |
||||
}; |
||||
|
||||
template<unsigned, class> struct PyStridedElement; |
||||
|
||||
} |
||||
|
||||
template<unsigned dimensions, class T> class PyStridedArrayView: public StridedArrayView<dimensions, T> { |
||||
/* the type is dynamic; ArrayView has the same check */ |
||||
static_assert(std::is_same<const T, const char>::value, "only the (const) char StridedArrayView is meant to be exposed"); |
||||
|
||||
public: |
||||
/* Null function pointers should be okay as it shouldn't ever get to
|
||||
them -- IndexError gets fired first. The format string can be null |
||||
as well (which nicely implies "general data"), in which case B |
||||
should be assumed: |
||||
https://docs.python.org/3/c-api/buffer.html#c.Py_buffer.format */
|
||||
/*implicit*/ PyStridedArrayView(): format{}, getitem{}, setitem{} {} |
||||
|
||||
template<class U> explicit PyStridedArrayView(const StridedArrayView<dimensions, U>& view): PyStridedArrayView{view, Implementation::pythonFormatString<typename std::decay<U>::type>(), sizeof(U)} {} |
||||
|
||||
template<class U> explicit PyStridedArrayView(const StridedArrayView<dimensions, U>& view, Containers::StringView format, std::size_t itemsize): PyStridedArrayView<dimensions, T>{ |
||||
arrayCast<T>(view), |
||||
format, |
||||
itemsize, |
||||
Implementation::PyStridedArrayViewItem<const U>::get, |
||||
Implementation::PyStridedArrayViewSetItem<T, U>::set |
||||
} {} |
||||
|
||||
explicit PyStridedArrayView(const StridedArrayView<dimensions, T>& view, Containers::StringView format, std::size_t itemsize, pybind11::object(*getitem)(const char*), void(*setitem)(char*, pybind11::handle)): StridedArrayView<dimensions, T>{view}, format{format}, itemsize{itemsize}, getitem{getitem}, setitem{setitem} {} |
||||
|
||||
/* All APIs that are exposed by bindings and return a StridedArrayView
|
||||
have to return the wrapper now */ |
||||
|
||||
typedef typename std::conditional<dimensions == 1, T&, PyStridedArrayView<dimensions - 1, T>>::type ElementType; |
||||
|
||||
ElementType operator[](std::size_t i) const { |
||||
return Implementation::PyStridedElement<dimensions, T>::wrap(StridedArrayView<dimensions, T>::operator[](i), format, itemsize, getitem, setitem); |
||||
} |
||||
T& operator[](const Containers::Size<dimensions>& i) const { |
||||
return StridedArrayView<dimensions, T>::operator[](i); |
||||
} |
||||
|
||||
PyStridedArrayView<dimensions, T> slice(std::size_t begin, std::size_t end) const { |
||||
return PyStridedArrayView<dimensions, T>{StridedArrayView<dimensions, T>::slice(begin, end), format, itemsize, getitem, setitem}; |
||||
} |
||||
PyStridedArrayView<dimensions, T> slice(const Containers::Size<dimensions>& begin, const Containers::Size<dimensions>& end) const { |
||||
return PyStridedArrayView<dimensions, T>{StridedArrayView<dimensions, T>::slice(begin, end), format, itemsize, getitem, setitem}; |
||||
} |
||||
|
||||
/* slice() with templated dimensions not used */ |
||||
/* slice(&T::member) not used */ |
||||
/* prefix(), suffix(), except() not used */ |
||||
|
||||
PyStridedArrayView<dimensions, T> every(std::size_t skip) const { |
||||
return PyStridedArrayView<dimensions, T>{StridedArrayView<dimensions, T>::every(skip), format, itemsize, getitem, setitem}; |
||||
} |
||||
|
||||
PyStridedArrayView<dimensions, T> every(const Containers::Stride<dimensions>& skip) const { |
||||
return PyStridedArrayView<dimensions, T>{StridedArrayView<dimensions, T>::every(skip), format, itemsize, getitem, setitem}; |
||||
} |
||||
|
||||
template<unsigned dimensionA, unsigned dimensionB> PyStridedArrayView<dimensions, T> transposed() const { |
||||
return PyStridedArrayView<dimensions, T>{StridedArrayView<dimensions, T>::template transposed<dimensionA, dimensionB>(), format, itemsize, getitem, setitem}; |
||||
} |
||||
|
||||
template<unsigned dimension> PyStridedArrayView<dimensions, T> flipped() const { |
||||
return PyStridedArrayView<dimensions, T>{StridedArrayView<dimensions, T>::template flipped<dimension>(), format, itemsize, getitem, setitem}; |
||||
} |
||||
|
||||
template<unsigned dimension> PyStridedArrayView<dimensions, T> broadcasted(std::size_t size) const { |
||||
return PyStridedArrayView<dimensions, T>{StridedArrayView<dimensions, T>::template broadcasted<dimension>(size), format, itemsize, getitem, setitem}; |
||||
} |
||||
|
||||
template<unsigned dimension, unsigned count> PyStridedArrayView<dimensions + count - 1, T> expanded(const Containers::Size<count>& size) const { |
||||
return PyStridedArrayView<dimensions + count - 1, T>{StridedArrayView<dimensions, T>::template expanded<dimension>(size), format, itemsize, getitem, setitem}; |
||||
} |
||||
|
||||
/* has to be public as it's accessed by the bindings directly */ |
||||
/* The assumption is that >99% of format strings should be just a few
|
||||
characters, stored with a SSO. I.e., not even bothering with |
||||
String::nullTerminatedGlobalView() anywhere. */ |
||||
Containers::String format; |
||||
std::size_t itemsize; |
||||
pybind11::object(*getitem)(const char*); |
||||
void(*setitem)(char*, pybind11::handle); |
||||
}; |
||||
|
||||
namespace Implementation { |
||||
|
||||
template<unsigned dimensions, class T> struct PyStridedElement { |
||||
static PyStridedArrayView<dimensions - 1, T> wrap(const StridedArrayView<dimensions - 1, T>& element, Containers::StringView format, std::size_t itemsize, pybind11::object(*getitem)(const char*), void(*setitem)(char*, pybind11::handle)) { |
||||
return PyStridedArrayView<dimensions - 1, T>{element, format, itemsize, getitem, setitem}; |
||||
} |
||||
}; |
||||
|
||||
template<class T> struct PyStridedElement<1, T> { |
||||
static T& wrap(T& element, Containers::StringView, std::size_t, pybind11::object(*)(const char*), void(*)(char*, pybind11::handle)) { |
||||
return element; |
||||
} |
||||
}; |
||||
|
||||
} |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -1,72 +0,0 @@
|
||||
#ifndef Corrade_PluginManager_PythonBindings_h |
||||
#define Corrade_PluginManager_PythonBindings_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#include <memory> /* :( */ |
||||
#include <pybind11/pybind11.h> |
||||
#include <Corrade/Containers/Pointer.h> |
||||
#include <Corrade/Utility/Assert.h> |
||||
|
||||
namespace Corrade { namespace PluginManager { |
||||
|
||||
/* Stores additional stuff needed for proper refcounting of plugin instances.
|
||||
Due to obvious reasons we can't subclass plugins so this is the only |
||||
possible way. */ |
||||
template<class T> struct PyPluginHolder: std::unique_ptr<T> { |
||||
explicit PyPluginHolder(T* object) noexcept: std::unique_ptr<T>{object} { |
||||
/* Plugin instance without an owner can only be without a manager and
|
||||
thus without any metadata */ |
||||
CORRADE_INTERNAL_ASSERT(!object->metadata()); |
||||
} |
||||
|
||||
explicit PyPluginHolder(T* object, pybind11::object manager) noexcept: std::unique_ptr<T>{object}, manager{std::move(manager)} {} |
||||
|
||||
PyPluginHolder(PyPluginHolder<T>&&) noexcept = default; |
||||
PyPluginHolder(const PyPluginHolder<T>&) = delete; |
||||
PyPluginHolder<T>& operator=(PyPluginHolder<T>&&) noexcept = default; |
||||
PyPluginHolder<T>& operator=(const PyPluginHolder<T>&) = delete; |
||||
|
||||
~PyPluginHolder() { |
||||
/* On destruction, first `manager` and then the plugin would be
|
||||
destroyed, which would mean it asserts due to the manager being |
||||
destructed while plugins are still around. To flip the order, we |
||||
need to reset the pointer first */ |
||||
std::unique_ptr<T>::reset(); |
||||
} |
||||
|
||||
pybind11::object manager; |
||||
}; |
||||
|
||||
template<class T> PyPluginHolder<T> pyPluginHolder(Containers::Pointer<T>&& plugin, pybind11::object owner) { |
||||
return PyPluginHolder<T>{plugin.release(), std::move(owner)}; |
||||
} |
||||
|
||||
}} |
||||
|
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, Corrade::PluginManager::PyPluginHolder<T>) |
||||
|
||||
#endif |
||||
@ -1,119 +0,0 @@
|
||||
#ifndef Magnum_StridedArrayViewPythonBindings_h |
||||
#define Magnum_StridedArrayViewPythonBindings_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#include <Magnum/Magnum.h> |
||||
|
||||
#include "Corrade/Containers/StridedArrayViewPythonBindings.h" |
||||
|
||||
namespace Corrade { namespace Containers { namespace Implementation { |
||||
|
||||
/* This expands Containers::Implementation::pythonFormatString() with Magnum
|
||||
types. Using e.g. "3f" instead of "fff" as that makes Numpy understand even |
||||
the slices as arrays in a concrete type (or it at least repr()s them as |
||||
such), with "fff" it gives back an untyped tuple. */ |
||||
|
||||
#define _c(type, string) \ |
||||
template<> constexpr const char* pythonFormatString<Magnum::type>() { return string; } |
||||
_c(Half, "e") |
||||
_c(Vector2, "2f") |
||||
_c(Vector2h, "2e") |
||||
_c(Vector2d, "2d") |
||||
_c(Vector2ub, "2B") |
||||
_c(Vector2b, "2b") |
||||
_c(Vector2us, "2H") |
||||
_c(Vector2s, "2h") |
||||
_c(Vector2ui, "2I") |
||||
_c(Vector2i, "2i") |
||||
_c(Vector3, "3f") |
||||
_c(Vector3h, "3e") |
||||
_c(Vector3d, "3d") |
||||
_c(Vector3ub, "3B") |
||||
_c(Vector3b, "3b") |
||||
_c(Vector3us, "3H") |
||||
_c(Vector3s, "3h") |
||||
_c(Vector3ui, "3I") |
||||
_c(Vector3i, "3i") |
||||
_c(Vector4, "4f") |
||||
_c(Vector4h, "4e") |
||||
_c(Vector4d, "4d") |
||||
_c(Vector4ub, "4B") |
||||
_c(Vector4b, "4b") |
||||
_c(Vector4us, "4H") |
||||
_c(Vector4s, "4h") |
||||
_c(Vector4ui, "4I") |
||||
_c(Vector4i, "4i") |
||||
|
||||
_c(Matrix2x2, "4f") |
||||
_c(Matrix2x2d, "4d") |
||||
_c(Matrix2x3, "6f") |
||||
_c(Matrix2x3d, "6d") |
||||
_c(Matrix2x4, "8f") |
||||
_c(Matrix2x4d, "8d") |
||||
_c(Matrix3x2, "6f") |
||||
_c(Matrix3x2d, "6d") |
||||
_c(Matrix3x3, "9f") |
||||
_c(Matrix3x3d, "9d") |
||||
_c(Matrix3x4, "12f") |
||||
_c(Matrix3x4d, "12d") |
||||
_c(Matrix4x2, "8f") |
||||
_c(Matrix4x2d, "8d") |
||||
_c(Matrix4x3, "12f") |
||||
_c(Matrix4x3d, "12d") |
||||
_c(Matrix4x4, "16f") |
||||
_c(Matrix4x4d, "16d") |
||||
|
||||
_c(Range1D, "2f") |
||||
_c(Range1Dd, "2d") |
||||
_c(Range1Di, "2i") |
||||
_c(Range2D, "4f") |
||||
_c(Range2Dd, "4d") |
||||
_c(Range2Di, "4i") |
||||
_c(Range3D, "6f") |
||||
_c(Range3Dd, "6d") |
||||
_c(Range3Di, "6i") |
||||
|
||||
_c(Complex, "2f") |
||||
_c(Complexd, "2d") |
||||
_c(DualComplex, "4f") |
||||
_c(DualComplexd, "4f") |
||||
_c(Quaternion, "4f") |
||||
_c(Quaterniond, "4d") |
||||
_c(DualQuaternion, "8f") |
||||
_c(DualQuaterniond, "8d") |
||||
|
||||
_c(Deg, "f") |
||||
_c(Degd, "d") |
||||
_c(Rad, "f") |
||||
_c(Radd, "d") |
||||
#undef _c |
||||
|
||||
} |
||||
|
||||
}} |
||||
|
||||
#endif |
||||
@ -1,30 +0,0 @@
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
# 2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# 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: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
# Prefixed with project name to avoid conflicts with VersionTest in Magnum and |
||||
# related repos |
||||
corrade_add_test(MagnumBindingsVersionTest VersionTest.cpp LIBRARIES Magnum::Magnum) |
||||
target_include_directories(MagnumBindingsVersionTest PRIVATE ${PROJECT_BINARY_DIR}/src) |
||||
@ -1,67 +0,0 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#include <Corrade/TestSuite/Tester.h> |
||||
#include <Corrade/TestSuite/Compare/Numeric.h> |
||||
|
||||
#include "Magnum/Magnum.h" |
||||
#include "Magnum/versionBindings.h" |
||||
|
||||
namespace Magnum { namespace Test { namespace { |
||||
|
||||
struct VersionTest: TestSuite::Tester { |
||||
explicit VersionTest(); |
||||
|
||||
void test(); |
||||
}; |
||||
|
||||
VersionTest::VersionTest() { |
||||
addTests({&VersionTest::test}); |
||||
} |
||||
|
||||
void VersionTest::test() { |
||||
Debug{} << "MAGNUMBINDINGS_VERSION_YEAR:" << MAGNUMBINDINGS_VERSION_YEAR; |
||||
Debug{} << "MAGNUMBINDINGS_VERSION_MONTH:" << MAGNUMBINDINGS_VERSION_MONTH; |
||||
#ifdef MAGNUMBINDINGS_VERSION_COMMIT |
||||
Debug{} << "MAGNUMBINDINGS_VERSION_COMMIT:" << MAGNUMBINDINGS_VERSION_COMMIT; |
||||
Debug{} << "MAGNUMBINDINGS_VERSION_HASH:" << Debug::hex << MAGNUMBINDINGS_VERSION_HASH; |
||||
Debug{} << "MAGNUMBINDINGS_VERSION_STRING:" << MAGNUMBINDINGS_VERSION_STRING; |
||||
#else |
||||
Debug{} << "No Git version information available."; |
||||
#endif |
||||
|
||||
CORRADE_COMPARE_AS(MAGNUMBINDINGS_VERSION_YEAR, 2019, TestSuite::Compare::GreaterOrEqual); |
||||
CORRADE_COMPARE_AS(MAGNUMBINDINGS_VERSION_YEAR, 2100, TestSuite::Compare::LessOrEqual); |
||||
CORRADE_COMPARE_AS(MAGNUMBINDINGS_VERSION_MONTH, 0, TestSuite::Compare::Greater); |
||||
CORRADE_COMPARE_AS(MAGNUMBINDINGS_VERSION_MONTH, 12, TestSuite::Compare::LessOrEqual); |
||||
#ifdef MAGNUMBINDINGS_VERSION_COMMIT |
||||
CORRADE_COMPARE_AS(MAGNUMBINDINGS_VERSION_COMMIT, 0, TestSuite::Compare::GreaterOrEqual); |
||||
#endif |
||||
} |
||||
|
||||
}}} |
||||
|
||||
CORRADE_TEST_MAIN(Magnum::Test::VersionTest) |
||||
@ -1,30 +0,0 @@
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
# 2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# 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: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
if(MAGNUM_WITH_PYTHON) |
||||
add_custom_target(MagnumTradePython SOURCES PythonBindings.h) |
||||
install(FILES PythonBindings.h DESTINATION ${MAGNUM_INCLUDE_INSTALL_DIR}/Trade) |
||||
endif() |
||||
@ -1,103 +0,0 @@
|
||||
#ifndef Magnum_Trade_PythonBindings_h |
||||
#define Magnum_Trade_PythonBindings_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#include <memory> /* :( */ |
||||
#include <pybind11/pybind11.h> |
||||
|
||||
#include "Magnum/Trade/Data.h" |
||||
#include "Magnum/Trade/MaterialData.h" /* :( */ |
||||
#include "Magnum/Trade/MeshData.h" /* :( */ |
||||
#include "Magnum/Trade/SceneData.h" |
||||
|
||||
namespace Magnum { namespace Trade { |
||||
|
||||
namespace Implementation { |
||||
|
||||
/* For assertions only */ |
||||
template<class T> inline bool pyDataFlagsNeedOwner(const T& data) { |
||||
return !(data.dataFlags() & (DataFlag::Owned|DataFlag::Global)); |
||||
} |
||||
inline bool pyDataFlagsNeedOwner(const MaterialData& data) { |
||||
return |
||||
!(data.attributeDataFlags() & (DataFlag::Owned|DataFlag::Global)) || |
||||
!(data.layerDataFlags() & (DataFlag::Owned|DataFlag::Global)); |
||||
} |
||||
inline bool pyDataFlagsNeedOwner(const MeshData& data) { |
||||
return |
||||
!(data.indexDataFlags() & (DataFlag::Owned|DataFlag::Global)) || |
||||
!(data.vertexDataFlags() & (DataFlag::Owned|DataFlag::Global)); |
||||
} |
||||
inline bool pyDataFlagsNeedOwner(const MeshAttributeData& data) { |
||||
return data.data().data(); |
||||
} |
||||
|
||||
} |
||||
|
||||
/* Stores additional stuff needed for proper refcounting of non-owning FooData.
|
||||
Better than subclassing each FooData class because then we would need to |
||||
wrap it every time it's exposed to Python, making 3rd party bindings |
||||
unnecessarily complex */ |
||||
template<class T> struct PyDataHolder: std::unique_ptr<T> { |
||||
explicit PyDataHolder(T* object): PyDataHolder{object, pybind11::none{}} { |
||||
/* Data without an owner can only be self-owned, global or empty */ |
||||
CORRADE_INTERNAL_ASSERT(!Implementation::pyDataFlagsNeedOwner(*object)); |
||||
} |
||||
|
||||
explicit PyDataHolder(T* object, pybind11::object owner): std::unique_ptr<T>{object}, owner{std::move(owner)} {} |
||||
|
||||
pybind11::object owner; |
||||
}; |
||||
|
||||
template<class T> PyDataHolder<T> pyDataHolder(T&& data, pybind11::object owner) { |
||||
return PyDataHolder<T>{new T{std::move(data)}, std::move(owner)}; |
||||
} |
||||
|
||||
/* Compared to PyDataHolder this stores two owner objects. Has to be a template
|
||||
even though it's only ever used for a single type because |
||||
PYBIND11_DECLARE_HOLDER_TYPE() wants it to be so. */ |
||||
template<class T> struct PySceneFieldDataHolder: std::unique_ptr<SceneFieldData> { |
||||
explicit PySceneFieldDataHolder(SceneFieldData* object): PySceneFieldDataHolder{object, pybind11::none{}, pybind11::none{}} { |
||||
/* Data without owners can only be empty */ |
||||
CORRADE_INTERNAL_ASSERT(!object->mappingData().data() && !object->fieldData().data()); |
||||
} |
||||
|
||||
explicit PySceneFieldDataHolder(SceneFieldData* object, pybind11::object mappingOwner, pybind11::object fieldOwner): std::unique_ptr<T>{object}, mappingOwner{std::move(mappingOwner)}, fieldOwner{std::move(fieldOwner)} {} |
||||
|
||||
pybind11::object mappingOwner, fieldOwner; |
||||
}; |
||||
|
||||
inline PySceneFieldDataHolder<SceneFieldData> pySceneFieldDataHolder(SceneFieldData&& data, pybind11::object mappingOwner, pybind11::object fieldOwner) { |
||||
return PySceneFieldDataHolder<SceneFieldData>{new SceneFieldData{std::move(data)}, std::move(mappingOwner), std::move(fieldOwner)}; |
||||
} |
||||
|
||||
}} |
||||
|
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, Magnum::Trade::PyDataHolder<T>) |
||||
PYBIND11_DECLARE_HOLDER_TYPE(T, Magnum::Trade::PySceneFieldDataHolder<T>) |
||||
|
||||
#endif |
||||
@ -1,39 +0,0 @@
|
||||
#ifndef Magnum_versionBindings_h |
||||
#define Magnum_versionBindings_h |
||||
/* |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
/* Note: this header is deliberately not included from anywhere except |
||||
VersionTest to avoid triggering a full rebuild every time the Git commit |
||||
hash changes. */ |
||||
|
||||
#define MAGNUMBINDINGS_VERSION_YEAR ${MAGNUMBINDINGS_VERSION_YEAR} |
||||
#define MAGNUMBINDINGS_VERSION_MONTH ${MAGNUMBINDINGS_VERSION_MONTH} |
||||
#cmakedefine MAGNUMBINDINGS_VERSION_COMMIT${MAGNUMBINDINGS_VERSION_COMMIT} |
||||
#cmakedefine MAGNUMBINDINGS_VERSION_HASH 0x${MAGNUMBINDINGS_VERSION_HASH} |
||||
#cmakedefine MAGNUMBINDINGS_VERSION_STRING "${MAGNUMBINDINGS_VERSION_STRING}" |
||||
|
||||
#endif |
||||
@ -1,82 +0,0 @@
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
# 2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# 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: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
"""Root Corrade module""" |
||||
|
||||
# If MAGNUM_BUILD_PYTHON_BINDINGS_RTLD_GLOBAL is enabled in CMake, the lines |
||||
# below are included, otherwise they are commented out. What it does is a |
||||
# futile attempt to make Corrade (and Magnum) built as static libraries work |
||||
# together when built into multiple dynamic Python modules. |
||||
${_MAGNUM_BUILD_PYTHON_BINDINGS_RTLD_GLOBAL}import sys |
||||
${_MAGNUM_BUILD_PYTHON_BINDINGS_RTLD_GLOBAL}import ctypes |
||||
${_MAGNUM_BUILD_PYTHON_BINDINGS_RTLD_GLOBAL}sys.setdlopenflags(sys.getdlopenflags()|ctypes.RTLD_GLOBAL) |
||||
|
||||
# On Windows, if a known directory layout is detected, add paths containing |
||||
# binaries to the DLL search path |
||||
import platform |
||||
if platform.system() == 'Windows': |
||||
import os |
||||
# os.add_dll_directory() is only since Python 3.8, in earlier versions |
||||
# PATH is used and that alone may be sufficient |
||||
if hasattr(os, 'add_dll_directory'): |
||||
# The variable might be empty, or might contain empty parts, so skip |
||||
# all empty items. There's no splitWithoutEmptyParts() like in Corrade, |
||||
# sigh. Using """ to prevent accidental syntax errors if the path |
||||
# itself would contain quotes. |
||||
for directory in """${MAGNUM_PYTHON_BINDINGS_DLL_PATH}""".split(';'): |
||||
if not directory: |
||||
continue |
||||
|
||||
# If the directory is relative, interpret is as relative to parent |
||||
# dir. Also add it only if it exists. |
||||
bin_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), directory) |
||||
if os.path.exists(bin_path): |
||||
os.add_dll_directory(bin_path) |
||||
|
||||
from _corrade import * |
||||
|
||||
import sys |
||||
|
||||
# In case Corrade is built statically, the whole core project is put into |
||||
# _corrade. The following feels extremely hackish, but without that it wouldn't |
||||
# be possible to do `import corrade.containers`, which is weird |
||||
# (`from corrade import containers` works, tho, for whatever reason) |
||||
for i in ['containers', 'pluginmanager', 'utility']: |
||||
if i in globals(): sys.modules['corrade.' + i] = globals()[i] |
||||
|
||||
# Just to not have the variable leak into stubs generated by pybind11-stubgen |
||||
# TODO any way to exclude it? |
||||
del i |
||||
|
||||
# Prevent all submodules being pulled in when saying `from corrade import *` -- |
||||
# this is consistent with behavior in magnum |
||||
__all__ = [ |
||||
# TARGET_*, BUILD_* are omitted as `from corrade import *` would pull them |
||||
# to globals and this would likely cause conflicts (magnum also defines |
||||
# BUILD_*) |
||||
] |
||||
|
||||
# kate: hl python |
||||
File diff suppressed because it is too large
Load Diff
@ -1,190 +0,0 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#include "pluginmanager.h" |
||||
|
||||
#include <pybind11/pybind11.h> |
||||
#include <pybind11/stl.h> /* for pluginList() and aliasList() */ |
||||
#include <Corrade/Containers/StringStl.h> /** @todo drop once we have our string casters */ |
||||
#include <Corrade/Containers/StringIterable.h> |
||||
#include <Corrade/PluginManager/AbstractManager.h> |
||||
#include <Corrade/PluginManager/AbstractPlugin.h> |
||||
#include <Corrade/PluginManager/PluginMetadata.h> |
||||
#include <Corrade/Utility/ConfigurationGroup.h> |
||||
|
||||
#include "Corrade/PythonBindings.h" |
||||
|
||||
#include "corrade/bootstrap.h" |
||||
#include "corrade/EnumOperators.h" |
||||
|
||||
namespace corrade { |
||||
|
||||
void pluginmanager(py::module_& m) { |
||||
m.doc() = "Plugin management"; |
||||
|
||||
#ifndef CORRADE_BUILD_STATIC |
||||
/* Need ConfigurationGroup from there. These are a part of the same module
|
||||
in the static build, no need to import (also can't import because there |
||||
it's _corrade.*) */ |
||||
py::module_::import("corrade.utility"); |
||||
#endif |
||||
|
||||
py::enum_<PluginManager::LoadState> loadState{m, "LoadState", "Plugin load state"}; |
||||
loadState |
||||
.value("NOT_FOUND", PluginManager::LoadState::NotFound) |
||||
.value("WRONG_PLUGIN_VERSION", PluginManager::LoadState::WrongPluginVersion) |
||||
.value("WRONG_INTERFACE_VERSION", PluginManager::LoadState::WrongInterfaceVersion) |
||||
.value("WRONG_METADATA_FILE", PluginManager::LoadState::WrongMetadataFile) |
||||
.value("UNRESOLVED_DEPENDENCY", PluginManager::LoadState::UnresolvedDependency) |
||||
.value("STATIC", PluginManager::LoadState::Static) |
||||
.value("LOADED", PluginManager::LoadState::Loaded) |
||||
.value("NOT_LOADED", PluginManager::LoadState::NotLoaded) |
||||
.value("UNLOAD_FAILED", PluginManager::LoadState::UnloadFailed) |
||||
.value("REQUIRED", PluginManager::LoadState::Required) |
||||
.value("USED", PluginManager::LoadState::Used); |
||||
corrade::enumOperators(loadState); |
||||
|
||||
py::class_<PluginManager::PluginMetadata>{m, "PluginMetadata", "Plugin metadata"} |
||||
.def_property_readonly("name", [](PluginManager::PluginMetadata& self) { |
||||
/** @todo drop std::string in favor of our own string caster */ |
||||
return std::string{self.name()}; |
||||
}, "Plugin name") |
||||
.def_property_readonly("depends", [](PluginManager::PluginMetadata& self) { |
||||
/** @todo make a generic caster for arbitrary arrays and strings */ |
||||
std::vector<std::string> out; |
||||
for(Containers::StringView i: self.depends()) |
||||
out.push_back(i); |
||||
return out; |
||||
}, "Plugins on which this plugin depends") |
||||
.def_property_readonly("used_by", [](PluginManager::PluginMetadata& self) { |
||||
/** @todo make a generic caster for arbitrary arrays and strings */ |
||||
std::vector<std::string> out; |
||||
for(Containers::StringView i: self.usedBy()) |
||||
out.push_back(i); |
||||
return out; |
||||
}, "Plugins which depend on this plugin") |
||||
.def_property_readonly("provides", [](PluginManager::PluginMetadata& self) { |
||||
/** @todo make a generic caster for arbitrary arrays and strings */ |
||||
std::vector<std::string> out; |
||||
for(Containers::StringView i: self.provides()) |
||||
out.push_back(i); |
||||
return out; |
||||
}, "Plugins which are provided by this plugin") |
||||
/** @todo data? no plugin uses this at the moment */ |
||||
.def_property_readonly("configuration", static_cast<Utility::ConfigurationGroup&(PluginManager::PluginMetadata::*)()>(&PluginManager::PluginMetadata::configuration), "Initial plugin-specific configuration", py::return_value_policy::reference_internal); |
||||
|
||||
PyNonDestructibleClass<PluginManager::AbstractManager> manager{m, "AbstractManager", "Base for plugin managers"}; |
||||
manager.attr("VERSION") = PluginManager::AbstractManager::Version; |
||||
manager |
||||
.def_property_readonly("plugin_interface", [](PluginManager::AbstractManager& self) { |
||||
/** @todo drop std::string in favor of our own string caster */ |
||||
return std::string{self.pluginInterface()}; |
||||
}, "Plugin interface string") |
||||
.def_property("plugin_directory", |
||||
/** @todo drop std::string in favor of our own string caster */ |
||||
[](PluginManager::AbstractManager& self) { |
||||
return std::string{self.pluginDirectory()}; |
||||
}, [](PluginManager::AbstractManager& self, const std::string& directory) { |
||||
self.setPluginDirectory(directory); |
||||
}, "Plugin directory") |
||||
.def("reload_plugin_directory", &PluginManager::AbstractManager::reloadPluginDirectory, "Reload plugin directory") |
||||
.def("set_preferred_plugins", [](PluginManager::AbstractManager& self, const std::string& alias, const std::vector<std::string>& plugins) { |
||||
if(self.loadState(alias) == PluginManager::LoadState::NotFound) { |
||||
PyErr_SetNone(PyExc_KeyError); |
||||
throw py::error_already_set{}; |
||||
} |
||||
|
||||
/** @todo drop all this once StringIterable can be a view on
|
||||
std::strings */ |
||||
Containers::Array<Containers::StringView> pluginViews{NoInit, plugins.size()}; |
||||
for(std::size_t i = 0; i != plugins.size(); ++i) |
||||
pluginViews[i] = plugins[i]; |
||||
self.setPreferredPlugins(alias, pluginViews); |
||||
}, "Set preferred plugins for given alias", py::arg("alias"), py::arg("plugins")) |
||||
.def_property_readonly("plugin_list", [](PluginManager::AbstractManager& self) { |
||||
/** @todo make a generic caster for arbitrary arrays and strings */ |
||||
std::vector<std::string> out; |
||||
for(Containers::StringView i: self.pluginList()) |
||||
out.push_back(i); |
||||
return out; |
||||
}, "List of all available plugin names") |
||||
.def_property_readonly("alias_list", [](PluginManager::AbstractManager& self) { |
||||
/** @todo make a generic caster for arbitrary arrays and strings */ |
||||
std::vector<std::string> out; |
||||
for(Containers::StringView i: self.aliasList()) |
||||
out.push_back(i); |
||||
return out; |
||||
}, "List of all available alias names") |
||||
.def("metadata", [](PluginManager::AbstractManager& self, const std::string& plugin) { |
||||
return self.metadata(plugin); |
||||
}, "Plugin metadata", py::arg("plugin"), py::return_value_policy::reference_internal) |
||||
/** @todo drop std::string in favor of our own string caster */ |
||||
.def("load_state", [](PluginManager::AbstractManager& self, const std::string& plugin) { |
||||
return self.loadState(plugin); |
||||
}, "Load state of a plugin", py::arg("plugin")) |
||||
.def("load", [](PluginManager::AbstractManager& self, const std::string& plugin) { |
||||
/** @todo log redirection -- but we'd need assertions to not be
|
||||
part of that so when it dies, the user can still see why */ |
||||
const PluginManager::LoadState state = self.load(plugin); |
||||
if(!(state & PluginManager::LoadState::Loaded)) { |
||||
PyErr_Format(PyExc_RuntimeError, "can't load plugin %s", plugin.data()); |
||||
throw py::error_already_set{}; |
||||
} |
||||
|
||||
return state; |
||||
}, "Load a plugin", py::arg("plugin")) |
||||
.def("unload", [](PluginManager::AbstractManager& self, const std::string& plugin) { |
||||
/** @todo log redirection -- but we'd need assertions to not be
|
||||
part of that so when it dies, the user can still see why */ |
||||
const PluginManager::LoadState state = self.unload(plugin); |
||||
if(state != PluginManager::LoadState::NotLoaded && state != PluginManager::LoadState::Static) { |
||||
PyErr_Format(PyExc_RuntimeError, "can't unload plugin %s", plugin.data()); |
||||
throw py::error_already_set{}; |
||||
} |
||||
|
||||
return state; |
||||
}, "Unload a plugin", py::arg("plugin")) |
||||
.def("register_external_manager", &PluginManager::AbstractManager::registerExternalManager, "Register an external manager for resolving inter-manager dependencies", py::arg("manager"), py::keep_alive<1, 2>()); |
||||
|
||||
py::class_<PluginManager::AbstractPlugin, PluginManager::PyPluginHolder<PluginManager::AbstractPlugin>>{m, "AbstractPlugin", "Base class for plugin interfaces"} |
||||
/* Plugin interface string, search paths, suffix, metadata file suffix
|
||||
are meant to be overriden in subclasses */ |
||||
.def_property_readonly("plugin", [](PluginManager::AbstractPlugin& self) { |
||||
/** @todo drop std::string in favor of our own string caster */ |
||||
return std::string{self.plugin()}; |
||||
}, "Plugin identifier string") |
||||
.def_property_readonly("metadata", &PluginManager::AbstractPlugin::metadata, "Plugin metadata", py::return_value_policy::reference_internal) |
||||
.def_property_readonly("configuration", static_cast<Utility::ConfigurationGroup&(PluginManager::AbstractPlugin::*)()>(&PluginManager::AbstractPlugin::configuration), "Plugin-specific configuration", py::return_value_policy::reference_internal); |
||||
} |
||||
|
||||
} |
||||
|
||||
#ifndef CORRADE_BUILD_STATIC |
||||
extern "C" PYBIND11_EXPORT PyObject* PyInit_pluginmanager(); |
||||
PYBIND11_MODULE(pluginmanager, m) { |
||||
corrade::pluginmanager(m); |
||||
} |
||||
#endif |
||||
@ -1,102 +0,0 @@
|
||||
#ifndef corrade_pluginmanager_h |
||||
#define corrade_pluginmanager_h |
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#include <memory> /* :( */ |
||||
#include <pybind11/pybind11.h> |
||||
#include <pybind11/stl.h> /** @todo remove once I can return Array<String> directly */ |
||||
#include <Corrade/Containers/Array.h> |
||||
#include <Corrade/Containers/StringStl.h> /** @todo drop once we have our string casters */ |
||||
#include <Corrade/PluginManager/Manager.h> |
||||
|
||||
#include "Corrade/PythonBindings.h" |
||||
#include "Corrade/PluginManager/PythonBindings.h" |
||||
|
||||
#include "corrade/bootstrap.h" |
||||
|
||||
namespace corrade { |
||||
|
||||
template<class T> void plugin(py::class_<T, PluginManager::PyPluginHolder<T>, PluginManager::AbstractPlugin>& c) { |
||||
c |
||||
.def_property_readonly_static("plugin_interface", [](const py::object&) { |
||||
/** @todo drop std::string in favor of our own string caster */ |
||||
return std::string{T::pluginInterface()}; |
||||
}, "Plugin interface string") |
||||
.def_property_readonly_static("plugin_search_paths", [](const py::object&) { |
||||
/** @todo drop std::string in favor of our own string caster */ |
||||
std::vector<std::string> out; |
||||
for(auto&& i: T::pluginSearchPaths()) |
||||
out.push_back(i); |
||||
return out; |
||||
}, "Plugin search paths") |
||||
.def_property_readonly_static("plugin_suffix", [](const py::object&) { |
||||
/** @todo drop std::string in favor of our own string caster */ |
||||
return std::string{T::pluginSuffix()}; |
||||
}, "Plugin binary suffix") |
||||
.def_property_readonly_static("plugin_metadata_suffix", [](const py::object&) { |
||||
/** @todo drop std::string in favor of our own string caster */ |
||||
return std::string{T::pluginMetadataSuffix()}; |
||||
}, "Plugin metadata file suffix") |
||||
/** @todo plugin interface string, search paths, suffix, metadata file
|
||||
suffix (all are static properties) */ |
||||
.def_property_readonly("manager", [](const T& self) { |
||||
return pyObjectHolderFor<PluginManager::PyPluginHolder>(self).manager; |
||||
}, "Manager owning this plugin instance"); |
||||
} |
||||
|
||||
template<class T> void manager(py::class_<PluginManager::Manager<T>, PluginManager::AbstractManager>& c) { |
||||
c |
||||
.def(py::init<const std::string&>(), py::arg("plugin_directory") = std::string{}, "Constructor") |
||||
.def("instantiate", [](PluginManager::Manager<T>& self, const std::string& plugin) { |
||||
/* This causes a double lookup, but well... better than dying */ |
||||
if(!(self.loadState(plugin) & PluginManager::LoadState::Loaded)) { |
||||
PyErr_Format(PyExc_RuntimeError, "plugin %s is not loaded", plugin.data()); |
||||
throw py::error_already_set{}; |
||||
} |
||||
|
||||
auto loaded = self.instantiate(plugin); |
||||
if(!loaded) { |
||||
PyErr_Format(PyExc_RuntimeError, "can't instantiate plugin %s", plugin.data()); |
||||
throw py::error_already_set{}; |
||||
} |
||||
|
||||
return PluginManager::pyPluginHolder(std::move(loaded), py::cast(self)); |
||||
}, "Instantiate a plugin") |
||||
.def("load_and_instantiate", [](PluginManager::Manager<T>& self, const std::string& plugin) { |
||||
auto loaded = self.loadAndInstantiate(plugin); |
||||
if(!loaded) { |
||||
PyErr_Format(PyExc_RuntimeError, "can't load and instantiate plugin %s", plugin.data()); |
||||
throw py::error_already_set{}; |
||||
} |
||||
|
||||
return PluginManager::pyPluginHolder(std::move(loaded), py::cast(self)); |
||||
}, "Load and instantiate plugin"); |
||||
} |
||||
|
||||
} |
||||
|
||||
#endif |
||||
@ -1,30 +0,0 @@
|
||||
/* |
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
/* Named corrade/staticconfigure.h to avoid it colliding with Corrade/configure.h |
||||
on case-insensitive filesystems */ |
||||
|
||||
#cmakedefine Corrade_PluginManager_FOUND |
||||
@ -1,36 +0,0 @@
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
# 2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# 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: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
# IDE folder in VS, Xcode etc. CMake 3.12+, older versions have only the FOLDER |
||||
# property that would have to be set on each target separately. |
||||
set(CMAKE_FOLDER "Corrade/Python/Test") |
||||
|
||||
foreach(_test optional stridedarrayview) |
||||
pybind11_add_module(test_${_test} ${pybind11_add_module_SYSTEM} test_${_test}.cpp) |
||||
target_include_directories(test_${_test} PRIVATE ${PROJECT_SOURCE_DIR}/src) |
||||
target_link_libraries(test_${_test} PRIVATE Corrade::Containers) |
||||
set_target_properties(test_${_test} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${output_dir}) |
||||
endforeach() |
||||
@ -1,6 +0,0 @@
|
||||
someKey=42 |
||||
[someGroup] |
||||
value=hello |
||||
[someGroup/subgroup] |
||||
anotherValue=another |
||||
[emptyGroup] |
||||
File diff suppressed because it is too large
Load Diff
@ -1,186 +0,0 @@
|
||||
# |
||||
# This file is part of Magnum. |
||||
# |
||||
# Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
# 2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
# Vladimír Vondruš <mosra@centrum.cz> |
||||
# |
||||
# 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: |
||||
# |
||||
# The above copyright notice and this permission notice shall be included |
||||
# in all copies or substantial portions of the Software. |
||||
# |
||||
# 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. |
||||
# |
||||
|
||||
import unittest |
||||
|
||||
from corrade import containers |
||||
import test_stridedarrayview |
||||
|
||||
try: |
||||
import numpy as np |
||||
except ModuleNotFoundError: |
||||
raise unittest.SkipTest("numpy not installed") |
||||
|
||||
class StridedArrayViewCustomType(unittest.TestCase): |
||||
# This tests exposing statically typed StridedArrayView instances from C++, |
||||
# see StridedArrayViewCustomDynamicType below for types specified |
||||
# dynamically and types inherited from the buffer protocol. The short and |
||||
# mutable_int variants tested in test_containers, as for those memoryview |
||||
# works well... well, for one dimension it does. |
||||
|
||||
def test_mutable_vector3d(self): |
||||
a = test_stridedarrayview.MutableContainer3d() |
||||
self.assertEqual(type(a.view), containers.MutableStridedArrayView2D) |
||||
self.assertEqual(a.view.format, 'ddd') |
||||
self.assertEqual(a.list, [ |
||||
[0.0, 0.0, 0.0], |
||||
[0.0, 0.0, 0.0], |
||||
[0.0, 0.0, 0.0], |
||||
[0.0, 0.0, 0.0], |
||||
[0.0, 0.0, 0.0], |
||||
[0.0, 0.0, 0.0] |
||||
]) |
||||
a.view[0][1] = [-765.6581, 3.5, 1.125] |
||||
a.view[1][2] = [4.666, 0.25, -7.5] |
||||
self.assertEqual(a.list, [ |
||||
[0.0, 0.0, 0.0], |
||||
[-765.6581, 3.5, 1.125], |
||||
[0.0, 0.0, 0.0], |
||||
[0.0, 0.0, 0.0], |
||||
[0.0, 0.0, 0.0], |
||||
[4.666, 0.25, -7.5] |
||||
]) |
||||
|
||||
# memoryview ... doesn't understand the type. HAH |
||||
mav = memoryview(a.view[0]) |
||||
with self.assertRaisesRegex(NotImplementedError, "unsupported format ddd"): |
||||
self.assertEqual(mav[1], [-765.6581, 3.5, 1.125]) |
||||
|
||||
# Test that numpy understands the type and has changes reflected |
||||
av = np.array(a.view, copy=False) |
||||
a.view[1][0] = [-3.33, 1.0, 0.0] |
||||
# Converting to a tuple, otherwise numpy always compares to False |
||||
self.assertEqual(tuple(av[1][0]), (-3.33, 1.0, 0.0)) |
||||
self.assertEqual(tuple(av[1][1]), (0.0, 0.0, 0.0)) |
||||
self.assertEqual(tuple(av[1][2]), (4.666, 0.25, -7.5)) |
||||
|
||||
# And the other way around as well |
||||
av[1][1] = (1.0, 0.125, 1.125) |
||||
self.assertEqual(a.list, [ |
||||
[0.0, 0.0, 0.0], |
||||
[-765.6581, 3.5, 1.125], |
||||
[0.0, 0.0, 0.0], |
||||
[-3.33, 1.0, 0.0], |
||||
[1.0, 0.125, 1.125], |
||||
[4.666, 0.25, -7.5] |
||||
]) |
||||
|
||||
def test_mutable_long_float(self): |
||||
a = test_stridedarrayview.MutableContainerlf() |
||||
self.assertEqual(type(a.view), containers.MutableStridedArrayView2D) |
||||
self.assertEqual(a.view.format, 'Qf') |
||||
self.assertEqual(a.list, [ |
||||
(0, 0.0), |
||||
(0, 0.0), |
||||
(0, 0.0), |
||||
(0, 0.0), |
||||
(0, 0.0), |
||||
(0, 0.0) |
||||
]) |
||||
a.view[0][1] = (7656581356781257, 1.125) |
||||
a.view[1][2] = (4666025, -7.5) |
||||
self.assertEqual(a.list, [ |
||||
(0, 0.0), |
||||
(7656581356781257, 1.125), |
||||
(0, 0.0), |
||||
(0, 0.0), |
||||
(0, 0.0), |
||||
(4666025, -7.5) |
||||
]) |
||||
|
||||
# memoryview ... doesn't understand the type. HAH |
||||
mav = memoryview(a.view[0]) |
||||
with self.assertRaisesRegex(NotImplementedError, "unsupported format Qf"): |
||||
self.assertEqual(mav[1], (7656581356781257, 1.125)) |
||||
|
||||
# Test that numpy understands the type and has changes reflected |
||||
av = np.array(a.view, copy=False) |
||||
a.view[1][0] = (333106832, 0.0) |
||||
# Converting to a tuple, otherwise numpy always compares to False |
||||
self.assertEqual(tuple(av[1][0]), (333106832, 0.0)) |
||||
self.assertEqual(tuple(av[1][1]), (0, 0.0)) |
||||
self.assertEqual(tuple(av[1][2]), (4666025, -7.5)) |
||||
|
||||
# And the other way around as well |
||||
av[1][1] = (1001, 1.125) |
||||
self.assertEqual(a.list, [ |
||||
(0, 0.0), |
||||
(7656581356781257, 1.125), |
||||
(0, 0.0), |
||||
(333106832, 0.0), |
||||
(1001, 1.125), |
||||
(4666025, -7.5) |
||||
]) |
||||
|
||||
class StridedArrayViewCustomDynamicType(unittest.TestCase): |
||||
def test_binding_short_short(self): |
||||
a = test_stridedarrayview.MutableContainerDynamicType('hh') |
||||
self.assertEqual(a.view.size, (2, 3)) |
||||
self.assertEqual(a.view.stride, (12, 4)) |
||||
self.assertEqual(a.view.format, 'hh') |
||||
|
||||
# Test that numpy understands the type and has changes reflected |
||||
av = np.array(a.view, copy=False) |
||||
av[1][0] = (22563, -17665) |
||||
a.view[0][1] = (15, 34) |
||||
a.view[1][1] = (-22, 18) |
||||
# Converting to a tuple, otherwise numpy always compares to False |
||||
self.assertEqual(tuple(av[0][1]), (15, 34)) |
||||
self.assertEqual(tuple(av[1][0]), (22563, -17665)) |
||||
self.assertEqual(tuple(av[1][1]), (-22, 18)) |
||||
|
||||
# And the other way around as well |
||||
self.assertEqual(a.view[0][0], (0, 0)) |
||||
self.assertEqual(a.view[0][1], (15, 34)) |
||||
self.assertEqual(a.view[0][2], (0, 0)) |
||||
self.assertEqual(a.view[1][0], (22563, -17665)) |
||||
self.assertEqual(a.view[1][1], (-22, 18)) |
||||
self.assertEqual(a.view[1][2], (0, 0)) |
||||
|
||||
def test_init_long(self): |
||||
a = np.array([[1, 2, 3], [-4, 5000000000, 6]], np.dtype('q')) |
||||
self.assertEqual(a.dtype, 'int64') |
||||
|
||||
b = containers.MutableStridedArrayView2D(a) |
||||
self.assertEqual(b.size, (2, 3)) |
||||
self.assertEqual(b.stride, (24, 8)) |
||||
self.assertEqual(b.format, 'q') |
||||
b[1, 1] *= 2 |
||||
self.assertEqual(b[0, 2], 3) |
||||
self.assertEqual(b[1, 0], -4) |
||||
self.assertEqual(b[1, 1], 10000000000) |
||||
|
||||
def test_init_double(self): |
||||
a = np.array([[[1.0], [2.0]], [[-4.0], [5.0]]], np.dtype('d')) |
||||
self.assertEqual(a.dtype, 'float64') |
||||
|
||||
b = containers.MutableStridedArrayView3D(a) |
||||
self.assertEqual(b.size, (2, 2, 1)) |
||||
self.assertEqual(b.stride, (16, 8, 8)) |
||||
self.assertEqual(b.format, 'd') |
||||
b[1, 1, 0] *= -2.0 |
||||
self.assertEqual(b[0, 1, 0], 2.0) |
||||
self.assertEqual(b[1, 1, 0], -10.0) |
||||
@ -1,76 +0,0 @@
|
||||
/*
|
||||
This file is part of Magnum. |
||||
|
||||
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, |
||||
2020, 2021, 2022, 2023, 2024, 2025, 2026 |
||||
Vladimír Vondruš <mosra@centrum.cz> |
||||
|
||||
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: |
||||
|
||||
The above copyright notice and this permission notice shall be included |
||||
in all copies or substantial portions of the Software. |
||||
|
||||
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. |
||||
*/ |
||||
|
||||
#include <pybind11/pybind11.h> |
||||
|
||||
#include "../bootstrap.h" /* for module / _module alias */ |
||||
|
||||
#include "Corrade/Containers/OptionalPythonBindings.h" |
||||
|
||||
using namespace Corrade; |
||||
namespace py = pybind11; |
||||
|
||||
namespace { |
||||
|
||||
struct Foo { |
||||
Foo(int a): a{a} {} |
||||
int a; |
||||
}; |
||||
|
||||
Containers::Optional<int> simpleType(bool set) { |
||||
return set ? Containers::optional(5) : Containers::NullOpt; |
||||
} |
||||
|
||||
Containers::Optional<Foo> nestedType(bool set) { |
||||
return set ? Containers::optional(Foo{15}) : Containers::NullOpt; |
||||
} |
||||
|
||||
int acquireSimpleType(Containers::Optional<int> value) { |
||||
return value ? *value : -1; |
||||
} |
||||
|
||||
int acquireNestedType(Containers::Optional<Foo> value) { |
||||
return value ? value->a : -1; |
||||
} |
||||
|
||||
} |
||||
|
||||
/* TODO: remove declaration when https://github.com/pybind/pybind11/pull/1863
|
||||
is released */ |
||||
extern "C" PYBIND11_EXPORT PyObject* PyInit_test_optional(); |
||||
PYBIND11_MODULE(test_optional, m) { |
||||
py::module_::import("corrade.containers"); |
||||
|
||||
py::class_<Foo>{m, "Foo"} |
||||
.def(py::init<int>()) |
||||
.def_readwrite("a", &Foo::a); |
||||
|
||||
m.def("simple_type", simpleType); |
||||
m.def("nested_type", nestedType); |
||||
|
||||
m.def("acquire_simple_type", acquireSimpleType); |
||||
m.def("acquire_nested_type", acquireNestedType); |
||||
} |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue