aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-07-29 00:39:45 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2016-07-29 00:39:45 +0200
commitc307e9f234e544386fa3ae53083c7510668e1716 (patch)
treebfca2e97330c05cc5d40e3193b2a138eb6c5a963
parentf9c8c5da8de36b0f95bc92e37e15d299b434c03f (diff)
downloadkicad-utils-c307e9f234e544386fa3ae53083c7510668e1716.tar.gz
kicad-utils-c307e9f234e544386fa3ae53083c7510668e1716.tar.bz2
kicad-utils-c307e9f234e544386fa3ae53083c7510668e1716.tar.xz
kicad-utils-c307e9f234e544386fa3ae53083c7510668e1716.zip
o Renaming cmake function from kicad_gen to kicad_generate_header, more to the point.
o Renaming binary from kicad_gen to generate-header too. Should probably be kicad-utils-generate-header or somesuch later. o Moving the cmake code used by the examples into its own file, should be part of the installation target later on.
-rw-r--r--.gitmodules4
-rw-r--r--CMakeLists.txt63
-rw-r--r--examples/arduino-led/CMakeLists.txt4
-rw-r--r--examples/arduino-led/schematic.h1
-rw-r--r--examples/intel-quark-d2000/CMakeLists.txt4
-rw-r--r--examples/intel-quark-d2000/schematic.h1
-rw-r--r--generate-header.cpp (renamed from main.cpp)4
-rw-r--r--kicad.cmake43
8 files changed, 61 insertions, 63 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..a84f300
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,4 @@
+[submodule "pybind11"]
+ path = pybind11
+ url = https://github.com/pybind/pybind11.git
+ branch = master
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff91ac6..926f7c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,62 +4,15 @@ project(kicad_utils)
find_package(Antlr4)
antlr4_add_target(TARGET KicadNet LEXER KicadNetLexer.g4 PARSER KicadNetParser.g4 STATIC)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
-set(SOURCE_FILES main.cpp kicad.cpp include/trygvis/kicad.h include-priv/trygvis/antlr.h include-priv/trygvis/string_utils.h)
-add_executable(kicad_utils ${SOURCE_FILES})
-target_include_directories(kicad_utils PUBLIC include PRIVATE include-priv)
-target_link_libraries(kicad_utils KicadNet Antlr4::antlr4_shared)
-target_compile_options(kicad_utils PUBLIC --std=c++14)
-target_compile_options(kicad_utils PUBLIC -Wall -Wextra)
+set(SOURCE_FILES generate-header.cpp kicad.cpp include/trygvis/kicad.h include-priv/trygvis/antlr.h include-priv/trygvis/string_utils.h)
+add_executable(generate-header ${SOURCE_FILES})
+target_include_directories(generate-header PUBLIC include PRIVATE include-priv)
+target_link_libraries(generate-header KicadNet Antlr4::antlr4_shared)
+target_compile_options(generate-header PUBLIC --std=c++14)
+target_compile_options(generate-header PUBLIC -Wall -Wextra)
+include(kicad.cmake)
add_custom_target(all_examples)
-
-function(kicad_gen)
- set(options IN_SOURCE)
- set(oneValueArgs TARGET NET REF OUTPUT_DIR)
-
- cmake_parse_arguments(kicad_gen "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- if (NOT kicad_gen_TARGET)
- message(FATAL_ERROR "TARGET is required")
- endif ()
- set(TARGET "${kicad_gen_TARGET}")
-
- if (NOT kicad_gen_NET)
- message(FATAL_ERROR "NET is required")
- endif ()
- set(NET "${CMAKE_CURRENT_SOURCE_DIR}/${kicad_gen_NET}")
-
- if (NOT kicad_gen_REF)
- message(FATAL_ERROR "REF is required")
- endif ()
- set(REF "${kicad_gen_REF}")
-
- if (kicad_gen_OUTPUT_DIR)
- if (kicad_gen_IN_SOURCE)
- message(FATAL_ERROR "IN_SOURCE can't be used if OUTPUT_DIR is used")
- endif ()
-
- set(OUTPUT_DIR "${kicad_gen_OUTPUT_DIR}")
- else ()
- message("IN_SOURCE=${kicad_gen_IN_SOURCE}")
- if (kicad_gen_IN_SOURCE)
- set(OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
- else ()
- set(OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
- endif ()
- endif ()
-
- set(OUTPUT_FILE "${OUTPUT_DIR}/${TARGET}")
- message("OUTPUT_FILE=${OUTPUT_FILE}")
- message("NET=${NET}")
-
- add_custom_command(OUTPUT ${OUTPUT_FILE}
- COMMAND kicad_utils -n ${NET} -r ${REF} -o ${OUTPUT_FILE}
- MAIN_DEPENDENCY ${NET}
- DEPENDS kicad_utils
- COMMENT "Generating ${TARGET}")
-endfunction()
-
add_subdirectory(examples)
diff --git a/examples/arduino-led/CMakeLists.txt b/examples/arduino-led/CMakeLists.txt
index 7bd82af..06ef920 100644
--- a/examples/arduino-led/CMakeLists.txt
+++ b/examples/arduino-led/CMakeLists.txt
@@ -1,5 +1,5 @@
-kicad_gen(
- TARGET schematic.h
+kicad_generate_header(
+ OUTPUT schematic.h
NET schematic/arduino-led.net
REF U1
IN_SOURCE)
diff --git a/examples/arduino-led/schematic.h b/examples/arduino-led/schematic.h
index f41a300..c935528 100644
--- a/examples/arduino-led/schematic.h
+++ b/examples/arduino-led/schematic.h
@@ -11,5 +11,4 @@ namespace schematic {
static const int STATUS_LED = 3;
static const int ANALOG_LIGHT_1 = 2;
} // namespace schematic
-
#endif // SCHEMATIC_H
diff --git a/examples/intel-quark-d2000/CMakeLists.txt b/examples/intel-quark-d2000/CMakeLists.txt
index e139440..1822996 100644
--- a/examples/intel-quark-d2000/CMakeLists.txt
+++ b/examples/intel-quark-d2000/CMakeLists.txt
@@ -1,5 +1,5 @@
-kicad_gen(
- TARGET schematic.h
+kicad_generate_header(
+ OUTPUT schematic.h
NET schematic/intel-quark-d2000.net
REF U1
IN_SOURCE)
diff --git a/examples/intel-quark-d2000/schematic.h b/examples/intel-quark-d2000/schematic.h
index 62545f0..8bc46ae 100644
--- a/examples/intel-quark-d2000/schematic.h
+++ b/examples/intel-quark-d2000/schematic.h
@@ -48,5 +48,4 @@ qm_rc_t schematic_PUSH_BUTTON_direction(enum schematic_direction dir) {
return qm_gpio_set_config(QM_GPIO_0, &cfg);
}
-
#endif // SCHEMATIC_H
diff --git a/main.cpp b/generate-header.cpp
index 4449f46..d134d47 100644
--- a/main.cpp
+++ b/generate-header.cpp
@@ -236,7 +236,7 @@ bool generate(const char *ref, const trygvis::kicad::netlist::netlist &netlist,
auto libraryO = gen.find_library(c->_lib_source.lib);
if (!libraryO) {
- cerr << "kicad_gen does not support library '" << c->_lib_source.lib << "'" << endl;
+ cerr << "Unsupported library '" << c->_lib_source.lib << "'" << endl;
return false;
}
@@ -247,7 +247,7 @@ bool generate(const char *ref, const trygvis::kicad::netlist::netlist &netlist,
auto partO = library->find_part(partName);
if (!partO) {
- cerr << "kicad_gen's library " << library->name << " does not have a component named " << partName << endl;
+ cerr << "The library library " << library->name << " does not have a component named " << partName << endl;
return false;
}
diff --git a/kicad.cmake b/kicad.cmake
new file mode 100644
index 0000000..f18e6fe
--- /dev/null
+++ b/kicad.cmake
@@ -0,0 +1,43 @@
+function(kicad_generate_header)
+ set(options IN_SOURCE)
+ set(oneValueArgs OUTPUT NET REF OUTPUT_DIR)
+
+ cmake_parse_arguments(kicad_gen "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if (NOT kicad_gen_OUTPUT)
+ message(FATAL_ERROR "OUTPUT is required")
+ endif ()
+ set(output "${kicad_gen_OUTPUT}")
+
+ if (NOT kicad_gen_NET)
+ message(FATAL_ERROR "NET is required")
+ endif ()
+ set(NET "${CMAKE_CURRENT_SOURCE_DIR}/${kicad_gen_NET}")
+
+ if (NOT kicad_gen_REF)
+ message(FATAL_ERROR "REF is required")
+ endif ()
+ set(REF "${kicad_gen_REF}")
+
+ if (kicad_gen_OUTPUT_DIR)
+ if (kicad_gen_IN_SOURCE)
+ message(FATAL_ERROR "IN_SOURCE can't be used if OUTPUT_DIR is used")
+ endif ()
+
+ set(output_dir "${kicad_gen_OUTPUT_DIR}")
+ else ()
+ if (kicad_gen_IN_SOURCE)
+ set(output_dir "${CMAKE_CURRENT_SOURCE_DIR}")
+ else ()
+ set(output_dir "${CMAKE_CURRENT_BINARY_DIR}")
+ endif ()
+ endif ()
+
+ set(output_file "${output_dir}/${output}")
+
+ add_custom_command(OUTPUT "${output_file}"
+ COMMAND generate-header -n ${NET} -r ${REF} -o ${output_file}
+ MAIN_DEPENDENCY ${NET}
+ DEPENDS kicad_utils
+ COMMENT "Generating ${output}")
+endfunction()