Skip to content

Commit d353ea9

Browse files
committed
feat: enable windows support
1 parent 5a2f3ca commit d353ea9

21 files changed

+1124
-23
lines changed

.github/workflows/release_for_linux.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
.flutter/bin/flutter build linux --release
3535
3636
- name: Package Executable
37-
run: 7z a -r -sse "..\..\..\..\..\build\app\watermeter-linux-release-amd64.zip" *
38-
working-directory: build\linux\x64\runner\Release
37+
run: 7z a -r -sse "../../../../../build/app/watermeter-linux-release-amd64.zip" *
38+
working-directory: build/linux/x64/runner/Release
3939

4040
- name: Release
4141
uses: softprops/action-gh-release@v1

.github/workflows/release_for_windows.yml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jobs:
1616
1717
- name: Build for Windows
1818
run: |
19-
.flutter/bin/flutter.bat create --platforms=windows .
2019
.flutter/bin/flutter.bat build windows --release
2120
2221
- name: Package Executable

.metadata

+5-20
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# This file should be version controlled and should not be manually edited.
55

66
version:
7-
revision: "78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9"
7+
revision: "7482962148e8d758338d8a28f589f317e1e42ba4"
88
channel: "stable"
99

1010
project_type: app
@@ -13,26 +13,11 @@ project_type: app
1313
migration:
1414
platforms:
1515
- platform: root
16-
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
17-
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
18-
- platform: android
19-
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
20-
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
21-
- platform: ios
22-
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
23-
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
24-
- platform: linux
25-
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
26-
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
27-
- platform: macos
28-
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
29-
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
30-
- platform: web
31-
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
32-
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
16+
create_revision: 7482962148e8d758338d8a28f589f317e1e42ba4
17+
base_revision: 7482962148e8d758338d8a28f589f317e1e42ba4
3318
- platform: windows
34-
create_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
35-
base_revision: 78666c8dc57e9f7548ca9f8dd0740fbf0c658dc9
19+
create_revision: 7482962148e8d758338d8a28f589f317e1e42ba4
20+
base_revision: 7482962148e8d758338d8a28f589f317e1e42ba4
3621

3722
# User provided section
3823

windows/.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
flutter/ephemeral/
2+
3+
# Visual Studio user-specific files.
4+
*.suo
5+
*.user
6+
*.userosscache
7+
*.sln.docstates
8+
9+
# Visual Studio build-related files.
10+
x64/
11+
x86/
12+
13+
# Visual Studio cache files
14+
# files ending in .cache can be ignored
15+
*.[Cc]ache
16+
# but keep track of directories ending in .cache
17+
!*.[Cc]ache/

