Skip to content

Commit 54685fa

Browse files
committed
Use symlink to make BUCK happy
1 parent 96f9c73 commit 54685fa

File tree

12 files changed

+48
-70
lines changed

12 files changed

+48
-70
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ethos-u-scratch/
2121
executorch.egg-info
2222
pip-out/
2323

24-
# Dynamically fetched third-party libraries
24+
# Third-party libraries, symlink'ed to FetchContent source directories
2525
third-party/gflags
2626

2727
# Any exported models and profiling outputs

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ project(executorch)
5252

5353
include(${PROJECT_SOURCE_DIR}/tools/cmake/common/preset.cmake)
5454
include(${PROJECT_SOURCE_DIR}/tools/cmake/Utils.cmake)
55-
include(${PROJECT_SOURCE_DIR}/tools/cmake/EXECUTORCH_FetchContent_Destination.cmake)
55+
include(${PROJECT_SOURCE_DIR}/tools/cmake/FetchContent.cmake)
5656
include(CMakeDependentOption)
5757
include(ExternalProject)
5858
include(FetchContent)

examples/models/llama/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
4747
set(TORCH_ROOT ${EXECUTORCH_ROOT}/third-party/pytorch)
4848

4949
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
50+
include(${EXECUTORCH_ROOT}/tools/cmake/FetchContent.cmake)
5051

5152
if(NOT PYTHON_EXECUTABLE)
5253
resolve_python_executable()
@@ -68,10 +69,8 @@ set(_common_compile_options -Wno-deprecated-declarations -fPIC)
6869
# Let files say "include <executorch/path/to/header.h>".
6970
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
7071

71-
# For some reason android build is not able to find where gflags is and hence
72-
# cannot find corresponding .cmake file
73-
set(gflags_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../third-party/gflags/gflags-build)
74-
find_package(gflags REQUIRED)
72+
# Fetch gflags
73+
FetchContent_gflags()
7574

7675
#
7776
# llama_main: test binary to run llama, with tokenizer and sampler integrated

examples/models/llava/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ endif()
4545
set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
4646

4747
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
48+
include(${EXECUTORCH_ROOT}/tools/cmake/FetchContent.cmake)
4849

4950
if(NOT PYTHON_EXECUTABLE)
5051
resolve_python_executable()
@@ -66,10 +67,8 @@ set(_common_compile_options -Wno-deprecated-declarations -fPIC)
6667
# Let files say "include <executorch/path/to/header.h>".
6768
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
6869

69-
# For some reason android build is not able to find where gflags is and hence
70-
# cannot find corresponding .cmake file
71-
set(gflags_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party/gflags/gflags-build)
72-
find_package(gflags REQUIRED)
70+
# Fetch gflags
71+
FetchContent_gflags()
7372

7473
#
7574
# llava_main: test binary to run llava, with tokenizer and sampler integrated

examples/portable/custom_ops/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ endif()
2929

3030
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
3131
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
32+
include(${EXECUTORCH_ROOT}/tools/cmake/FetchContent.cmake)
3233

3334
if(NOT PYTHON_EXECUTABLE)
3435
resolve_python_executable()
@@ -40,8 +41,7 @@ set(_common_compile_options -Wno-deprecated-declarations -fPIC)
4041
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
4142

4243
find_package(executorch CONFIG REQUIRED)
43-
set(gflags_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../third-party/gflags/gflags-build)
44-
find_package(gflags REQUIRED)
44+
FetchContent_gflags()
4545

4646
target_include_directories(executorch INTERFACE ${_common_include_directories})
4747

examples/qualcomm/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ endif()
3131
find_package(executorch CONFIG REQUIRED)
3232
target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED)
3333

34-
set(gflags_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../third-party/gflags/gflags-build)
35-
find_package(gflags REQUIRED)
36-
3734
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
3835

3936
# Let files say "include <executorch/path/to/header.h>".

examples/selective_build/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ set(TORCH_ROOT ${EXECUTORCH_ROOT}/third-party/pytorch)
2323

2424
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
2525
include(${EXECUTORCH_ROOT}/tools/cmake/Codegen.cmake)
26+
include(${EXECUTORCH_ROOT}/tools/cmake/FetchContent.cmake)
2627

2728
if(NOT PYTHON_EXECUTABLE)
2829
resolve_python_executable()
@@ -39,8 +40,7 @@ set(_common_compile_options -Wno-deprecated-declarations -fPIC)
3940
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
4041

4142
find_package(executorch CONFIG REQUIRED)
42-
set(gflags_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../third-party/gflags/gflags-build)
43-
find_package(gflags REQUIRED)
43+
FetchContent_gflags()
4444

4545
target_include_directories(executorch_core INTERFACE ${_common_include_directories})
4646

