[libc-commits] [libc] 1ef0baf - [libc][NFC] Move the Linux file implementation to a subdirectory
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Tue May 30 04:49:29 PDT 2023
Author: Joseph Huber
Date: 2023-05-30T06:49:21-05:00
New Revision: 1ef0bafc4f6f03805558b900d703292fb957c100
URL: https://github.com/llvm/llvm-project/commit/1ef0bafc4f6f03805558b900d703292fb957c100
DIFF: https://github.com/llvm/llvm-project/commit/1ef0bafc4f6f03805558b900d703292fb957c100.diff
LOG: [libc][NFC] Move the Linux file implementation to a subdirectory
This patch simply moves the special handling for `linux` files to a
subdirectory. This is done to make it easier in the future to extend
this support to targets (like the GPU) that will have different
dependencies.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D151231
Added:
libc/src/__support/File/linux/CMakeLists.txt
libc/src/__support/File/linux/dir.cpp
libc/src/__support/File/linux/file.cpp
Modified:
libc/src/__support/File/CMakeLists.txt
Removed:
libc/src/__support/File/linux_dir.cpp
libc/src/__support/File/linux_file.cpp
################################################################################
diff --git a/libc/src/__support/File/CMakeLists.txt b/libc/src/__support/File/CMakeLists.txt
index 79de9250c642b..53b2171deb6d7 100644
--- a/libc/src/__support/File/CMakeLists.txt
+++ b/libc/src/__support/File/CMakeLists.txt
@@ -29,34 +29,29 @@ add_object_library(
libc.src.__support.threads.mutex
)
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}_file.cpp)
- add_object_library(
- platform_file
- SRCS
- ${LIBC_TARGET_OS}_file.cpp
- DEPENDS
- .file
- libc.include.fcntl
- libc.include.stdio
- libc.include.sys_syscall
- libc.src.__support.CPP.new
- libc.src.__support.OSUtil.osutil
- libc.src.errno.errno
- libc.src.__support.error_or
- )
+if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
+ return()
endif()
-if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}_dir.cpp)
- add_object_library(
- platform_dir
- SRCS
- ${LIBC_TARGET_OS}_dir.cpp
- DEPENDS
- .dir
- libc.include.fcntl
- libc.include.sys_syscall
- libc.src.__support.OSUtil.osutil
- libc.src.__support.error_or
- libc.src.errno.errno
- )
+add_subdirectory(${LIBC_TARGET_OS})
+set(target_file libc.src.__support.File.${LIBC_TARGET_OS}.${LIBC_TARGET_OS}_file)
+set(target_dir libc.src.__support.File.${LIBC_TARGET_OS}.${LIBC_TARGET_OS}_dir)
+if((NOT TARGET ${target_file}) OR (NOT TARGET ${target_dir}))
+ return()
endif()
+
+add_object_library(
+ platform_file
+ ALIAS
+ ${target_file}
+ DEPENDS
+ ${target_file}
+)
+
+add_object_library(
+ platform_dir
+ ALIAS
+ ${target_dir}
+ DEPENDS
+ ${target_dir}
+)
diff --git a/libc/src/__support/File/linux/CMakeLists.txt b/libc/src/__support/File/linux/CMakeLists.txt
new file mode 100644
index 0000000000000..c2ba66462ca37
--- /dev/null
+++ b/libc/src/__support/File/linux/CMakeLists.txt
@@ -0,0 +1,27 @@
+add_object_library(
+ linux_file
+ SRCS
+ file.cpp
+ DEPENDS
+ libc.include.fcntl
+ libc.include.stdio
+ libc.include.sys_syscall
+ libc.src.__support.CPP.new
+ libc.src.__support.OSUtil.osutil
+ libc.src.errno.errno
+ libc.src.__support.error_or
+ libc.src.__support.File.file
+)
+
+add_object_library(
+ linux_dir
+ SRCS
+ dir.cpp
+ DEPENDS
+ libc.include.fcntl
+ libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
+ libc.src.__support.error_or
+ libc.src.errno.errno
+ libc.src.__support.File.dir
+)
diff --git a/libc/src/__support/File/linux_dir.cpp b/libc/src/__support/File/linux/dir.cpp
similarity index 97%
rename from libc/src/__support/File/linux_dir.cpp
rename to libc/src/__support/File/linux/dir.cpp
index aae565ffb337a..4521a9bb44000 100644
--- a/libc/src/__support/File/linux_dir.cpp
+++ b/libc/src/__support/File/linux/dir.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "dir.h"
+#include "src/__support/File/dir.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/error_or.h"
diff --git a/libc/src/__support/File/linux_file.cpp b/libc/src/__support/File/linux/file.cpp
similarity index 99%
rename from libc/src/__support/File/linux_file.cpp
rename to libc/src/__support/File/linux/file.cpp
index 001aa0cef9802..02746eeedc0bf 100644
--- a/libc/src/__support/File/linux_file.cpp
+++ b/libc/src/__support/File/linux/file.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include "file.h"
+#include "src/__support/File/file.h"
#include "src/__support/CPP/new.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
More information about the libc-commits
mailing list