Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lint-license: Add patches for lowRISC/misc-linters #8

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lint-license/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
description: 'Revision of `lowRISC/misc-linters` to use'
required: true
default: '20220921_01'
patches:
description: 'A list of patches from the patches/ directory to apply to lowRISC/misc-linters'
required: true
default: ''

runs:
using: "composite"
Expand All @@ -49,6 +53,9 @@ runs:
git clone https://github.com/lowRISC/misc-linters.git
cd misc-linters
git checkout ${{ inputs.linters_revision }}
git config user.email "[email protected]"
git config user.name "Luca Colagrande"
${{ github.action_path }}/apply_patches.py ${{ runner.temp }}/pulp-actions/lint-license/misc-linters ${{ inputs.patches }} --patch-dir=${{ github.action_path }}/patches
- name: Generate config
shell: bash
run: ${{ github.action_path }}/gen_config.py "${{ runner.temp }}/pulp-actions/lint-license/cfg.hjson" ${{ inputs.match_regex }} "${{ inputs.license }}" "${{ inputs.exclude_paths }}"
Expand Down
43 changes: 43 additions & 0 deletions lint-license/apply_patches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3
#
# Copyright 2023 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Luca Colagrande <[email protected]>

import os
import argparse
from pathlib import Path


def main():
# Argument parsing
parser = argparse.ArgumentParser()
parser.add_argument(
'repo',
help='Path to Git repository to patch',
)
parser.add_argument(
'patches',
nargs='+',
help='List of patches to apply')
parser.add_argument(
'--patch-dir',
action='store',
help='(Optional) Path to look for the patches in')
args = parser.parse_args()
patches = args.patches
repo = args.repo
patch_dir = args.patch_dir

# Apply patches
for patch in patches:
patchfile = Path(patch)
if patch_dir:
patchfile = Path(patch_dir) / patchfile
os.system(f'git -C {repo} am {patchfile}')


if __name__ == '__main__':
main()
27 changes: 27 additions & 0 deletions lint-license/patches/0001-Allow-hash-comments-in-assembly.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 8f0ef9a7b9af190e49ee74adc6232f43374012e3 Mon Sep 17 00:00:00 2001
From: Luca Colagrande <[email protected]>
Date: Wed, 19 Apr 2023 14:05:28 +0200
Subject: [PATCH] Allow hash comments in assembly

---
licence-checker/licence-checker.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/licence-checker/licence-checker.py b/licence-checker/licence-checker.py
index e863f94..6263f50 100755
--- a/licence-checker/licence-checker.py
+++ b/licence-checker/licence-checker.py
@@ -142,8 +142,8 @@ COMMENT_CHARS = [
# Software Files
([".c", ".h", ".inc", ".cc", ".cpp"], SLASH_SLASH), # C, C++
([".def"], SLASH_SLASH), # C, C++ X-Include List Declaration Files
- ([".S"], [SLASH_SLASH, SLASH_STAR]), # Assembly (With Preprocessing)
- ([".s"], SLASH_STAR), # Assembly (Without Preprocessing)
+ ([".S"], [SLASH_SLASH, SLASH_STAR, HASH]), # Assembly (With Preprocessing)
+ ([".s"], [SLASH_STAR, HASH]), # Assembly (Without Preprocessing)
([".ld"], SLASH_STAR), # Linker Scripts
([".rs"], SLASH_SLASH), # Rust
([".go"], SLASH_SLASH), # Golang
--
2.28.0