aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/CMakeLists.txt4
-rw-r--r--cli/generate-header.cpp21
2 files changed, 13 insertions, 12 deletions
diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt
index f3dd326..6cad70c 100644
--- a/cli/CMakeLists.txt
+++ b/cli/CMakeLists.txt
@@ -15,8 +15,8 @@ install(TARGETS generate-header
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
-install(DIRECTORY ../template/
- DESTINATION share/kicad-utils/template
+install(DIRECTORY ../templates/
+ DESTINATION share/kicad-utils/templates
FILES_MATCHING PATTERN *.py
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
diff --git a/cli/generate-header.cpp b/cli/generate-header.cpp
index 6fd64c6..9d5a4f4 100644
--- a/cli/generate-header.cpp
+++ b/cli/generate-header.cpp
@@ -21,15 +21,15 @@ namespace py = pybind11;
#include <cstring>
#include <experimental/filesystem>
+using namespace std;
+namespace fs = std::experimental::filesystem;
+
#ifdef _WIN32
-static const char PATH_SEPARATOR = ';';
+static string PATH_SEPARATOR(";");
#else
-static const char PATH_SEPARATOR = ':';
+static string PATH_SEPARATOR(":");
#endif
-using namespace std;
-namespace fs = std::experimental::filesystem;
-
char *program;
__attribute__((noreturn))
@@ -118,9 +118,9 @@ opt<fs::path> find_py_template(const string &py_template, const vector<fs::path>
bool generate(const string &ref, nl *const netlist, stringstream &out, const fs::path &py_template) {
py::dict vars;
- pybind11::module kicad_utils_py_module = py::module::import("kicad_utils_py");
- pybind11::module main_module = py::module::import("__main__");
- vars = main_module.attr("__dict__");
+ py::module::import("kicad_utils_py");
+ vars = py::module::import("__main__").
+ attr("__dict__");
pybind11::object netlist_py = py::cast(netlist);
@@ -128,7 +128,8 @@ bool generate(const string &ref, nl *const netlist, stringstream &out, const fs:
vars["ref"] = py::cast(ref);
string init;
- init += "generateHeader = GenerateHeader(ref, netlist)\n";
+ init += "import kicad_utils_py\n";
+ init += "generateHeader = kicad_utils_py.GenerateHeader(ref, netlist)\n";
init += "del ref\n";
init += "del netlist\n";
py::eval<py::eval_mode::eval_statements>(init, vars);
@@ -210,7 +211,7 @@ int main(int argc, char **argv) {
struct opts opts = parse_args(argc, argv);
opts.template_libs.push_back(fs::current_path());
- opts.template_libs.push_back(basedir / "share" / "kicad-utils" / "template");
+ opts.template_libs.push_back(basedir / "share" / "kicad-utils" / "templates");
kicad_net_loader loader;