diff --git a/Documentation/Development.md b/Documentation/Development.md index 83470d89..ef47bcaa 100644 --- a/Documentation/Development.md +++ b/Documentation/Development.md @@ -133,7 +133,7 @@ On Windows follow the instructions on the official documentation to install 'Win 3. Build the firmware for Pinecil V2: ```sh - cd source/source + cd source/ ./build.sh -l EN -m Pinecilv2 ``` diff --git a/Documentation/Hardware.md b/Documentation/Hardware.md index 7341eb5c..4734a552 100644 --- a/Documentation/Hardware.md +++ b/Documentation/Hardware.md @@ -1,8 +1,62 @@ ## Notes on the various supported hardware + +### TS100 + +TS100\* is a neat soldering iron: + +- can run from 9-25V DC; +- provides a power range that is determined by the input voltage; +- voltages below 12V don't overly work well for any substantial mass; +- the default firmware can be found [here](https://www.minidso.com/forum.php?mod=viewthread&tid=892&extra=page%3D1). + +![](https://brushlesswhoop.com/images/ts100-og.jpg) + + +### TS80 + +TS80\* is a successor to TS100: + +- uses _Quick Charge 3.0_ / _QC3_ capable charger only (18W max); +- doesn't support PD as it is not designed on the hardware level; +- the default firmware can be found [here](https://www.minidso.com/forum.php?mod=viewthread&tid=3208&extra=page%3D1). + +![](https://core-electronics.com.au/media/catalog/product/4/2/4244-01.jpg) + + +### TS80P + +TS80P\* is a successor to TS80: + +- supports _Quick Charge 3.0_ (_QC3_: 9V/3A, 18W max); +- supports _Power Delivery_ (_PD_: 9V/3A & 12V/3A, 30W max)\*\*; +- the default firmware can be found [here](https://www.minidso.com/forum.php?mod=viewthread&tid=4085&extra=page%3D1). + +\*\*: use valid PD device that supports 12V/3A as power source to get full 30W potential, otherwise the iron will fall back to 9V/18W power mode. + +![](https://static.eleshop.nl/mage/media/catalog/product/cache/10/image/800x/040ec09b1e35df139433887a97daa66f/s/-/s-l1600_5.jpg) + + ### MHP30 -- Accelerometer is the MSA301, this is mounted roughly in the middle of the unit -- USB-PD is using the FUSB302 -- The hardware I2C bus on PB6/7 is used for the MSA301 and FUSB302 -- The OLED is the same SSD1306 as everything else, but it’s on a bit-banged bus +MHP30 is a **M**ini **H**ot **P**late: + +- accelerometer is the MSA301, this is mounted roughly in the middle of the unit; +- USB-PD is using the FUSB302; +- the hardware I2C bus on PB6/7 is used for the MSA301 and FUSB302; +- the OLED is the same SSD1306 as everything else, but it’s on a bit-banged bus. + + +### Pinecil + +Pincecil\*: + +- first model of soldering iron from PINE64; +- the default firmware can be found [here](https://files.pine64.org/os/Pinecil/Pinecil_firmware_20201115.zip). + +![](https://pine64.com/wp-content/uploads/2020/11/pinecil-bb2-04.jpg?v=0446c16e2e66) + + +\*: Please note: these soldering irons do *NOT* contain DC/DC converters. This means that your power at the tip is a function of the supplied voltage. Just because the iron "supports" running at a wide range of voltages, you should always use a voltage near the upper limit where possible. It is highly recommended to use a PD adapter where possible as this allows the iron to _know_ the limitations of your supply. The marked irons can only turn the tip on and off in software, this means that they can't control the maximum power drawn from the supply. This is why when using PD the iron may select a lower voltage than your power supplies maximum. This is to prevent your power supply failing from over current. For more information about power management underhood, please, [see the related documentation section](https://ralim.github.io/IronOS/Power/). + + diff --git a/Documentation/Power.md b/Documentation/Power.md index e2a08db3..a6532adf 100644 --- a/Documentation/Power.md +++ b/Documentation/Power.md @@ -20,6 +20,8 @@ The resistance of the tip is a fixed constant in ohms (Ω): This means the power delivered to the soldering tip is proportional to the voltage squared. Therefore the Pinecil and TS100 perform poorly when run off 12V power supplies and may issue a `Thermal Runaway` message (weak power supply). + + #### Use an [Ohm calculator](https://www.rapidtables.com/calc/electric/power-calculator.html#dc) to quickly derive watts. | Type | Volts| / | Tip Ω | = | Amps | * | Volts | = | Watts | @@ -44,3 +46,8 @@ To measure the tip temperature in the iron, the iron has a small op-amp connecte Once the output is turned off (via the FET), the system has a recovery time as the tip capacitance discharges and the op-amp exits saturation. After this delay period, the MCU's ADC (analog-to-digital converter) samples the output of the op-amp 8 times quickly and then sets a flag to turn the PWM output back on. This enforces a small dead time in the output signal while this occurs, so there is a balance between sampling the temperature often to maintain a stable tip temperature control and sampling less often to increase the maximum power deliverable to the tip ([see Complexity of measurement](https://ralim.github.io/IronOS/Temperature/#complexity-of-measurement)). + + +## Power sources + +Supported by IronOS hardware may use different power sources (chargers/powerbanks/battery packs) with different standards & protocols (QC/PD/etc). For more information collected by the community on that, please, [see the related documentation section](https://ralim.github.io/IronOS/PowerSources/). diff --git a/Documentation/PowerSources.md b/Documentation/PowerSources.md new file mode 100644 index 00000000..0b588008 --- /dev/null +++ b/Documentation/PowerSources.md @@ -0,0 +1,80 @@ +# Power sources + +Supported by IronOS hardware may use different power sources (chargers/powerbanks/battery packs) with different standards & protocols (QC/PD/etc). This document contains information collected by the community with tested power sources. + +This is not ads but first hands-on experience results from real users since some chargers/powerbanks regardless labels on the box may not fully support what's declared! + + +## QC(3) + + +### Compatible Devices (QuickCharge for TS80/P) + +The following table is the list of compatible device and remarks when powering up the TS80 through it for both stock firmware from MiniDso and IronOS. The list of devices below are primarily taken from [#349](https://github.com/Ralim/ts100/issues/349#issuecomment-449559806) + +| Device Name | Stock FW | IronOS FW | +|-------------|:--------:|:---------:| +| Anker PowerCore II Slim 10000 Powerbank | Not Working | Good | +| [Aukey 26.5/30 Ah Powerbank (PB-Y3)](https://www.aukey.com/products/30000mah-power-bank-with-quick-charge-3-0/) | OK\*\* (15sec t/o) | OK\*\* (15sec t/o) | +| Aukey QC3 Charger | Good | Only 5V | +| [Aukey QC3 Charging Station (PA-T11)](https://www.aukey.com/products/6-port-charging-station-with-quick-charge-3-0-pa-t11/) | Good | Good | +| Besiter 20000mah QC3 | Not Working | Only 5V | +| BlitzWolf BW-P5 | Not Working\* | Unknown | +| BlitzWolf BW-PF2 | OK\*\* (10sec t/o) | OK\*\* (10sec t/o) | +| BlitzWolf BW-PL3 | Low Voltage | OK | +| BlitzWolf BW-PL4 | Unknown | Not Working | +| BlitzWolf BW-S6 | Unknown | OK | +| Charmast 20800 mAh QC 3.0 | Low Voltage\* | Good | +| Clas Ohlson Powerbank USB-C 10050 mAh, Clas Ohlson | Unknown | OK\*\* | +| [Cygnett 20,000mAh USB-C](https://www.cygnett.com/products/20-000mah-usb-c-power-bank-in-black)| Not Working | Good | +| [HAME H13D](https://www.amazon.com/dp/B07GWMFW82) 10000mAh PD/QC3.0 Power Bank | OK\*\* (30sec t/o) | OK\*\* (30sec t/o?) | +| HIPER 10000 mAh 18W PD+QC3.0 (MPX10000) | Low Voltage | OK\*\* (30sec t/o) | +| [iMuto Portable Charger 30000mAh](https://www.amazon.com/gp/product/B01MXCMGB8/ref=ppx_yo_dt_b_asin_title_o05_s00) | Low Voltage | Good | +| ISDT BG-8S | Good | Good | +| [iVoler Quick Charge 3.0 USB C 30W 2-Port USB](https://www.amazon.de/dp/B077P8ZZB8/) | Good | Good | +| [imuto X6L Pro 30000 mah](https://www.amazon.com/dp/B01MXCMGB8) | Not Working | Bad | +| Interstep 10000 mAh 18W PD+QC3.0+FCP+AFC (MPX10000) | Good | OK\*\* (30sec t/o) | +| Jackery Black 420 | Low Voltage | Good | +| Kogan Premium 80W 5 Port USB Charger| Low Voltage | Good | +| Nokia AD-18WE | Unknown | OK | +| [Omars 2000mAh USB-C PD+QC3.0 (OMPB20KBUPLT / OMPB20KPLT)](https://www.amazon.com/dp/B07CMLVR6C) | OK\*\* (20sec t/o) | Unknown | +| Polaroid PS100 Powerbank (https://polaroid.com/products/ps100) | Good | Good | +| Xiaomi 10000mAh Mi Power Bank Pro (PLM03ZM) | Good | Unknown | +| Xiaomi 10000mAh Mi Power Bank 2i (PLM09ZM) | Good | Good | +| Xiaomi 20000mAh Mi Power Bank 3 (PLM07ZM) | Unknown | Good Type A, Bad Type C | +| [ZeroLemon ToughJuice](https://www.amazon.com/dp/B01CZR3LT2/) 30000mAh PD/QC2.0 Power Bank | OK\*\* (20sec t/o) | OK\*\* (20sec t/o?) | +| [URUAV XT-60 to USB module](https://www.banggood.com/URUAV-XT-60-to-USB-Charger-Converter-Support-3S-6S-LiPo-Battery-10_5V-32V-Input-3V-20V-Output-45W-Max-Fast-Charging-Adapter-For-RC-Racing-Drone-p-1475876.html) | Unknown | Good | + + +\* Need further tests on newer firmware + +\*\* Most Power Banks shut down if current draw drops below 50mA, assuming that charging is complete and avoiding overcharging. Custom firmware is designed to avoid this until it enters Zzzz mode. + + +### DIY QC3.0 + +You may also build your own QC3.0 power source that requires this little [thing](https://www.tindie.com/products/soubitos/qualcomm-qc2-3-diy-8-32vin-36-12vout-3a-max/) and have at least 3S lithium packs or any input voltage from 8 to 32V. + +You can also go for an [alternate module](https://www.banggood.com/DC-Buck-Module-12V24V-to-QC3_0-Single-USB-Mobile-Charging-Board-p-1310585.html) which has at least one good review of it. + +**DISCLAIMER:** _**We do not hold any responsibility for accidents that happen when building your own QC3.0 power source!!!**_ + + +## PD + +The following additional table is the list of devices compatible with hardware which requires Power Delivery support (>= 30W). Devices from the list have been successfully tested & used with TS80P in PD mode. Please, keep in mind that: + +- PD can be provided only through usb-c <-> usb-c cable; +- not only a charger but a cable itself should be capable to carry higher wattages. + + +### Compatible Devices (PowerDelivery for TS80P) + +| Device Name | IronOS FW | +|-------------|:---------:| +| Traver Charger QC09 (45W max)\* | OK | +| Xiaomi AD65GEU Mi 65W Fast Charger with GaN Tech (AD65GEU, 65W max) | OK | + +\* Comes as an _option_ for extra price in the package with TS80P from [official store](https://aliexpress.com/item/4000764937427.html) or from [NovelLife store separately](https://aliexpress.com/item/4001316262433.html) on AliExpress. + +Please, DO NOT BUY cheap "fast chargers with QC/PD support" for a few dollars online (i.e., less than ~10$): if you check reviews, then you see that they are phonies - even if you get lucky, you probably get 5V/1A max from them. diff --git a/Documentation/README.md b/Documentation/README.md index 87807298..ff27c854 100644 --- a/Documentation/README.md +++ b/Documentation/README.md @@ -25,5 +25,6 @@ - [Hardware Notes](../Documentation/Hardware.md) - [Troubleshooting](../Documentation/Troubleshooting.md) - [Known Hardware Issues](../Documentation/HardwareIssues.md) + - [Power sources](../Documentation/PowerSources.md) - [Translations](../Documentation/Translation.md) - [Development](../Documentation/Development.md) diff --git a/Documentation/index.md b/Documentation/index.md index 94096acc..f301f2ec 100644 --- a/Documentation/index.md +++ b/Documentation/index.md @@ -8,7 +8,7 @@ For soldering irons that are designed to be powered by batteries (TS100 & Pineci Currently **31** languages are supported. When downloading the firmware for your soldering iron, take note of the language code in the file name. -This project is considered feature complete for use as a soldering iron, _so please suggest any feature improvements you would like!_ +This project is considered stable & feature complete for everyday use with a supported device, _so please suggest any feature improvements you would like!_ _This firmware does **NOT** support the USB port while running for changing settings. This is done through the onscreen menu only. Logos are edited on a computer and flashed like firmware._ @@ -39,6 +39,12 @@ For notes on installation for your device, please refer to the flashing guide fo - [TS80 / TS80P](https://ralim.github.io/IronOS/Flashing/TS80%28P%29/) - [TS100](https://ralim.github.io/IronOS/Flashing/TS100) +But the _generic_ [TL;DR](https://www.merriam-webster.com/dictionary/TL%3BDR) is to: + +- [download firmware from here](https://github.com/Ralim/IronOS/releases) for the correct model with suitable language support; +- put a device into DFU/bootloader mode (usually by keep holding A/+/front button while connecting a device to power source to power device on); +- flash the firmware by drag-n-drop the firmware file using a file manager of your OS **or** using a separate flashing tool. + ## Key Features - PID style iron temperature control @@ -74,17 +80,21 @@ Operation details are over in the [Menu information.](https://ralim.github.io/Ir ## Feedback If you would like to: + - report any issue related to IronOS - request a feature - provide some suggestion -then you can [fill this form](https://github.com/Ralim/IronOS/issues/new/choose) using github account[^gh]. + +then you can [fill this form](https://github.com/Ralim/IronOS/issues/new/choose) using github account\*. And if you would like to: + - ask more generic question about IronOS/supported hardware/something you're curious about/etc. - reach out community to chat with - share your soldering & DIY skills - share some interesting finding - share useful related hardware/software with others + or _anything_ like that, then you can use forum-like [Discussions here](https://github.com/Ralim/IronOS/discussions). -[^gh]: You may need to create it first if you don't have one - it's free of charge. +\*: You may need to create it first if you don't have one - it's free of charge. diff --git a/Env.yml b/Env.yml index 28024651..c7625b34 100644 --- a/Env.yml +++ b/Env.yml @@ -10,4 +10,4 @@ services: command: /bin/sh volumes: - ./scripts/ci:/build/ci:Z - - ./:/build/source:Z + - ./:/build/ironos:Z diff --git a/Translations/translation_IT.json b/Translations/translation_IT.json index 70000971..e1b7d32b 100644 --- a/Translations/translation_IT.json +++ b/Translations/translation_IT.json @@ -162,7 +162,7 @@ }, "ProfilePreheatSpeed": { "displayText": "Velocità\npreriscaldamento", - "description": "Imposta la velocità di preriscaldamento [gradi al secondo]" + "description": "Imposta la velocità di preriscaldamento [°C/s]" }, "ProfilePhase1Temp": { "displayText": "Temperatura\nfase 1", @@ -206,7 +206,7 @@ }, "ProfileCooldownSpeed": { "displayText": "Velocità\nraffreddamento", - "description": "Imposta la velocità di raffreddamento al termine del profilo di riscaldamento [gradi al secondo]" + "description": "Imposta la velocità di raffreddamento al termine del profilo di riscaldamento [°C/s]" }, "MotionSensitivity": { "displayText": "Sensibilità\nal movimento", diff --git a/scripts/IronOS-mkdocs.yml b/scripts/IronOS-mkdocs.yml index 24515f68..196167aa 100644 --- a/scripts/IronOS-mkdocs.yml +++ b/scripts/IronOS-mkdocs.yml @@ -39,6 +39,7 @@ nav: - Hardware Notes: Hardware.md - Troubleshooting: Troubleshooting.md - Known Hardware Issues: HardwareIssues.md + - Power sources: PowerSources.md - Translations: Translation.md - Development: Development.md diff --git a/scripts/IronOS.Dockerfile b/scripts/IronOS.Dockerfile index 6d196676..c15fb2b6 100644 --- a/scripts/IronOS.Dockerfile +++ b/scripts/IronOS.Dockerfile @@ -4,7 +4,7 @@ FROM alpine:3.16 LABEL maintainer="Ben V. Brown " # Default current dir when container starts -WORKDIR /build/source +WORKDIR /build/ironos # Installing the two compilers (ARM & RISCV), python3 & pip, clang tools: ## - compilers: gcc-*, newlib-* @@ -29,7 +29,7 @@ RUN apk add --no-cache ${APK_COMPS} ${APK_PYTHON} ${APK_MISC} ${APK_DEV} RUN python3 -m pip install ${PIP_PKGS} # Git trust to avoid related warning -RUN git config --global --add safe.directory /build/source +RUN git config --global --add safe.directory /build/ironos -COPY . /build/source +COPY . /build/ironos COPY ./scripts/ci /build/ci diff --git a/scripts/ci/buildAll.sh b/scripts/ci/buildAll.sh index 566cfe72..f5fcf067 100755 --- a/scripts/ci/buildAll.sh +++ b/scripts/ci/buildAll.sh @@ -2,12 +2,20 @@ set -e set -u -mkdir -p /build/ci/artefacts +# Init vars +dir_ci="/build/ci" +dir_ironos="/build/ironos" +dir_source="${dir_ironos}/source" -# Build STM code -cd /build/source/source/ +# Prepare output dir +dir_artefacts="${dir_ci}/artefacts" +mkdir -p "${dir_artefacts}" + +# Build firmware +cd "${dir_source}" bash ./build.sh || exit 1 echo "All Firmware built" + # Copy out all the final resulting files we would like to store for the next op -cp -r /build/source/source/Hexfile/*.hex /build/ci/artefacts/ -cp -r /build/source/source/Hexfile/*.bin /build/ci/artefacts/ +cp -r "${dir_source}"/Hexfile/*.bin "${dir_artefacts}" +cp -r "${dir_source}"/Hexfile/*.hex "${dir_artefacts}" diff --git a/scripts/deploy.sh b/scripts/deploy.sh index ab388323..56db72df 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -20,7 +20,8 @@ usage() echo -e "\tclean - delete created docker container (but not pre-downloaded data for it)\n" echo "CMD (helper routines):" echo -e "\tdocs_readme - generate & OVERWRITE(!) README.md inside Documentation/ based on nav section from mkdocs.yml if it changed\n" - echo -e "\tcheck_style - run clang-format using source/Makefile and generate gcc-compatible error log in source/check-style.log\n" + echo -e "\tcheck_style_file SRC - run code style checks based on clang-format & custom parsers for source code file SRC\n" + echo -e "\tcheck_style_log - run clang-format using source/Makefile and generate gcc-compatible error log in source/check-style.log\n" echo -e "STORAGE NOTICE: for \"shell\" and \"build\" commands extra files will be downloaded so make sure that you have ~5GB of free space.\n" } @@ -70,8 +71,43 @@ EOF return "${ret}" } +# Helper function to check code style using clang-format & grep/sed custom parsers: +# - basic logic moved from source/Makefile : `check-style` target for better maintainance since a lot of sh script involved; +# - output goes in gcc-like error compatible format for IDEs/editors. +check_style_file() +{ + ret=0 + src="${1}" + test ! -f "${src}" && echo "ERROR!!! Provided file ${src} is not available to check/read!!!" && exit 1 + # count lines using diff between beauty-fied file & original file to detect format issue + var="$(clang-format "$src" | diff "$src" - | wc -l)" + if [ "${var}" -ne 0 ]; then + # show full log error or, if LIST=anything provided, then show only filename of interest (implemented for debug purposes mainly) + if [ -z "${LIST}" ]; then + # sed is here only for pretty logging + clang-format "${src}" | diff "${src}" - | sed 's/^---/-------------------------------------------------------------------------------/; s/^< /--- /; s/^> /+++ /; /^[0-9].*/ s/[acd,].*$/ERROR1/; /^[0-9].*/ s,^,\n\n\n\n'"${src}"':,; /ERROR1$/ s,ERROR1$,:1: error: clang-format code style mismatch:,; ' + else + echo "${src}" + fi; + ret=1 + fi; + # - clang-format has neat option for { } in condition blocks but it's available only since version 15: + # * https://clang.llvm.org/docs/ClangFormatStyleOptions.html#insertbraces + # - since reference env is alpine 3.16 with clang-format 13, implement custom parser to do the similar thing here with grep: + # it used to trace missing { and } for if/else/do/while/for BUT IT'S VERY SPECULATIVE, very-very hacky & dirty. + test -z "${LIST}" || silent_opt="-q" + # if file is problematic but filename only requested make final grep in pipe silent ... + grep -H -n -e "^ .*if .*)$" -e "^ .*else$" -e "^ .* do$" -e "^ .*while .*)$" -e "^ .*for .*)$" "${src}" | grep -v -e "^.*//" -e "^.*:.*: .*if ((.*[^)])$" | sed 's,^,\n\n,; s,: ,:1: error: probably missing { or } for conditional or loop block:\n>>>,;' | grep "${silent_opt}" -e "^.*$" + if [ "${?}" -ne 1 ]; then + # ... and only print the filename + test -z "${LIST}" || echo "${src}" + ret=1; + fi; + return "${ret}" +} + # check_style routine for those who too lazy to do it everytime manually -check_style() +check_style_log() { log="source/check-style.log" make -C source check-style 2>&1 | tee "${log}" @@ -130,8 +166,13 @@ if [ "docs_readme" = "${cmd}" ]; then exit "${?}" fi; -if [ "check_style" = "${cmd}" ]; then - check_style +if [ "check_style_file" = "${cmd}" ]; then + check_style_file "${2}" + exit "${?}" +fi; + +if [ "check_style_log" = "${cmd}" ]; then + check_style_log exit "${?}" fi; diff --git a/source/Makefile b/source/Makefile index 32f8aa86..49b86532 100644 --- a/source/Makefile +++ b/source/Makefile @@ -60,7 +60,7 @@ APP_INC_DIR=./Core/Inc BRIEFLZ_INC_DIR=./Core/brieflz MINIWARE_INC_CMSIS_DEVICE=./Core/BSP/Miniware/Vendor/CMSIS/Device/ST/STM32F1xx/Include MINIWARE_CMSIS_CORE_INC_DIR=./Core/BSP/Miniware/Vendor/CMSIS/Include -MINIWARE_HAL_SRC_DIR= ./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver +MINIWARE_HAL_SRC_DIR=./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver MINIWARE_HAL_INC_DIR=./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc MINIWARE_HAL_LEGACY_INC_DIR=./Core/BSP/Miniware/Vendor/STM32F1xx_HAL_Driver/Inc/Legacy MINIWARE_STARTUP_DIR=./Startup @@ -474,8 +474,8 @@ DEV_GLOBAL_DEFS=-DCFG_FREERTOS \ # -DCONFIG_BT_SMP # Required to be turned off due to their drivers tripping warnings -DEV_CFLAGS= -Wno-error=enum-conversion -Wno-type-limits -Wno-implicit-fallthrough -DEV_CXXFLAGS= $(DEV_CFLAGS) +DEV_CFLAGS=-Wno-error=enum-conversion -Wno-type-limits -Wno-implicit-fallthrough +DEV_CXXFLAGS=$(DEV_CFLAGS) flash_size=128k bootldr_size=0x0 @@ -852,52 +852,36 @@ clean: clean-all: clean rm -Rf $(HEXFILE_DIR) -# Code style checks using clang-format +# Style formatting helper targets -# Show only list of affected files for debug purposes -check-style-list: - @ret=0; for src in $(ALL_SOURCE) $(ALL_INCLUDES) ; do \ - var=`clang-format "$$src" | diff "$$src" - | wc -l` ; \ - if [ $$var -ne 0 ] ; then \ - echo "$$src" ; \ - ret=1; test -n "$(STOP)" && break; \ - fi ; \ - grep -H -n -e "^ .*if .*)$$" -e "^ .*else$$" -e "^ .* do$$" -e "^ .*while .*)$$" -e "^ .*for .*)$$" "$$src" | grep -v -e "^.*//" -e "^.*:.*: .*if ((.*[^)])$$" | sed 's,^,\n\n,; s,: ,:1: error: probably missing { or } for conditional or loop block:\n>>>,;' | grep -q -e "^.*$$" ; \ - if [ "$$?" -ne 1 ]; then \ - echo "$$src" ; \ - ret=1; test -n "$(STOP)" && break; \ - fi ; \ - done ; \ - if [ $$ret -eq 0 ] ; then \ - echo "Style check: PASS" && exit 0 ; \ - else \ - echo "Style check: FAIL!" && echo "Please, check the log above for the details." && exit 1 ; \ - fi ; +# Overwrite source files in your local repo copy according to IronOS code style rules (source/.clang-format) WITHOUT A WARNING! +# Use `git diff` or your favorite diff tool via `git difftool` before commit to make sure there are no false-negative changes. +# If so, report an issue, please. +style: + @for src in $(ALL_SOURCE) $(ALL_INCLUDES); do echo "Formatting $$src" ; clang-format -i "$$src" ; done; + @echo "Done! Please, check the changes before commit." -# Show output in gcc-like error compatible format for IDEs/editors; call `make check-style STOP=1` to exit after first failed file -# NOTICE: -# - clang-format has neat option for { } in condition blocks but it's available only since version 15: -# * https://clang.llvm.org/docs/ClangFormatStyleOptions.html#insertbraces -# - grep block in the middle used to trace missing { and } for if/else BUT IT'S VERY SPECULATIVE, very-very hacky & dirty +# Code style checks using clang-format: +# - show output in gcc-like error compatible format for IDEs/editors; +# - external variables for debug purposes (can be used at the same time, i.e. STOP=1 LIST=1 ...): +# * call `make check-style STOP=1` to exit after first failed file; +# * call `make check-style LIST=1` to show failed file names only; +# - here we process only list of files; +# - per-file check happens in scripts/deploy.sh : check_style_file - since shell commands involved, the check logic moved to shell script for better maintainance outside of makefile syntax crossing. +# - $? / error / STOP conditional logic needed to: +# * check errors in formatting from deploy.sh +# * process STOP env variable check-style: - @ret=0; for src in $(ALL_SOURCE) $(ALL_INCLUDES) ; do \ - var=`clang-format "$$src" | diff "$$src" - | wc -l` ; \ - if [ $$var -ne 0 ] ; then \ - clang-format "$$src" | diff "$$src" - | sed 's/^---/-------------------------------------------------------------------------------/; s/^< /--- /; s/^> /+++ /; /^[0-9].*/ s/[acd,].*$$/ERROR1/; /^[0-9].*/ s,^,\n\n\n\n'"$$src"':,; /ERROR1$$/ s,ERROR1$$,:1: error: clang-format code style mismatch:,; ' ; \ - ret=1; test -n "$(STOP)" && break; \ - fi ; \ - grep -H -n -e "^ .*if .*)$$" -e "^ .*else$$" -e "^ .* do$$" -e "^ .*while .*)$$" -e "^ .*for .*)$$" "$$src" | grep -v -e "^.*//" -e "^.*:.*: .*if ((.*[^)])$$" | sed 's,^,\n\n,; s,: ,:1: error: probably missing { or } for conditional or loop block:\n>>>,;' | grep -e "^.*$$" ; \ - if [ "$$?" -ne 1 ]; then \ - ret=1; test -n "$(STOP)" && break; \ - fi ; \ - done ; \ - if [ $$ret -eq 0 ] ; then \ - echo "Style check: PASS" && exit 0 ; \ - else \ - echo "Style check: FAIL!" && echo "Please, check the log above for the details." && exit 1 ; \ - fi ; + @error=0; export LIST=$$LIST; for src in $(ALL_SOURCE) $(ALL_INCLUDES) ; do \ + ../scripts/deploy.sh check_style_file "$$src" ; \ + test "$${?}" -eq 1 && export error=1 ; \ + test "$${error}" -eq 1 && test -n "$${STOP}" && break; \ + done; \ + if [ $$error -eq 0 ] ; then echo "" && echo "" && echo "Style check: PASS" && echo "" && echo "" && exit 0 ; \ + else echo "" && echo "" && echo "Style check: FAIL! Please, check the log above for the details." && echo "If there is a false-negative trigger, please, report an issue attaching the log or link to the log!" && echo "" && echo "" && exit 1 ; \ + fi; -.PHONY: check-style-list check-style all clean default clean-all +.PHONY: style check-style all clean default clean-all .SECONDARY: # Pull in dependency info for *existing* .o files