@@ -197,7 +197,7 @@ def __init__(
197
197
dst : str ,
198
198
name : str ,
199
199
is_cmake_built : bool = True ,
200
- is_dst_dir : bool = False ,
200
+ dst_is_dir : bool = False ,
201
201
):
202
202
# Source path; semantics defined by the subclass.
203
203
self .src : str = src
@@ -219,7 +219,7 @@ def __init__(
219
219
220
220
# If True, the destination is a directory. If False, the destination is a
221
221
# file.
222
- self .is_dst_dir : bool = is_dst_dir
222
+ self .dst_is_dir : bool = dst_is_dir
223
223
224
224
super ().__init__ (name = self .name , sources = [])
225
225
@@ -328,29 +328,24 @@ class HeaderFile(_BaseExtension):
328
328
def __init__ (
329
329
self ,
330
330
src_dir : str ,
331
- src_name : Optional [ str ] = None ,
332
- dst_dir : Optional [ str ] = None ,
331
+ src_name : str = "*.h" ,
332
+ dst_dir : str = "executorch/include/executorch/" ,
333
333
):
334
334
"""Initializes a BuiltFile.
335
335
336
336
Args:
337
337
src_dir: The directory of the headers to install, relative to the root
338
- ExecuTorch source directory. Under the hood, we glob all the headers
339
- using `*.h` patterns.
338
+ ExecuTorch source directory. Under the hood, we recursively glob all
339
+ the headers using `*.h` patterns.
340
340
src_name: The name of the header to install. If not specified, all the
341
341
headers in the src_dir will be installed.
342
342
dst_dir: The directory to install to, relative to the root of the pip
343
- package. If not specified, defaults to `include/executorch/<src_dir> `.
343
+ package. If not specified, defaults to `executorch/ include/executorch/`.
344
344
"""
345
- if src_name is None :
346
- src_name = "*.h"
347
345
src = os .path .join (src_dir , src_name )
348
- if dst_dir is None :
349
- dst = "executorch/include/executorch/"
350
- else :
351
- dst = dst_dir
346
+ assert dst_dir .endswith ("/" ), f"dst_dir must end with '/', got { dst_dir } "
352
347
super ().__init__ (
353
- src = src , dst = dst , name = src_name , is_cmake_built = False , is_dst_dir = True
348
+ src = src , dst = dst_dir , name = src_name , is_cmake_built = False , dst_is_dir = True
354
349
)
355
350
356
351
def dst_path (self , installer : "InstallerBuildExt" ) -> Path :
@@ -429,7 +424,7 @@ def build_extension(self, ext: _BaseExtension) -> None:
429
424
# Copy the file.
430
425
src_list = src_file .parent .rglob (src_file .name )
431
426
for src in src_list :
432
- if ext .is_dst_dir :
427
+ if ext .dst_is_dir :
433
428
# Destination is a prefix directory. Copy the file to the
434
429
# destination directory.
435
430
dst = dst_file / src
@@ -438,8 +433,7 @@ def build_extension(self, ext: _BaseExtension) -> None:
438
433
dst = dst_file
439
434
440
435
# Ensure that the destination directory exists.
441
- if not dst .parent .exists ():
442
- self .mkpath (os .fspath (dst .parent ))
436
+ self .mkpath (os .fspath (dst .parent ))
443
437
444
438
self .copy_file (os .fspath (src ), os .fspath (dst ))
445
439
@@ -693,13 +687,18 @@ def get_ext_modules() -> List[Extension]:
693
687
ext_modules = []
694
688
695
689
# Copy all the necessary headers into include/executorch/ so that they can
696
- # be found in the pip package. This is a subset of the headers that are
697
- # essential for building custom ops extensions
690
+ # be found in the pip package. This is the subset of headers that are
691
+ # essential for building custom ops extensions.
692
+ # TODO: Use cmake to gather the headers instead of hard-coding them here.
693
+ # For example: https://discourse.cmake.org/t/installing-headers-the-modern-
694
+ # way-regurgitated-and-revisited/3238/3
698
695
for include_dir in [
699
696
"runtime/core/" ,
700
697
"runtime/kernel/" ,
701
698
"runtime/platform/" ,
702
699
"extension/kernel_util/" ,
700
+ "extension/tensor/" ,
701
+ "extension/threadpool/" ,
703
702
]:
704
703
ext_modules .append (
705
704
HeaderFile (
0 commit comments