From 4a967682d48ed16db75f787976e99cd97df28356 Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 7 Feb 2021 12:47:49 +0100 Subject: Make inital test run on debian, ubuntu, arch, fedora --- MANIFEST.in | 1 + README.rst | 31 +- podman/arch-testenv | 9 + podman/debian-testenv | 11 + podman/fedora-testenv | 7 + podman/testdata/gerbolyze-2.0.0.tar.gz | Bin 0 -> 830632 bytes podman/testdata/test_svg_readme.svg | 515 +++++++++++++++++++++++++++++++++ podman/testdata/testscript.sh | 5 + podman/ubuntu-testenv | 7 + run-tests.sh | 14 + svg-flatten/Makefile | 7 +- svg-flatten/src/main.cpp | 10 +- 12 files changed, 598 insertions(+), 19 deletions(-) create mode 100644 podman/arch-testenv create mode 100644 podman/debian-testenv create mode 100644 podman/fedora-testenv create mode 100644 podman/testdata/gerbolyze-2.0.0.tar.gz create mode 100644 podman/testdata/test_svg_readme.svg create mode 100755 podman/testdata/testscript.sh create mode 100644 podman/ubuntu-testenv create mode 100755 run-tests.sh diff --git a/MANIFEST.in b/MANIFEST.in index 58a8c1f..031eca7 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -7,3 +7,4 @@ recursive-exclude upstream/poisson-disk-sampling/images * recursive-exclude upstream/clipper-6.4.2/Documentation * recursive-exclude upstream/CavalierContours tests/* examples/* recursive-exclude upstream/argagg doc/* examples/* tests/* +recursive-exclude svg-flatten/build * diff --git a/README.rst b/README.rst index 15aa176..10007e8 100644 --- a/README.rst +++ b/README.rst @@ -73,13 +73,18 @@ Note: rustup default stable cargo install usvg + pip3 install --user gerbolyze --no-binary gerbolyze - git clone --recurse-submodules https://git.jaseg.de/gerbolyze.git - cd gerbolyze +Ubuntu +~~~~~~ + +.. code-block:: shell + + sudo apt install libopencv-dev libpugixml-dev libpangocairo-1.0-0 libpango1.0-dev libcairo2-dev clang make python3 git python3-wheel curl python3-pip python3-venv cargo + cargo install usvg + + pip3 install --user gerbolyze --no-binary gerbolyze - python3 -m venv - source venv/bin/activate - python3 setup.py install Fedora ~~~~~~ @@ -89,12 +94,7 @@ Fedora sudo dnf install python3 make clang opencv-devel pugixml-devel pango-devel cairo-devel rust cargo cargo install usvg - git clone --recurse-submodules https://git.jaseg.de/gerbolyze.git - cd gerbolyze - - python3 -m venv - source venv/bin/activate - python3 setup.py install + pip3 install --user gerbolyze --no-binary gerbolyze Arch ~~~~ @@ -107,6 +107,15 @@ Arch rustup default stable cargo install usvg + pip3 install --user gerbolyze --no-binary gerbolyze + +Build from source (any distro) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +First, install prerequisites like shown above. Then, + +.. code-block:: shell + git clone --recurse-submodules https://git.jaseg.de/gerbolyze.git cd gerbolyze diff --git a/podman/arch-testenv b/podman/arch-testenv new file mode 100644 index 0000000..37236c9 --- /dev/null +++ b/podman/arch-testenv @@ -0,0 +1,9 @@ + +FROM docker.io/archlinux:latest +MAINTAINER gerbolyze@jaseg.de +RUN pacman --noconfirm -Syu +RUN pacman --noconfirm -Sy pugixml opencv pango cairo git python make clang rustup cargo python-pip base-devel +RUN rustup install stable +RUN rustup default stable +RUN cargo install usvg + diff --git a/podman/debian-testenv b/podman/debian-testenv new file mode 100644 index 0000000..544b3f2 --- /dev/null +++ b/podman/debian-testenv @@ -0,0 +1,11 @@ + +FROM docker.io/debian:latest +MAINTAINER gerbolyze@jaseg.de +RUN env DEBIAN_FRONTEND=noninteractive apt update -y +RUN env DEBIAN_FRONTEND=noninteractive apt install -y libopencv-dev libpugixml-dev libpangocairo-1.0-0 libpango1.0-dev libcairo2-dev clang make python3 git python3-wheel curl python3-pip python3-venv + +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +RUN sh -c '. ~/.cargo/env && rustup install stable' +RUN sh -c '. ~/.cargo/env && rustup default stable' +RUN sh -c '. ~/.cargo/env && cargo install usvg' + diff --git a/podman/fedora-testenv b/podman/fedora-testenv new file mode 100644 index 0000000..c37de87 --- /dev/null +++ b/podman/fedora-testenv @@ -0,0 +1,7 @@ + +FROM docker.io/fedora:latest +MAINTAINER gerbolyze@jaseg.de +RUN dnf update --refresh -y +RUN dnf install -y python3 make clang opencv-devel pugixml-devel pango-devel cairo-devel rust cargo +RUN cargo install usvg + diff --git a/podman/testdata/gerbolyze-2.0.0.tar.gz b/podman/testdata/gerbolyze-2.0.0.tar.gz new file mode 100644 index 0000000..50b2da0 Binary files /dev/null and b/podman/testdata/gerbolyze-2.0.0.tar.gz differ diff --git a/podman/testdata/test_svg_readme.svg b/podman/testdata/test_svg_readme.svg new file mode 100644 index 0000000..1a0178e --- /dev/null +++ b/podman/testdata/test_svg_readme.svg @@ -0,0 +1,515 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + सर्वे मानवाः स्वतन्त्राः समुत्पन्नाः वर्तन्ते अपि च, गौरवदृशा + + + + + لكن لا بد أن أوضح لك أن كل هذه الأفكار المغلوطة حول استنكار + + This is a gerber export test + + diff --git a/podman/testdata/testscript.sh b/podman/testdata/testscript.sh new file mode 100755 index 0000000..59d8b0e --- /dev/null +++ b/podman/testdata/testscript.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +pip3 install --user /data/gerbolyze-*.tar.gz --no-binary gerbolyze +/root/.local/bin/svg-flatten --clear-color black --dark-color white --format svg /data/test_svg_readme.svg /out/test_out.svg + diff --git a/podman/ubuntu-testenv b/podman/ubuntu-testenv new file mode 100644 index 0000000..2665d9b --- /dev/null +++ b/podman/ubuntu-testenv @@ -0,0 +1,7 @@ + +FROM docker.io/ubuntu:latest +MAINTAINER gerbolyze@jaseg.de +RUN env DEBIAN_FRONTEND=noninteractive apt update -y +RUN env DEBIAN_FRONTEND=noninteractive apt install -y libopencv-dev libpugixml-dev libpangocairo-1.0-0 libpango1.0-dev libcairo2-dev clang make python3 git python3-wheel curl python3-pip python3-venv cargo +RUN cargo install usvg + diff --git a/run-tests.sh b/run-tests.sh new file mode 100755 index 0000000..dae718b --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e + +python setup.py sdist build +cp dist/*.tar.gz podman/testdata + +for distro in arch fedora debian ubuntu +do + podman build -t gerbolyze-$distro-testenv -f podman/$distro-testenv + mkdir -p /tmp/gerbolyze-test-out + podman run --mount type=bind,src=podman/testdata,dst=/data,ro --mount type=bind,src=/tmp/gerbolyze-test-out,dst=/out gerbolyze-$distro-testenv /data/testscript.sh +done + diff --git a/svg-flatten/Makefile b/svg-flatten/Makefile index 88619fc..25c8048 100644 --- a/svg-flatten/Makefile +++ b/svg-flatten/Makefile @@ -1,6 +1,6 @@ CXX := clang++ -LD := ld +LD ?= ld INSTALL := install PKG_CONFIG ?= pkg-config @@ -46,7 +46,8 @@ CXXFLAGS += $(shell $(PKG_CONFIG) --cflags opencv4 2> /dev/null || $(PKG_CONFIG) 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) +OPENCV_LDFLAGS := $(shell $(PKG_CONFIG) --libs opencv4 2> /dev/null || $(PKG_CONFIG) --libs opencv 2>/dev/null) +LDFLAGS += $(shell echo $(OPENCV_LDFLAGS) | sed 's/-l\S\+ //g') -lopencv_core -lopencv_imgproc -lopencv_imgcodecs TARGET := svg-flatten @@ -65,7 +66,7 @@ $(BUILDDIR)/%.o: %.cpp $(BUILDDIR)/$(TARGET): $(SOURCES:%.cpp=$(BUILDDIR)/%.o) @mkdir -p $(dir $@) - $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^ -lstdc++fs + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ -Wl,--start-group $^ -lstdc++fs -Wl,--end-group .PHONY: install install: diff --git a/svg-flatten/src/main.cpp b/svg-flatten/src/main.cpp index e120a9c..3427373 100644 --- a/svg-flatten/src/main.cpp +++ b/svg-flatten/src/main.cpp @@ -168,7 +168,7 @@ int main(int argc, char **argv) { precision = atoi(args["precision"]); } - string fmt = args["ofmt"] ? args["ofmt"] : "gerber"; + string fmt = args["ofmt"] ? args["ofmt"].as() : "gerber"; transform(fmt.begin(), fmt.end(), fmt.begin(), [](unsigned char c){ return std::tolower(c); }); /* c++ yeah */ string sexp_layer = args["sexp_layer"] ? args["sexp_layer"].as() : "auto"; @@ -179,8 +179,8 @@ int main(int argc, char **argv) { PolygonSink *flattener = nullptr; PolygonSink *dilater = nullptr; if (fmt == "svg") { - string dark_color = args["svg_dark_color"] ? args["svg_dark_color"] : "#000000"; - string clear_color = args["svg_clear_color"] ? args["svg_clear_color"] : "#ffffff"; + string dark_color = args["svg_dark_color"] ? args["svg_dark_color"].as() : "#000000"; + string clear_color = args["svg_clear_color"] ? args["svg_clear_color"].as() : "#ffffff"; sink = new SimpleSVGOutput(*out_f, only_polys, precision, dark_color, clear_color); } else if (fmt == "gbr" || fmt == "grb" || fmt == "gerber") { @@ -232,7 +232,7 @@ int main(int argc, char **argv) { sel.layers = &gerbolyze::kicad_default_layers; } - string vectorizer = args["vectorizer"] ? args["vectorizer"] : "poisson-disc"; + string vectorizer = args["vectorizer"] ? args["vectorizer"].as() : "poisson-disc"; /* Check argument */ ImageVectorizer *vec = makeVectorizer(vectorizer); if (!vec) { @@ -408,7 +408,7 @@ int main(int argc, char **argv) { } } - VectorizerSelectorizer vec_sel(vectorizer, args["vectorizer_map"] ? args["vectorizer_map"] : ""); + VectorizerSelectorizer vec_sel(vectorizer, args["vectorizer_map"] ? args["vectorizer_map"].as() : ""); RenderSettings rset { min_feature_size, vec_sel, -- cgit