windows/CMakeLists.txt

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Project-level configuration.
2+
cmake_minimum_required(VERSION 3.14)
3+
project(traintime_pda LANGUAGES CXX)
4+
5+
# The name of the executable created for the application. Change this to change
6+
# the on-disk name of your application.
7+
set(BINARY_NAME "traintime_pda")
8+
9+
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
10+
# versions of CMake.
11+
cmake_policy(VERSION 3.14...3.25)
12+
13+
# Define build configuration option.
14+
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
15+
if(IS_MULTICONFIG)
16+
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
17+
CACHE STRING "" FORCE)
18+
else()
19+
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
20+
set(CMAKE_BUILD_TYPE "Debug" CACHE
21+
STRING "Flutter build mode" FORCE)
22+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
23+
"Debug" "Profile" "Release")
24+
endif()
25+
endif()
26+
# Define settings for the Profile build mode.
27+
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
28+
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
29+
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
30+
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
31+
32+
# Use Unicode for all projects.
33+
add_definitions(-DUNICODE -D_UNICODE)
34+
35+
# Compilation settings that should be applied to most targets.
36+
#
37+
# Be cautious about adding new options here, as plugins use this function by
38+
# default. In most cases, you should add new options to specific targets instead
39+
# of modifying this function.
40+
function(APPLY_STANDARD_SETTINGS TARGET)
41+
target_compile_features(${TARGET} PUBLIC cxx_std_17)
42+
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
43+
target_compile_options(${TARGET} PRIVATE /EHsc)
44+
target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0")
45+
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
46+
endfunction()
47+
48+
# Flutter library and tool build rules.
49+
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
50+
add_subdirectory(${FLUTTER_MANAGED_DIR})
51+
52+
# Application build; see runner/CMakeLists.txt.
53+
add_subdirectory("runner")
54+
55+
56+
# Generated plugin build rules, which manage building the plugins and adding
57+
# them to the application.
58+
include(flutter/generated_plugins.cmake)
59+
60+
61+
# === Installation ===
62+
# Support files are copied into place next to the executable, so that it can
63+
# run in place. This is done instead of making a separate bundle (as on Linux)
64+
# so that building and running from within Visual Studio will work.
65+
set(BUILD_BUNDLE_DIR "$<TARGET_FILE_DIR:${BINARY_NAME}>")
66+
# Make the "install" step default, as it's required to run.
67+
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
68+
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
69+
set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE)
70+
endif()
71+
72+
set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data")
73+
set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}")
74+
75+
install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
76+
COMPONENT Runtime)
77+
78+
install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
79+
COMPONENT Runtime)
80+
81+
install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
82+
COMPONENT Runtime)
83+
84+
if(PLUGIN_BUNDLED_LIBRARIES)
85+
install(FILES "${PLUGIN_BUNDLED_LIBRARIES}"
86+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
87+
COMPONENT Runtime)
88+
endif()
89+
90+
# Copy the native assets provided by the build.dart from all packages.
91+
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
92+
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
93+
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
94+
COMPONENT Runtime)
95+
96+
# Fully re-copy the assets directory on each build to avoid having stale files
97+
# from a previous install.
98+
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
99+
install(CODE "
100+
file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")
101+
" COMPONENT Runtime)
102+
install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
103+
DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime)
104+
105+
# Install the AOT library on non-Debug builds only.
106+
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
107+
CONFIGURATIONS Profile;Release
108+
COMPONENT Runtime)

