pw_env_setup: add warning when using *.bat on Linux

Change-Id: I62da6ad0f14fd0563eee07c20b8fd78e38b53e28
This commit is contained in:
Rob Mohr 2020-04-17 11:50:47 -07:00
parent e010bff531
commit 709472a957
3 changed files with 36 additions and 4 deletions

View File

@ -1,3 +1,4 @@
:<<"::WINDOWS_ONLY"
@echo off
:: Copyright 2020 The Pigweed Authors
::
@ -12,6 +13,13 @@
:: WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
:: License for the specific language governing permissions and limitations under
:: the License.
::WINDOWS_ONLY
:; echo "ERROR: Attempting to run Windows .bat from a Unix/POSIX shell!"
:; echo "Instead, run the following command."
:; echo ""
:; echo " source ./activate.sh"
:; echo ""
:<<"::WINDOWS_ONLY"
:: Activates a Pigweed development environment by setting the appropriate
:: environment variables. bootstrap.bat must be run initially to install all
@ -21,3 +29,4 @@
set PW_SKIP_BOOTSTRAP=1
call "%~dp0\bootstrap.bat"
set PW_SKIP_BOOTSTRAP=
::WINDOWS_ONLY

View File

@ -1,3 +1,4 @@
:<<"::WINDOWS_ONLY"
@echo off
:: Copyright 2020 The Pigweed Authors
::
@ -12,6 +13,13 @@
:: WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
:: License for the specific language governing permissions and limitations under
:: the License.
::WINDOWS_ONLY
:; echo "ERROR: Attempting to run Windows .bat from a Unix/POSIX shell!"
:; echo "Instead, run the following command."
:; echo ""
:; echo " source ./bootstrap.sh"
:; echo ""
:<<"::WINDOWS_ONLY"
:: Pigweed Windows environment setup.
@ -86,3 +94,4 @@ set PW_CARGO_PACKAGE_FILES=%_PW_OLD_CARGO_PACKAGE_FILES%
call "%shell_file%"
:finish
::WINDOWS_ONLY

View File

@ -299,6 +299,14 @@ if sys.platform != 'darwin':
COPYRIGHT_FIRST_LINE = re.compile(
r'^(#|//| \*|REM|::) Copyright 20\d\d The Pigweed Authors$')
COPYRIGHT_FIRST_LINE_EXCEPTIONS = (
'#!',
'/*',
'@echo off',
'# -*-',
':',
)
COPYRIGHT_LINES = tuple("""\
Licensed under the Apache License, Version 2.0 (the "License"); you may not
@ -340,13 +348,19 @@ def copyright_notice(ctx: PresubmitContext):
for path in ctx.paths:
_LOG.debug('Checking %s', path)
with open(path) as file:
# Skip shebang and blank lines
line = file.readline()
while line and (line.startswith(
('#!', '/*', '@echo off', '# -*-')) or not line.strip()):
first_line = None
while line:
first_line = COPYRIGHT_FIRST_LINE.match(line)
if first_line:
break
if (line.strip() and
not line.startswith(COPYRIGHT_FIRST_LINE_EXCEPTIONS)):
break
line = file.readline()
first_line = COPYRIGHT_FIRST_LINE.match(line)
if not first_line:
_LOG.debug('%s: invalid first line %r', path, line)
errors.append(path)