File tree Expand file tree Collapse file tree 6 files changed +44
-12
lines changed Expand file tree Collapse file tree 6 files changed +44
-12
lines changed Original file line number Diff line number Diff line change 3
3
# This source code is licensed under the MIT license found in the
4
4
# LICENSE file in the root directory of this source tree.
5
5
6
+ include_guard (GLOBAL )
7
+ include (cg_target_outputs)
8
+
6
9
function (cg_filegroup)
7
10
cmake_parse_arguments (_ARG "PUBLIC" "NAME" "FILES;DEPENDS" ${ARGN} )
8
11
rename_bazel_targets(_NAME "${_ARG_NAME} " )
9
12
add_custom_target (${_NAME} )
10
13
14
+ rename_bazel_targets(_DEPS "${_ARG_DEPENDS} " )
15
+ cg_target_outputs(TARGETS ${_DEPS} RESULT _DEPS_OUTPUTS)
16
+
17
+ unset (_OUTPUTS)
18
+
11
19
foreach (FILE_ ${_ARG_FILES} )
12
20
if (IS_ABSOLUTE "${FILE_} " )
13
21
set (_INPUT_PATH "${FILE_} " )
@@ -29,22 +37,19 @@ function(cg_filegroup)
29
37
COMMAND
30
38
${CMAKE_COMMAND} -E create_symlink "${_INPUT_PATH} "
31
39
"${_OUTPUT_PATH} "
32
- DEPENDS "${_INPUT_PATH} "
40
+ DEPENDS "${_INPUT_PATH} " ${_DEPS_OUTPUTS}
33
41
)
34
42
endif ()
35
43
add_custom_target (${_TARGET} DEPENDS "${_OUTPUT_PATH} " )
36
44
endif ()
45
+ list (APPEND _OUTPUTS "${_OUTPUT_PATH} " )
37
46
38
47
add_dependencies (${_NAME} ${_TARGET} )
39
48
endforeach ()
40
49
41
50
if (_ARG_DEPENDS)
42
- rename_bazel_targets(_DEPS "${_ARG_DEPENDS} " )
43
51
add_dependencies (${_NAME} ${_DEPS} )
44
52
endif ()
45
53
46
- set_target_properties (
47
- ${_NAME}
48
- PROPERTIES IS_FILEGROUP TRUE OUTPUTS "${_SRCS} "
49
- )
54
+ set_property (TARGET ${_NAME} PROPERTY OUTPUTS ${_OUTPUTS} )
50
55
endfunction ()
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ include_guard(GLOBAL)
7
7
8
8
include (CMakeParseArguments)
9
9
include (cg_macros)
10
+ include (cg_target_outputs)
10
11
11
12
# cg_genrule()
12
13
#
@@ -55,10 +56,11 @@ function(cg_genrule)
55
56
string (REPLACE "$(@D)" "${_OUTS_DIR} " _CMD "${_CMD} " )
56
57
57
58
if (_OUTS)
59
+ cg_target_outputs(TARGETS ${_DEPS} RESULT _DEPS_OUTPUTS)
58
60
add_custom_command (
59
61
OUTPUT ${_OUTS}
60
62
COMMAND bash -c "${_CMD} "
61
- DEPENDS ${_DEPS} ${_SRCS}
63
+ DEPENDS ${_DEPS} ${_DEPS_OUTPUTS} ${ _SRCS}
62
64
VERBATIM
63
65
USES_TERMINAL
64
66
)
@@ -83,7 +85,7 @@ function(cg_genrule)
83
85
)
84
86
endif ()
85
87
86
- set_target_properties ( ${_NAME} PROPERTIES OUTPUTS " ${_OUTS} " )
88
+ set_property ( TARGET ${_NAME} PROPERTY OUTPUTS ${_OUTS} )
87
89
88
90
list (LENGTH _OUTS _OUTS_LENGTH)
89
91
if (_OUTS_LENGTH EQUAL "1" )
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ function(cg_py_library)
42
42
43
43
# TODO(boian): remove this renaming when call sites do not include ":" in target dependency names
44
44
rename_bazel_targets(_RULE_DEPS "${_RULE_DEPS} " )
45
+ cg_target_outputs(TARGETS ${_RULE_DEPS} RESULT _DEPS_OUTPUTS)
45
46
46
47
# Prefix the library with the package name, so we get: cg_package_name.
47
48
rename_bazel_targets(_NAME "${_RULE_NAME} " )
@@ -64,19 +65,24 @@ function(cg_py_library)
64
65
COMMAND
65
66
${CMAKE_COMMAND} -E create_symlink
66
67
"${CMAKE_CURRENT_SOURCE_DIR} /${_SRC_FILE} " "${_SRC_BIN_PATH} "
67
- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR} /${_SRC_FILE} "
68
+ DEPENDS
69
+ "${CMAKE_CURRENT_SOURCE_DIR} /${_SRC_FILE} "
70
+ ${_RULE_DEPS}
71
+ ${_DEPS_OUTPUTS}
72
+ ${_RULE_GENERATED_SRCS}
68
73
VERBATIM
69
74
)
70
75
list (APPEND _BIN_PATHS "${_SRC_BIN_PATH} " )
71
76
endforeach ()
72
77
73
78
list (APPEND _BIN_PATHS ${_RULE_GENERATED_SRCS} )
74
-
75
79
set (_DEPS ${_RULE_DEPS} ${_BIN_PATHS} )
76
80
add_custom_target (${_NAME} ALL DEPENDS ${_DEPS} )
77
81
78
82
cg_add_data_dependencies(NAME ${_RULE_NAME} DATA ${_RULE_DATA} )
79
83
84
+ set_property (TARGET ${_NAME} PROPERTY OUTPUTS ${_BIN_PATHS} )
85
+
80
86
# If only one src file set the LOCATION target property to point to it.
81
87
list (LENGTH _BIN_PATHS _BIN_PATHS_LENGTH)
82
88
if (_BIN_PATHS_LENGTH EQUAL "1" )
Original file line number Diff line number Diff line change
1
+ # Copyright (c) Facebook, Inc. and its affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ include_guard (GLOBAL )
7
+ include (CMakeParseArguments)
8
+
9
+ function (cg_target_outputs)
10
+ cmake_parse_arguments (ARG "" "RESULT" "TARGETS" ${ARGN} )
11
+ unset (RES_)
12
+ foreach (TARGET_ ${ARG_TARGETS} )
13
+ list (APPEND RES_ $<TARGET_PROPERTY:${TARGET_} ,OUTPUTS>)
14
+ endforeach ()
15
+ set ("${ARG_RESULT} " ${RES_} PARENT_SCOPE)
16
+ endfunction ()
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ include_guard(GLOBAL)
10
10
include (CMakeParseArguments)
11
11
include (cg_macros)
12
12
include (cg_py_library)
13
+ include (cg_target_outputs)
13
14
include (protobuf)
14
15
15
16
function (get_cc_grpc_proto_out_files _PROTO_FILENAME _RESULT)
@@ -43,6 +44,7 @@ function(cc_grpc_library)
43
44
endif ()
44
45
45
46
rename_bazel_targets(_DEPS "${_RULE_DEPS} " )
47
+ cg_target_outputs(TARGETS ${_DEPS} RESULT _DEPS_OUTPUTS)
46
48
rename_bazel_targets(_NAME "${_RULE_NAME} " )
47
49
rename_bazel_targets(_SRCS "${_RULE_SRCS} " )
48
50
@@ -84,6 +86,7 @@ function(cc_grpc_library)
84
86
"${_DESCRIPTOR_SET_FILE} "
85
87
"${_PROTO_FILE} "
86
88
${_DEPS}
89
+ ${_DEPS_OUTPUTS}
87
90
VERBATIM
88
91
)
89
92
@@ -119,6 +122,7 @@ function(py_grpc_library)
119
122
cmake_parse_arguments (_RULE "" "NAME;SRCS" "DEPS" ${ARGN} )
120
123
121
124
rename_bazel_targets(_DEPS "${_RULE_DEPS} " )
125
+ cg_target_outputs(TARGETS ${_DEPS} RESULT _DEPS_OUTPUTS)
122
126
rename_bazel_targets(_SRCS "${_RULE_SRCS} " )
123
127
124
128
get_target_property (_DESCRIPTOR_SET_FILE ${_SRCS} PROTO_DESCRIPTOR_SETS)
@@ -150,6 +154,7 @@ function(py_grpc_library)
150
154
"${_DESCRIPTOR_SET_FILE} "
151
155
"${_PROTO_FILE} "
152
156
${_DEPS}
157
+ ${_DEPS_OUTPUTS}
153
158
VERBATIM
154
159
)
155
160
Original file line number Diff line number Diff line change @@ -32,8 +32,6 @@ cg_py_library(
32
32
"thread_pool.py"
33
33
"timer.py"
34
34
"truncate.py"
35
- GENERATED_SRCS
36
- "$<TARGET_PROPERTY:compiler_gym__util__make_version,LOCATION>"
37
35
DEPS
38
36
make_version
39
37
compiler_gym::errors::errors
You can’t perform that action at this time.
0 commit comments