Skip to content

improve Android compatibility #1518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/common/RuntimeUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,17 @@
#include "LogtailCommonFlags.h"
#include "FileSystemUtil.h"

DECLARE_FLAG_STRING(logtail_sys_conf_dir);

namespace logtail {

// TODO: In ConfigManager.cpp, some places use / to concat path, which might fail on Windows,
// replace them with PATH_SEPARATOR.
std::string GetProcessExecutionDir(void) {
#if defined(__linux__)
#if defined(__ANDROID__)
// In Android, runtime configuration files cannot be stored in the same directory as the executable
return STRING_FLAG(logtail_sys_conf_dir);
#elif defined(__linux__)
char exePath[PATH_MAX + 1] = "";
readlink("/proc/self/exe", exePath, sizeof(exePath));
std::string fullPath(exePath);
Expand Down
4 changes: 3 additions & 1 deletion core/common/links.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ macro(common_link target_name)
link_zlib(${target_name})
link_zstd(${target_name})
link_unwind(${target_name})
link_asan(${target_name})
if (NOT ANDROID)
link_asan(${target_name})
endif()
if (UNIX)
link_uuid(${target_name})
if (LINUX)
Expand Down
2 changes: 2 additions & 0 deletions core/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ endmacro()
macro(link_zlib target_name)
if (zlib_${LINK_OPTION_SUFFIX})
target_link_libraries(${target_name} "${zlib_${LINK_OPTION_SUFFIX}}")
elseif(ANDROID)
target_link_libraries(${target_name} z)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

z的含义是?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zlib在安卓的ndk里有内置的库,库名就叫 z

elseif (UNIX)
target_link_libraries(${target_name} "${zlib_${LIBRARY_DIR_SUFFIX}}/libz.a")
elseif (MSVC)
Expand Down
4 changes: 3 additions & 1 deletion core/logtail.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ int main(int argc, char** argv) {
gflags::SetUsageMessage(
std::string("The Lightweight Collector of SLS in Alibaba Cloud\nUsage: ./ilogtail [OPTION]"));
gflags::SetVersionString(std::string(ILOGTAIL_VERSION) + " Community Edition");
google::ParseCommandLineFlags(&argc, &argv, true);
if (argc != 0) {
google::ParseCommandLineFlags(&argc, &argv, true);
}

if (setenv("TCMALLOC_RELEASE_RATE", "10.0", 1) == -1) {
exit(3);
Expand Down
Loading