提交 0cea428e 编写于 作者: L liuqi

Fix repository_rule not re-execute when file changed.

上级 3713852b
......@@ -87,6 +87,8 @@ def encrypt_opencl_codegen(cl_kernel_dir, output_path):
with open(output_path, "w") as w_file:
w_file.write(cpp_cl_encrypted_kernel)
print('Generate OpenCL kernel done.')
def parse_args():
"""Parses command line arguments."""
......
......@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
MACE_SOURCE_DIR=$(dirname $0)
MACE_SOURCE_DIR=$(dirname $(dirname $(dirname $(dirname $0))))
OUTPUT_FILENAME=$1
if [[ -z "${OUTPUT_FILENAME}}" ]]; then
......@@ -28,16 +28,16 @@ fi
mkdir -p $OUTPUT_DIR
pushd $MACE_SOURCE_DIR
DATE_STR=$(date +%Y%m%d)
GIT_VERSION=$(git describe --long --tags)
GIT_VERSION=$(git --git-dir=${MACE_SOURCE_DIR}/.git --work-tree=${MACE_SOURCE_DIR} describe --long --tags)
if [[ $? != 0 ]]; then
GIT_VERSION=unknown-${DATE_STR}
else
GIT_VERSION=${GIT_VERSION}-${DATE_STR}
fi
echo $GIT_VERSION
cat <<EOF > ${OUTPUT_FILENAME}
// Copyright 2018 Xiaomi, Inc. All rights reserved.
//
......@@ -61,4 +61,3 @@ const char *MaceVersion() { return "MACEVER-${GIT_VERSION}" + 8; }
} // namespace mace
EOF
popd
......@@ -9,6 +9,9 @@ def _git_version_conf_impl(repository_ctx):
generated_files_path = repository_ctx.path("gen")
unused_var = repository_ctx.path(Label("//:.git/HEAD"))
unused_var = repository_ctx.path(Label("//:.git/refs/heads/master"))
repository_ctx.execute([
'bash', '%s/mace/tools/git/gen_version_source.sh' % mace_root_path
, '%s/version' % generated_files_path
......@@ -17,5 +20,4 @@ def _git_version_conf_impl(repository_ctx):
git_version_repository = repository_rule(
implementation = _git_version_conf_impl,
local=True,
)
......@@ -5,6 +5,34 @@ def _opencl_encrypt_kernel_impl(repository_ctx):
"BUILD",
Label("//repository/opencl-kernel:BUILD.tpl"))
unused_var = repository_ctx.path(Label("//:.git/HEAD"))
unused_var = repository_ctx.path(Label("//:.git/refs/heads/master"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/activation.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/addn.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/batch_norm.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/bias_add.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/buffer_to_image.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/channel_shuffle.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/common.h"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/concat.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/conv_2d.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/conv_2d_1x1.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/conv_2d_3x3.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/deconv_2d.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/depth_to_space.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/depthwise_conv2d.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/eltwise.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/fully_connected.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/matmul.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/pad.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/pooling.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/reduce_mean.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/resize_bilinear.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/slice.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/softmax.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/space_to_batch.cl"))
unused_var = repository_ctx.path(Label("//:mace/kernels/opencl/cl/winograd_transform.cl"))
mace_root_path = str(repository_ctx.path(Label("@mace//:BUILD")))[:-len("BUILD")]
generated_files_path = repository_ctx.path("gen")
......@@ -20,5 +48,4 @@ def _opencl_encrypt_kernel_impl(repository_ctx):
encrypt_opencl_kernel_repository = repository_rule(
implementation = _opencl_encrypt_kernel_impl,
local=True,
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册