windows/flutter/CMakeLists.txt

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# This file controls Flutter-level build steps. It should not be edited.
2+
cmake_minimum_required(VERSION 3.14)
3+
4+
set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral")
5+
6+
# Configuration provided via flutter tool.
7+
include(${EPHEMERAL_DIR}/generated_config.cmake)
8+
9+
# TODO: Move the rest of this into files in ephemeral. See
10+
# https://github.com/flutter/flutter/issues/57146.
11+
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
12+
13+
# Set fallback configurations for older versions of the flutter tool.
14+
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
15+
set(FLUTTER_TARGET_PLATFORM "windows-x64")
16+
endif()
17+
18+
# === Flutter Library ===
19+
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
20+
21+
# Published to parent scope for install step.
22+
set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE)
23+
set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE)
24+
set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE)
25+
set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE)
26+
27+
list(APPEND FLUTTER_LIBRARY_HEADERS
28+
"flutter_export.h"
29+
"flutter_windows.h"
30+
"flutter_messenger.h"
31+
"flutter_plugin_registrar.h"
32+
"flutter_texture_registrar.h"
33+
)
34+
list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/")
35+
add_library(flutter INTERFACE)
36+
target_include_directories(flutter INTERFACE
37+
"${EPHEMERAL_DIR}"
38+
)
39+
target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib")
40+
add_dependencies(flutter flutter_assemble)
41+
42+
# === Wrapper ===
43+
list(APPEND CPP_WRAPPER_SOURCES_CORE
44+
"core_implementations.cc"
45+
"standard_codec.cc"
46+
)
47+
list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/")
48+
list(APPEND CPP_WRAPPER_SOURCES_PLUGIN
49+
"plugin_registrar.cc"
50+
)
51+
list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/")
52+
list(APPEND CPP_WRAPPER_SOURCES_APP
53+
"flutter_engine.cc"
54+
"flutter_view_controller.cc"
55+
)
56+
list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/")
57+
58+
# Wrapper sources needed for a plugin.
59+
add_library(flutter_wrapper_plugin STATIC
60+
${CPP_WRAPPER_SOURCES_CORE}
61+
${CPP_WRAPPER_SOURCES_PLUGIN}
62+
)
63+
apply_standard_settings(flutter_wrapper_plugin)
64+
set_target_properties(flutter_wrapper_plugin PROPERTIES
65+
POSITION_INDEPENDENT_CODE ON)
66+
set_target_properties(flutter_wrapper_plugin PROPERTIES
67+
CXX_VISIBILITY_PRESET hidden)
68+
target_link_libraries(flutter_wrapper_plugin PUBLIC flutter)
69+
target_include_directories(flutter_wrapper_plugin PUBLIC
70+
"${WRAPPER_ROOT}/include"
71+
)
72+
add_dependencies(flutter_wrapper_plugin flutter_assemble)
73+
74+
# Wrapper sources needed for the runner.
75+
add_library(flutter_wrapper_app STATIC
76+
${CPP_WRAPPER_SOURCES_CORE}
77+
${CPP_WRAPPER_SOURCES_APP}
78+
)
79+
apply_standard_settings(flutter_wrapper_app)
80+
target_link_libraries(flutter_wrapper_app PUBLIC flutter)
81+
target_include_directories(flutter_wrapper_app PUBLIC
82+
"${WRAPPER_ROOT}/include"
83+
)
84+
add_dependencies(flutter_wrapper_app flutter_assemble)
85+
86+
# === Flutter tool backend ===
87+
# _phony_ is a non-existent file to force this command to run every time,
88+
# since currently there's no way to get a full input/output list from the
89+
# flutter tool.
90+
set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_")
91+
set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE)
92+
add_custom_command(
93+
OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS}
94+
${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN}
95+
${CPP_WRAPPER_SOURCES_APP}
96+
${PHONY_OUTPUT}
97+
COMMAND ${CMAKE_COMMAND} -E env
98+
${FLUTTER_TOOL_ENVIRONMENT}
99+
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
100+
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
101+
VERBATIM
102+
)
103+
add_custom_target(flutter_assemble DEPENDS
104+
"${FLUTTER_LIBRARY}"
105+
${FLUTTER_LIBRARY_HEADERS}
106+
${CPP_WRAPPER_SOURCES_CORE}
107+
${CPP_WRAPPER_SOURCES_PLUGIN}
108+
${CPP_WRAPPER_SOURCES_APP}
109+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// clang-format off
6+
7+
#include "generated_plugin_registrant.h"
8+
9+
#include <charset_converter/charset_converter_plugin.h>
10+
#include <permission_handler_windows/permission_handler_windows_plugin.h>
11+
#include <share_plus/share_plus_windows_plugin_c_api.h>
12+
#include <url_launcher_windows/url_launcher_windows.h>
13+
14+
void RegisterPlugins(flutter::PluginRegistry* registry) {
15+
CharsetConverterPluginRegisterWithRegistrar(
16+
registry->GetRegistrarForPlugin("CharsetConverterPlugin"));
17+
PermissionHandlerWindowsPluginRegisterWithRegistrar(
18+
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
19+
SharePlusWindowsPluginCApiRegisterWithRegistrar(
20+
registry->GetRegistrarForPlugin("SharePlusWindowsPluginCApi"));
21+
UrlLauncherWindowsRegisterWithRegistrar(
22+
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// Generated file. Do not edit.
3+
//
4+
5+
// clang-format off
6+
7+
#ifndef GENERATED_PLUGIN_REGISTRANT_
8+
#define GENERATED_PLUGIN_REGISTRANT_
9+
10+
#include <flutter/plugin_registry.h>
11+
12+
// Registers Flutter plugins.
13+
void RegisterPlugins(flutter::PluginRegistry* registry);
14+
15+
#endif // GENERATED_PLUGIN_REGISTRANT_
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#
2+
# Generated file, do not edit.
3+
#
4+
5+
list(APPEND FLUTTER_PLUGIN_LIST
6+
charset_converter
7+
permission_handler_windows
8+
share_plus
9+
url_launcher_windows
10+
)
11+
12+
list(APPEND FLUTTER_FFI_PLUGIN_LIST
13+
)
14+
15+
set(PLUGIN_BUNDLED_LIBRARIES)
16+
17+
foreach(plugin ${FLUTTER_PLUGIN_LIST})
18+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin})
19+
target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin)
20+
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
21+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
22+
endforeach(plugin)
23+
24+
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
25+
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
26+
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
27+
endforeach(ffi_plugin)

0 commit comments

Comments
 (0)