diff --git a/.github/workflows/build-deb.yml b/.github/workflows/pipeline.yml similarity index 56% rename from .github/workflows/build-deb.yml rename to .github/workflows/pipeline.yml index 3cc82f35..9ae24fbb 100644 --- a/.github/workflows/build-deb.yml +++ b/.github/workflows/pipeline.yml @@ -1,15 +1,43 @@ -name: Build libmicrohammer .deb +name: Pipeline on: + pull_request: workflow_dispatch: permissions: contents: write jobs: + clang-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install clang-format + run: | + sudo apt-get update + sudo apt-get install -y clang-format + + - name: Check formatting + run: | + find src examples -name '*.c' -o -name '*.h' | xargs clang-format --dry-run --Werror + + scons-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y scons gcc libglib2.0-dev pkg-config + + - name: Run tests + run: scons test + build-deb: runs-on: ubuntu-latest - + needs: [clang-format, scons-test] steps: - uses: actions/checkout@v4 @@ -30,14 +58,6 @@ jobs: mv $DEB_FILE $NEW_NAME echo "deb_file=$NEW_NAME" >> $GITHUB_OUTPUT - - name: Create tag - id: tag - run: | - VERSION=$(cat VERSION) - TAG="v$VERSION" - git tag $TAG - echo "tag=$TAG" >> $GITHUB_OUTPUT - - name: Upload build artifact uses: actions/upload-artifact@v4 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml deleted file mode 100644 index 784fd75c..00000000 --- a/.pre-commit-config.yaml +++ /dev/null @@ -1,6 +0,0 @@ -repos: - - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v18.1.8 - hooks: - - id: clang-format - files: \.(c|h)$ diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 5af050ab..3e5dfc91 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -6,12 +6,12 @@ Tested on Ubuntu 22.04 and 24.04 (VM and WSL). ## Contributor Setup -### Formatting and pre-commit +### Formatting Install formatting tools: ```bash -sudo apt install -y clang-format pre-commit +sudo apt install -y clang-format ``` Use `clang-format` to keep C code consistent. @@ -26,11 +26,6 @@ clang-format -i **/*.c **/*.h clang-format -i path/to/file.c ``` -Install the pre-commit hooks defined in `.pre-commit-config.yaml` to run formatting automatically: -```bash -pre-commit install -``` - ### Version management The repository centralizes the semantic version in the `VERSION` file. Update that file to bump the project version. All downstream artifacts read from it: diff --git a/VERSION b/VERSION index 9084fa2f..524cb552 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.1.1 diff --git a/debian/changelog b/debian/changelog index e34cfb0d..bb19d6d4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,14 @@ +libmicrohammer (1.1.1-1) unstable; urgency=medium + + * Add scons uninstall target to remove installed libhammer files + * Remove version suffix from installed .so files + * Add variant=microhammer to pkg-config metadata + * Document uninstall and version/variant query in README + * Fix crashing scons test compilation from pruned backends + * Improve h_in and h_not_in documentation in hammer.h + + -- Mahmoud Elbasiouny Tue, 03 Mar 2026 12:00:00 -0500 + libmicrohammer (1.1.0-1) unstable; urgency=medium * Testing infrastructure overhaul diff --git a/src/benchmark.c b/src/benchmark.c index 23096016..9364217a 100644 --- a/src/benchmark.c +++ b/src/benchmark.c @@ -8,7 +8,7 @@ #include #include -static const char *HParserBackendNames[] = {"Packrat", "Regular", "LL(k)", "LALR", "GLR"}; +static const char *HParserBackendNames[] = {"Invalid", "Packrat"}; /* Usage: diff --git a/src/hammer.h b/src/hammer.h index 62e7d7dc..6c8bd560 100644 --- a/src/hammer.h +++ b/src/hammer.h @@ -420,8 +420,7 @@ HParseResult *h_parse__m(HAllocator *mm__, const HParser *parser, const uint8_t size_t length); /** - * @brief Initialize a parser for iteratively consuming an input stream in chunks. This is only - * supported by some backends. + * @brief Initialize a parser for iteratively consuming an input stream in chunks. * * @param parser Parser to use * @return Result is NULL if not supported by the backend. @@ -517,7 +516,7 @@ HParser *h_bits(size_t len, _Bool sign); HParser *h_bits__m(HAllocator *mm__, size_t len, _Bool sign); /** - * @brief Returns a parser that parses the specified number of octets. The input does not have to be + * @brief Returns a parser that parses the specified number of bytes. The input does not have to be * aligned to a byte boundary. * * @param len Number of bytes @@ -657,19 +656,27 @@ HParser *h_action(const HParser *p, const HAction a, void *user_data); HParser *h_action__m(HAllocator *mm__, const HParser *p, const HAction a, void *user_data); /** - * @brief Parse a single character in the given charset - * @param charset Character set - * @param length Charset length + * @brief Parse a single byte that is in the given charset. Always attempts to + * consume exactly one byte from the input; advances the cursor by one byte on + * success. Fails (and does not advance the cursor) if the byte is not in the + * charset. + * @param charset Array of accepted byte values + * @param length Number of bytes in charset * @return Result token type: TT_UINT + * @note Consumes 1 byte (8 bits) from the input stream on success */ HParser *h_in(const uint8_t *charset, size_t length); HParser *h_in__m(HAllocator *mm__, const uint8_t *charset, size_t length); /** - * @brief Parse a single character *NOT* in the given charset - * @param charset Character set to exclude - * @param length Charset length + * @brief Parse a single byte that is *NOT* in the given charset. Always + * attempts to consume exactly one byte from the input; advances the cursor by + * one byte on success. Fails (and does not advance the cursor) if the byte is + * in the charset. + * @param charset Array of excluded byte values + * @param length Number of bytes in charset * @return Result token type: TT_UINT + * @note Consumes 1 byte (8 bits) from the input stream on success */ HParser *h_not_in(const uint8_t *charset, size_t length); HParser *h_not_in__m(HAllocator *mm__, const uint8_t *charset, size_t length); @@ -878,8 +885,7 @@ HParser *h_epsilon_p__m(HAllocator *mm__); /** * @brief This parser applies its first argument to read an unsigned integer value, then applies its * second argument that many times. length should parse an unsigned integer value; this is checked - * at runtime. Specifically, the token_type of the returned token must be TT_UINT. In future we - * might relax this to include TT_USER but don't count on it. + * at runtime. Specifically, the token_type of the returned token must be TT_UINT. * * @param length Parser to read length * @param value Parser to apply length times diff --git a/src/t_bitreader.c b/src/t_bitreader.c index d634be64..d3655586 100644 --- a/src/t_bitreader.c +++ b/src/t_bitreader.c @@ -7,7 +7,10 @@ #include #define MK_INPUT_STREAM(buf, len, endianness_) \ - {.input = (uint8_t *)buf, .length = len, .index = 0, .bit_offset = 0, .endianness = endianness_} + { \ + .input = (uint8_t *)buf, .length = len, .index = 0, .bit_offset = 0, \ + .endianness = endianness_ \ + } static void test_bitreader_ints(void) { HInputStream is =