diff --git a/interfaces/main.cpp b/interfaces/main.cpp deleted file mode 100644 index 3e0d8b7..0000000 --- a/interfaces/main.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include -import Crafter.Math; -import std; - -using namespace Crafter; - -int main() { - -} \ No newline at end of file diff --git a/project.cpp b/project.cpp new file mode 100644 index 0000000..af716a2 --- /dev/null +++ b/project.cpp @@ -0,0 +1,52 @@ +import std; +import Crafter.Build; +namespace fs = std::filesystem; +using namespace Crafter; + +extern "C" Configuration CrafterBuildProject(std::span args) { + constexpr std::array mathInterfaces = { + "interfaces/Crafter.Math-Basic", + "interfaces/Crafter.Math", + "interfaces/Crafter.Math-Common", + "interfaces/Crafter.Math-Vector", + "interfaces/Crafter.Math-Intersection", + "interfaces/Crafter.Math-MatrixRowMajor", + "interfaces/Crafter.Math-VectorF16", + "interfaces/Crafter.Math-VectorF32", + }; + + Configuration cfg; + cfg.path = "./"; + cfg.name = "Crafter.Math"; + cfg.outputName = "Crafter.Math"; + ApplyStandardArgs(cfg, args); + cfg.type = ConfigurationType::LibraryStatic; + { + std::array ifaces; + std::ranges::copy(mathInterfaces, ifaces.begin()); + std::array impls = {}; + cfg.GetInterfacesAndImplementations(ifaces, impls); + } + + auto addVectorTest = [&](std::string march, std::string mtune) { + Test t; + t.config.path = "./"; + t.config.name = std::format("Vector-{}", march); + t.config.outputName = t.config.name; + t.config.target = cfg.target; + t.config.type = ConfigurationType::Executable; + t.config.march = march; + t.config.mtune = mtune; + t.config.debug = cfg.debug; + std::array ifaces; + std::ranges::copy(mathInterfaces, ifaces.begin()); + std::array impls = { "tests/Vector" }; + t.config.GetInterfacesAndImplementations(ifaces, impls); + cfg.tests.push_back(std::move(t)); + }; + addVectorTest("sapphirerapids", "native"); + addVectorTest("x86-64-v4", "generic"); + addVectorTest("x86-64-v3", "generic"); + + return cfg; +} diff --git a/project.json b/project.json deleted file mode 100644 index b2a7349..0000000 --- a/project.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "name": "crafter-math", - "configurations": [ - { - "name": "base", - "interfaces": [ - "interfaces/Crafter.Math-Basic", - "interfaces/Crafter.Math", - "interfaces/Crafter.Math-Common", - "interfaces/Crafter.Math-Vector", - "interfaces/Crafter.Math-Intersection", - "interfaces/Crafter.Math-MatrixRowMajor", - "interfaces/Crafter.Math-VectorF16", - "interfaces/Crafter.Math-VectorF32" - ], - "implementations": [] - }, - { - "name": "lib", - "extends": ["base"], - "type":"library", - "dependencies": [] - }, - { - "name": "lib-shared", - "extends": ["base"], - "type":"shared-library", - "dependencies": [] - }, - { - "name": "lib-debug", - "extends": ["lib"], - "debug": true - } - ], - "tests":[ - { - "name": "Vector-x86-64-sapphirerapids", - "implementations": ["tests/Vector"], - "march": "sapphirerapids", - "extends": ["lib-shared"] - }, - { - "name": "Vector-x86-64-v4", - "implementations": ["tests/Vector"], - "march": "x86-64-v4", - "mtune": "generic", - "extends": ["lib-shared"] - }, - { - "name": "Vector-x86-64-v3", - "implementations": ["tests/Vector"], - "march": "x86-64-v3", - "mtune": "generic", - "extends": ["lib-shared"] - } - ] -} \ No newline at end of file diff --git a/tests/Vector.cpp b/tests/Vector.cpp index ce86770..5a80d7c 100644 --- a/tests/Vector.cpp +++ b/tests/Vector.cpp @@ -598,16 +598,14 @@ std::string* TestAllCombinations() { } } -extern "C" { - std::string* RunTest() { - std::string* err = TestAllCombinations<_Float16, VectorF16, VectorF16<1, 1>::MaxElement>(); - if (err) { - return err; - } - err = TestAllCombinations::MaxElement>(); - if (err) { - return err; - } - return nullptr; +int main() { + if (auto err = std::unique_ptr(TestAllCombinations<_Float16, VectorF16, VectorF16<1, 1>::MaxElement>())) { + std::println(std::cerr, "{}", *err); + return 1; } + if (auto err = std::unique_ptr(TestAllCombinations::MaxElement>())) { + std::println(std::cerr, "{}", *err); + return 1; + } + return 0; } \ No newline at end of file