extension/training/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ target_link_libraries(extension_training executorch_core kernels_util_all_deps
3131

3232
list(TRANSFORM _train_xor__srcs PREPEND "${EXECUTORCH_ROOT}/")
3333
add_executable(train_xor ${_train_xor__srcs})
34+
3435
target_include_directories(
3536
train_xor PUBLIC ${_common_include_directories}
3637
)

third-party/CMakeLists.txt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ if(BUILD_TESTING)
1414
add_subdirectory(googletest)
1515
endif()
1616

17-
EXECUTORCH_FetchContent_Destination("${CMAKE_CURRENT_SOURCE_DIR}/gflags")
18-
FetchContent_Declare(
19-
gflags
20-
GIT_REPOSITORY https://github.com/gflags/gflags.git
21-
GIT_TAG v2.2.2
17+
FetchContent_gflags()
18+
# Create a symlink from the gflags source directory to third-party/gflags
19+
message(STATUS "gflags source dir: ${gflags_SOURCE_DIR}")
20+
execute_process(
21+
COMMAND ${CMAKE_COMMAND} -E create_symlink "${gflags_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/gflags"
2222
)
23-
set(GFLAGS_INTTYPES_FORMAT C99)
24-
FetchContent_MakeAvailable(gflags)
2523

2624
# MARK: - flatbuffers
2725

third-party/gflags_defs.bzl

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
# ------------------------------------------------------------------------------
2-
3-
# gflags is materialized during build time by cmake. See third-party/CMakeLists.txt.
4-
def _path(relative_path):
5-
return "gflags/gflags-src/{}".format(relative_path)
6-
72
# Add native rules to configure source files
83
# Not tested for building on windows platforms
94
def gflags_sources(namespace = ["google", "gflags"]):
@@ -12,7 +7,7 @@ def gflags_sources(namespace = ["google", "gflags"]):
127
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
138
native.genrule(
149
name = "gflags_declare_h",
15-
srcs = [_path("src/gflags_declare.h.in")],
10+
srcs = ["gflags/src/gflags_declare.h.in"],
1611
out = "gflags/gflags_declare.h",
1712
cmd = (common_preamble + "awk '{ " +
1813
"gsub(/@GFLAGS_NAMESPACE@/, \"" + namespace[0] + "\"); " +
@@ -27,7 +22,7 @@ def gflags_sources(namespace = ["google", "gflags"]):
2722
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
2823
native.genrule(
2924
name = gflags_ns_h_file.replace(".", "_"),
30-
srcs = [_path("src/gflags_ns.h.in")],
25+
srcs = ["gflags/src/gflags_ns.h.in"],
3126
out = "gflags/" + gflags_ns_h_file,
3227
cmd = (common_preamble + "awk '{ " +
3328
"gsub(/@ns@/, \"" + ns + "\"); " +
@@ -39,7 +34,7 @@ def gflags_sources(namespace = ["google", "gflags"]):
3934
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
4035
native.genrule(
4136
name = "gflags_h",
42-
srcs = [_path("src/gflags.h.in")],
37+
srcs = ["gflags/src/gflags.h.in"],
4338
out = "gflags/gflags.h",
4439
cmd = (common_preamble + "awk '{ " +
4540
"gsub(/@GFLAGS_ATTRIBUTE_UNUSED@/, \"\"); " +
@@ -50,15 +45,15 @@ def gflags_sources(namespace = ["google", "gflags"]):
5045
# @lint-ignore BUCKLINT: native and fb_native are explicitly forbidden in fbcode.
5146
native.genrule(
5247
name = "gflags_completions_h",
53-
srcs = [_path("src/gflags_completions.h.in")],
48+
srcs = ["gflags/src/gflags_completions.h.in"],
5449
out = "gflags/gflags_completions.h",
5550
cmd = common_preamble + "awk '{ gsub(/@GFLAGS_NAMESPACE@/, \"" + namespace[0] + "\"); print; }' $SRCS > $OUT",
5651
)
5752
headers = {
58-
"config.h": _path("src/config.h"),
59-
"mutex.h": _path("src/mutex.h"),
60-
"util.h": _path("src/util.h"),
61-
"windows_port.h": _path("src/windows_port.h"),
53+
"config.h": "gflags/src/config.h",
54+
"mutex.h": "gflags/src/mutex.h",
55+
"util.h": "gflags/src/util.h",
56+
"windows_port.h": "gflags/src/windows_port.h",
6257
}
6358
exported_headers = {
6459
"gflags/gflags.h": ":gflags_h",
@@ -67,9 +62,9 @@ def gflags_sources(namespace = ["google", "gflags"]):
6762
}
6863
exported_headers.update({"gflags/" + hdr: ":" + hdr.replace(".", "_") for hdr in gflags_ns_h_files})
6964
srcs = [
70-
_path("src/gflags.cc"),
71-
_path("src/gflags_completions.cc"),
72-
_path("src/gflags_reporting.cc"),
65+
"gflags/src/gflags.cc",
66+
"gflags/src/gflags_completions.cc",
67+
"gflags/src/gflags_reporting.cc",
7368
]
7469
return [exported_headers, headers, srcs]
7570

0 commit comments

Comments
 (0)