47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/includes_normalize.h:
--------------------------------------------------------------------------------
1 | // Copyright 2012 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include
16 | #include
17 |
18 | struct StringPiece;
19 |
20 | /// Utility functions for normalizing include paths on Windows.
21 | /// TODO: this likely duplicates functionality of CanonicalizePath; refactor.
22 | struct IncludesNormalize {
23 | /// Normalize path relative to |relative_to|.
24 | IncludesNormalize(const std::string& relative_to);
25 |
26 | // Internal utilities made available for testing, maybe useful otherwise.
27 | static std::string AbsPath(StringPiece s, std::string* err);
28 | static std::string Relativize(StringPiece path,
29 | const std::vector& start_list,
30 | std::string* err);
31 |
32 | /// Normalize by fixing slashes style, fixing redundant .. and . and makes the
33 | /// path |input| relative to |this->relative_to_| and store to |result|.
34 | bool Normalize(const std::string& input, std::string* result,
35 | std::string* err) const;
36 |
37 | private:
38 | std::string relative_to_;
39 | std::vector split_relative_to_;
40 | };
41 |
--------------------------------------------------------------------------------
/automation/tools/InteractiveHtmlBom/InteractiveHtmlBom/ecad/kicad_extra/__init__.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | from .xmlparser import XmlParser
4 | from .netlistparser import NetlistParser
5 |
6 | PARSERS = {
7 | '.xml': XmlParser,
8 | '.net': NetlistParser
9 | }
10 |
11 |
12 | def parse_schematic_data(file_name, normalize_case):
13 | if not os.path.isfile(file_name):
14 | return None
15 | extension = os.path.splitext(file_name)[1]
16 | if extension not in PARSERS:
17 | return None
18 | else:
19 | parser = PARSERS[extension](file_name)
20 | return parser.parse(normalize_case)
21 |
22 |
23 | def find_latest_schematic_data(base_name, directories):
24 | """
25 | :param base_name: base name of pcb file
26 | :param directories: list of directories to search
27 | :return: last modified parsable file path or None if not found
28 | """
29 | files = []
30 | for d in directories:
31 | files.extend(_find_in_dir(d))
32 | # sort by decreasing modification time
33 | files = sorted(files, reverse=True)
34 | if files:
35 | # try to find first (last modified) file that has name matching pcb file
36 | for _, f in files:
37 | if os.path.splitext(os.path.basename(f))[0] == base_name:
38 | return f
39 | # if no such file is found just return last modified
40 | return files[0][1]
41 | else:
42 | return None
43 |
44 |
45 | def _find_in_dir(dir):
46 | _, _, files = next(os.walk(dir), (None, None, []))
47 | # filter out files that we can not parse
48 | files = [f for f in files if os.path.splitext(f)[1] in PARSERS.keys()]
49 | files = [os.path.join(dir, f) for f in files]
50 | # get their modification time and sort in descending order
51 | return [(os.path.getmtime(f), f) for f in files]
52 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/canon_perftest.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2012 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include
16 | #include
17 |
18 | #include "util.h"
19 | #include "metrics.h"
20 |
21 | using namespace std;
22 |
23 | const char kPath[] =
24 | "../../third_party/WebKit/Source/WebCore/"
25 | "platform/leveldb/LevelDBWriteBatch.cpp";
26 |
27 | int main() {
28 | vector times;
29 | string err;
30 |
31 | char buf[200];
32 | size_t len = strlen(kPath);
33 | strcpy(buf, kPath);
34 |
35 | for (int j = 0; j < 5; ++j) {
36 | const int kNumRepetitions = 2000000;
37 | int64_t start = GetTimeMillis();
38 | uint64_t slash_bits;
39 | for (int i = 0; i < kNumRepetitions; ++i) {
40 | CanonicalizePath(buf, &len, &slash_bits, &err);
41 | }
42 | int delta = (int)(GetTimeMillis() - start);
43 | times.push_back(delta);
44 | }
45 |
46 | int min = times[0];
47 | int max = times[0];
48 | float total = 0;
49 | for (size_t i = 0; i < times.size(); ++i) {
50 | total += times[i];
51 | if (times[i] < min)
52 | min = times[i];
53 | else if (times[i] > max)
54 | max = times[i];
55 | }
56 |
57 | printf("min %dms max %dms avg %.1fms\n",
58 | min, max, total / times.size());
59 | }
60 |
--------------------------------------------------------------------------------
/automation/tools/ninja/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to successfully make changes to Ninja
2 |
3 | We're very wary of changes that increase the complexity of Ninja (in particular,
4 | new build file syntax or command-line flags) or increase the maintenance burden
5 | of Ninja. Ninja is already successfully used by hundreds of developers for large
6 | projects and it already achieves (most of) the goals we set out for it to do.
7 | It's probably best to discuss new feature ideas on the
8 | [mailing list](https://groups.google.com/forum/#!forum/ninja-build) or in an
9 | issue before creating a PR.
10 |
11 | ## Coding guidelines
12 |
13 | Generally it's the
14 | [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html) with
15 | a few additions:
16 |
17 | * Any code merged into the Ninja codebase which will be part of the main
18 | executable must compile as C++03. You may use C++11 features in a test or an
19 | unimportant tool if you guard your code with `#if __cplusplus >= 201103L`.
20 | * We have used `using namespace std;` a lot in the past. For new contributions,
21 | please try to avoid relying on it and instead whenever possible use `std::`.
22 | However, please do not change existing code simply to add `std::` unless your
23 | contribution already needs to change that line of code anyway.
24 | * All source files should have the Google Inc. license header.
25 | * Use `///` for [Doxygen](http://www.doxygen.nl/) (use `\a` to refer to
26 | arguments).
27 | * It's not necessary to document each argument, especially when they're
28 | relatively self-evident (e.g. in
29 | `CanonicalizePath(string* path, string* err)`, the arguments are hopefully
30 | obvious).
31 |
32 | If you're unsure about code formatting, please use
33 | [clang-format](https://clang.llvm.org/docs/ClangFormat.html). However, please do
34 | not format code that is not otherwise part of your contribution.
35 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/gen_doxygen_mainpage.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Copyright 2011 Google Inc. All Rights Reserved.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | set -o errexit
18 | set -o nounset
19 |
20 | STATUS=0
21 |
22 | # Print each of its arguments on stderr (one per line) prefixed by the
23 | # basename of this script.
24 | stderr()
25 | {
26 | local me=$(basename "$0")
27 | local i
28 | for i
29 | do
30 | echo >&2 "$me: $i"
31 | done
32 | }
33 |
34 | # Print each of its arguments on stderr (one per line) prefixed by the
35 | # basename of this script and 'error'.
36 | error()
37 | {
38 | local i
39 | for i
40 | do
41 | stderr "error: $i"
42 | done
43 | STATUS=1
44 | }
45 |
46 | generate_header()
47 | {
48 | cat <&2 "usage: $0 inputs..."
82 | exit 1
83 | fi
84 |
85 | generate_header
86 | for i in "$@"
87 | do
88 | include_file "$i"
89 | done
90 | generate_footer
91 |
92 | exit $STATUS
93 |
--------------------------------------------------------------------------------
/automation/tools/InteractiveHtmlBom/InteractiveHtmlBom/core/fontparser.py:
--------------------------------------------------------------------------------
1 | from .newstroke_font import NEWSTROKE_FONT
2 |
3 |
4 | class FontParser:
5 | STROKE_FONT_SCALE = 1.0 / 21.0
6 | FONT_OFFSET = -10
7 |
8 | def __init__(self):
9 | self.parsed_font = {}
10 |
11 | def parse_font_char(self, chr):
12 | lines = []
13 | line = []
14 | glyph_x = 0
15 | index = ord(chr) - ord(' ')
16 | if index >= len(NEWSTROKE_FONT):
17 | index = ord('?') - ord(' ')
18 | glyph_str = NEWSTROKE_FONT[index]
19 | for i in range(0, len(glyph_str), 2):
20 | coord = glyph_str[i:i + 2]
21 |
22 | # The first two values contain the width of the char
23 | if i < 2:
24 | glyph_x = (ord(coord[0]) - ord('R')) * self.STROKE_FONT_SCALE
25 | glyph_width = (ord(coord[1]) - ord(coord[0])) * self.STROKE_FONT_SCALE
26 | elif coord[0] == ' ' and coord[1] == 'R':
27 | lines.append(line)
28 | line = []
29 | else:
30 | line.append([
31 | (ord(coord[0]) - ord('R')) * self.STROKE_FONT_SCALE - glyph_x,
32 | (ord(coord[1]) - ord('R') + self.FONT_OFFSET) * self.STROKE_FONT_SCALE
33 | ])
34 |
35 | if len(line) > 0:
36 | lines.append(line)
37 |
38 | return {
39 | 'w': glyph_width,
40 | 'l': lines
41 | }
42 |
43 | def parse_font_for_string(self, s):
44 | for c in s:
45 | if c == '\t' and ' ' not in self.parsed_font:
46 | # tabs rely on space char to calculate offset
47 | self.parsed_font[' '] = self.parse_font_char(' ')
48 | if c not in self.parsed_font and ord(c) >= ord(' '):
49 | self.parsed_font[c] = self.parse_font_char(c)
50 |
51 | def get_parsed_font(self):
52 | return self.parsed_font
53 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/getopt.h:
--------------------------------------------------------------------------------
1 | #ifndef GETOPT_H
2 | #define GETOPT_H
3 |
4 | /* include files needed by this include file */
5 |
6 | /* macros defined by this include file */
7 | #define no_argument 0
8 | #define required_argument 1
9 | #define OPTIONAL_ARG 2
10 |
11 | /* types defined by this include file */
12 |
13 | /* GETOPT_LONG_OPTION_T: The type of long option */
14 | typedef struct GETOPT_LONG_OPTION_T
15 | {
16 | const char *name; /* the name of the long option */
17 | int has_arg; /* one of the above macros */
18 | int *flag; /* determines if getopt_long() returns a
19 | * value for a long option; if it is
20 | * non-NULL, 0 is returned as a function
21 | * value and the value of val is stored in
22 | * the area pointed to by flag. Otherwise,
23 | * val is returned. */
24 | int val; /* determines the value to return if flag is
25 | * NULL. */
26 | } GETOPT_LONG_OPTION_T;
27 |
28 | typedef GETOPT_LONG_OPTION_T option;
29 |
30 | #ifdef __cplusplus
31 | extern "C"
32 | {
33 | #endif
34 |
35 | /* externally-defined variables */
36 | extern char *optarg;
37 | extern int optind;
38 | extern int opterr;
39 | extern int optopt;
40 |
41 | /* function prototypes */
42 | #ifndef _AIX
43 | int getopt (int argc, char **argv, char *optstring);
44 | #endif
45 | int getopt_long (int argc, char **argv, const char *shortopts,
46 | const GETOPT_LONG_OPTION_T * longopts, int *longind);
47 | int getopt_long_only (int argc, char **argv, const char *shortopts,
48 | const GETOPT_LONG_OPTION_T * longopts, int *longind);
49 |
50 | #ifdef __cplusplus
51 | };
52 |
53 | #endif
54 |
55 | #endif /* GETOPT_H */
56 |
57 | /* END OF FILE getopt.h */
58 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/edit_distance_test.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "edit_distance.h"
16 |
17 | #include "test.h"
18 |
19 | TEST(EditDistanceTest, TestEmpty) {
20 | EXPECT_EQ(5, EditDistance("", "ninja"));
21 | EXPECT_EQ(5, EditDistance("ninja", ""));
22 | EXPECT_EQ(0, EditDistance("", ""));
23 | }
24 |
25 | TEST(EditDistanceTest, TestMaxDistance) {
26 | const bool allow_replacements = true;
27 | for (int max_distance = 1; max_distance < 7; ++max_distance) {
28 | EXPECT_EQ(max_distance + 1,
29 | EditDistance("abcdefghijklmnop", "ponmlkjihgfedcba",
30 | allow_replacements, max_distance));
31 | }
32 | }
33 |
34 | TEST(EditDistanceTest, TestAllowReplacements) {
35 | bool allow_replacements = true;
36 | EXPECT_EQ(1, EditDistance("ninja", "njnja", allow_replacements));
37 | EXPECT_EQ(1, EditDistance("njnja", "ninja", allow_replacements));
38 |
39 | allow_replacements = false;
40 | EXPECT_EQ(2, EditDistance("ninja", "njnja", allow_replacements));
41 | EXPECT_EQ(2, EditDistance("njnja", "ninja", allow_replacements));
42 | }
43 |
44 | TEST(EditDistanceTest, TestBasics) {
45 | EXPECT_EQ(0, EditDistance("browser_tests", "browser_tests"));
46 | EXPECT_EQ(1, EditDistance("browser_test", "browser_tests"));
47 | EXPECT_EQ(1, EditDistance("browser_tests", "browser_test"));
48 | }
49 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/version.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2013 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "version.h"
16 |
17 | #include
18 |
19 | #include "util.h"
20 |
21 | using namespace std;
22 |
23 | const char* kNinjaVersion = "1.10.1.git";
24 |
25 | void ParseVersion(const string& version, int* major, int* minor) {
26 | size_t end = version.find('.');
27 | *major = atoi(version.substr(0, end).c_str());
28 | *minor = 0;
29 | if (end != string::npos) {
30 | size_t start = end + 1;
31 | end = version.find('.', start);
32 | *minor = atoi(version.substr(start, end).c_str());
33 | }
34 | }
35 |
36 | void CheckNinjaVersion(const string& version) {
37 | int bin_major, bin_minor;
38 | ParseVersion(kNinjaVersion, &bin_major, &bin_minor);
39 | int file_major, file_minor;
40 | ParseVersion(version, &file_major, &file_minor);
41 |
42 | if (bin_major > file_major) {
43 | Warning("ninja executable version (%s) greater than build file "
44 | "ninja_required_version (%s); versions may be incompatible.",
45 | kNinjaVersion, version.c_str());
46 | return;
47 | }
48 |
49 | if ((bin_major == file_major && bin_minor < file_minor) ||
50 | bin_major < file_major) {
51 | Fatal("ninja version (%s) incompatible with build file "
52 | "ninja_required_version version (%s).",
53 | kNinjaVersion, version.c_str());
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/automation/tools/InteractiveHtmlBom/InteractiveHtmlBom/__init__.py:
--------------------------------------------------------------------------------
1 | import os
2 | import sys
3 | import threading
4 | import time
5 |
6 | import wx
7 | import wx.aui
8 |
9 |
10 | def check_for_bom_button():
11 | # From Miles McCoo's blog
12 | # https://kicad.mmccoo.com/2017/03/05/adding-your-own-command-buttons-to-the-pcbnew-gui/
13 | def find_pcbnew_window():
14 | windows = wx.GetTopLevelWindows()
15 | pcbneww = [w for w in windows if "pcbnew" in w.GetTitle().lower()]
16 | if len(pcbneww) != 1:
17 | return None
18 | return pcbneww[0]
19 |
20 | def callback(_):
21 | plugin.Run()
22 |
23 | path = os.path.dirname(__file__)
24 | while not wx.GetApp():
25 | time.sleep(1)
26 | bm = wx.Bitmap(path + '/icon.png', wx.BITMAP_TYPE_PNG)
27 | button_wx_item_id = 0
28 |
29 | from pcbnew import ID_H_TOOLBAR
30 | while True:
31 | time.sleep(1)
32 | pcbnew_window = find_pcbnew_window()
33 | if not pcbnew_window:
34 | continue
35 |
36 | top_tb = pcbnew_window.FindWindowById(ID_H_TOOLBAR)
37 | if button_wx_item_id == 0 or not top_tb.FindTool(button_wx_item_id):
38 | top_tb.AddSeparator()
39 | button_wx_item_id = wx.NewId()
40 | top_tb.AddTool(button_wx_item_id, "iBOM", bm,
41 | "Generate interactive BOM", wx.ITEM_NORMAL)
42 | top_tb.Bind(wx.EVT_TOOL, callback, id=button_wx_item_id)
43 | top_tb.Realize()
44 |
45 |
46 | if not os.environ.get('INTERACTIVE_HTML_BOM_CLI_MODE', False):
47 | from .ecad.kicad import InteractiveHtmlBomPlugin
48 |
49 | plugin = InteractiveHtmlBomPlugin()
50 | plugin.register()
51 |
52 | # Add a button the hacky way if plugin button is not supported
53 | # in pcbnew, unless this is linux.
54 | if not plugin.pcbnew_icon_support and not sys.platform.startswith('linux'):
55 | t = threading.Thread(target=check_for_bom_button)
56 | t.daemon = True
57 | t.start()
58 |
--------------------------------------------------------------------------------
/.kiplot.yml:
--------------------------------------------------------------------------------
1 | # Adapted from example KiPlot config file
2 | # at `tools/kiplot/docs/samples/generic_plot.kiplot.yaml`
3 |
4 | kiplot:
5 | version: 1
6 |
7 | preflight:
8 |
9 | # one day....
10 | check_zone_fills: false
11 | run_drc: false
12 |
13 | outputs:
14 |
15 | - name: 'gerbers'
16 | comment: "Gerbers for the board house"
17 | type: gerber
18 | dir: .
19 | options:
20 | # generic layer options
21 | exclude_edge_layer: true
22 | exclude_pads_from_silkscreen: true
23 | use_aux_axis_as_origin: false
24 | plot_sheet_reference: false
25 | plot_footprint_refs: true
26 | plot_footprint_values: false
27 | force_plot_invisible_refs_vals: false
28 | tent_vias: true
29 | check_zone_fills: true
30 |
31 | # gerber options
32 | line_width: 0.1
33 | subtract_mask_from_silk: false
34 | use_protel_extensions: false
35 | gerber_precision: 4.6
36 | create_gerber_job_file: true
37 | use_gerber_x2_attributes: false
38 | use_gerber_net_attributes: false
39 |
40 | layers:
41 | - layer: F.Cu
42 | suffix: F_Cu
43 | - layer: B.Cu
44 | suffix: B_Cu
45 | - layer: F.SilkS
46 | suffix: F_SilkS
47 | - layer: B.SilkS
48 | suffix: B_SilkS
49 | - layer: F.Mask
50 | suffix: F_Mask
51 | - layer: B.Mask
52 | suffix: B_Mask
53 | - layer: F.Paste
54 | suffix: F_Paste
55 | - layer: B.Paste
56 | suffix: B_Paste
57 | - layer: Edge.Cuts
58 | suffix: Edge_Cuts
59 | - layer: F.Fab
60 | suffix: F_Fab
61 | - layer: B.Fab
62 | suffix: B_Fab
63 |
64 | - name: excellon_drill
65 | comment: "Excellon drill files"
66 | type: excellon
67 | dir: .
68 | options:
69 | metric_units: true
70 | pth_and_npth_single_file: false
71 | use_aux_axis_as_origin: false
72 | minimal_header: false
73 | mirror_y_axis: false
74 | map:
75 | type: 'gerber'
76 |
77 |
78 |
--------------------------------------------------------------------------------
/automation/tools/PcbDraw/examples/readme.md:
--------------------------------------------------------------------------------
1 | # Examples
2 |
3 | To use any of the examples, simply run `./init.sh` in the examples directory.
4 | The script will download a simple demo board by RoboticsBrno.
5 |
6 |
7 | # Example usages of PcbDraw
8 |
9 | All the examples assumes the current directory is the root of the repository.
10 |
11 | To render the board invoke:
12 |
13 | ```
14 | pcbdraw examples/ArduinoLearningKitStarter/ArduinoLearningKitStarter.kicad_pcb front.svg
15 | ```
16 |
17 | To render board, but e.g. change colors of LEDs:
18 |
19 | ```
20 | pcbdraw --remap examples/pcbdraw/remap.json examples/ArduinoLearningKitStarter/ArduinoLearningKitStarter.kicad_pcb front.svg
21 | ```
22 |
23 | To render the back side:
24 |
25 | ```
26 | pcbdraw -b examples/ArduinoLearningKitStarter/ArduinoLearningKitStarter.kicad_pcb back.svg
27 | ```
28 |
29 | To use different style:
30 |
31 | ```
32 | pcbdraw --style oshpark-purple examples/ArduinoLearningKitStarter/ArduinoLearningKitStarter.kicad_pcb front.svg
33 | ```
34 |
35 | To render only the board without components:
36 |
37 | ```
38 | pcbdraw --filter "" examples/ArduinoLearningKitStarter/ArduinoLearningKitStarter.kicad_pcb front.svg
39 | ```
40 |
41 | To render board with only `L_R1` and `L_Y1`:
42 |
43 | ```
44 | pcbdraw --filter L_R1,L_Y1 examples/ArduinoLearningKitStarter/ArduinoLearningKitStarter.kicad_pcb front.svg
45 | ```
46 |
47 | To render board and highlight `L_R1` and `L_Y1`:
48 |
49 | ```
50 | pcbdraw --highlight L_R1,L_Y1 examples/ArduinoLearningKitStarter/ArduinoLearningKitStarter.kicad_pcb front.svg
51 | ```
52 |
53 |
54 | ## Populate
55 |
56 | There are two example for the populate - HTML one and a Mardown one. They are
57 | the same and are located in files `source_md.md` and `source_html.md`. To see
58 | the result, run
59 |
60 | ```
61 | populate examples/populate/source_md.md markdown_demo
62 | ```
63 | or
64 | ```
65 | populate examples/populate/source_html.md html_demo
66 | ```
67 |
68 | You can find results
69 | in the directories `markdown_demo` and `html_demo` respectively.
70 |
71 |
--------------------------------------------------------------------------------
/automation/tools/ninja/misc/measure.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 |
3 | # Copyright 2011 Google Inc. All Rights Reserved.
4 | #
5 | # Licensed under the Apache License, Version 2.0 (the "License");
6 | # you may not use this file except in compliance with the License.
7 | # You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | """measure the runtime of a command by repeatedly running it.
18 | """
19 |
20 | from __future__ import print_function
21 |
22 | import time
23 | import subprocess
24 | import sys
25 |
26 | devnull = open('/dev/null', 'w')
27 |
28 | def run(cmd, repeat=10):
29 | print('sampling:', end=' ')
30 | sys.stdout.flush()
31 |
32 | samples = []
33 | for _ in range(repeat):
34 | start = time.time()
35 | subprocess.call(cmd, stdout=devnull, stderr=devnull)
36 | end = time.time()
37 | dt = (end - start) * 1000
38 | print('%dms' % int(dt), end=' ')
39 | sys.stdout.flush()
40 | samples.append(dt)
41 | print()
42 |
43 | # We're interested in the 'pure' runtime of the code, which is
44 | # conceptually the smallest time we'd see if we ran it enough times
45 | # such that it got the perfect time slices / disk cache hits.
46 | best = min(samples)
47 | # Also print how varied the outputs were in an attempt to make it
48 | # more obvious if something has gone terribly wrong.
49 | err = sum(s - best for s in samples) / float(len(samples))
50 | print('estimate: %dms (mean err %.1fms)' % (best, err))
51 |
52 | if __name__ == '__main__':
53 | if len(sys.argv) < 2:
54 | print('usage: measure.py command args...')
55 | sys.exit(1)
56 | run(cmd=sys.argv[1:])
57 |
--------------------------------------------------------------------------------
/automation/tools/kiplot/src/kiplot/__main__.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import argparse
4 | import logging
5 | import os
6 | import sys
7 |
8 | from . import kiplot
9 | from . import config_reader
10 |
11 |
12 | def main():
13 |
14 | EXIT_BAD_ARGS = 1
15 | EXIT_BAD_CONFIG = 2
16 |
17 | parser = argparse.ArgumentParser(
18 | description='Command-line Plotting for KiCad')
19 | parser.add_argument('-v', '--verbose', action='store_true',
20 | help='show debugging information')
21 | parser.add_argument('-b', '--board-file', required=True,
22 | help='The PCB .kicad-pcb board file')
23 | parser.add_argument('-c', '--plot-config', required=True,
24 | help='The plotting config file to use')
25 | parser.add_argument('-d', '--out-dir', default='.',
26 | help='The output directory (cwd if not given)')
27 |
28 | args = parser.parse_args()
29 |
30 | log_level = logging.DEBUG if args.verbose else logging.INFO
31 | logging.basicConfig(level=log_level)
32 |
33 | if not os.path.isfile(args.board_file):
34 | logging.error("Board file not found: {}".format(args.board_file))
35 |
36 | if not os.path.isfile(args.plot_config):
37 | logging.error("Plot config file not found: {}"
38 | .format(args.plot_config))
39 | sys.exit(EXIT_BAD_ARGS)
40 |
41 | cr = config_reader.CfgYamlReader()
42 |
43 | with open(args.plot_config) as cf_file:
44 | cfg = cr.read(cf_file)
45 |
46 | # relative to CWD (absolute path overrides)
47 | outdir = os.path.join(os.getcwd(), args.out_dir)
48 | cfg.outdir = outdir
49 |
50 | # Finally, once all value are in, check they make sense
51 | errs = cfg.validate()
52 |
53 | if errs:
54 | logging.error('Invalid config:\n\n' + "\n".join(errs))
55 | sys.exit(EXIT_BAD_CONFIG)
56 |
57 | # Set up the plotter and do it
58 | plotter = kiplot.Plotter(cfg)
59 | plotter.plot(args.board_file)
60 |
61 |
62 | if __name__ == "__main__":
63 | main()
64 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/parser.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2018 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "parser.h"
16 |
17 | #include "disk_interface.h"
18 | #include "metrics.h"
19 |
20 | using namespace std;
21 |
22 | bool Parser::Load(const string& filename, string* err, Lexer* parent) {
23 | METRIC_RECORD(".ninja parse");
24 | string contents;
25 | string read_err;
26 | if (file_reader_->ReadFile(filename, &contents, &read_err) !=
27 | FileReader::Okay) {
28 | *err = "loading '" + filename + "': " + read_err;
29 | if (parent)
30 | parent->Error(string(*err), err);
31 | return false;
32 | }
33 |
34 | // The lexer needs a nul byte at the end of its input, to know when it's done.
35 | // It takes a StringPiece, and StringPiece's string constructor uses
36 | // string::data(). data()'s return value isn't guaranteed to be
37 | // null-terminated (although in practice - libc++, libstdc++, msvc's stl --
38 | // it is, and C++11 demands that too), so add an explicit nul byte.
39 | contents.resize(contents.size() + 1);
40 |
41 | return Parse(filename, contents, err);
42 | }
43 |
44 | bool Parser::ExpectToken(Lexer::Token expected, string* err) {
45 | Lexer::Token token = lexer_.ReadToken();
46 | if (token != expected) {
47 | string message = string("expected ") + Lexer::TokenName(expected);
48 | message += string(", got ") + Lexer::TokenName(token);
49 | message += Lexer::TokenErrorHint(expected);
50 | return lexer_.Error(message, err);
51 | }
52 | return true;
53 | }
54 |
--------------------------------------------------------------------------------
/automation/tools/kicad-jlcpcb-bom-plugin/README.md:
--------------------------------------------------------------------------------
1 | # KiCad JLCPCB BOM Plugin
2 |
3 | Export a JLCPCB Compatible BOM directly from your KiCad schematic!
4 |
5 | ## Installation
6 |
7 | This script requires **Python 3**. If you need a Python 2 version, please get
8 | [kicad-jlcpcb-bom-plugin version 1.0.0](https://github.com/wokwi/kicad-jlcpcb-bom-plugin/releases/tag/1.0.0) instead.
9 |
10 | The script has been tested with KiCad 5.1.4.
11 |
12 | 1. Copy `bom_csv_jlcpcb.py` to your KiCad installation folder under the `bin/scripting/plugins` directory
13 | 2. In Eschema (the Schematics editor) go to "Tools" -> "Generate Bill of Materials", press the "+" button
14 | at the bottom of the screen, and choose the plugin file you have just copied. When asked for a nickname,
15 | go with the default, "bom_csv_jlcpcb".
16 |
17 | ## Usage
18 |
19 | Instructions for exporting JLCPCB BOM from KiCad's Eschema:
20 |
21 | 1. Go to "Tools" -> "Generate Bill of Materials"
22 | 2. Choose "bom_csv_jlcpcb" from the "BOM plugins" list on the left
23 | 3. Make sure the command line ends with "%O.csv" (otherwise, change "%O" into "%O.csv")
24 | 4. Click on "Generate". The BOM file should be created inside your project's directory, as a CSV file.
25 |
26 | ## Custom Fields
27 |
28 | You can customize the script's output by adding the following fields to your components:
29 |
30 | 1. "LCSC Part" - Add this field to include an LCSC Part number in the generated BOM. e.g.: C2286 for a red LED.
31 | 2. "JLCPCB BOM" - Set this field to 0 (or "False") to omit the component from the generated BOM.
32 |
33 | ## Generating a JLCPCB CPL File
34 |
35 | You can use the `kicad_pos_to_cpl.py` script to convert a KiCad Footprint Position (.pos) file into a CPL file
36 | compatible with JLCPCB SMT Assembly service. The `.pos` file can be generated from Pcbnew, by going into
37 | "File" -> "Fabrication Outputs" -> "Footprint Position (.pos) File..." and choosing the following options:
38 |
39 | * Format: CSV
40 | * Units: Millimeters
41 | * Files: Separate files for front and back
42 |
43 | Also, make sure to uncheck "Include footprints with SMD pads even if not marked Surface Mount".
44 |
45 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/hash_collision_bench.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2012 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "build_log.h"
16 |
17 | #include
18 |
19 | #include
20 | #include
21 |
22 | using namespace std;
23 |
24 | int random(int low, int high) {
25 | return int(low + (rand() / double(RAND_MAX)) * (high - low) + 0.5);
26 | }
27 |
28 | void RandomCommand(char** s) {
29 | int len = random(5, 100);
30 | *s = new char[len];
31 | for (int i = 0; i < len; ++i)
32 | (*s)[i] = (char)random(32, 127);
33 | }
34 |
35 | int main() {
36 | const int N = 20 * 1000 * 1000;
37 |
38 | // Leak these, else 10% of the runtime is spent destroying strings.
39 | char** commands = new char*[N];
40 | pair* hashes = new pair[N];
41 |
42 | srand((int)time(NULL));
43 |
44 | for (int i = 0; i < N; ++i) {
45 | RandomCommand(&commands[i]);
46 | hashes[i] = make_pair(BuildLog::LogEntry::HashCommand(commands[i]), i);
47 | }
48 |
49 | sort(hashes, hashes + N);
50 |
51 | int collision_count = 0;
52 | for (int i = 1; i < N; ++i) {
53 | if (hashes[i - 1].first == hashes[i].first) {
54 | if (strcmp(commands[hashes[i - 1].second],
55 | commands[hashes[i].second]) != 0) {
56 | printf("collision!\n string 1: '%s'\n string 2: '%s'\n",
57 | commands[hashes[i - 1].second],
58 | commands[hashes[i].second]);
59 | collision_count++;
60 | }
61 | }
62 | }
63 | printf("\n\n%d collisions after %d runs\n", collision_count, N);
64 | }
65 |
--------------------------------------------------------------------------------
/automation/tools/ninja/misc/bash-completion:
--------------------------------------------------------------------------------
1 | # Copyright 2011 Google Inc. All Rights Reserved.
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | # Add the following to your .bashrc to tab-complete ninja targets
16 | # . path/to/ninja/misc/bash-completion
17 |
18 | _ninja_target() {
19 | local cur prev targets dir line targets_command OPTIND
20 |
21 | # When available, use bash_completion to:
22 | # 1) Complete words when the cursor is in the middle of the word
23 | # 2) Complete paths with files or directories, as appropriate
24 | if _get_comp_words_by_ref cur prev &>/dev/null ; then
25 | case $prev in
26 | -f)
27 | _filedir
28 | return 0
29 | ;;
30 | -C)
31 | _filedir -d
32 | return 0
33 | ;;
34 | esac
35 | else
36 | cur="${COMP_WORDS[COMP_CWORD]}"
37 | fi
38 |
39 | if [[ "$cur" == "--"* ]]; then
40 | # there is currently only one argument that takes --
41 | COMPREPLY=($(compgen -P '--' -W 'version' -- "${cur:2}"))
42 | else
43 | dir="."
44 | line=$(echo ${COMP_LINE} | cut -d" " -f 2-)
45 | # filter out all non relevant arguments but keep C for dirs
46 | while getopts :C:f:j:l:k:nvd:t: opt $line; do
47 | case $opt in
48 | # eval for tilde expansion
49 | C) eval dir="$OPTARG" ;;
50 | esac
51 | done;
52 | targets_command="eval ninja -C \"${dir}\" -t targets all 2>/dev/null | cut -d: -f1"
53 | COMPREPLY=($(compgen -W '`${targets_command}`' -- "$cur"))
54 | fi
55 | return
56 | }
57 | complete -F _ninja_target ninja
58 |
--------------------------------------------------------------------------------
/automation/tools/InteractiveHtmlBom/README.md:
--------------------------------------------------------------------------------
1 | # Interactive HTML BOM plugin for KiCad
2 | 
3 |
4 | This plugin generates convenient BOM listing with ability to visually correlate
5 | and easily search for components and their placements on the pcb.
6 |
7 | This is really useful when hand soldering your prototype and you have to find 50
8 | places where 0.1uF cap should be or which of the SOP8 footprints are for the same
9 | micro. Dynamically highlighting all components in the same group on the rendering
10 | of the pcb makes manually populating the board much easier.
11 |
12 | This plugin utilizes Pcbnew python bindings to read pcb data and render
13 | silkscreen, fab layer, footprint pads, text and drawings. Additionally it can
14 | pull data from schematic if you export it through netlist or xml file that
15 | Eeschema can generate from it's internal bom tool. That extra data can be added
16 | as additional columns in the BOM table (for example manufacturer id) or it can be
17 | used to indicate which components should be omitted altogether (dnp field). For
18 | full description of functionality see [wiki](https://github.com/openscopeproject/InteractiveHtmlBom/wiki).
19 |
20 | Generated html page is fully self contained, doesn't need internet connection to work
21 | and can be packaged with documentation of your project or hosted anywhere on the web.
22 |
23 | [Demo is worth a thousand words.](https://openscopeproject.org/InteractiveHtmlBomDemo/)
24 |
25 | ## Installation and Usage
26 |
27 | See [project wiki](https://github.com/openscopeproject/InteractiveHtmlBom/wiki) for instructions.
28 |
29 | ## License and credits
30 |
31 | Plugin code is licensed under MIT license, see `LICENSE` for more info.
32 |
33 | Html page uses [Split.js](https://github.com/nathancahill/Split.js),
34 | [PEP.js](https://github.com/jquery/PEP) and (stripped down)
35 | [lz-string.js](https://github.com/pieroxy/lz-string) libraries that get embedded into
36 | generated bom page.
37 |
38 | `units.py` is borrowed from [KiBom](https://github.com/SchrodingersGat/KiBoM)
39 | plugin (MIT license).
40 |
41 | `svgpath.py` is heavily based on
42 | [svgpathtools](https://github.com/mathandy/svgpathtools) module (MIT license).
43 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/string_piece_util.cc:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #include "string_piece_util.h"
16 |
17 | #include
18 | #include
19 | #include
20 | using namespace std;
21 |
22 | vector SplitStringPiece(StringPiece input, char sep) {
23 | vector elems;
24 | elems.reserve(count(input.begin(), input.end(), sep) + 1);
25 |
26 | StringPiece::const_iterator pos = input.begin();
27 |
28 | for (;;) {
29 | const char* next_pos = find(pos, input.end(), sep);
30 | if (next_pos == input.end()) {
31 | elems.push_back(StringPiece(pos, input.end() - pos));
32 | break;
33 | }
34 | elems.push_back(StringPiece(pos, next_pos - pos));
35 | pos = next_pos + 1;
36 | }
37 |
38 | return elems;
39 | }
40 |
41 | string JoinStringPiece(const vector& list, char sep) {
42 | if (list.empty()) {
43 | return "";
44 | }
45 |
46 | string ret;
47 |
48 | {
49 | size_t cap = list.size() - 1;
50 | for (size_t i = 0; i < list.size(); ++i) {
51 | cap += list[i].len_;
52 | }
53 | ret.reserve(cap);
54 | }
55 |
56 | for (size_t i = 0; i < list.size(); ++i) {
57 | if (i != 0) {
58 | ret += sep;
59 | }
60 | ret.append(list[i].str_, list[i].len_);
61 | }
62 |
63 | return ret;
64 | }
65 |
66 | bool EqualsCaseInsensitiveASCII(StringPiece a, StringPiece b) {
67 | if (a.len_ != b.len_) {
68 | return false;
69 | }
70 |
71 | for (size_t i = 0; i < a.len_; ++i) {
72 | if (ToLowerASCII(a.str_[i]) != ToLowerASCII(b.str_[i])) {
73 | return false;
74 | }
75 | }
76 |
77 | return true;
78 | }
79 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/string_piece.h:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef NINJA_STRINGPIECE_H_
16 | #define NINJA_STRINGPIECE_H_
17 |
18 | #include
19 |
20 | #include
21 |
22 | /// StringPiece represents a slice of a string whose memory is managed
23 | /// externally. It is useful for reducing the number of std::strings
24 | /// we need to allocate.
25 | struct StringPiece {
26 | typedef const char* const_iterator;
27 |
28 | StringPiece() : str_(NULL), len_(0) {}
29 |
30 | /// The constructors intentionally allow for implicit conversions.
31 | StringPiece(const std::string& str) : str_(str.data()), len_(str.size()) {}
32 | StringPiece(const char* str) : str_(str), len_(strlen(str)) {}
33 |
34 | StringPiece(const char* str, size_t len) : str_(str), len_(len) {}
35 |
36 | bool operator==(const StringPiece& other) const {
37 | return len_ == other.len_ && memcmp(str_, other.str_, len_) == 0;
38 | }
39 |
40 | bool operator!=(const StringPiece& other) const {
41 | return !(*this == other);
42 | }
43 |
44 | /// Convert the slice into a full-fledged std::string, copying the
45 | /// data into a new string.
46 | std::string AsString() const {
47 | return len_ ? std::string(str_, len_) : std::string();
48 | }
49 |
50 | const_iterator begin() const {
51 | return str_;
52 | }
53 |
54 | const_iterator end() const {
55 | return str_ + len_;
56 | }
57 |
58 | char operator[](size_t pos) const {
59 | return str_[pos];
60 | }
61 |
62 | size_t size() const {
63 | return len_;
64 | }
65 |
66 | const char* str_;
67 | size_t len_;
68 | };
69 |
70 | #endif // NINJA_STRINGPIECE_H_
71 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/clparser.h:
--------------------------------------------------------------------------------
1 | // Copyright 2015 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef NINJA_CLPARSER_H_
16 | #define NINJA_CLPARSER_H_
17 |
18 | #include
19 | #include
20 |
21 | /// Visual Studio's cl.exe requires some massaging to work with Ninja;
22 | /// for example, it emits include information on stderr in a funny
23 | /// format when building with /showIncludes. This class parses this
24 | /// output.
25 | struct CLParser {
26 | /// Parse a line of cl.exe output and extract /showIncludes info.
27 | /// If a dependency is extracted, returns a nonempty string.
28 | /// Exposed for testing.
29 | static std::string FilterShowIncludes(const std::string& line,
30 | const std::string& deps_prefix);
31 |
32 | /// Return true if a mentioned include file is a system path.
33 | /// Filtering these out reduces dependency information considerably.
34 | static bool IsSystemInclude(std::string path);
35 |
36 | /// Parse a line of cl.exe output and return true if it looks like
37 | /// it's printing an input filename. This is a heuristic but it appears
38 | /// to be the best we can do.
39 | /// Exposed for testing.
40 | static bool FilterInputFilename(std::string line);
41 |
42 | /// Parse the full output of cl, filling filtered_output with the text that
43 | /// should be printed (if any). Returns true on success, or false with err
44 | /// filled. output must not be the same object as filtered_object.
45 | bool Parse(const std::string& output, const std::string& deps_prefix,
46 | std::string* filtered_output, std::string* err);
47 |
48 | std::set includes_;
49 | };
50 |
51 | #endif // NINJA_CLPARSER_H_
52 |
--------------------------------------------------------------------------------
/automation/tools/InteractiveHtmlBom/InteractiveHtmlBom/web/lz-string.js:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013 Pieroxy
2 | // This work is free. You can redistribute it and/or modify it
3 | // under the terms of the WTFPL, Version 2
4 | // For more information see LICENSE.txt or http://www.wtfpl.net/
5 | //
6 | // For more information, the home page:
7 | // http://pieroxy.net/blog/pages/lz-string/testing.html
8 | //
9 | // LZ-based compression algorithm, version 1.4.4
10 | var LZString=function(){var o=String.fromCharCode,i={};var n={decompressFromBase64:function(o){return null==o?"":""==o?null:n._decompress(o.length,32,function(n){return function(o,n){if(!i[o]){i[o]={};for(var t=0;t>=1,0==m.position&&(m.position=n,m.val=t(m.index++)),a|=(s>0?1:0)*u,u<<=1;switch(a){case 0:for(a=0,p=Math.pow(2,8),u=1;u!=p;)s=m.val&m.position,m.position>>=1,0==m.position&&(m.position=n,m.val=t(m.index++)),a|=(s>0?1:0)*u,u<<=1;l=o(a);break;case 1:for(a=0,p=Math.pow(2,16),u=1;u!=p;)s=m.val&m.position,m.position>>=1,0==m.position&&(m.position=n,m.val=t(m.index++)),a|=(s>0?1:0)*u,u<<=1;l=o(a);break;case 2:return""}for(f[3]=l,e=l,g.push(l);;){if(m.index>i)return"";for(a=0,p=Math.pow(2,h),u=1;u!=p;)s=m.val&m.position,m.position>>=1,0==m.position&&(m.position=n,m.val=t(m.index++)),a|=(s>0?1:0)*u,u<<=1;switch(l=a){case 0:for(a=0,p=Math.pow(2,8),u=1;u!=p;)s=m.val&m.position,m.position>>=1,0==m.position&&(m.position=n,m.val=t(m.index++)),a|=(s>0?1:0)*u,u<<=1;f[d++]=o(a),l=d-1,c--;break;case 1:for(a=0,p=Math.pow(2,16),u=1;u!=p;)s=m.val&m.position,m.position>>=1,0==m.position&&(m.position=n,m.val=t(m.index++)),a|=(s>0?1:0)*u,u<<=1;f[d++]=o(a),l=d-1,c--;break;case 2:return g.join("")}if(0==c&&(c=Math.pow(2,h),h++),f[l])v=f[l];else{if(l!==d)return null;v=e+e.charAt(0)}g.push(v),f[d++]=e+v.charAt(0),e=v,0==--c&&(c=Math.pow(2,h),h++)}}};return n}();"function"==typeof define&&define.amd?define(function(){return LZString}):"undefined"!=typeof module&&null!=module?module.exports=LZString:"undefined"!=typeof angular&&null!=angular&&angular.module("LZString",[]).factory("LZString",function(){return LZString});
--------------------------------------------------------------------------------
/automation/tools/kiplot/setup.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 |
3 | import io
4 | import os
5 |
6 | from setuptools import setup, find_packages
7 |
8 | # Package meta-data.
9 | NAME = 'kiplot'
10 | DESCRIPTION = 'Plotting driver for KiCad'
11 | URL = 'https://github.com/johnbeard/kiplot'
12 | EMAIL = 'john.j.beard@gmail.com'
13 | AUTHOR = 'John Beard'
14 | REQUIRES_PYTHON = '>=2.7.0'
15 |
16 |
17 | # What packages are required for this module to be executed?
18 | REQUIRED = [
19 | 'pyyaml',
20 | # 'pcbnew'
21 | ]
22 |
23 | here = os.path.abspath(os.path.dirname(__file__))
24 |
25 | # Import the README and use it as the long-description.
26 | # Note: this will only work if 'README.md' is present in your MANIFEST.in file!
27 | with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
28 | long_description = '\n' + f.read()
29 |
30 |
31 | about = {}
32 | with open(os.path.join(here, 'src', NAME, '__version__.py')) as f:
33 | exec(f.read(), about)
34 |
35 |
36 | # Where the magic happens:
37 | setup(
38 | name=NAME,
39 | version=about['__version__'],
40 | description=DESCRIPTION,
41 | long_description=long_description,
42 | long_description_content_type='text/markdown',
43 | author=AUTHOR,
44 | author_email=EMAIL,
45 | python_requires=REQUIRES_PYTHON,
46 | url=URL,
47 | packages=find_packages('src'),
48 | package_dir={'': 'src'},
49 | # If your package is a single module, use this instead of 'packages':
50 | # py_modules=['mypackage'],
51 |
52 | entry_points={
53 | 'console_scripts': ['kiplot=kiplot.__main__:main'],
54 | },
55 | install_requires=REQUIRED,
56 | include_package_data=True,
57 | license='MIT',
58 | classifiers=[
59 | # Trove classifiers
60 | # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
61 | 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
62 | 'Programming Language :: Python',
63 | 'Programming Language :: Python :: 2',
64 | 'Programming Language :: Python :: 2.7',
65 | 'Programming Language :: Python :: Implementation :: CPython',
66 | 'Programming Language :: Python :: Implementation :: PyPy',
67 | 'Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)',
68 | ],
69 | setup_requires=['pytest-runner'],
70 | tests_require=['pytest'],
71 | )
72 |
--------------------------------------------------------------------------------
/automation/tools/ninja/src/manifest_parser.h:
--------------------------------------------------------------------------------
1 | // Copyright 2011 Google Inc. All Rights Reserved.
2 | //
3 | // Licensed under the Apache License, Version 2.0 (the "License");
4 | // you may not use this file except in compliance with the License.
5 | // You may obtain a copy of the License at
6 | //
7 | // http://www.apache.org/licenses/LICENSE-2.0
8 | //
9 | // Unless required by applicable law or agreed to in writing, software
10 | // distributed under the License is distributed on an "AS IS" BASIS,
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | // See the License for the specific language governing permissions and
13 | // limitations under the License.
14 |
15 | #ifndef NINJA_MANIFEST_PARSER_H_
16 | #define NINJA_MANIFEST_PARSER_H_
17 |
18 | #include "parser.h"
19 |
20 | struct BindingEnv;
21 | struct EvalString;
22 |
23 | enum DupeEdgeAction {
24 | kDupeEdgeActionWarn,
25 | kDupeEdgeActionError,
26 | };
27 |
28 | enum PhonyCycleAction {
29 | kPhonyCycleActionWarn,
30 | kPhonyCycleActionError,
31 | };
32 |
33 | struct ManifestParserOptions {
34 | ManifestParserOptions()
35 | : dupe_edge_action_(kDupeEdgeActionWarn),
36 | phony_cycle_action_(kPhonyCycleActionWarn) {}
37 | DupeEdgeAction dupe_edge_action_;
38 | PhonyCycleAction phony_cycle_action_;
39 | };
40 |
41 | /// Parses .ninja files.
42 | struct ManifestParser : public Parser {
43 | ManifestParser(State* state, FileReader* file_reader,
44 | ManifestParserOptions options = ManifestParserOptions());
45 |
46 | /// Parse a text string of input. Used by tests.
47 | bool ParseTest(const std::string& input, std::string* err) {
48 | quiet_ = true;
49 | return Parse("input", input, err);
50 | }
51 |
52 | private:
53 | /// Parse a file, given its contents as a string.
54 | bool Parse(const std::string& filename, const std::string& input,
55 | std::string* err);
56 |
57 | /// Parse various statement types.
58 | bool ParsePool(std::string* err);
59 | bool ParseRule(std::string* err);
60 | bool ParseLet(std::string* key, EvalString* val, std::string* err);
61 | bool ParseEdge(std::string* err);
62 | bool ParseDefault(std::string* err);
63 |
64 | /// Parse either a 'subninja' or 'include' line.
65 | bool ParseFileInclude(bool new_scope, std::string* err);
66 |
67 | BindingEnv* env_;
68 | ManifestParserOptions options_;
69 | bool quiet_;
70 | };
71 |
72 | #endif // NINJA_MANIFEST_PARSER_H_
73 |
--------------------------------------------------------------------------------