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
|
@ -28,3 +28,13 @@ target_link_libraries(sample_console PUBLIC console core network
|
|||
|
||||
set_property(TARGET sample_console 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>;
|
||||
|
|
|
@ -8,6 +8,8 @@ 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,24 +1,18 @@
|
|||
list(APPEND video_HEADERS
|
||||
Video.h
|
||||
FfmpegInterface.h
|
||||
BasicVideoConverter.h
|
||||
IVideoConverter.h
|
||||
)
|
||||
|
||||
list(APPEND video_LIB_INCLUDES
|
||||
Video.cpp
|
||||
FfmegInterface.cpp
|
||||
BasicVideoConverter.cpp
|
||||
)
|
||||
|
||||
add_library(video SHARED ${video_LIB_INCLUDES} ${video_HEADERS})
|
||||
|
||||
target_include_directories(video PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
set_target_properties( video PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
|
||||
list(APPEND video_LIBS image)
|
||||
list(APPEND video_DEFINES "")
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
set(_HAS_FFMPEG Off)
|
||||
if(PkgConfig)
|
||||
pkg_check_modules(LIBAV IMPORTED_TARGET
|
||||
libavdevice
|
||||
|
@ -30,11 +24,27 @@ pkg_check_modules(LIBAV IMPORTED_TARGET
|
|||
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}")
|
||||
set_target_properties( video PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON )
|
||||
|
||||
list(APPEND video_LIBS image)
|
||||
|
||||
target_link_libraries( video PUBLIC ${video_LIBS})
|
||||
|
||||
|
||||
set_property(TARGET video PROPERTY FOLDER src)
|
0
src/video/IVideoConverter.h
Normal file
0
src/video/IVideoConverter.h
Normal file
|
@ -1,6 +1,8 @@
|
|||
set (platform_INCLUDES "")
|
||||
set (platform_LIBS "")
|
||||
|
||||
set(_HAS_WAYLAND Off)
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND platform_INCLUDES
|
||||
ui_interfaces/x11/XcbInterface.cpp
|
||||
|
@ -12,10 +14,6 @@ list(APPEND platform_INCLUDES
|
|||
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
|
||||
)
|
||||
|
||||
list(APPEND platform_LIBS
|
||||
|
@ -26,22 +24,31 @@ list(APPEND platform_LIBS
|
|||
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
|
||||
)
|
||||
|
||||
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/win32/Win32UIInterface.h
|
||||
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
|
||||
|
@ -54,6 +61,8 @@ list(APPEND platform_INCLUDES
|
|||
)
|
||||
endif()
|
||||
|
||||
set(HAS_WAYLAND ${_HAS_WAYLAND} CACHE BOOL "Can build with Wayland")
|
||||
|
||||
list(APPEND windows_LIB_INCLUDES
|
||||
managers/WindowManager.cpp
|
||||
managers/DesktopManager.cpp
|
||||
|
@ -73,8 +82,7 @@ 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})
|
||||
|
|
|
@ -23,12 +23,21 @@ list(APPEND TestFiles
|
|||
network/TestNetworkManagerClient.cpp
|
||||
network/TestNetworkManagerServer.cpp
|
||||
publishing/TestPdfWriter.cpp
|
||||
video/TestVideoDecoder.cpp
|
||||
windows/TestWaylandWindow.cpp
|
||||
web/TestMarkdownParser.cpp
|
||||
web/TestSvgWriter.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)
|
||||
include_directories(${DBUS_INCLUDE_DIRS})
|
||||
|
|
|
@ -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