Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
a1392e91
Unverified
Commit
a1392e91
authored
Dec 04, 2018
by
Scott Cyphers
Committed by
GitHub
Dec 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into master
parents
37380b8d
aaf25652
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
310 deletions
+103
-310
CMakeLists.txt
CMakeLists.txt
+9
-1
style_apply.cmake
cmake/Modules/style_apply.cmake
+42
-0
style_check.cmake
cmake/Modules/style_check.cmake
+52
-0
apply-code-format.sh
maint/apply-code-format.sh
+0
-64
bash_lib.sh
maint/bash_lib.sh
+0
-91
check-code-format.sh
maint/check-code-format.sh
+0
-80
clang_format_lib.sh
maint/clang_format_lib.sh
+0
-74
No files found.
CMakeLists.txt
View file @
a1392e91
...
...
@@ -234,7 +234,15 @@ if (NOT DEFINED NGRAPH_TBB_ENABLE)
endif
()
add_custom_target
(
style-check
COMMAND
${
PROJECT_SOURCE_DIR
}
/maint/check-code-format.sh
COMMAND
${
CMAKE_COMMAND
}
-DNGRAPH_SOURCE_DIR=
"
${
CMAKE_SOURCE_DIR
}
"
-P
${
CMAKE_MODULE_PATH
}
style_check.cmake
)
add_custom_target
(
style-apply
COMMAND
${
CMAKE_COMMAND
}
-DNGRAPH_SOURCE_DIR=
"
${
CMAKE_SOURCE_DIR
}
"
-P
${
CMAKE_MODULE_PATH
}
style_apply.cmake
)
#-----------------------------------------------------------------------------------------------
...
...
cmake/Modules/style_apply.cmake
0 → 100644
View file @
a1392e91
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
# ******************************************************************************
function
(
STYLE_APPLY_FILE PATH
)
execute_process
(
COMMAND
${
CLANG_FORMAT
}
-style=file -i
${
PATH
}
OUTPUT_VARIABLE STYLE_CHECK_RESULT
)
endfunction
()
set
(
DIRECTORIES_OF_INTEREST
src
doc
test
python/pyngraph
)
set
(
CLANG_FORMAT_FILENAME clang-format-3.9
)
find_program
(
CLANG_FORMAT
${
CLANG_FORMAT_FILENAME
}
PATHS ENV PATH
)
if
(
CLANG_FORMAT
)
foreach
(
DIRECTORY
${
DIRECTORIES_OF_INTEREST
}
)
set
(
DIR
"
${
NGRAPH_SOURCE_DIR
}
/
${
DIRECTORY
}
/*.?pp"
)
file
(
GLOB_RECURSE XPP_FILES
${
DIR
}
)
foreach
(
FILE
${
XPP_FILES
}
)
style_apply_file
(
${
FILE
}
)
endforeach
(
FILE
)
endforeach
(
DIRECTORY
)
else
()
message
(
STATUS
"
${
CLANG_FORMAT_FILENAME
}
not found, style not available"
)
endif
()
cmake/Modules/style_check.cmake
0 → 100644
View file @
a1392e91
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
# ******************************************************************************
set
(
CLANG_FORMAT_FILENAME clang-format-3.9
)
find_program
(
CLANG_FORMAT
${
CLANG_FORMAT_FILENAME
}
PATHS ENV PATH
)
macro
(
STYLE_CHECK_FILE PATH
)
execute_process
(
COMMAND
${
CLANG_FORMAT
}
-style=file -output-replacements-xml
${
PATH
}
OUTPUT_VARIABLE STYLE_CHECK_RESULT
)
list
(
LENGTH STYLE_CHECK_RESULT RESULT_LENGTH
)
if
(
RESULT_LENGTH GREATER 1
)
list
(
APPEND ERROR_LIST
${
PATH
}
)
endif
()
endmacro
()
set
(
DIRECTORIES_OF_INTEREST
src
doc
test
python/pyngraph
)
if
(
CLANG_FORMAT
)
foreach
(
DIRECTORY
${
DIRECTORIES_OF_INTEREST
}
)
set
(
DIR
"
${
NGRAPH_SOURCE_DIR
}
/
${
DIRECTORY
}
/*.?pp"
)
file
(
GLOB_RECURSE XPP_FILES
${
DIR
}
)
foreach
(
FILE
${
XPP_FILES
}
)
style_check_file
(
${
FILE
}
)
endforeach
(
FILE
)
endforeach
(
DIRECTORY
)
if
(
ERROR_LIST
)
foreach
(
ERROR
${
ERROR_LIST
}
)
message
(
STATUS
"style error:
${
ERROR
}
"
)
endforeach
()
message
(
FATAL_ERROR
"style errors"
)
endif
()
else
()
message
(
STATUS
"
${
CLANG_FORMAT_FILENAME
}
not found, style not available"
)
endif
()
maint/apply-code-format.sh
deleted
100755 → 0
View file @
37380b8d
#!/bin/bash
set
-e
set
-u
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
# ******************************************************************************
# NOTE: The results of `clang-format` depend _both_ of the following factors:
# - The `.clang-format` file, and
# - The particular version of the `clang-format` program being used.
#
# For this reason, this script specifies the exact version of clang-format to be used.
declare
CLANG_FORMAT_BASENAME
=
"clang-format-3.9"
declare
REQUIRED_CLANG_FORMAT_VERSION
=
3.9
declare
THIS_SCRIPT_DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
source
"
${
THIS_SCRIPT_DIR
}
/bash_lib.sh"
source
"
${
THIS_SCRIPT_DIR
}
/clang_format_lib.sh"
declare
CLANG_FORMAT_PROG
if
!
CLANG_FORMAT_PROG
=
"
$(
which
"
${
CLANG_FORMAT_BASENAME
}
"
)
"
;
then
bash_lib_die
"Unable to find program
${
CLANG_FORMAT_BASENAME
}
"
>
&2
fi
clang_format_lib_verify_version
"
${
CLANG_FORMAT_PROG
}
"
"
${
REQUIRED_CLANG_FORMAT_VERSION
}
"
bash_lib_status
"Verified that '
${
CLANG_FORMAT_PROG
}
' has version '
${
REQUIRED_CLANG_FORMAT_VERSION
}
'"
pushd
"
${
THIS_SCRIPT_DIR
}
/.."
declare
PYBIND_WRAPPER
=
"python/pyngraph"
declare
ROOT_SUBDIR
for
ROOT_SUBDIR
in
src doc/examples
test
${
PYBIND_WRAPPER
}
;
do
if
!
[[
-d
"
${
ROOT_SUBDIR
}
"
]]
;
then
bash_lib_status
"In directory '
$(
pwd
)
', no subdirectory named '
${
ROOT_SUBDIR
}
' was found."
else
bash_lib_status
"About to format C/C++ code in directory tree '
$(
pwd
)
/
${
ROOT_SUBDIR
}
' ..."
# Note that we restrict to "-type f" to exclude symlinks. Emacs sometimes
# creates dangling symlinks with .cpp/.hpp suffixes as a sort of locking
# mechanism, and this confuses clang-format.
find
"
${
ROOT_SUBDIR
}
"
-type
f
-and
\(
-name
'*.cpp'
-or
-name
'*.hpp'
\)
| xargs
"
${
CLANG_FORMAT_PROG
}
"
-i
-style
=
file
find
"
${
ROOT_SUBDIR
}
"
-type
f
-and
\(
-name
'*.cpp'
-or
-name
'*.hpp'
-or
-name
'CMakeLists.txt'
\)
| xargs
chmod
0644
bash_lib_status
"Done."
fi
done
popd
maint/bash_lib.sh
deleted
100644 → 0
View file @
37380b8d
#!/bin/bash
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
# ******************************************************************************
#===================================================================================================
# A library of general-purpose Bash functions
#===================================================================================================
declare
_intelnervana_bash_lib_SCRIPT_NAME
=
"
${
BASH_SOURCE
[
${#
BASH_SOURCE
[@]
}
- 1]
}
"
declare
_maint_SCRIPT_DIR
=
"
$(
cd
$(
dirname
"
${
_intelnervana_bash_lib_SCRIPT_NAME
}
"
)
&&
pwd
)
"
declare
_intelnervana_bash_lib_IS_LOADED
=
1
bash_lib_get_my_BASH_LINENO
()
{
echo
"
${
BASH_LINENO
[
${#
BASH_LINENO
[@]
}
-1 ]
}
"
}
bash_lib_get_callers_BASH_LINENO
()
{
echo
"
${
BASH_LINENO
[
${#
BASH_LINENO
[@]
}
- 2]
}
"
}
bash_lib_get_my_BASH_SOURCE
()
{
echo
"
${
BASH_SOURCE
[
${#
BASH_SOURCE
[@]
}
]
}
"
}
bash_lib_get_callers_BASH_SOURCE
()
{
echo
"
${
BASH_SOURCE
[
${#
BASH_SOURCE
[@]
}
- 1]
}
"
}
bash_lib_status
()
{
local
CONTEXT_STRING
=
"
$(
basename
$(
bash_lib_get_callers_BASH_SOURCE
))
"
local
TEXT_LINE
local
IS_FIRST_LINE
=
1
for
TEXT_LINE
in
"
${
@
}
"
;
do
if
((
IS_FIRST_LINE
==
1
))
;
then
IS_FIRST_LINE
=
0
printf
"%s STATUS: "
"
${
CONTEXT_STRING
}
"
>
&2
else
printf
" "
>
&2
fi
printf
"%s
\n
"
"
${
TEXT_LINE
}
"
>
&2
done
}
bash_lib_print_error
()
{
local
CONTEXT_STRING
=
"
$(
basename
$(
bash_lib_get_callers_BASH_SOURCE
))
:
$(
bash_lib_get_callers_BASH_LINENO
)
"
local
TEXT_LINE
local
IS_FIRST_LINE
=
1
for
TEXT_LINE
in
"
${
@
}
"
;
do
if
((
IS_FIRST_LINE
==
1
))
;
then
IS_FIRST_LINE
=
0
printf
"%s ERROR: "
"
${
CONTEXT_STRING
}
"
>
&2
else
printf
" "
>
&2
fi
printf
"%s
\n
"
"
${
TEXT_LINE
}
"
>
&2
done
}
bash_lib_die
()
{
bash_lib_print_error
$@
exit
1
}
bash_lib_am_sudo_or_root
()
{
[
"
$EUID
"
-eq
0
]
}
if
bash_lib_am_sudo_or_root
;
then
bash_lib_MAYBE_SUDO
=
''
else
bash_lib_MAYBE_SUDO
=
'sudo --set-home'
fi
maint/check-code-format.sh
deleted
100755 → 0
View file @
37380b8d
#!/bin/bash
set
-e
set
-u
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
# ******************************************************************************
# NOTE: The results of `clang-format` depend _both_ of the following factors:
# - The `.clang-format` file, and
# - The particular version of the `clang-format` program being used.
#
# For this reason, this script specifies the exact version of clang-format to be used.
declare
CLANG_FORMAT_BASENAME
=
"clang-format-3.9"
declare
REQUIRED_CLANG_FORMAT_VERSION
=
3.9
declare
THIS_SCRIPT_DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
source
"
${
THIS_SCRIPT_DIR
}
/bash_lib.sh"
source
"
${
THIS_SCRIPT_DIR
}
/clang_format_lib.sh"
declare
CLANG_FORMAT_PROG
if
!
CLANG_FORMAT_PROG
=
"
$(
which
"
${
CLANG_FORMAT_BASENAME
}
"
)
"
;
then
bash_lib_die
"Unable to find program
${
CLANG_FORMAT_BASENAME
}
"
>
&2
fi
clang_format_lib_verify_version
"
${
CLANG_FORMAT_PROG
}
"
"
${
REQUIRED_CLANG_FORMAT_VERSION
}
"
bash_lib_status
"Verified that '
${
CLANG_FORMAT_PROG
}
' has version '
${
REQUIRED_CLANG_FORMAT_VERSION
}
'"
declare
-a
FAILED_FILES
=()
declare
NUM_FILES_CHECKED
=
0
pushd
"
${
THIS_SCRIPT_DIR
}
/.."
declare
PYBIND_WRAPPER
=
"python/pyngraph"
declare
ROOT_SUBDIR
for
ROOT_SUBDIR
in
src doc/examples
test
${
PYBIND_WRAPPER
}
;
do
if
!
[[
-d
"
${
ROOT_SUBDIR
}
"
]]
;
then
bash_lib_status
"In directory '
$(
pwd
)
', no subdirectory named '
${
ROOT_SUBDIR
}
' was found."
else
bash_lib_status
"About to format C/C++ code in directory tree '
$(
pwd
)
/
${
ROOT_SUBDIR
}
' ..."
declare
SRC_FILE
# Note that we restrict to "-type f" to exclude symlinks. Emacs sometimes
# creates dangling symlinks with .cpp/.hpp suffixes as a sort of locking
# mechanism, and this confuses clang-format.
for
SRC_FILE
in
$(
find
"
${
ROOT_SUBDIR
}
"
-type
f
-and
\(
-name
'*.cpp'
-or
-name
'*.hpp'
\)
)
;
do
if
"
${
CLANG_FORMAT_PROG
}
"
-style
=
file
-output-replacements-xml
"
${
SRC_FILE
}
"
|
grep
-c
"<replacement "
>
/dev/null
;
then
FAILED_FILES+
=(
"
${
SRC_FILE
}
"
)
fi
NUM_FILES_CHECKED
=
$((
NUM_FILES_CHECKED+1
))
done
fi
done
popd
if
[[
${#
FAILED_FILES
[@]
}
-eq
0
]]
;
then
bash_lib_status
"All
${
NUM_FILES_CHECKED
}
C/C++ files pass the code-format check."
else
echo
"
${#
FAILED_FILES
[@]
}
of
${
NUM_FILES_CHECKED
}
source files failed the code-format check:"
declare
FAILED_SRC_FILE
for
FAILED_SRC_FILE
in
${
FAILED_FILES
[@]
}
;
do
echo
"
${
FAILED_SRC_FILE
}
"
done
exit
1
fi
maint/clang_format_lib.sh
deleted
100644 → 0
View file @
37380b8d
#!/bin/bash
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
# ******************************************************************************
#===================================================================================================
# Provides Bash functions for dealing with clang-format.
#===================================================================================================
declare
_intelnervana_clang_format_lib_SCRIPT_NAME
=
"
${
BASH_SOURCE
[
${#
BASH_SOURCE
[@]
}
- 1]
}
"
declare
_maint_SCRIPT_DIR
=
"
$(
cd
$(
dirname
"
${
_intelnervana_clang_format_lib_SCRIPT_NAME
}
"
)
&&
pwd
)
"
source
"
${
_maint_SCRIPT_DIR
}
/bash_lib.sh"
clang_format_lib_verify_version
()
{
if
((
$#
!=
2
))
;
then
bash_lib_print_error
"Usage:
${
FUNCNAME
[0]
}
<clang-format-prog-pathname> <required-version-number>"
return
1
fi
local
PROGNAME
=
"
${
1
}
"
local
REQUIRED_VERSION_X_Y
=
"
${
2
}
"
if
!
[[
"
${
REQUIRED_VERSION_X_Y
}
"
=
~ ^[0-9]+.[0-9]+
$
]]
;
then
bash_lib_print_error
"
${
FUNCNAME
[0]
}
: required-version-number must have the form (number).(number)."
return
1
fi
if
!
[[
-f
"
${
PROGNAME
}
"
]]
;
then
bash_lib_print_error
"Unable to find clang-format program named '
${
PROGNAME
}
'"
return
1
fi
local
VERSION_LINE
if
!
VERSION_LINE
=
$(
"
${
PROGNAME
}
"
--version
)
;
then
bash_lib_print_error
"Failed invocation of command '
${
PROGNAME
}
--version'"
return
1
fi
local
SED_FLAGS
if
[[
"
$(
uname
)
"
==
'Darwin'
]]
;
then
SED_FLAGS
=
'-En'
else
SED_FLAGS
=
'-rn'
fi
local
VERSION_X_Y
if
!
VERSION_X_Y
=
$(
echo
"
${
VERSION_LINE
}
"
|
sed
${
SED_FLAGS
}
's/^clang-format version ([0-9]+.[0-9]+).*$/\1/p'
)
then
bash_lib_print_error
"Failed invocation of sed."
return
1
fi
if
[[
"
${
REQUIRED_VERSION_X_Y
}
"
!=
"
${
VERSION_X_Y
}
"
]]
;
then
bash_lib_print_error
\
"Program '
${
PROGNAME
}
' reports version number '
${
VERSION_X_Y
}
'"
\
"but we require '
${
REQUIRED_VERSION_X_Y
}
'"
return
1
fi
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment