Fix up build and start site generator.
This commit is contained in:
parent
d471609712
commit
bd60a28eef
15 changed files with 267 additions and 96 deletions
|
@ -27,4 +27,14 @@ target_link_libraries(sample_console PUBLIC console core network
|
|||
database geometry audio web)
|
||||
|
||||
set_property(TARGET sample_console PROPERTY FOLDER apps)
|
||||
set_property(TARGET sample_gui PROPERTY FOLDER apps)
|
||||
set_property(TARGET sample_gui PROPERTY FOLDER apps)
|
||||
|
||||
# Website Generator
|
||||
add_executable(website_generator website-generator.cpp)
|
||||
#target_include_directories(website_generator PUBLIC
|
||||
# "${PROJECT_SOURCE_DIR}/src/console"
|
||||
# )
|
||||
target_link_libraries(website_generator PUBLIC core web)
|
||||
|
||||
set_property(TARGET website_generator PROPERTY FOLDER apps)
|
||||
|
||||
|
|
129
apps/website-generator.cpp
Normal file
129
apps/website-generator.cpp
Normal file
|
@ -0,0 +1,129 @@
|
|||
#include "CommandLineArgs.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
class GeneratorConfig
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
class ContentPage
|
||||
{
|
||||
public:
|
||||
|
||||
ContentPage(const std::string& filename)
|
||||
: mFilename(filename)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string getFilename() const
|
||||
{
|
||||
return mFilename;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
std::string mFilename;
|
||||
};
|
||||
|
||||
|
||||
class WebsiteGenerator
|
||||
{
|
||||
public:
|
||||
|
||||
void findProject(const std::string& searchPath)
|
||||
{
|
||||
const auto config_path = std::filesystem::path(searchPath) / "config.toml";
|
||||
if (std::filesystem::exists(config_path))
|
||||
{
|
||||
mProjectPath = searchPath;
|
||||
std::cout << "Found config.toml in " << searchPath << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void readConfig()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void parseContentFiles()
|
||||
{
|
||||
const auto content_dir = mProjectPath / "content";
|
||||
if (std::filesystem::is_directory(content_dir))
|
||||
{
|
||||
std::cout << "checking " << content_dir << std::endl;
|
||||
const auto pages_dir = content_dir / "pages";
|
||||
if (std::filesystem::is_directory(pages_dir))
|
||||
{
|
||||
std::cout << "checking " << pages_dir << std::endl;
|
||||
for (const auto& entry : std::filesystem::directory_iterator(pages_dir))
|
||||
{
|
||||
if (std::filesystem::is_regular_file(entry) && entry.path().extension() == ".md")
|
||||
{
|
||||
mPages.push_back(ContentPage(entry.path()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "nope in " << content_dir << std::endl;
|
||||
}
|
||||
|
||||
for(const auto& page : mPages)
|
||||
{
|
||||
std::cout << "Got page " << page.getFilename() << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void parseTemplateFiles()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void doSubstitutions()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void write()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
std::filesystem::path mProjectPath;
|
||||
GeneratorConfig mConfig;
|
||||
std::vector<ContentPage> mPages;
|
||||
};
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
auto args = CommandLineArgs::Create();
|
||||
args->process(argc, argv);
|
||||
args->recordLaunchPath();
|
||||
|
||||
WebsiteGenerator generator;
|
||||
generator.findProject(args->getArg(1));
|
||||
|
||||
generator.readConfig();
|
||||
|
||||
// Find and process project files
|
||||
generator.parseContentFiles();
|
||||
|
||||
// Find template files
|
||||
|
||||
// Substitute template files
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -7,22 +7,22 @@ CommandLineArgs::CommandLineArgs()
|
|||
|
||||
}
|
||||
|
||||
std::unique_ptr<CommandLineArgs> CommandLineArgs::CreateUnique()
|
||||
std::unique_ptr<CommandLineArgs> CommandLineArgs::Create()
|
||||
{
|
||||
return std::make_unique<CommandLineArgs>();
|
||||
}
|
||||
|
||||
std::filesystem::path CommandLineArgs::GetLaunchPath()
|
||||
std::filesystem::path CommandLineArgs::getLaunchPath()
|
||||
{
|
||||
return mLaunchPath;
|
||||
}
|
||||
|
||||
void CommandLineArgs::RecordLaunchPath()
|
||||
void CommandLineArgs::recordLaunchPath()
|
||||
{
|
||||
mLaunchPath = std::filesystem::current_path();
|
||||
}
|
||||
|
||||
void CommandLineArgs::Process(int argc, char *argv[])
|
||||
void CommandLineArgs::process(int argc, char *argv[])
|
||||
{
|
||||
for(int idx=0; idx<argc; idx++)
|
||||
{
|
||||
|
@ -30,17 +30,17 @@ void CommandLineArgs::Process(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
void CommandLineArgs::Process(const std::vector<std::string>& args)
|
||||
void CommandLineArgs::process(const std::vector<std::string>& args)
|
||||
{
|
||||
mArugments = args;
|
||||
}
|
||||
|
||||
std::size_t CommandLineArgs::GetNumberOfArgs() const
|
||||
std::size_t CommandLineArgs::getNumberOfArgs() const
|
||||
{
|
||||
return mArugments.size();
|
||||
}
|
||||
|
||||
std::string CommandLineArgs::GetArg(std::size_t index) const
|
||||
std::string CommandLineArgs::getArg(std::size_t index) const
|
||||
{
|
||||
if(index<mArugments.size())
|
||||
{
|
||||
|
|
|
@ -6,26 +6,27 @@
|
|||
|
||||
class CommandLineArgs
|
||||
{
|
||||
std::vector<std::string> mArugments;
|
||||
std::filesystem::path mLaunchPath;
|
||||
|
||||
public:
|
||||
|
||||
CommandLineArgs();
|
||||
|
||||
static std::unique_ptr<CommandLineArgs> CreateUnique();
|
||||
static std::unique_ptr<CommandLineArgs> Create();
|
||||
|
||||
void RecordLaunchPath();
|
||||
std::filesystem::path getLaunchPath();
|
||||
|
||||
std::filesystem::path GetLaunchPath();
|
||||
std::size_t getNumberOfArgs() const;
|
||||
|
||||
void Process(int argc, char *argv[]);
|
||||
std::string getArg(std::size_t index) const;
|
||||
|
||||
void Process(const std::vector<std::string>& args);
|
||||
void process(int argc, char *argv[]);
|
||||
|
||||
std::size_t GetNumberOfArgs() const;
|
||||
void process(const std::vector<std::string>& args);
|
||||
|
||||
std::string GetArg(std::size_t index) const;
|
||||
void recordLaunchPath();
|
||||
|
||||
private:
|
||||
std::vector<std::string> mArugments;
|
||||
std::filesystem::path mLaunchPath;
|
||||
};
|
||||
|
||||
using CommandLineArgsUPtr = std::unique_ptr<CommandLineArgs>;
|
||||
|
|
|
@ -17,13 +17,13 @@ list(APPEND image_DEFINES "")
|
|||
|
||||
find_package(PNG QUIET)
|
||||
if(PNG_FOUND)
|
||||
list(APPEND image_LIBS PNG::PNG)
|
||||
list(APPEND image_LIB_INCLUDES
|
||||
PngWriterLibPng.cpp
|
||||
)
|
||||
list(APPEND image_DEFINES HAS_LIBPNG)
|
||||
list(APPEND image_LIBS PNG::PNG)
|
||||
list(APPEND image_LIB_INCLUDES
|
||||
PngWriterLibPng.cpp
|
||||
)
|
||||
list(APPEND image_DEFINES HAS_LIBPNG)
|
||||
else()
|
||||
message(STATUS "LIBRARY CHECK: libPNG not found - disabling libPNG based image i/o.")
|
||||
message(STATUS "LIBRARY CHECK: libPNG not found - disabling libPNG based image i/o.")
|
||||
endif()
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ class Image;
|
|||
class PngWriterImpl
|
||||
{
|
||||
public:
|
||||
virtual ~PngWriterImpl() = default;
|
||||
|
||||
virtual void setPath(const std::string& path) = 0;
|
||||
|
||||
virtual void write(const std::unique_ptr<Image>& image) const = 0;
|
||||
};
|
||||
};
|
||||
|
|
0
src/video/BasicVideoConverter.cppcd
Normal file
0
src/video/BasicVideoConverter.cppcd
Normal file
0
src/video/BasicVideoConverter.h
Normal file
0
src/video/BasicVideoConverter.h
Normal file
|
@ -1,40 +1,50 @@
|
|||
list(APPEND video_HEADERS
|
||||
Video.h
|
||||
FfmpegInterface.h
|
||||
BasicVideoConverter.h
|
||||
IVideoConverter.h
|
||||
)
|
||||
|
||||
list(APPEND video_LIB_INCLUDES
|
||||
Video.cpp
|
||||
FfmegInterface.cpp
|
||||
BasicVideoConverter.cpp
|
||||
)
|
||||
|
||||
list(APPEND video_DEFINES "")
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
set(_HAS_FFMPEG Off)
|
||||
if(PkgConfig)
|
||||
pkg_check_modules(LIBAV IMPORTED_TARGET
|
||||
libavdevice
|
||||
libavfilter
|
||||
libavformat
|
||||
libavcodec
|
||||
libswresample
|
||||
libswscale
|
||||
libavutil
|
||||
)
|
||||
list(APPEND video_LIBS PkgConfig::LIBAV)
|
||||
list(APPEND video_HEADERS
|
||||
FfmpegInterface.h
|
||||
)
|
||||
list(APPEND video_LIB_INCLUDES
|
||||
FfmegInterface.cpp
|
||||
)
|
||||
list(APPEND video_DEFINES "HAS_FFMPEG")
|
||||
set(_HAS_FFMPEG ON)
|
||||
else()
|
||||
message(STATUS "LIBRARY CHECK: PkgConfig not found - disabling ffmpeg based video i/o.")
|
||||
endif()
|
||||
|
||||
set(HAS_FFMPEG ${_HAS_FFMPEG} CACHE BOOL "Can build with FFMPEG")
|
||||
|
||||
add_library(video SHARED ${video_LIB_INCLUDES} ${video_HEADERS})
|
||||
|
||||
target_include_directories(video PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
target_include_directories(video PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
set_target_properties( video PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
|
||||
list(APPEND video_LIBS image)
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
if(PkgConfig)
|
||||
pkg_check_modules(LIBAV IMPORTED_TARGET
|
||||
libavdevice
|
||||
libavfilter
|
||||
libavformat
|
||||
libavcodec
|
||||
libswresample
|
||||
libswscale
|
||||
libavutil
|
||||
)
|
||||
list(APPEND video_LIBS PkgConfig::LIBAV)
|
||||
else()
|
||||
message(STATUS "LIBRARY CHECK: PkgConfig not found - disabling ffmpeg based video i/o.")
|
||||
endif()
|
||||
|
||||
target_link_libraries( video PUBLIC ${video_LIBS})
|
||||
|
||||
|
||||
set_property(TARGET video PROPERTY FOLDER src)
|
||||
set_property(TARGET video PROPERTY FOLDER src)
|
||||
|
|
0
src/video/IVideoConverter.h
Normal file
0
src/video/IVideoConverter.h
Normal file
|
@ -1,59 +1,68 @@
|
|||
set (platform_INCLUDES "")
|
||||
set (platform_LIBS "")
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND platform_INCLUDES
|
||||
ui_interfaces/x11/XcbInterface.cpp
|
||||
ui_interfaces/x11/XcbEventInterface.cpp
|
||||
ui_interfaces/x11/XcbWindow.cpp
|
||||
ui_interfaces/x11/XcbScreen.cpp
|
||||
ui_interfaces/x11/XcbWindowInterface.cpp
|
||||
ui_interfaces/x11/XcbLayerInterface.cpp
|
||||
ui_interfaces/x11/XcbTextInterface.cpp
|
||||
ui_interfaces/x11/XcbKeyboard.cpp
|
||||
ui_interfaces/x11/GlxInterface.cpp
|
||||
|
||||
ui_interfaces/wayland/WaylandWindowInterface.cpp
|
||||
ui_interfaces/wayland/WaylandSurface.cpp
|
||||
ui_interfaces/wayland/WaylandBuffer.cpp
|
||||
)
|
||||
set(_HAS_WAYLAND Off)
|
||||
|
||||
list(APPEND platform_LIBS
|
||||
X11 X11-xcb xcb )
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND platform_INCLUDES
|
||||
ui_interfaces/x11/XcbInterface.cpp
|
||||
ui_interfaces/x11/XcbEventInterface.cpp
|
||||
ui_interfaces/x11/XcbWindow.cpp
|
||||
ui_interfaces/x11/XcbScreen.cpp
|
||||
ui_interfaces/x11/XcbWindowInterface.cpp
|
||||
ui_interfaces/x11/XcbLayerInterface.cpp
|
||||
ui_interfaces/x11/XcbTextInterface.cpp
|
||||
ui_interfaces/x11/XcbKeyboard.cpp
|
||||
ui_interfaces/x11/GlxInterface.cpp
|
||||
)
|
||||
|
||||
list(APPEND platform_LIBS
|
||||
X11 X11-xcb xcb )
|
||||
|
||||
|
||||
find_path(
|
||||
WAYLAND_CLIENT_INCLUDE_DIR
|
||||
NAMES wayland-client.h
|
||||
)
|
||||
)
|
||||
list(APPEND WAYLAND_INCLUDE_DIRS ${WAYLAND_CLIENT_INCLUDE_DIR})
|
||||
|
||||
find_path(
|
||||
WAYLAND_EXTENSIONS_INCLUDE_DIR
|
||||
NAMES xdg-shell-client-protocol.h
|
||||
HINTS ENV WAYLAND_EXTENSION_DIR
|
||||
)
|
||||
|
||||
find_library(
|
||||
WAYLAND_CLIENT_LIBRARY
|
||||
NAMES wayland-client libwayland-client
|
||||
)
|
||||
|
||||
list(APPEND platform_INCLUDES
|
||||
ui_interfaces/win32/Win32UIInterface.h
|
||||
${WAYLAND_EXTENSIONS_INCLUDE_DIR}/xdg-shell-protocol.cpp
|
||||
)
|
||||
)
|
||||
if(NOT ${WAYLAND_EXTENSIONS_INCLUDE_DIR-NOTFOUND})
|
||||
find_library(
|
||||
WAYLAND_CLIENT_LIBRARY
|
||||
NAMES wayland-client libwayland-client
|
||||
)
|
||||
|
||||
list(APPEND WAYLAND_INCLUDE_DIRS ${WAYLAND_EXTENSIONS_INCLUDE_DIR})
|
||||
|
||||
list(APPEND platform_INCLUDES
|
||||
ui_interfaces/wayland/WaylandWindowInterface.cpp
|
||||
ui_interfaces/wayland/WaylandSurface.cpp
|
||||
ui_interfaces/wayland/WaylandBuffer.cpp
|
||||
${WAYLAND_EXTENSIONS_INCLUDE_DIR}/xdg-shell-protocol.cpp
|
||||
)
|
||||
set(_HAS_WAYLAND ON)
|
||||
else()
|
||||
message(STATUS "Wayland Extensions Header not found - not building Wayland support")
|
||||
endif()
|
||||
|
||||
else()
|
||||
list(APPEND platform_INCLUDES
|
||||
ui_interfaces/win32/Win32UIInterface.h
|
||||
ui_interfaces/win32/Win32UIInterface.cpp
|
||||
ui_interfaces/win32/Win32WindowInterface.h
|
||||
ui_interfaces/win32/Win32WindowInterface.cpp
|
||||
ui_interfaces/win32/Win32Window.h
|
||||
ui_interfaces/win32/Win32Window.cpp
|
||||
)
|
||||
list(APPEND platform_INCLUDES
|
||||
ui_interfaces/win32/Win32UIInterface.h
|
||||
ui_interfaces/win32/Win32UIInterface.cpp
|
||||
ui_interfaces/win32/Win32WindowInterface.h
|
||||
ui_interfaces/win32/Win32WindowInterface.cpp
|
||||
ui_interfaces/win32/Win32Window.h
|
||||
ui_interfaces/win32/Win32Window.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
set(HAS_WAYLAND ${_HAS_WAYLAND} CACHE BOOL "Can build with Wayland")
|
||||
|
||||
list(APPEND windows_LIB_INCLUDES
|
||||
managers/WindowManager.cpp
|
||||
managers/DesktopManager.cpp
|
||||
|
@ -73,11 +82,10 @@ target_include_directories(windows PUBLIC
|
|||
"${PROJECT_SOURCE_DIR}/src/graphics"
|
||||
"${PROJECT_SOURCE_DIR}/src/ui_elements"
|
||||
"${PROJECT_SOURCE_DIR}/src/ui_elements/widgets"
|
||||
${WAYLAND_CLIENT_INCLUDE_DIR}
|
||||
${WAYLAND_EXTENSIONS_INCLUDE_DIR}
|
||||
${WAYLAND_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(windows PUBLIC ${platform_LIBS} core geometry graphics ui_elements ${WAYLAND_CLIENT_LIBRARY})
|
||||
|
||||
set_property(TARGET windows PROPERTY FOLDER src)
|
||||
set_target_properties( windows PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
set_target_properties( windows PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
|
|
|
@ -22,12 +22,21 @@ list(APPEND TestFiles
|
|||
image/TestPngWriter.cpp
|
||||
network/TestNetworkManagerClient.cpp
|
||||
network/TestNetworkManagerServer.cpp
|
||||
publishing/TestPdfWriter.cpp
|
||||
video/TestVideoDecoder.cpp
|
||||
windows/TestWaylandWindow.cpp
|
||||
web/TestMarkdownParser.cpp
|
||||
web/TestSvgWriter.cpp
|
||||
publishing/TestPdfWriter.cpp
|
||||
web/TestMarkdownParser.cpp
|
||||
web/TestXmlParser.cpp)
|
||||
|
||||
if (${HAS_FFMPEG})
|
||||
list(APPEND TestFiles
|
||||
video/TestVideoDecoder.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (${HAS_WAYLAND})
|
||||
list(APPEND TestFiles
|
||||
windows/TestWaylandWindow.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig)
|
||||
pkg_check_modules(DBUS dbus-1)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "Image.h"
|
||||
#include "PngWriter.h"
|
||||
#include "PngWriterImpl.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "Image.h"
|
||||
#include "FfmpegInterface.h"
|
||||
#include "PngWriter.h"
|
||||
#include "PngWriterImpl.h"
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
|
|
Loading…
Reference in a new issue