Work on fedora/debian compatibility

This commit is contained in:
jaseg 2021-02-06 00:05:27 +01:00
parent bf428103d3
commit 8c494f7736
4 changed files with 25 additions and 8 deletions

View file

@ -58,9 +58,18 @@ Debian
Step 1: Install dependencies
****************************
.. note::
Right now, debian stable ships with a rust that is so stable it can't even build half of usvg's dependencies. That's
why we yolo-install our own rust here. Sorry about that. I guess it'll work with the packaged rust on sid.
.. code-block:: shell
sudo apt install libopencv-dev libpugixml-dev libpangocairo-1.0-0 libpango1.0-dev libcairo2-dev clang make python3 rustc cargo git python3-wheel
git clone --recurse-submodules https://git.jaseg.de/gerbolyze.git
cd gerbolyze
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
sudo apt install libopencv-dev libpugixml-dev libpangocairo-1.0-0 libpango1.0-dev libcairo2-dev clang make python3 git python3-wheel curl
python3 setup.py install
Fedora
~~~~~~
@ -70,6 +79,8 @@ Step 1: Install dependencies
.. code-block:: shell
git clone --recurse-submodules https://git.jaseg.de/gerbolyze.git
cd gerbolyze
sudo dnf install python3 make clang opencv-devel pugixml-devel pango-devel cairo-devel rust cargo
Arch

View file

@ -37,12 +37,16 @@ SUBPROCESS_INCLUDES ?= -I$(UPSTREAM_DIR)/subprocess.h
SOURCES += $(CLIPPER_SOURCES)
INCLUDES := -Iinclude -Isrc $(CLIPPER_INCLUDES) $(VORONOI_INCLUDES) $(POISSON_INCLUDES) $(BASE64_INCLUDES) $(ARGAGG_INCLUDES) $(CAVC_INCLUDES) $(SUBPROCESS_INCLUDES)
PKG_CONFIG_DEPS := pangocairo pugixml opencv4
PKG_CONFIG_DEPS := pangocairo pugixml
CXXFLAGS := -std=c++2a -g -Wall -Wextra -O0
CXXFLAGS += $(shell $(PKG_CONFIG) --cflags $(PKG_CONFIG_DEPS))
# hack for stone age opencv in debian stable
CXXFLAGS += $(shell $(PKG_CONFIG) --cflags opencv4 2> /dev/null || $(PKG_CONFIG) --cflags opencv 2>/dev/null)
LDFLAGS := -lm -lc -lstdc++
LDFLAGS += $(shell $(PKG_CONFIG) --libs $(PKG_CONFIG_DEPS))
# debian hack. see above.
LDFLAGS += $(shell $(PKG_CONFIG) --libs opencv4 2> /dev/null || $(PKG_CONFIG) --libs opencv 2>/dev/null)
TARGET := svg-flatten
@ -51,7 +55,9 @@ all: $(BUILDDIR)/$(TARGET)
.PHONY: check-deps
check-deps:
@echo
@$(PKG_CONFIG) --cflags --libs $(PKG_CONFIG_DEPS) >/dev/null
@$(PKG_CONFIG) --cflags --libs pangocairo pugixml >/dev/null
# debian hack. see above.
@$(PKG_CONFIG) --cflags --libs opencv4 >/dev/null ||$(PKG_CONFIG) --cflags --libs opencv >/dev/null
$(BUILDDIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@ -59,7 +65,7 @@ $(BUILDDIR)/%.o: %.cpp
$(BUILDDIR)/$(TARGET): $(SOURCES:%.cpp=$(BUILDDIR)/%.o)
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -lstdc++fs
.PHONY: install
install:

View file

@ -95,14 +95,14 @@ bool gerbolyze::SVGDocument::load(istream &in, string debug_out_filename) {
const Paths *gerbolyze::SVGDocument::lookup_clip_path(const pugi::xml_node &node) {
string id(usvg_id_url(node.attribute("clip-path").value()));
if (id.empty() || !clip_path_map.contains(id)) {
if (id.empty() || clip_path_map.count(id) == 0) {
return nullptr;
}
return &clip_path_map[id];
}
Pattern *gerbolyze::SVGDocument::lookup_pattern(const string id) {
if (id.empty() || !pattern_map.contains(id)) {
if (id.empty() || pattern_map.count(id) == 0) {
return nullptr;
}
return &pattern_map[id];
@ -484,7 +484,7 @@ void gerbolyze::SVGDocument::load_clips() {
/* Support clip paths that themselves have clip paths */
if (!meta_clip_path_id.empty()) {
if (clip_path_map.contains(meta_clip_path_id)) {
if (clip_path_map.count(meta_clip_path_id) > 0) {
/* all clip paths must be closed */
c.AddPaths(clip_path_map[meta_clip_path_id], ptClip, /* closed */ true);

View file

@ -556,7 +556,7 @@ gerbolyze::VectorizerSelectorizer::VectorizerSelectorizer(const string default_v
ImageVectorizer *gerbolyze::VectorizerSelectorizer::select(const pugi::xml_node &img) {
const string id = img.attribute("id").value();
cerr << "selecting vectorizer for image \"" << id << "\"" << endl;
if (m_map.contains(id)) {
if (m_map.count(id) > 0) {
cerr << " -> found" << endl;
return makeVectorizer(m_map[id]);
}