aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <antiagainst@google.com>2016-08-16 16:32:19 -0400
committerLei Zhang <antiagainst@google.com>2016-08-16 16:32:19 -0400
commit6d112337e3cbc1bba5660958b41a516ce19967c8 (patch)
treefda6eb775bb3c221494a7f71e8c6723d324acf04
parent800d472eb287445fbe55acb970238d16a6e57d7e (diff)
parent68b8e9443788b47f221b7b410af9016dfe3e6fff (diff)
downloadshaderc-6d112337e3cbc1bba5660958b41a516ce19967c8.tar.gz
Merge remote-tracking branch 'aosp/upstream-master'
Pulls in the following: 68b8e94 Invoke python via PYTHON_EXE discovered by cmake 8541199 Build SPIRV-Tools file Instruction.cpp instead of Id.cpp 620166a Use with clause to handle files. b077f3e Avoid redefining builtin dir and break long comment lines. Change-Id: If9ee4c343a3d5d2225653baa286d116911e9ed65
-rw-r--r--CHANGES2
-rw-r--r--CMakeLists.txt6
-rw-r--r--cmake/setup_build.cmake2
-rw-r--r--glslc/test/CMakeLists.txt2
-rw-r--r--third_party/Android.mk2
-rw-r--r--third_party/CMakeLists.txt2
-rwxr-xr-xutils/add_copyright.py11
-rwxr-xr-xutils/update_build_version.py45
8 files changed, 40 insertions, 32 deletions
diff --git a/CHANGES b/CHANGES
index 01ef943..45373d5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,8 @@ Revision history for Shaderc
v2016.1-dev 2016-07-08
- Start v2016.1
+ - Fixes issues:
+ #238: Fix invocation of python scripts during build
v2016.0 2016-07-07
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 801d4f0..a4c2fac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,13 +18,13 @@ include(cmake/setup_build.cmake)
include(cmake/utils.cmake)
add_custom_target(check-copyright ALL
- ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/add_copyright.py
+ ${PYTHON_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/add_copyright.py
--check
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Check copyright")
add_custom_target(add-copyright
- ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/add_copyright.py
+ ${PYTHON_EXE} ${CMAKE_CURRENT_SOURCE_DIR}/utils/add_copyright.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Add copyright")
@@ -54,7 +54,7 @@ add_subdirectory(glslc)
add_subdirectory(examples)
add_custom_target(build-version
- ${PYTHON_EXECUTABLE}
+ ${PYTHON_EXE}
${CMAKE_CURRENT_SOURCE_DIR}/utils/update_build_version.py
${shaderc_SOURCE_DIR} ${spirv-tools_SOURCE_DIR} ${glslang_SOURCE_DIR}
COMMENT "Update build-version.inc in the Shaderc build directory (if necessary).")
diff --git a/cmake/setup_build.cmake b/cmake/setup_build.cmake
index fa75fa4..b46d920 100644
--- a/cmake/setup_build.cmake
+++ b/cmake/setup_build.cmake
@@ -71,7 +71,7 @@ if (ENABLE_CODE_COVERAGE)
# The symptom is that some .gcno files are wrong after code change and
# recompiling. We don't know the exact reason yet. Figure it out.
# Remove all .gcno files in the directory recursively.
- COMMAND ${PYTHON_EXECUTABLE}
+ COMMAND ${PYTHON_EXE}
${shaderc_SOURCE_DIR}/utils/remove-file-by-suffix.py . ".gcno"
# .gcno files are not tracked by CMake. So no recompiling is triggered
# even if they are missing. Unfortunately, we just removed all of them
diff --git a/glslc/test/CMakeLists.txt b/glslc/test/CMakeLists.txt
index 7f02328..bb82a70 100644
--- a/glslc/test/CMakeLists.txt
+++ b/glslc/test/CMakeLists.txt
@@ -3,7 +3,7 @@ shaderc_add_nosetests(glslc_test_framework)
if(${SHADERC_ENABLE_TESTS})
add_test(NAME glslc_tests
- COMMAND ${PYTHON_EXECUTABLE}
+ COMMAND ${PYTHON_EXE}
${CMAKE_CURRENT_SOURCE_DIR}/glslc_test_framework.py
$<TARGET_FILE:glslc_exe> --test-dir ${CMAKE_CURRENT_SOURCE_DIR})
endif()
diff --git a/third_party/Android.mk b/third_party/Android.mk
index b01f01a..7084297 100644
--- a/third_party/Android.mk
+++ b/third_party/Android.mk
@@ -186,7 +186,7 @@ LOCAL_SRC_FILES:= \
source/val/BasicBlock.cpp \
source/val/Construct.cpp \
source/val/Function.cpp \
- source/val/Id.cpp \
+ source/val/Instruction.cpp \
source/val/ValidationState.cpp \
source/validate.cpp \
source/validate_cfg.cpp \
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index 8f7f8b2..0b50b96 100644
--- a/third_party/CMakeLists.txt
+++ b/third_party/CMakeLists.txt
@@ -64,7 +64,7 @@ if(${SHADERC_ENABLE_TESTS})
endif()
add_custom_target(copy-tests-if-necessary ALL
- COMMAND ${PYTHON_EXECUTABLE}
+ COMMAND ${PYTHON_EXE}
${shaderc_SOURCE_DIR}/utils/copy-tests-if-necessary.py
${GLSLANG_TEST_SRC_DIR} ${GLSLANG_TEST_BIN_DIR} ${GLSLANG_CONFIGURATION_DIR}
COMMENT "Copying and patching glslang tests if needed")
diff --git a/utils/add_copyright.py b/utils/add_copyright.py
index 63d725a..2d3f734 100755
--- a/utils/add_copyright.py
+++ b/utils/add_copyright.py
@@ -12,7 +12,8 @@
# 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.
-"""Adds copyright notices to all the files that need them under the current directory.
+"""Adds copyright notices to all the files that need them under the
+current directory.
usage: add_copyright.py [--check]
@@ -29,7 +30,7 @@ import re
import sys
COPYRIGHTRE = re.compile(
- 'Copyright \d+ The Shaderc Authors. All rights reserved.')
+ r'Copyright \d+ The Shaderc Authors. All rights reserved.')
COPYRIGHT = 'Copyright 2016 The Shaderc Authors. All rights reserved.'
LICENSED = """
Licensed under the Apache License, Version 2.0 (the "License");
@@ -46,7 +47,8 @@ limitations under the License."""
def find(top, filename_glob, skip_glob_list):
- """Returns files in the tree rooted at top matching filename_glob but not in directories matching skip_glob_list."""
+ """Returns files in the tree rooted at top matching filename_glob but not
+ in directories matching skip_glob_list."""
file_list = []
for path, dirs, files in os.walk(top):
@@ -59,7 +61,8 @@ def find(top, filename_glob, skip_glob_list):
def filtered_descendants(glob):
- """Returns glob-matching filenames under the current directory, but skips some irrelevant paths."""
+ """Returns glob-matching filenames under the current directory, but skips
+ some irrelevant paths."""
return find('.', glob, ['third_party', 'ext', 'build*', 'out*'])
diff --git a/utils/update_build_version.py b/utils/update_build_version.py
index e223646..b1a4b0b 100755
--- a/utils/update_build_version.py
+++ b/utils/update_build_version.py
@@ -17,7 +17,7 @@
# Updates build-version.inc in the current directory, unless the update is
# identical to the existing content.
#
-# Args: <shaderc_dir> <spirv-tools_dir> <glslang_dir>
+# Args: <shaderc-dir> <spirv-tools-dir> <glslang-dir>
#
# For each directory, there will be a line in build-version.inc containing that
# directory's "git describe" output enclosed in double quotes and appropriately
@@ -34,7 +34,7 @@ import sys
OUTFILE = 'build-version.inc'
-def command_output(cmd, dir):
+def command_output(cmd, directory):
"""Runs a command in a directory and returns its standard output stream.
Captures the standard error stream.
@@ -42,24 +42,24 @@ def command_output(cmd, dir):
Raises a RuntimeError if the command fails to launch or otherwise fails.
"""
p = subprocess.Popen(cmd,
- cwd=dir,
+ cwd=directory,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(stdout, _) = p.communicate()
if p.returncode != 0:
- raise RuntimeError('Failed to run %s in %s' % (cmd, dir))
+ raise RuntimeError('Failed to run {} in {}'.format(cmd, directory))
return stdout
-def deduce_software_version(dir):
+def deduce_software_version(directory):
"""Returns a software version number parsed from the CHANGES file
- in the given dir.
+ in the given directory.
The CHANGES file describes most recent versions first.
"""
- pattern = re.compile('(v\d+\.\d+(-dev)?) \d\d\d\d-\d\d-\d\d$')
- changes_file = os.path.join(dir, 'CHANGES')
+ pattern = re.compile(r'(v\d+\.\d+(-dev)?) \d\d\d\d-\d\d-\d\d$')
+ changes_file = os.path.join(directory, 'CHANGES')
with open(changes_file) as f:
for line in f.readlines():
match = pattern.match(line)
@@ -68,11 +68,11 @@ def deduce_software_version(dir):
raise Exception('No version number found in {}'.format(changes_file))
-def describe(dir):
+def describe(directory):
"""Returns a string describing the current Git HEAD version as descriptively
as possible.
- Runs 'git describe', or alternately 'git rev-parse HEAD', in dir. If
+ Runs 'git describe', or alternately 'git rev-parse HEAD', in directory. If
successful, returns the output; otherwise returns 'unknown hash, <date>'."""
try:
# decode() is needed here for Python3 compatibility. In Python2,
@@ -80,30 +80,29 @@ def describe(dir):
# Popen.communicate() returns a bytes instance, which needs to be
# decoded into text data first in Python3. And this decode() won't
# hurt Python2.
- return command_output(['git', 'describe'], dir).rstrip().decode()
+ return command_output(['git', 'describe'], directory).rstrip().decode()
except:
try:
return command_output(
- ['git', 'rev-parse', 'HEAD'], dir).rstrip().decode()
+ ['git', 'rev-parse', 'HEAD'], directory).rstrip().decode()
except:
return 'unknown hash, ' + datetime.date.today().isoformat()
-def get_version_string(project, dir):
+def get_version_string(project, directory):
"""Returns a detailed version string for a given project with its directory,
which consists of software version string and git description string."""
detailed_version_string_lst = [project]
if project != 'glslang':
- detailed_version_string_lst.append(deduce_software_version(dir))
- detailed_version_string_lst.append(describe(dir).replace('"', '\\"'))
+ detailed_version_string_lst.append(deduce_software_version(directory))
+ detailed_version_string_lst.append(describe(directory).replace('"', '\\"'))
return ' '.join(detailed_version_string_lst)
def main():
if len(sys.argv) != 4:
- print(
- 'usage: {0} <shaderc_dir> <spirv-tools_dir> <glslang_dir>'.format(
- sys.argv[0]))
+ print('usage: {} <shaderc-dir> <spirv-tools-dir> <glslang-dir>'.format(
+ sys.argv[0]))
sys.exit(1)
projects = ['shaderc', 'spirv-tools', 'glslang']
@@ -111,9 +110,13 @@ def main():
'"{}\\n"\n'.format(get_version_string(p, d))
for (p, d) in zip(projects, sys.argv[1:])
])
- if os.path.isfile(OUTFILE) and new_content == open(OUTFILE, 'r').read():
- sys.exit(0)
- open(OUTFILE, 'w').write(new_content)
+
+ if os.path.isfile(OUTFILE):
+ with open(OUTFILE, 'r') as f:
+ if new_content == f.read():
+ return
+ with open(OUTFILE, 'w') as f:
+ f.write(new_content)
if __name__ == '__main__':