Compare commits
No commits in common. "19a0e409771dc82158fb5edb154736fd4dd3575b" and "e77b61b1d98e7e418837a4096c8dd14c40f3b092" have entirely different histories.
19a0e40977
...
e77b61b1d9
68
cmake/Qt.cmake
Normal file
68
cmake/Qt.cmake
Normal file
@ -0,0 +1,68 @@
|
||||
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
|
||||
include_directories(${Qt5_INCLUDES} ${Qt5_DIR})
|
||||
|
||||
file(READ "${CMAKE_SOURCE_DIR}/res/moc.txt" moclist)
|
||||
string(REGEX REPLACE "\n" ";" moclist ${moclist}) # split into array by line
|
||||
|
||||
# note: i am aware of the existence of qt5_wrap_cpp and friends, but those functions
|
||||
# aren't aware of my code generator so i have to do it myself
|
||||
# also, qt5_wrap_ui just dumps headers in the root of the build dir. ew.
|
||||
|
||||
if(NOT QT_UIC_EXECUTABLE)
|
||||
string(REPLACE moc uic QT_UIC_EXECUTABLE "${QT_MOC_EXECUTABLE}")
|
||||
endif()
|
||||
|
||||
set(mocsources)
|
||||
set(qtcogged FALSE)
|
||||
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/src/qtgenerated")
|
||||
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/src/qtgenerated")
|
||||
endif()
|
||||
foreach(mocfile ${moclist})
|
||||
if(EXISTS ${CMAKE_SOURCE_DIR}/${mocfile})
|
||||
string(REGEX REPLACE ".h\$" ".cpp" implfile_rel "${mocfile}")
|
||||
string(REGEX REPLACE "include/" "src/qtgenerated/moc_" implfile_rel "${implfile_rel}")
|
||||
set(implfile_abs "${CMAKE_CURRENT_BINARY_DIR}/${implfile_rel}")
|
||||
add_custom_command(OUTPUT "${implfile_abs}" PRE_BUILD
|
||||
COMMAND ${QT_MOC_EXECUTABLE} -o "${implfile_abs}" "${CMAKE_SOURCE_DIR}/${mocfile}"
|
||||
DEPENDS "${CMAKE_SOURCE_DIR}/${mocfile}"
|
||||
COMMENT "Qt MOC: ${BoldCyan}${mocfile}${ColourReset}")
|
||||
elseif(EXISTS ${CMAKE_SOURCE_DIR}/${mocfile}.cog)
|
||||
set(qtcogged TRUE)
|
||||
string(REGEX REPLACE ".h\$" ".cpp" implfile_rel "${mocfile}")
|
||||
string(REGEX REPLACE "include/" "src/qtgenerated/moc_" implfile_rel "${implfile_rel}")
|
||||
set(implfile_abs "${CMAKE_CURRENT_BINARY_DIR}/${implfile_rel}")
|
||||
add_custom_command(OUTPUT "${implfile_abs}" PRE_BUILD
|
||||
COMMAND ${QT_MOC_EXECUTABLE} -o "${implfile_abs}" "${CMAKE_CURRENT_BINARY_DIR}/${mocfile}"
|
||||
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${mocfile}"
|
||||
COMMENT "Qt MOC: ${BoldCyan}${mocfile}${ColourReset}")
|
||||
endif()
|
||||
|
||||
set(mocsources ${mocsources} "${implfile_abs}")
|
||||
endforeach()
|
||||
|
||||
file(GLOB_RECURSE uilist RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/res/ui/*.ui")
|
||||
set(uicsources)
|
||||
foreach(uifile ${uilist})
|
||||
string(REGEX REPLACE "res/ui/" "" uiname ${uifile})
|
||||
string(REGEX REPLACE ".ui\$" "" uiname ${uiname})
|
||||
string(REGEX REPLACE "/" "_" uiname ${uiname})
|
||||
# res/ui/dlg/license.ui should result in ${uiname} being "dlg_license" at this point
|
||||
|
||||
set(headerfile "${CMAKE_CURRENT_BINARY_DIR}/include/ui_${uiname}.h")
|
||||
|
||||
add_custom_command(OUTPUT "${headerfile}" PRE_BUILD
|
||||
# TODO: not hardcode this path
|
||||
COMMAND ${QT_UIC_EXECUTABLE} -o "${headerfile}" "${CMAKE_SOURCE_DIR}/${uifile}"
|
||||
DEPENDS "${CMAKE_SOURCE_DIR}/${uifile}"
|
||||
COMMENT "Qt UIC: ${BoldCyan}${uifile}${ColourReset}")
|
||||
|
||||
set(uicsources ${uicsources} "${headerfile}")
|
||||
endforeach()
|
||||
|
||||
add_library(qtgenerated STATIC ${mocsources} ${uicsources})
|
||||
target_link_libraries(qtgenerated Qt5::Core Qt5::Widgets)
|
||||
if (qtcogged)
|
||||
add_dependencies(qtgenerated cog)
|
||||
endif()
|
||||
|
||||
message(STATUS "Found Qt: ${Qt5_VERSION}")
|
37
cmake/Sphinx.cmake
Normal file
37
cmake/Sphinx.cmake
Normal file
@ -0,0 +1,37 @@
|
||||
find_program(DVIPNG dvipng)
|
||||
find_program(DVISVGM dvisvgm)
|
||||
find_program(SPHINX_BUILD sphinx-build)
|
||||
|
||||
if(NOT DOCS_TOO)
|
||||
set(DOCS_TOO 0)
|
||||
endif()
|
||||
|
||||
if(NOT DVIPNG OR NOT DVISVGM OR NOT SPHINX_BUILD)
|
||||
message(WARNING "${BoldYellow}Cannot build library documentation.${ColourReset}")
|
||||
|
||||
# report what's missing
|
||||
if(NOT DVIPNG)
|
||||
message(WARNING " dvipng not installed.")
|
||||
endif()
|
||||
if(NOT DVISVGM)
|
||||
message(WARNING " dvisvgm not installed.")
|
||||
endif()
|
||||
if(NOT SPHINX_BUILD)
|
||||
message(WARNING " Sphinx not installed.")
|
||||
endif()
|
||||
|
||||
if (DOCS_TOO EQUAL 1)
|
||||
message(FATAL_ERROR "${BoldRed}This is a problem, since you specified DOCS_TOO.${ColourReset}")
|
||||
endif()
|
||||
else()
|
||||
if(DOCS_TOO EQUAL 1)
|
||||
set(MAYBE_ALL ALL)
|
||||
else()
|
||||
message(STATUS "${Green}Not building docs automatically. Build them with: ${BoldGreen}${CMAKE_MAKE_PROGRAM} sphinx${ColourReset}
|
||||
An alternative strategy would be to run CMake again with ${BoldYellow}-DDOCS_TOO=1${ColourReset}")
|
||||
set(MAYBE_ALL "")
|
||||
endif()
|
||||
|
||||
add_custom_target(sphinx ${MAYBE_ALL}
|
||||
COMMAND ${SPHINX_BUILD} -b html "${CMAKE_SOURCE_DIR}/doc/sphinx" "${CMAKE_CURRENT_BINARY_DIR}/doc")
|
||||
endif()
|
@ -1,5 +1,4 @@
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -8,7 +7,6 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "tclap/CmdLine.h"
|
||||
|
||||
#include "bottles.hpp"
|
||||
#include "output.hpp"
|
||||
#include "paths.hpp"
|
||||
#include "version.hpp"
|
||||
@ -24,6 +22,10 @@ string cellar::paths::translate(std::string in_path, bool lazy) {
|
||||
|
||||
windows_input = regex_match(in_path.substr(0, 3), drive_letter_rgx);
|
||||
|
||||
if (!lazy) {
|
||||
output::warning("non-lazy path translation is not implemented yet");
|
||||
}
|
||||
|
||||
if (windows_input) {
|
||||
if (lazy) {
|
||||
if (boost::algorithm::to_lower_copy(in_path.substr(0,1)) != "z") {
|
||||
@ -42,51 +44,14 @@ string cellar::paths::translate(std::string in_path, bool lazy) {
|
||||
return paths::resolve_drive_letter(in_path);
|
||||
}
|
||||
} else {
|
||||
string out_path;
|
||||
string str_absolutepath = filesystem::canonical(in_path);
|
||||
// lazy
|
||||
string out_path = "Z:";
|
||||
out_path.append(in_path);
|
||||
|
||||
if (lazy) {
|
||||
out_path = "Z:";
|
||||
out_path.append(str_absolutepath);
|
||||
|
||||
size_t slashpos = out_path.find("/");
|
||||
while (slashpos != std::string::npos) {
|
||||
out_path.replace(slashpos, 1, "\\");
|
||||
slashpos = out_path.find("/");
|
||||
}
|
||||
} else {
|
||||
map<string, string> dct_drives;
|
||||
for (auto hnd_curitem : filesystem::directory_iterator(filesystem::path(bottles::active_bottle.canonical_path) / "dosdevices")) {
|
||||
auto pth_curitem = hnd_curitem.path();
|
||||
dct_drives.insert_or_assign(pth_curitem.filename().string(), filesystem::canonical(pth_curitem));
|
||||
}
|
||||
|
||||
for (auto hnd_curdrive : dct_drives) {
|
||||
size_t sz_drivelen = hnd_curdrive.second.length();
|
||||
size_t sz_findpos = in_path.rfind(hnd_curdrive.second, 0);
|
||||
if (sz_findpos == 0) {
|
||||
out_path.append(hnd_curdrive.first);
|
||||
out_path.append(in_path.substr(sz_drivelen));
|
||||
|
||||
size_t slashpos = out_path.find("/");
|
||||
while (slashpos != std::string::npos) {
|
||||
out_path.replace(slashpos, 1, "\\");
|
||||
slashpos = out_path.find("/");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we're here, it's not on a drive letter. use Z:
|
||||
out_path = "Z:";
|
||||
out_path.append(str_absolutepath);
|
||||
|
||||
size_t slashpos = out_path.find("/");
|
||||
while (slashpos != std::string::npos) {
|
||||
out_path.replace(slashpos, 1, "\\");
|
||||
slashpos = out_path.find("/");
|
||||
}
|
||||
size_t slashpos = out_path.find("/");
|
||||
while (slashpos != std::string::npos) {
|
||||
out_path.replace(slashpos, 1, "\\");
|
||||
slashpos = out_path.find("/");
|
||||
}
|
||||
|
||||
return out_path;
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include <exception>
|
||||
#include <filesystem>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
@ -13,7 +12,6 @@
|
||||
using namespace std;
|
||||
|
||||
string cellar::paths::resolve_drive_letter(string in_path) {
|
||||
filesystem::path lastwd = filesystem::current_path();
|
||||
bool windows_input;
|
||||
static regex drive_letter_rgx(R"([a-zA-Z]:\\)");
|
||||
|
||||
@ -27,7 +25,6 @@ string cellar::paths::resolve_drive_letter(string in_path) {
|
||||
string link_path = "";
|
||||
link_path.append(bottles::active_bottle.canonical_path);
|
||||
link_path.append("/dosdevices/");
|
||||
filesystem::current_path(filesystem::path(link_path));
|
||||
link_path.append(drive_letter);
|
||||
|
||||
char stringbuffer[512];
|
||||
@ -35,9 +32,7 @@ string cellar::paths::resolve_drive_letter(string in_path) {
|
||||
|
||||
if (bufflen != -1) {
|
||||
stringbuffer[bufflen] = '\0';
|
||||
string str_absolutepath = filesystem::canonical(stringbuffer);
|
||||
out_path.append(str_absolutepath);
|
||||
out_path.append("/");
|
||||
out_path.append(stringbuffer);
|
||||
} else {
|
||||
throw runtime_error("readlink isn't having it");
|
||||
}
|
||||
@ -52,6 +47,5 @@ string cellar::paths::resolve_drive_letter(string in_path) {
|
||||
out_path.append(rest_of_path);
|
||||
}
|
||||
|
||||
filesystem::current_path(lastwd);
|
||||
return out_path;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user