Skip to content

Commit 7b3959b

Browse files
author
AhmedYasserrr
committed
refactor: update submodule path; add pre-commit hooks
1 parent 40c7cb4 commit 7b3959b

File tree

6 files changed

+197
-166
lines changed

6 files changed

+197
-166
lines changed

.gitlab-ci.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "extern/FrameworkWindowsUtils"]
2-
path = extern/FrameworkWindowsUtils
3-
url = https://github.com/DHowett/FrameworkWindowsUtils
1+
[submodule "src/extern/FrameworkWindowsUtils"]
2+
path = src/extern/FrameworkWindowsUtils
3+
url = https://github.com/DHowett/FrameworkWindowsUtils

.pre-commit-config.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# To use:
2+
#
3+
# pre-commit run -a
4+
#
5+
# Or:
6+
#
7+
# pre-commit install # (runs every time you commit in git)
8+
#
9+
# To update this file:
10+
#
11+
# pre-commit autoupdate
12+
#
13+
# See https://github.com/pre-commit/pre-commit
14+
15+
ci:
16+
autoupdate_commit_msg: "chore: update pre-commit hooks"
17+
autofix_commit_msg: "style: pre-commit fixes"
18+
19+
repos:
20+
# Standard hooks
21+
- repo: https://github.com/pre-commit/pre-commit-hooks
22+
rev: v5.0.0
23+
hooks:
24+
- id: check-added-large-files
25+
- id: check-case-conflict
26+
- id: check-merge-conflict
27+
- id: check-symlinks
28+
- id: check-yaml
29+
exclude: ^conda\.recipe/meta\.yaml$
30+
- id: debug-statements
31+
- id: end-of-file-fixer
32+
- id: mixed-line-ending
33+
- id: requirements-txt-fixer
34+
- id: trailing-whitespace
35+
36+
# Check linting and style issues
37+
- repo: https://github.com/astral-sh/ruff-pre-commit
38+
rev: "v0.11.13"
39+
hooks:
40+
- id: ruff
41+
args: ["--fix", "--show-fixes"]
42+
- id: ruff-format
43+
exclude: ^(docs)
44+
45+
# Changes tabs to spaces
46+
- repo: https://github.com/Lucas-C/pre-commit-hooks
47+
rev: v1.5.5
48+
hooks:
49+
- id: remove-tabs
50+
exclude: ^(docs)
51+
52+
# CMake formatting
53+
- repo: https://github.com/cheshirekow/cmake-format-precommit
54+
rev: v0.6.13
55+
hooks:
56+
- id: cmake-format
57+
additional_dependencies: [pyyaml]
58+
types: [file]
59+
files: (\.cmake|CMakeLists.txt)(.in)?$

pyproject.toml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[build-system]
2+
requires = ["scikit-build-core>=0.10", "pybind11"]
3+
build-backend = "scikit_build_core.build"
4+
5+
6+
[project]
7+
name = "libectool"
8+
version = "0.0.1"
9+
description="A shared library (libectool) that exposes ectool functionalities for seamless integration with other applications"
10+
readme = "README.md"
11+
authors = [
12+
{ name = "Ahmed Gamea", email = "ahmed.gamea@ejust.edu.eg" },
13+
]
14+
15+
[tool.scikit-build]
16+
wheel.expand-macos-universal-tags = true
17+
minimum-version = "build-system.requires"
18+
19+
[tool.cibuildwheel]
20+
build-frontend = "build[uv]"
21+
22+
[tool.ruff.lint]
23+
extend-select = [
24+
"B", # flake8-bugbear
25+
"I", # isort
26+
"ARG", # flake8-unused-arguments
27+
"C4", # flake8-comprehensions
28+
"EM", # flake8-errmsg
29+
"ICN", # flake8-import-conventions
30+
"G", # flake8-logging-format
31+
"PGH", # pygrep-hooks
32+
"PIE", # flake8-pie
33+
"PL", # pylint
34+
"PT", # flake8-pytest-style
35+
"PTH", # flake8-use-pathlib
36+
"RET", # flake8-return
37+
"RUF", # Ruff-specific
38+
"SIM", # flake8-simplify
39+
"T20", # flake8-print
40+
"UP", # pyupgrade
41+
"YTT", # flake8-2020
42+
"EXE", # flake8-executable
43+
"NPY", # NumPy specific rules
44+
"PD", # pandas-vet
45+
]
46+
ignore = [
47+
"PLR09", # Too many X
48+
"PLR2004", # Magic comparison
49+
]
50+
isort.required-imports = ["from __future__ import annotations"]
51+
52+
[tool.ruff.lint.per-file-ignores]
53+
"tests/**" = ["T20"]

