Skip to content

Commit

Permalink
Fix C# module to build on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktooth committed Jun 24, 2022
1 parent 57acd3d commit ead24da
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 18 deletions.
5 changes: 5 additions & 0 deletions native-schema-registry/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ ELSE()
set(LIB_NATIVE_SCHEMA_REGISTRY_LIBRARY_NAME ${LIB_NATIVE_SCHEMA_REGISTRY_LIBRARY_NAME_PREFIX}.so)
ENDIF()

set(DATA_TYPES_MODULE_NAME native_schema_registry_c_data_types)
set(SERDE_MODULE_NAME native_schema_registry_c)
set(NATIVE_SCHEMA_REGISTRY_MODULE_NAME libnativeschemaregistry)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

add_subdirectory("src")
include (CTest)
enable_testing()
Expand Down
17 changes: 9 additions & 8 deletions native-schema-registry/c/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
set(DATA_TYPES_MODULE_NAME native_schema_registry_c_data_types)
set(SERDE_MODULE_NAME native_schema_registry_c)
set(NATIVE_SCHEMA_REGISTRY_MODULE_NAME libnativeschemaregistry)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

#Fix the include path in GraalVM generated header file.
execute_process(COMMAND sed -ie "s/<graal_isolate.h>/\"graal_isolate.h\"/" ${LIB_NATIVE_SCHEMA_REGISTRY_PATH}/libnativeschemaregistry.h)

Expand All @@ -15,6 +10,12 @@ add_library(
read_only_byte_array.c
mutable_byte_array.c
)
add_custom_command(
TARGET ${DATA_TYPES_MODULE_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${DATA_TYPES_MODULE_NAME}> ${LIB_NATIVE_SCHEMA_REGISTRY_PATH}/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_LINKER_FILE:${DATA_TYPES_MODULE_NAME}> ${LIB_NATIVE_SCHEMA_REGISTRY_PATH}/
)

#Add reference to the GraalVM generated Native schema registry module.
add_library(
Expand Down Expand Up @@ -52,9 +53,9 @@ file(

#####CSharp
set(CSHARP_MODULE_NAME GsrSerDeCsGen)
set(CSHARP_SOURCE_PATH ${PROJECT_SOURCE_DIR}/../csharp/AWSGsrSerDe/AWSGsrSerDe/)
set(CSHARP_GEN_LIB_PATH ${CSHARP_SOURCE_PATH}/bin/)

set(CSHARP_ROOT_PATH ${PROJECT_SOURCE_DIR}/../csharp/AWSGsrSerDe)
set(CSHARP_SOURCE_PATH ${CSHARP_ROOT_PATH}/AWSGsrSerDe/)
set(CSHARP_GEN_LIB_PATH ${CSHARP_ROOT_PATH}/Libs/)
swig_add_library(
${CSHARP_MODULE_NAME}
TYPE SHARED
Expand Down
17 changes: 10 additions & 7 deletions native-schema-registry/c/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ list(
mutable_byte_array_test
)

foreach (test ${tests})
foreach (test ${tests})
add_executable(
"${test}"
"${test}.c"
)
target_link_libraries(
"${test}"
native_schema_registry_c_data_types
native_schema_registry_c
${LIB_NATIVE_SCHEMA_REGISTRY_PATH}/${LIB_NATIVE_SCHEMA_REGISTRY_LIBRARY_NAME}
cmocka
"${DATA_TYPES_MODULE_NAME}"
"cmocka"
)

add_test(NAME "${test}" COMMAND "${test}")
endforeach ()
add_test(NAME "${test}" COMMAND "${test}" ${CMAKE_CURRENT_BINARY_DIR})
endforeach ()

add_custom_target(copy-libs-for-tests ALL
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${DATA_TYPES_MODULE_NAME}> ${CMAKE_CURRENT_BINARY_DIR}/
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:cmocka> ${CMAKE_CURRENT_BINARY_DIR}/
)
19 changes: 17 additions & 2 deletions native-schema-registry/csharp/AWSGsrSerDe/AWSGsrSerDe.sln
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWSGsrSerDe", "AWSGsrSerDe\AWSGsrSerDe.csproj", "{A36E4C3C-B7C4-4670-90B1-2FC9D883CCD0}"
# Visual Studio Version 17
VisualStudioVersion = 17.2.32616.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSGsrSerDe", "AWSGsrSerDe\AWSGsrSerDe.csproj", "{A36E4C3C-B7C4-4670-90B1-2FC9D883CCD0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AWSGsrSerDe.Tests", "AWSGsrSerDe.Tests\AWSGsrSerDe.Tests.csproj", "{AD987D8A-EC56-47E8-837F-4D2A9E4ABA6C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AWSGsrSerDe.Tests", "AWSGsrSerDe.Tests\AWSGsrSerDe.Tests.csproj", "{AD987D8A-EC56-47E8-837F-4D2A9E4ABA6C}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Libs", "Libs\Libs.shproj", "{5801DEDB-DA53-4B21-91CC-E31B118C8029}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -19,4 +24,14 @@ Global
{AD987D8A-EC56-47E8-837F-4D2A9E4ABA6C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD987D8A-EC56-47E8-837F-4D2A9E4ABA6C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1048530E-CE84-4D97-A3E1-8AFB8946267B}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Libs\Libs.projitems*{5801dedb-da53-4b21-91cc-e31b118c8029}*SharedItemsImports = 13
Libs\Libs.projitems*{a36e4c3c-b7c4-4670-90b1-2fc9d883ccd0}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
<PackageReference Include="Apache.Avro" Version="1.11.0" />
</ItemGroup>

<Import Project="..\Libs\Libs.projitems" Label="Shared" />

</Project>
25 changes: 25 additions & 0 deletions native-schema-registry/csharp/AWSGsrSerDe/Libs/Libs.projitems
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<SharedGUID>5801dedb-da53-4b21-91cc-e31b118c8029</SharedGUID>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<Import_RootNamespace>Libs</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)GsrSerDeCsGen.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)libnativeschemaregistry.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)native_schema_registry_c.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="$(MSBuildThisFileDirectory)native_schema_registry_c_data_types.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions native-schema-registry/csharp/AWSGsrSerDe/Libs/Libs.shproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<ProjectGuid>5801dedb-da53-4b21-91cc-e31b118c8029</ProjectGuid>
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
<PropertyGroup />
<Import Project="Libs.projitems" Label="Shared" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class DataTypes {
static class HandlerDirectives implements CContext.Directives {

public static final String INCLUDE_PATH = "c/include/";
public static final String LIB_PATH = "c/build/src/";
public static final String LIB_PATH = "target/";
//Intentionally blank.
public static final String PROJECT_NAME = "";

Expand Down
1 change: 1 addition & 0 deletions native-schema-registry/target/.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Intentionally empty for build to work as expected

0 comments on commit ead24da

Please sign in to comment.