Skip to content

Commit

Permalink
Enforce license info in src/brave (fixes brave/brave-browser#9408)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmarier committed May 13, 2020
1 parent 564afa2 commit f020ffb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
14 changes: 12 additions & 2 deletions patches/tools-licenses.py.patch
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
diff --git a/tools/licenses.py b/tools/licenses.py
index 6405b31497a425c68b0486a2653071f23e515671..e957c14c924a7a405bf9e20f3c8e2ffc56ea1306 100755
index 6405b31497a425c68b0486a2653071f23e515671..5402e94334b0ecb6ebcbefb9e4cd93b070eb5cbd 100755
--- a/tools/licenses.py
+++ b/tools/licenses.py
@@ -35,6 +35,7 @@ else:
_REPOSITORY_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
sys.path.insert(0, os.path.join(_REPOSITORY_ROOT, 'build/android/gyp'))
from util import build_utils
+from brave_license_helper import AddBraveCredits, BRAVE_THIRD_PARTY_DIRS
+from brave_license_helper import AddBraveCredits, BRAVE_THIRD_PARTY_DIRS, CheckBraveMissingLicense


# Paths from the root of the tree to directories to skip.
Expand All @@ -28,3 +28,13 @@ index 6405b31497a425c68b0486a2653071f23e515671..e957c14c924a7a405bf9e20f3c8e2ffc
# Add all subdirectories that are not marked for skipping.
for dir in dirs:
dirpath = os.path.join(path, dir)
@@ -663,7 +666,8 @@ def GenerateCredits(
for path in third_party_dirs:
try:
metadata = ParseDir(path, _REPOSITORY_ROOT)
- except LicenseError:
+ except LicenseError as e:
+ CheckBraveMissingLicense(target_os, path, e)
# TODO(phajdan.jr): Convert to fatal error (http://crbug.com/39240).
continue
if metadata['License File'] == NOT_SHIPPED:
19 changes: 19 additions & 0 deletions script/brave_license_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
'vendor',
]

ANDROID_ONLY_PATHS = [
os.path.join('brave', 'components', 'brave_sync', 'extension', 'brave-sync-android'),
]

DESKTOP_ONLY_PATHS = [
os.path.join('brave', 'components', 'brave_sync', 'extension', 'brave-sync'),
]


def AddBraveCredits(prune_paths, special_cases, prune_dirs, additional_paths):
# Exclude these specific paths from needing a README.chromium file.
Expand Down Expand Up @@ -149,3 +157,14 @@ def AddBraveCredits(prune_paths, special_cases, prune_dirs, additional_paths):
additional_paths = tuple(additional_list)

return (prune_dirs, additional_paths)


def CheckBraveMissingLicense(target_os, path, error):
if path.startswith('brave'):
if (target_os == 'android'):
if path in DESKTOP_ONLY_PATHS:
return # Desktop failures are not relevant on Android.
else:
if path in ANDROID_ONLY_PATHS:
return # Android failures are not relevant on desktop.
raise error

0 comments on commit f020ffb

Please sign in to comment.