Skip to content
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

feat: loongcollector support windows build #2082

Open
wants to merge 36 commits into
base: main
Choose a base branch
from

Conversation

bilosikia
Copy link
Contributor

@bilosikia bilosikia commented Feb 10, 2025

  1. windows 64位不兼容函数调用均使用#if defined(linux)或者#if defined(_MSC_VER)进行区分
  2. 部分暂未实现或者暂未修复的ut均使用// TODO: windows进行标识
  3. CI已添加windows编译+运行UT的workflow,代码合入之后,后续所有代码均会运行windows编译的CI

@bilosikia bilosikia force-pushed the feat/windows branch 26 times, most recently from c56cd6c to 065ff03 Compare February 12, 2025 14:58
@bilosikia bilosikia changed the title feat: windows build bat feat: windows build Feb 12, 2025
@bilosikia bilosikia force-pushed the feat/windows branch 3 times, most recently from 4a3174b to e9ea349 Compare February 16, 2025 07:18
@linrunqi08 linrunqi08 changed the title feat: windows build feat: loongcollector support windows build Mar 11, 2025

if (mIdleFlag)
// check exiting
if (mIdleFlag && !Application::GetInstance()->IsExiting())
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里为啥加了一个条件?

Copy link
Collaborator

Choose a reason for hiding this comment

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

这个文件直接删了吧

@@ -38,10 +38,31 @@ struct CompressedLogGroup {
CompressedLogGroup(std::string&& data, size_t rawSize) : mData(std::move(data)), mRawSize(rawSize) {}
};

// vc++ must implemented with declare, cant implement in cpp file.
Copy link
Collaborator

Choose a reason for hiding this comment

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

改一下描述吧,template specialization must be implemented in h file in vc++

@@ -180,7 +180,7 @@ std::string EncodingConverter::FromACPToUTF8(const std::string& s) const {

auto input = const_cast<char*>(s.c_str());
auto inputLen = s.length();
std::vector<size_t> ignore;
std::vector<long> ignore;
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里为什么要改?

Comment on lines +114 to +118
#if defined(_MSC_VER)
setsockopt(fd, IPPROTO_IP, IP_TOS, (const char*)&(*socket->mTOS), sizeof(socket->mTOS));
#else
setsockopt(fd, IPPROTO_IP, IP_TOS, &socket->mTOS, sizeof(socket->mTOS));
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

统一改成这样&socket->mTOS.value(), sizeof(uint32_t));可以吗?

@@ -390,6 +390,8 @@ bool CommonConfigProvider::DumpConfigFile(const configserver::proto::v2::ConfigD
return false;
}
fout << configDetail;
// in windows, if not close fout, rename will faield, This file is being used by other programs.
fout.close();
Copy link
Collaborator

Choose a reason for hiding this comment

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

387到392行用花括号包起来吧,别加close了,其它地方也是这么改的,这里漏了

Copy link
Collaborator

Choose a reason for hiding this comment

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

同主文件,这些相关的类也需要条件编译

@@ -68,6 +68,11 @@ void ProcessorTagNativeUnittest::TestInit() {
}
}

// TODO: windows
#if defined(_MSC_VER)
void ProcessorTagNativeUnittest::TestProcess() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里是什么原因不过?

Copy link
Collaborator

Choose a reason for hiding this comment

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

放到内部去

@@ -39,6 +39,8 @@ if(MSVC)
if (ENABLE_ENTERPRISE)
list(REMOVE_ITEM THIS_SOURCE_FILES_LIST ${CMAKE_SOURCE_DIR}/common/LinuxDaemonUtil.h ${CMAKE_SOURCE_DIR}/common/LinuxDaemonUtil.cpp)
endif()
elseif(UNIX)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里也要加上enterprise

@@ -61,6 +61,10 @@
#endif
#else
#include "provider/Provider.h"
#if defined(_MSC_VER)
Copy link
Collaborator

Choose a reason for hiding this comment

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

应该不需要了

@@ -222,15 +222,18 @@ bool MultilineOptions::ParseRegex(const string& pattern, shared_ptr<boost::regex

const string& UnmatchedContentTreatmentToString(MultilineOptions::UnmatchedContentTreatment unmatchedContentTreatment) {
switch (unmatchedContentTreatment) {
case MultilineOptions::UnmatchedContentTreatment::DISCARD:
case MultilineOptions::UnmatchedContentTreatment::DISCARD: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

不加{},windows编译有问题?

@@ -1878,6 +1878,81 @@ void AppConfig::RegisterCallback(const std::string& key, std::function<bool()>*
mCallbacks[key] = callback;
}

#if defined(_MSC_VER)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

有单测覆盖

#else
// TODO: windows
// need fopen with "rb"?
std::FILE* file = std::fopen(filePath.c_str(), "r");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

有单测覆盖

@@ -141,7 +141,7 @@ void CommonConfigProvider::LoadConfigFile() {
Json::Value detail;
if (LoadConfigDetailFromFile(entry, detail)) {
ConfigInfo info;
info.name = entry.path().stem();
info.name = entry.path().stem().string();
Copy link
Contributor Author

Choose a reason for hiding this comment

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


if (mIdleFlag)
// check exiting
if (mIdleFlag && !Application::GetInstance()->IsExiting())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个地方可能会一直 continue,无法退出。

// TODO: windows
// windows can't instantiation with char32_t, unsigend maybe not ok.
#if defined(_MSC_VER)
std::wstring_convert<std::codecvt_utf8<unsigned long>, unsigned long> convert;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

目前只有 parse docker log 用了,有单测覆盖。

mkdir output
xcopy /Y %LOONCOLLECTOR_CORE_BUILD_PATH%\go_pipeline\Release\GoPluginAdapter.dll %LOONGCOLLECTOR_SRC_PATH%\pkg\logtail\
set LDFLAGS="-X "github.com/alibaba/ilogtail/pluginmanager.BaseVersion=%LOONCOLLECTOR_VERSION%""
%GO_BIN% build -mod=mod -buildmode=c-shared -ldflags=%LDFLAGS% -o output\PluginBase.dll %LOONGCOLLECTOR_SRC_UNIX_PATH%\plugin_main
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个命名不对,需改下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants