Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flaub committed Apr 29, 2024
1 parent be8cefa commit 2452907
Show file tree
Hide file tree
Showing 21 changed files with 18 additions and 19 deletions.
30 changes: 16 additions & 14 deletions license-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from pathlib import Path
import subprocess

PUBLIC_HEADER = '''
PUBLIC_HEADER = """
// Copyright {YEAR} RISC Zero, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -19,50 +19,52 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
'''.strip().splitlines()
""".strip().splitlines()

EXTENSIONS = [
'.cpp',
'.h',
'.rs',
".cpp",
".h",
".rs",
]

SKIP_DIRS = [
str(Path.cwd()) + "/templates/rust-starter",
str(Path.cwd()) + "/risc0/circuit/rv32im-sys/cxx/vendor",
]


def check_header(expected_year, lines_actual):
for (expected, actual) in zip(PUBLIC_HEADER, lines_actual):
expected = expected.replace('{YEAR}', expected_year)
for expected, actual in zip(PUBLIC_HEADER, lines_actual):
expected = expected.replace("{YEAR}", expected_year)
if expected != actual:
return (expected, actual)
return None


def check_file(root, file):
cmd = ['git', 'log', '-1', '--format=%ad', '--date=format:%Y', file]
expected_year = subprocess.check_output(cmd, encoding='UTF-8').strip()
cmd = ["git", "log", "-1", "--format=%ad", "--date=format:%Y", file]
expected_year = subprocess.check_output(cmd, encoding="UTF-8").strip()
rel_path = file.relative_to(root)
lines = file.read_text().splitlines()
result = check_header(expected_year, lines)
if result:
print(f'{rel_path}: invalid header!')
print(f' expected: {result[0]}')
print(f' actual: {result[1]}')
print(f"{rel_path}: invalid header!")
print(f" expected: {result[0]}")
print(f" actual: {result[1]}")
return 1
return 0


def repo_root():
"""Return an absolute Path to the repo root"""
cmd = ["git", "rev-parse", "--show-toplevel"]
return Path(subprocess.check_output(cmd, encoding='UTF-8').strip())
return Path(subprocess.check_output(cmd, encoding="UTF-8").strip())


def tracked_files():
"""Yield all file paths tracked by git"""
cmd = ["git", "ls-tree", "--full-tree", "--name-only", "-r", "HEAD"]
tree = subprocess.check_output(cmd, encoding='UTF-8').strip()
tree = subprocess.check_output(cmd, encoding="UTF-8").strip()
for path in tree.splitlines():
yield (repo_root() / Path(path)).absolute()

Expand Down
6 changes: 2 additions & 4 deletions risc0/circuit/rv32im-sys/cxx/extern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

#include "ffi.h"
#include "fp.h"
#include "nvtx3/nvtx3.hpp"
#include "poolstl.hpp"
#include "vendor/nvtx3/nvtx3.hpp"
#include "vendor/poolstl.hpp"

#include <algorithm>
#include <cassert>
#include <cstring>
#include <execution>
#include <iostream>
#include <stdexcept>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion risc0/circuit/rv32im-sys/cxx/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include "fp.h"

#include <array>
#include <initializer_list>
#include <vector>

#if defined(__clang__)
Expand Down
File renamed without changes.

0 comments on commit 2452907

Please sign in to comment.