# Rewrite 5
- Move Libraries Source into pd directory and give them all their own CMakeLists.txt - Partial rewrite core (color, autogenerated vec), lithium (now uses UNIQUE PTR for Commands), UI7 - Use MenuV2 as new standart in UI7 - Implementz ViewPort Pre alpha to UI7 - Add Line Drawing to DrawList (not Working) - Implement a Complete new drievrs API (static Drivers) - NO SUPPORT FOR SHARED LIBRARY BUILDS IN VERSION 5 YET - Add Tools to Autogenerate Headers and Stuff
This commit is contained in:
5
tools/CMakeLists.txt
Executable file
5
tools/CMakeLists.txt
Executable file
@ -0,0 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
add_subdirectory(lazyvec)
|
||||
add_subdirectory(ppam)
|
||||
add_subdirectory(pdlm)
|
@ -1,94 +0,0 @@
|
||||
import os
|
||||
import glob
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
|
||||
# Simple Script to generate/update Shaders
|
||||
# WHY? Cause having this stupid .v.pica files in
|
||||
# sourcecode is pain with some buildsystems
|
||||
|
||||
license_text = """
|
||||
/*
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 tobid7
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
"""
|
||||
|
||||
def file2array(path, custom_incluse_path):
|
||||
print(path)
|
||||
cip = len(custom_incluse_path)
|
||||
sip = ''
|
||||
if cip > 0:
|
||||
sip = custom_incluse_path
|
||||
name = Path(path).stem
|
||||
filei = open(path, 'rb')
|
||||
buf = filei.read()
|
||||
filei.close()
|
||||
fs = open(name + '.cpp', 'w')
|
||||
fs.write("// THIS FILE WAS GENERATED BY build_shaders.py!!!\n")
|
||||
fs.write(license_text)
|
||||
fs.write('#include <'+ sip + name + '.hpp>\n\n')
|
||||
fs.write('// clang-format off\n')
|
||||
fs.write('unsigned char ' + name + '[] = {\n')
|
||||
for byte in buf:
|
||||
fs.write(hex(byte) + ', ')
|
||||
fs.write('\n};\n')
|
||||
fs.write('// clang-format on\n')
|
||||
fs.write('size_t ' + name + '_size = ' + hex(len(buf)) + ';')
|
||||
fs.close()
|
||||
fh = open(name + '.hpp', 'w')
|
||||
fh.write("// THIS FILE WAS GENERATED BY build_shaders.py!!!\n")
|
||||
fh.write('#pragma once\n')
|
||||
fh.write(license_text)
|
||||
fh.write('#include <cstddef>\n\n')
|
||||
fh.write('extern unsigned char ' + name + '[];\n')
|
||||
fh.write('extern size_t ' + name + '_size;')
|
||||
fh.close()
|
||||
|
||||
def build_shader(path):
|
||||
p = os.path.dirname(path)
|
||||
n = Path(Path(path).stem).stem
|
||||
os.system('picasso -o ' + p + '/' + n + '.shbin ' + path)
|
||||
|
||||
def cleanup():
|
||||
t3x = glob.glob('shaders/*.shbin')
|
||||
for f in t3x:
|
||||
os.remove(f)
|
||||
|
||||
def install_code(what, where):
|
||||
if Path(what).is_dir:
|
||||
os.error('Must be a file!!!')
|
||||
shutil.move(what, where + Path(what).name)
|
||||
|
||||
print("Generating...")
|
||||
shaders = glob.glob('shaders/*v.pica')
|
||||
for object in shaders:
|
||||
name = Path(Path(object).stem).stem
|
||||
bp = os.path.dirname(object)
|
||||
build_shader(object)
|
||||
file2array(bp + '/' + name + '.shbin', 'pd/lithium/')
|
||||
install_code(name + '.cpp', 'source/lithium/')
|
||||
install_code(name + '.hpp', 'include/pd/lithium/')
|
||||
|
||||
cleanup()
|
||||
print("Done")
|
@ -1,28 +0,0 @@
|
||||
import subprocess
|
||||
import glob
|
||||
from pathlib import Path
|
||||
# Format script
|
||||
|
||||
def fmt_file(path):
|
||||
if Path(path).is_dir():
|
||||
return # Skip
|
||||
try:
|
||||
subprocess.run(['clang-format', '-i', path, '--style=Google'], check=True)
|
||||
except subprocess.CalledProcessError as e:
|
||||
print('Error for ' + Path(path).stem + ': ' + e)
|
||||
|
||||
def fmt_dir(path):
|
||||
sources = glob.glob(path+'/*')
|
||||
for file in sources:
|
||||
fmt_file(file)
|
||||
|
||||
print('Formatting...')
|
||||
fmt_dir('source/base')
|
||||
fmt_dir('source/drivers')
|
||||
fmt_dir('include')
|
||||
fmt_dir('include/pd/base')
|
||||
fmt_dir('include/pd/app')
|
||||
fmt_dir('include/pd/drivers')
|
||||
fmt_dir('include/pd/gfx')
|
||||
|
||||
print('Done')
|
7
tools/lazyvec/CMakeLists.txt
Executable file
7
tools/lazyvec/CMakeLists.txt
Executable file
@ -0,0 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(lazyvec LANGUAGES CXX VERSION 1.0.0)
|
||||
|
||||
add_executable(lazyvec
|
||||
source/main.cpp
|
||||
)
|
226
tools/lazyvec/source/main.cpp
Executable file
226
tools/lazyvec/source/main.cpp
Executable file
@ -0,0 +1,226 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
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 <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
const char* license_text = R"(/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
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.
|
||||
*/
|
||||
)";
|
||||
|
||||
const std::vector<std::string> elems = {"x", "y", "z", "w"};
|
||||
|
||||
void MakeOperationFor(std::fstream& off, char op, int n) {
|
||||
off << " template <typename T1>\n";
|
||||
off << " vec" << n << "<T>& operator" << op << "=(T1 v) {\n";
|
||||
for (int i = 0; i < n; i++) {
|
||||
off << " " << elems[i] << " " << op << "= (T)v;\n";
|
||||
}
|
||||
off << " return *this;\n";
|
||||
off << " }\n\n";
|
||||
|
||||
off << " template <typename T1>\n";
|
||||
off << " vec" << n << "<T>& operator" << op << "=(const vec" << n
|
||||
<< "<T1>& v) {\n";
|
||||
for (int i = 0; i < n; i++) {
|
||||
off << " " << elems[i] << " " << op << "= (T)v." << elems[i] << ";\n";
|
||||
}
|
||||
off << " return *this;\n";
|
||||
off << " }\n\n";
|
||||
|
||||
off << " template <typename T1>\n";
|
||||
off << " vec" << n << "<T> operator" << op << "(T1 v) const {\n";
|
||||
off << " return vec" << n << "<T>(";
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (i > 0) off << ", ";
|
||||
off << elems[i] << " " << op << " (T)v";
|
||||
}
|
||||
off << ");\n }\n\n";
|
||||
|
||||
off << " template <typename T1>\n";
|
||||
off << " vec" << n << "<T> operator" << op << "(const vec" << n
|
||||
<< "<T1>& v) const {\n";
|
||||
off << " return vec" << n << "<T>(";
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (i > 0) off << ", ";
|
||||
off << elems[i] << " " << op << " (T)v." << elems[i];
|
||||
}
|
||||
off << ");\n }\n\n";
|
||||
}
|
||||
|
||||
void SwapHaxx(std::fstream& off, int n) {
|
||||
std::unordered_set<std::string> done;
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
std::string a = elems[i];
|
||||
std::string b = elems[j];
|
||||
/** Make sure we generate nothing twice */
|
||||
if (a == b || done.count(b + a)) {
|
||||
continue;
|
||||
}
|
||||
off << " void Swap" << (char)toupper(a[0]) << (char)toupper(b[0])
|
||||
<< "() {\n";
|
||||
off << " T t = " << a << ";\n " << a << " = " << b << ";\n";
|
||||
off << " " << b << " = t;\n }\n";
|
||||
done.insert(a + b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateVec(int n) {
|
||||
if (n < 2 || n > 4) {
|
||||
std::cout << "Only 2 to 4 supported.\n";
|
||||
return;
|
||||
}
|
||||
|
||||
std::fstream off("vec" + std::to_string(n) + ".hpp", std::ios::out);
|
||||
|
||||
off << "#pragma once\n" << std::endl;
|
||||
off << license_text << std::endl;
|
||||
off << "// This file is generated by lazyvec\n#include "
|
||||
"<pd/core/common.hpp>\n\n";
|
||||
off << "namespace PD {" << std::endl;
|
||||
off << "template <typename T>\nclass vec" << n << " {\npublic:\n";
|
||||
for (int i = 0; i < n; i++) {
|
||||
off << " T " << elems[i] << ";\n";
|
||||
}
|
||||
off << "\n";
|
||||
off << " vec" << n << "(): ";
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (i > 0) {
|
||||
off << ", ";
|
||||
}
|
||||
off << elems[i] << "(0)";
|
||||
}
|
||||
off << " {}" << std::endl;
|
||||
// Magic Construtor (support for anytype vec)
|
||||
off << " template <typename T1>\n";
|
||||
off << " explicit vec" << n << "(T1 v) {\n";
|
||||
for (int i = 0; i < n; i++) {
|
||||
off << " " << elems[i] << " = (T)v;\n";
|
||||
}
|
||||
off << " }\n\n";
|
||||
|
||||
// Magic Constructor 2
|
||||
off << " template <typename T1>\n";
|
||||
off << " explicit vec" << n << "(vec" << n << "<T1> v) {\n";
|
||||
for (int i = 0; i < n; i++) {
|
||||
off << " " << elems[i] << " = (T)v. " << elems[i] << ";\n";
|
||||
}
|
||||
off << " }\n\n";
|
||||
|
||||
off << " vec" << n << "(";
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (i > 0) off << ", ";
|
||||
off << "T " << elems[i];
|
||||
}
|
||||
off << ") : ";
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (i > 0) off << ", ";
|
||||
off << elems[i] << "(" << elems[i] << ")";
|
||||
}
|
||||
off << " {}\n\n";
|
||||
|
||||
MakeOperationFor(off, '+', n);
|
||||
MakeOperationFor(off, '-', n);
|
||||
MakeOperationFor(off, '*', n);
|
||||
MakeOperationFor(off, '/', n);
|
||||
|
||||
off << " vec" << n << " operator-() const {return vec" << n << "(";
|
||||
for (int i = 0; i < n; i++) {
|
||||
off << "-" << elems[i];
|
||||
if (i != n - 1) {
|
||||
off << ", ";
|
||||
}
|
||||
}
|
||||
off << ");}\n\n";
|
||||
|
||||
off << " bool operator==(const vec" << n << "& v) const { return ";
|
||||
for (int i = 0; i < n; i++) {
|
||||
off << elems[i] << " == v." << elems[i];
|
||||
if (i != n - 1) {
|
||||
off << " && ";
|
||||
}
|
||||
}
|
||||
off << ";}\n";
|
||||
off << " bool operator!=(const vec" << n
|
||||
<< "&v) const { return !(*this == v); }\n\n";
|
||||
|
||||
off << " double Len() const {return std::sqrt(SqLen()); }\n";
|
||||
off << " double SqLen() const { return ";
|
||||
for (int i = 0; i < n; i++) {
|
||||
off << elems[i] << " * " << elems[i];
|
||||
if (i != n - 1) {
|
||||
off << " + ";
|
||||
}
|
||||
}
|
||||
off << "; }\n\n";
|
||||
|
||||
SwapHaxx(off, n);
|
||||
|
||||
off << "};\n";
|
||||
off << "using fvec" << n << " = vec" << n << "<float>;\n";
|
||||
off << "using dvec" << n << " = vec" << n << "<double>;\n";
|
||||
off << "using ivec" << n << " = vec" << n << "<int>;\n";
|
||||
off << "}\n";
|
||||
off.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Yet another Stupid Code generation tool
|
||||
* Why ?
|
||||
* Cause this is written and tested faster then
|
||||
* manually writeup vec2 to vec4
|
||||
*/
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 2) {
|
||||
std::cout << argv[0] << " <num (2 to 4)>" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
GenerateVec(std::stoi(argv[1]));
|
||||
return 0;
|
||||
}
|
11
tools/pdlm/CMakeLists.txt
Executable file
11
tools/pdlm/CMakeLists.txt
Executable file
@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(pdlm LANGUAGES CXX VERSION 1.0.0)
|
||||
|
||||
### Requires C++ 20
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||
|
||||
add_executable(pdlm
|
||||
source/main.cpp
|
||||
)
|
66
tools/pdlm/source/main.cpp
Executable file
66
tools/pdlm/source/main.cpp
Executable file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// C++ 20 capable compiler required (eg. force use
|
||||
// self compiled clang on debian based systems)
|
||||
#include <filesystem>
|
||||
#include <format>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
constexpr std::string_view cmake_file = R"(cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
# Generated with pdlm
|
||||
|
||||
project({0} LANGUAGES {1} VERSION {2})
|
||||
|
||||
set(SRC
|
||||
{3}
|
||||
)
|
||||
|
||||
if(PD_BUILD_SHARED)
|
||||
pd_add_lib({0} BUILD_SHARED TRUE SRC_FILES ${{SRC}})
|
||||
else()
|
||||
pd_add_lib({0} SRC_FILES ${{SRC}})
|
||||
endif()
|
||||
)";
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 4) {
|
||||
std::cout << argv[0] << " <libname> <lang (in \"\")> <libver>" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
if (std::filesystem::exists("CMakeLists.txt")) {
|
||||
std::cout << "!!! CMakeLists.txt in your working directory !!!"
|
||||
<< std::endl;
|
||||
std::cout
|
||||
<< "!!! Make sure to execute this command in an Empty directory !!!"
|
||||
<< std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::fstream off("CMakeLists.txt", std::ios::out);
|
||||
off << std::format(cmake_file, argv[1], argv[2], argv[3], "your_source.cpp");
|
||||
off.close();
|
||||
return 0;
|
||||
}
|
11
tools/ppam/CMakeLists.txt
Executable file
11
tools/ppam/CMakeLists.txt
Executable file
@ -0,0 +1,11 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
project(ppam LANGUAGES CXX VERSION 1.0.0)
|
||||
|
||||
### Requires C++ 20
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||
|
||||
add_executable(ppam
|
||||
source/main.cpp
|
||||
)
|
97
tools/ppam/source/main.cpp
Executable file
97
tools/ppam/source/main.cpp
Executable file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
// C++ 20 capable compiler required (eg. force use
|
||||
// self compiled clang on debian based systems)
|
||||
#include <format>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
const char* license_text = R"(/*
|
||||
MIT License
|
||||
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||||
|
||||
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.
|
||||
*/
|
||||
)";
|
||||
|
||||
constexpr std::string_view ppa_text =
|
||||
"#pragma once\n\n{0}\n"
|
||||
"/** Generated with ppam */\n\n"
|
||||
"#ifdef _WIN32 // Windows (MSVC Tested)\n"
|
||||
"#ifdef {1}_BUILD_SHARED\n"
|
||||
"#define {1}_API __declspec(dllexport)\n"
|
||||
"#else\n"
|
||||
"#define {1}_API __declspec(dllimport)\n"
|
||||
"#endif\n"
|
||||
"#elif defined(__APPLE__) // macOS (untested yet)\n"
|
||||
"#ifdef {1}_BUILD_SHARED\n"
|
||||
"#define {1}_API __attribute__((visibility(\"default\")))\n"
|
||||
"#else\n"
|
||||
"#define {1}_API\n"
|
||||
"#endif\n"
|
||||
"#elif defined(__linux__) // Linux (untested yet)\n"
|
||||
"#ifdef {1}_BUILD_SHARED\n"
|
||||
"#define {1}_API __attribute__((visibility(\"default\")))\n"
|
||||
"#else\n"
|
||||
"#define {1}_API\n"
|
||||
"#endif\n"
|
||||
"#elif defined(__3DS__) // 3ds Specific\n"
|
||||
"// Only Static supported\n"
|
||||
"#define {1}_API\n"
|
||||
"#else\n"
|
||||
"#define {1}_API\n"
|
||||
"#endif\n";
|
||||
|
||||
/**
|
||||
* Tool to generate the `pd_p_api.hpp` (Palladium Platform Api)
|
||||
* for palladiums sub libraries to support dll/so/dlsym
|
||||
*/
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 2) {
|
||||
std::cout << argv[0] << " <name>" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::fstream off("pd_p_api.hpp", std::ios::out);
|
||||
off << std::format(ppa_text, license_text, argv[1]);
|
||||
off.close();
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user