Skip to content
This repository was archived by the owner on Jun 5, 2023. It is now read-only.
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.vscode/
bin/
obj/
builddir/
*.user
Debug/
Release/
Expand Down
27 changes: 27 additions & 0 deletions src/WebWindow.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
cmake_minimum_required(VERSION 3.7)
project(WebWindowNative)

if(APPLE)
file(GLOB LIB_SOURCE "src/WebWindow.Mac.*")
else()
file(GLOB LIB_SOURCE "src/WebWindow.Linux.*")
endif()

add_library(WebWindow.Native SHARED ${LIB_SOURCE})
target_include_directories(WebWindow.Native PUBLIC include)

if(APPLE)
target_compile_definitions(WebWindow.Native PUBLIC "-DOS_MAC")
target_link_libraries(WebWindow.Native "-framework Cocoa" "-framework WebKit")
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(WEBKIT4 REQUIRED webkit2gtk-4.0)

target_compile_definitions(WebWindow.Native PUBLIC "-DOS_LINUX")
target_compile_options(WebWindow.Native PUBLIC ${GTK3_CFLAGS_OTHER} ${WEBKIT4_CFLAGS_OTHER})
target_include_directories(WebWindow.Native PUBLIC ${GTK3_INCLUDE_DIRS} ${WEBKIT4_INCLUDE_DIRS})
# target_link_directories(WebWindow.Native PUBLIC ${GTK3_LIBRARY_DIRS} ${WEBKIT4_LIBRARY_DIRS})
link_directories(${GTK3_LIBRARY_DIRS} ${WEBKIT4_LIBRARY_DIRS})
target_link_libraries(WebWindow.Native ${GTK3_LIBRARIES} ${WEBKIT4_LIBRARIES})
endif()
3 changes: 3 additions & 0 deletions src/WebWindow.Native/WebWindow.Native.cmproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project Sdk="MSBuild.Sdk.CMake/0.1.0">

</Project>
11 changes: 7 additions & 4 deletions src/WebWindow.Native/WebWindow.Native.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,19 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>include;$(VC_IncludePath);$(WindowsSDK_IncludePath);</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
Expand Down Expand Up @@ -147,12 +151,11 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Exports.cpp" />
<ClCompile Include="WebWindow.Linux.cpp" />
<ClCompile Include="WebWindow.Windows.cpp" />
<ClCompile Include="src\Exports.cpp" />
<ClCompile Include="src\WebWindow.Windows.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="WebWindow.h" />
<ClInclude Include="include\WebWindow.h" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
11 changes: 4 additions & 7 deletions src/WebWindow.Native/WebWindow.Native.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WebWindow.Windows.cpp">
<ClCompile Include="src\WebWindow.Windows.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Exports.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="WebWindow.Linux.cpp">
<ClCompile Include="src\Exports.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="WebWindow.h">
<ClInclude Include="include\WebWindow.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="$(MSBuildThisFileDirectory)$(EffectivePlatform)\WebView2Loader.dll" />
<None Include="packages.config" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// For this to build on WSL (Ubuntu 18.04) you need to:
// sudo apt-get install libgtk-3-dev libwebkit2gtk-4.0-dev
#ifdef OS_LINUX

#include "WebWindow.h"
#include <mutex>
#include <condition_variable>
Expand Down Expand Up @@ -308,5 +308,3 @@ void WebWindow::SetIconFile(AutoString filename)
{
gtk_window_set_icon_from_file(GTK_WINDOW(_window), filename, NULL);
}

#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#ifdef OS_MAC
#include "WebWindow.h"
#import "WebWindow.Mac.AppDelegate.h"
#import "WebWindow.Mac.UiDelegate.h"
Expand Down Expand Up @@ -277,5 +276,3 @@
[[window standardWindowButton:NSWindowDocumentIconButton] setImage:icon];
}
}

#endif
15 changes: 5 additions & 10 deletions src/WebWindow/WebWindow.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<PackageDescription>Open native OS windows hosting web UI on Windows, Mac, and Linux</PackageDescription>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<TargetFramework>netstandard2.1</TargetFramework>
<NativeOutputDir>..\WebWindow.Native\x64\$(Configuration)\</NativeOutputDir>
<NativeOutputDir Condition="'$(OS)' == 'Windows_NT'">..\WebWindow.Native\x64\$(Configuration)\</NativeOutputDir>
<NativeOutputDir Condition="'$(OS)' != 'Windows_NT'">..\WebWindow.Native\builddir\$(Configuration)\any\</NativeOutputDir>
<IsMacOS>$([MSBuild]::IsOsPlatform('OSX'))</IsMacOS>
<NativeAssetRuntimeIdentifier Condition="'$(OS)' == 'Windows_NT'" >win-x64</NativeAssetRuntimeIdentifier>
<NativeAssetRuntimeIdentifier Condition="'$(OS)' != 'Windows_NT' AND '$(IsMacOS)' != 'true'" >linux-x64</NativeAssetRuntimeIdentifier>
Expand All @@ -17,20 +18,14 @@
</ItemGroup>

<Target Name="BuildNonWindowsNative" Condition="'$(OS)' != 'Windows_NT'" BeforeTargets="Build">
<MakeDir Directories="..\WebWindow.Native\x64\$(Configuration)" />
<Exec Condition="'$(IsMacOS)' == 'true'"
WorkingDirectory="..\WebWindow.Native"
Command="gcc -shared -lstdc++ -DOS_MAC -framework Cocoa -framework WebKit WebWindow.Mac.mm Exports.cpp WebWindow.Mac.AppDelegate.mm WebWindow.Mac.UiDelegate.mm WebWindow.Mac.UrlSchemeHandler.m -o x64/$(Configuration)/WebWindow.Native.dylib" />
<Exec Condition="'$(IsMacOS)' != 'true'"
WorkingDirectory="..\WebWindow.Native"
Command="gcc -std=c++11 -shared -DOS_LINUX Exports.cpp WebWindow.Linux.cpp -o x64/$(Configuration)/WebWindow.Native.so `pkg-config --cflags --libs gtk+-3.0 webkit2gtk-4.0` -fPIC" />
<MSBuild Projects="..\WebWindow.Native\WebWindow.Native.cmproj" Targets="Build" Properties="Configuration=$(Configuration)" />
</Target>

<ItemGroup>
<_NativeLibraries Include="$(NativeOutputDir)WebWindow.Native.dll" Condition="Exists('$(NativeOutputDir)WebWindow.Native.dll')" />
<_NativeLibraries Include="$(NativeOutputDir)WebView2Loader.dll" Condition="Exists('$(NativeOutputDir)WebView2Loader.dll')" />
<_NativeLibraries Include="$(NativeOutputDir)WebWindow.Native.so" Condition="Exists('$(NativeOutputDir)WebWindow.Native.so')" />
<_NativeLibraries Include="$(NativeOutputDir)WebWindow.Native.dylib" Condition="Exists('$(NativeOutputDir)WebWindow.Native.dylib')" />
<_NativeLibraries Include="$(NativeOutputDir)libWebWindow.Native.so" Condition="Exists('$(NativeOutputDir)libWebWindow.Native.so')" />
<_NativeLibraries Include="$(NativeOutputDir)libWebWindow.Native.dylib" Condition="Exists('$(NativeOutputDir)libWebWindow.Native.dylib')" />
<Content Include="@(_NativeLibraries)">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>%(Filename)%(Extension)</Link>
Expand Down