src/core/CMakeLists.txt

Lines changed: 45 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -9,127 +9,81 @@ set(ECTOOL_COMMON_SOURCES
99
misc_util.cc
1010
crc.cc
1111
comm-host.cc
12-
lock/gec_lock.cc
13-
)
12+
lock/gec_lock.cc)
1413

1514
if(NOT WIN32)
16-
list(APPEND ECTOOL_COMMON_SOURCES
17-
comm-dev.cc
18-
comm-i2c.cc
19-
comm-lpc.cc
20-
comm-servo-spi.cc
21-
comm-usb.cc
22-
lock/file_lock.cc
23-
)
15+
list(
16+
APPEND
17+
ECTOOL_COMMON_SOURCES
18+
comm-dev.cc
19+
comm-i2c.cc
20+
comm-lpc.cc
21+
comm-servo-spi.cc
22+
comm-usb.cc
23+
lock/file_lock.cc)
2424
else()
25-
list(APPEND ECTOOL_COMMON_SOURCES
26-
comm-win32.cc
27-
lock/win32_mutex_lock.cc
28-
)
25+
list(APPEND ECTOOL_COMMON_SOURCES comm-win32.cc lock/win32_mutex_lock.cc)
2926
endif()
3027

31-
32-
3328
# ============================
3429
# Add Executable Target: ectool
3530
# ============================
3631
add_executable(ectool ectool.cc ${ECTOOL_COMMON_SOURCES})
3732

38-
target_include_directories(ectool PRIVATE
39-
../include
40-
${libusb_INCLUDE_DIRS}
41-
)
33+
target_include_directories(ectool PRIVATE ../include ${libusb_INCLUDE_DIRS})
4234

43-
target_compile_definitions(ectool PRIVATE
44-
CHROMIUM_EC
45-
EXTERNAL_ECTOOL_BUILD
46-
)
35+
target_compile_definitions(ectool PRIVATE CHROMIUM_EC EXTERNAL_ECTOOL_BUILD)
4736

48-
target_compile_options(ectool PRIVATE
49-
-Wno-c99-designator
50-
-Wno-address-of-packed-member
51-
-Wno-format-security
52-
)
37+
target_compile_options(
38+
ectool PRIVATE -Wno-c99-designator -Wno-address-of-packed-member
39+
-Wno-format-security)
5340

5441
if(WIN32)
55-
target_compile_definitions(ectool PRIVATE
56-
_CRT_SECURE_NO_WARNINGS
57-
)
58-
target_link_libraries(ectool PRIVATE
59-
getopt
60-
CrosECDriver
61-
onecoreuap_apiset.lib
62-
)
63-
if(MSVC)
64-
target_compile_options(ectool PRIVATE
65-
/FI"..\\include\\win32_shim.h"
66-
)
67-
else()
68-
target_compile_options(ectool PRIVATE
69-
-include "..\\include\\win32_shim.h"
70-
)
71-
endif()
72-
target_include_directories(ectool PRIVATE
73-
../include/win32
74-
)
42+
target_compile_definitions(ectool PRIVATE _CRT_SECURE_NO_WARNINGS)
43+
target_link_libraries(ectool PRIVATE getopt CrosECDriver
44+
onecoreuap_apiset.lib)
45+
if(MSVC)
46+
target_compile_options(ectool PRIVATE /FI"..\\include\\win32_shim.h")
47+
else()
48+
target_compile_options(ectool PRIVATE -include "..\\include\\win32_shim.h")
49+
endif()
50+
target_include_directories(ectool PRIVATE ../include/win32)
7551
endif()
7652

