Skip to content

Commit

Permalink
fix windows 64-bit cgo interface
Browse files Browse the repository at this point in the history
  • Loading branch information
yyuuttaaoo committed May 2, 2023
1 parent baf0f66 commit b0e659c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 26 deletions.
4 changes: 2 additions & 2 deletions core/plugin/LogtailPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
extern "C" {
// The definition of Golang type is copied from PluginAdaptor.h that
// generated by `go build -buildmode=c-shared ...`.
#if defined(__linux__) || defined(__APPLE__) // *unix amd64
#if defined(__linux__) || defined(__APPLE__) || defined(_WIN64) // 64-bit system
typedef long long GoInt64;
typedef GoInt64 GoInt;
typedef struct {
Expand All @@ -40,7 +40,7 @@ typedef struct {
GoInt len;
GoInt cap;
} GoSlice;
#elif defined(_MSC_VER) // x86 Go + x86 MinGW + Win32 VS.
#elif defined(_WIN32) // x86 Go + x86 MinGW + Win32 VS.
typedef long long GoInt64;
typedef int GoInt32;
typedef GoInt32 GoInt;
Expand Down
4 changes: 2 additions & 2 deletions docs/cn/installation/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
| -------------------------------------------------------------------------------------------------------------------------------------------- | ----- | ------ | ---------------------------------------------------------------- |
| [ilogtail-1.5.0.linux-amd64.tar.gz](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.5.0/ilogtail-1.5.0.linux-amd64.tar.gz) | Linux | x86-64 | ccb7e637bc7edc4e9fe22ab3ac79cedee63d80678711e0efc77122387ec73882 |
| [ilogtail-1.5.0.linux-arm64.tar.gz](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.5.0/ilogtail-1.5.0.linux-arm64.tar.gz) | Linux | arm64 | f1d7940e08ee51f2c66d963d91c16903658ab1e0fc856002351248c94d0e6b0a |
| [ilogtail-1.5.0.windows-amd64.zip](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.5.0/ilogtail-1.5.0.windows-amd64.zip) | Linux | x86-64 | f7ba5c913839f86d4b589b6573e4f87f13b36fa61db246abf652734500b76ec3 |
| [ilogtail-1.5.0.windows-amd64.zip](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.5.0/ilogtail-1.5.0.windows-amd64.zip) | Windows | x86-64 | 7b3ccbfcca18e1ffeb2e5db06b32fbcac3e8b7ecf8113a7006891bbe3c1a5a84 |

### Docker 镜像

**Docker Pull 命令** 

```
``` bash
docker pull sls-opensource-registry.cn-shanghai.cr.aliyuncs.com/ilogtail-community-edition/ilogtail:1.5.0
```

Expand Down
25 changes: 14 additions & 11 deletions scripts/windows32_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ set P1Path=%P1Path%%content%\
goto begin
:end

set ILOGTAIL_PLUGIN_SRC_PATH=%P1Path%
set ILOGTAIL_PLUGIN_SRC_PATH="%P1Path%"
set ILOGTAIL_PLUGIN_SRC_UNIX_PATH=%ILOGTAIL_PLUGIN_SRC_PATH:\=/%
REM Change to where boost_1_68_0 locates
set BOOST_ROOT=C:\workspace\boost_1_68_0
REM Change to where ilogtail-deps.windows-386 locates, path seperator must be /
set ILOGTAIL_DEPS_PATH=C:/workspace/ilogtail-deps.windows-386
REM Change to where ilogtail-deps.windows-386 locates
set ILOGTAIL_DEPS_PATH=C:\workspace\ilogtail-deps.windows-386
set ILOGTAIL_DEPS_PATH=%ILOGTAIL_DEPS_PATH:\=/%
REM Change to where cmake locates
set CMAKE_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake
set CMAKE_BIN="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake"
REM Change to where devenv locates
set DEVENV_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.com
set DEVENV_BIN="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.com"
REM Change to where mingw locates
set MINGW_PATH=C:\workspace\mingw32\bin

set OUTPUT_DIR=%ILOGTAIL_PLUGIN_SRC_PATH%\output
set OUTPUT_UNIX_DIR=%OUTPUT_DIR:\=/%
set ILOGTAIL_CORE_BUILD_PATH=%ILOGTAIL_PLUGIN_SRC_PATH%\core\build

go env -w GOPROXY="https://goproxy.cn,direct"
Expand All @@ -45,18 +48,18 @@ REM Clean up
IF exist %OUTPUT_DIR% ( rd /s /q %OUTPUT_DIR% )
mkdir %OUTPUT_DIR%

REM Build C++ core(ilogtail.exePluginAdapter.dll)
REM Build C++ core (ilogtail.exe, PluginAdapter.dll)
echo begin to compile core
cd %ILOGTAIL_PLUGIN_SRC_PATH%\core
IF exist build ( rd /s /q build )
mkdir build
cd build
"%CMAKE_BIN%" -DCMAKE_BUILD_TYPE=Release -DLOGTAIL_VERSION=%ILOGTAIL_VERSION% -DDEPS_ROOT=%ILOGTAIL_DEPS_PATH% ..
%CMAKE_BIN% -DCMAKE_BUILD_TYPE=Release -DLOGTAIL_VERSION=%ILOGTAIL_VERSION% -DDEPS_ROOT=%ILOGTAIL_DEPS_PATH% ..
if not %ERRORLEVEL% == 0 (
echo Run cmake failed.
goto quit
)
"%DEVENV_BIN%" logtail.sln /Build "Release|Win32" 1>build.stdout 2>build.stderr
%DEVENV_BIN% logtail.sln /Build "Release|Win32" 1>build.stdout 2>build.stderr
if not %ERRORLEVEL% == 0 (
echo Build iLogtail source failed.
goto quit
Expand All @@ -70,16 +73,16 @@ del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all.go
del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_debug.go
del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_windows.go
del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_linux.go
go run -mod=mod "%ILOGTAIL_PLUGIN_SRC_PATH%\tools\builder" -root-dir="%ILOGTAIL_PLUGIN_SRC_PATH%" -config="plugins.yml,external_plugins.yml" -modfile="go.mod"
go run -mod=mod %ILOGTAIL_PLUGIN_SRC_UNIX_PATH%/tools/builder -root-dir=%ILOGTAIL_PLUGIN_SRC_UNIX_PATH% -config="plugins.yml,external_plugins.yml" -modfile="go.mod"
echo generating plugins finished successfully

REM Build plugins(PluginBase.dllPluginBase.h)
REM Build plugins(PluginBase.dll, PluginBase.h)
echo Begin to build plugins...
IF exist %OUTPUT_DIR% ( rd /s /q %OUTPUT_DIR% )
mkdir %OUTPUT_DIR%
xcopy /Y %ILOGTAIL_CORE_BUILD_PATH%\plugin\Release\PluginAdapter.dll %ILOGTAIL_PLUGIN_SRC_PATH%\pkg\logtail
set LDFLAGS="-X "github.com/alibaba/ilogtail/pluginmanager.BaseVersion=%ILOGTAIL_VERSION%""
go build -mod=mod -buildmode=c-shared -ldflags=%LDFLAGS% -o output\PluginBase.dll %ILOGTAIL_PLUGIN_SRC_PATH%/plugin_main
go build -mod=mod -buildmode=c-shared -ldflags=%LDFLAGS% -o %OUTPUT_UNIX_DIR%/PluginBase.dll %ILOGTAIL_PLUGIN_SRC_UNIX_PATH%/plugin_main
if not %ERRORLEVEL% == 0 (
echo Build iLogtail plugin source failed.
goto quit
Expand Down
25 changes: 14 additions & 11 deletions scripts/windows64_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,22 @@ set P1Path=%P1Path%%content%\
goto begin
:end

set ILOGTAIL_PLUGIN_SRC_PATH=%P1Path%
set ILOGTAIL_PLUGIN_SRC_PATH="%P1Path%"
set ILOGTAIL_PLUGIN_SRC_UNIX_PATH=%ILOGTAIL_PLUGIN_SRC_PATH:\=/%
REM Change to where boost_1_68_0 locates
set BOOST_ROOT=C:\workspace\boost_1_68_0
REM Change to where ilogtail-deps.windows-x64 locates, path seperator must be /
set ILOGTAIL_DEPS_PATH=C:/workspace/ilogtail-deps.windows-x64
REM Change to where ilogtail-deps.windows-x64 locates
set ILOGTAIL_DEPS_PATH=C:\workspace\ilogtail-deps.windows-x64
set ILOGTAIL_DEPS_PATH=%ILOGTAIL_DEPS_PATH:\=/%
REM Change to where cmake locates
set CMAKE_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake
set CMAKE_BIN="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake"
REM Change to where devenv locates
set DEVENV_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.com
set DEVENV_BIN="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.com"
REM Change to where mingw locates
set MINGW_PATH=C:\workspace\mingw64\bin

set OUTPUT_DIR=%ILOGTAIL_PLUGIN_SRC_PATH%\output
set OUTPUT_UNIX_DIR=%OUTPUT_DIR:\=/%
set ILOGTAIL_CORE_BUILD_PATH=%ILOGTAIL_PLUGIN_SRC_PATH%\core\build

go env -w GOPROXY="https://goproxy.cn,direct"
Expand All @@ -45,18 +48,18 @@ REM Clean up
IF exist %OUTPUT_DIR% ( rd /s /q %OUTPUT_DIR% )
mkdir %OUTPUT_DIR%

REM Build C++ core(ilogtail.exePluginAdapter.dll)
REM Build C++ core(ilogtail.exe, PluginAdapter.dll)
echo begin to compile core
cd %ILOGTAIL_PLUGIN_SRC_PATH%\core
IF exist build ( rd /s /q build )
mkdir build
cd build
"%CMAKE_BIN%" -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DLOGTAIL_VERSION=%ILOGTAIL_VERSION% -DDEPS_ROOT=%ILOGTAIL_DEPS_PATH% ..
%CMAKE_BIN% -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DLOGTAIL_VERSION=%ILOGTAIL_VERSION% -DDEPS_ROOT=%ILOGTAIL_DEPS_PATH% ..
if not %ERRORLEVEL% == 0 (
echo Run cmake failed.
goto quit
)
"%DEVENV_BIN%" logtail.sln /Build "Release|x64" 1>build.stdout 2>build.stderr
%DEVENV_BIN% logtail.sln /Build "Release|x64" 1>build.stdout 2>build.stderr
if not %ERRORLEVEL% == 0 (
echo Build iLogtail source failed.
goto quit
Expand All @@ -70,16 +73,16 @@ del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all.go
del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_debug.go
del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_windows.go
del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_linux.go
go run -mod=mod "%ILOGTAIL_PLUGIN_SRC_PATH%\tools\builder" -root-dir="%ILOGTAIL_PLUGIN_SRC_PATH%" -config="plugins.yml,external_plugins.yml" -modfile="go.mod"
go run -mod=mod %ILOGTAIL_PLUGIN_SRC_UNIX_PATH%/tools/builder -root-dir=%ILOGTAIL_PLUGIN_SRC_UNIX_PATH% -config="plugins.yml,external_plugins.yml" -modfile="go.mod"
echo generating plugins finished successfully

REM Build plugins(PluginBase.dllPluginBase.h)
REM Build plugins (PluginBase.dll, PluginBase.h)
echo Begin to build plugins...
IF exist %OUTPUT_DIR% ( rd /s /q %OUTPUT_DIR% )
mkdir %OUTPUT_DIR%
xcopy /Y %ILOGTAIL_CORE_BUILD_PATH%\plugin\Release\PluginAdapter.dll %ILOGTAIL_PLUGIN_SRC_PATH%\pkg\logtail
set LDFLAGS="-X "github.com/alibaba/ilogtail/pluginmanager.BaseVersion=%ILOGTAIL_VERSION%""
go build -mod=mod -buildmode=c-shared -ldflags=%LDFLAGS% -o output\PluginBase.dll %ILOGTAIL_PLUGIN_SRC_PATH%/plugin_main
go build -mod=mod -buildmode=c-shared -ldflags=%LDFLAGS% -o %OUTPUT_UNIX_DIR%/PluginBase.dll %ILOGTAIL_PLUGIN_SRC_UNIX_PATH%/plugin_main
if not %ERRORLEVEL% == 0 (
echo Build iLogtail plugin source failed.
goto quit
Expand Down

0 comments on commit b0e659c

Please sign in to comment.