7753
target_link_libraries(ectool ${libusb_LIBRARIES} ${libftdi1_LIBRARIES})
7854

79-
8055
# ============================
8156
# Add Shared Library : libectool.so
8257
# ============================
8358

84-
set(LIBECTOOL_SOURCES ${ECTOOL_COMMON_SOURCES} ectool_fanctrl.cc)
59+
set(LIBECTOOL_SOURCES ${ECTOOL_COMMON_SOURCES} ectool_wrapper.cc)
8560

8661
add_library(libectool SHARED ${LIBECTOOL_SOURCES})
8762

88-
target_include_directories(libectool PRIVATE
89-
../include
90-
${libusb_INCLUDE_DIRS}
91-
)
63+
target_include_directories(libectool PRIVATE ../include ${libusb_INCLUDE_DIRS})
9264

93-
target_compile_definitions(libectool PRIVATE
94-
CHROMIUM_EC
95-
EXTERNAL_ECTOOL_BUILD
96-
)
65+
target_compile_definitions(libectool PRIVATE CHROMIUM_EC EXTERNAL_ECTOOL_BUILD)
9766

98-
target_compile_options(libectool PRIVATE
99-
-Wno-c99-designator
100-
-Wno-address-of-packed-member
101-
-Wno-format-security
102-
)
67+
target_compile_options(
68+
libectool PRIVATE -Wno-c99-designator -Wno-address-of-packed-member
69+
-Wno-format-security)
10370

104-
target_link_libraries(libectool PRIVATE
105-
${libusb_LIBRARIES}
106-
${libftdi1_LIBRARIES}
107-
)
71+
target_link_libraries(libectool PRIVATE ${libusb_LIBRARIES}
72+
${libftdi1_LIBRARIES})
10873

10974
if(WIN32)
110-
target_compile_definitions(ectool PRIVATE
111-
_CRT_SECURE_NO_WARNINGS
112-
)
113-
target_link_libraries(ectool PRIVATE
114-
getopt
115-
CrosECDriver
116-
onecoreuap_apiset.lib
117-
)
118-
if(MSVC)
119-
target_compile_options(ectool PRIVATE
120-
/FI"..\\include\\win32_shim.h"
121-
)
122-
else()
123-
target_compile_options(ectool PRIVATE
124-
-include "..\\include\\win32_shim.h"
125-
)
126-
endif()
127-
target_include_directories(ectool PRIVATE
128-
../include/win32
129-
)
75+
target_compile_definitions(ectool PRIVATE _CRT_SECURE_NO_WARNINGS)
76+
target_link_libraries(ectool PRIVATE getopt CrosECDriver
77+
onecoreuap_apiset.lib)
78+
if(MSVC)
79+
target_compile_options(ectool PRIVATE /FI"..\\include\\win32_shim.h")
80+
else()
81+
target_compile_options(ectool PRIVATE -include "..\\include\\win32_shim.h")
82+
endif()
83+
target_include_directories(ectool PRIVATE ../include/win32)
13084
endif()
13185

132-
set_target_properties(libectool PROPERTIES
133-
OUTPUT_NAME "ectool" # Generates `libectool.so` or `libectool.dll`
86+
set_target_properties(
87+
libectool PROPERTIES OUTPUT_NAME "ectool" # Generates `libectool.so` or
88+
# `libectool.dll`
13489
)
135-

0 commit comments

Comments
 (0)