Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit c258ec5

Browse files
committed
enable windows support
1 parent 21760af commit c258ec5

23 files changed

+1139
-5
lines changed

ios/Runner.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@
299299
"$(inherited)",
300300
"$(PROJECT_DIR)/Flutter",
301301
);
302-
PRODUCT_BUNDLE_IDENTIFIER = come.turrant.server-manager;
302+
PRODUCT_BUNDLE_IDENTIFIER = come.csgo.server.manager;
303303
PRODUCT_NAME = "$(TARGET_NAME)";
304304
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
305305
SWIFT_VERSION = 5.0;
@@ -431,7 +431,7 @@
431431
"$(inherited)",
432432
"$(PROJECT_DIR)/Flutter",
433433
);
434-
PRODUCT_BUNDLE_IDENTIFIER = come.turrant.server-manager;
434+
PRODUCT_BUNDLE_IDENTIFIER = come.csgo.server.manager;
435435
PRODUCT_NAME = "$(TARGET_NAME)";
436436
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
437437
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -458,7 +458,7 @@
458458
"$(inherited)",
459459
"$(PROJECT_DIR)/Flutter",
460460
);
461-
PRODUCT_BUNDLE_IDENTIFIER = come.turrant.server-manager;
461+
PRODUCT_BUNDLE_IDENTIFIER = come.csgo.server.manager;
462462
PRODUCT_NAME = "$(TARGET_NAME)";
463463
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
464464
SWIFT_VERSION = 5.0;
@@ -492,4 +492,4 @@
492492
/* End XCConfigurationList section */
493493
};
494494
rootObject = 97C146E61CF9000F007C117D /* Project object */;
495-
}
495+
}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies:
3535
provider: ^4.3.2+2
3636
shared_preferences: ^0.5.12+4
3737
source_server: ^1.1.0
38-
flutter_launcher_icons: "^0.8.0"
38+
flutter_launcher_icons: ^0.8.0
3939

4040
dev_dependencies:
4141
flutter_test:

test/widget_test.dart

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// This is a basic Flutter widget test.
2+
//
3+
// To perform an interaction with a widget in your test, use the WidgetTester
4+
// utility that Flutter provides. For example, you can send tap and scroll
5+
// gestures. You can also use WidgetTester to find child widgets in the widget
6+
// tree, read text, and verify that the values of widget properties are correct.
7+
8+
import 'package:flutter/material.dart';
9+
import 'package:flutter_test/flutter_test.dart';
10+
11+
import 'package:turrant/main.dart';
12+
13+
void main() {
14+
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15+
// Build our app and trigger a frame.
16+
await tester.pumpWidget(MyApp());
17+
18+
// Verify that our counter starts at 0.
19+
expect(find.text('0'), findsOneWidget);
20+
expect(find.text('1'), findsNothing);
21+
22+
// Tap the '+' icon and trigger a frame.
23+
await tester.tap(find.byIcon(Icons.add));
24+
await tester.pump();
25+
26+
// Verify that our counter has incremented.
27+
expect(find.text('0'), findsNothing);
28+
expect(find.text('1'), findsOneWidget);
29+
});
30+
}

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

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

windows/flutter/CMakeLists.txt

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

windows/runner/CMakeLists.txt

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
cmake_minimum_required(VERSION 3.15)
2+
project(runner LANGUAGES CXX)
3+
4+
add_executable(${BINARY_NAME} WIN32
5+
"flutter_window.cpp"
6+
"main.cpp"
7+
"run_loop.cpp"
8+
"utils.cpp"
9+
"win32_window.cpp"
10+
"${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc"
11+
"Runner.rc"
12+
"runner.exe.manifest"
13+
)
14+
apply_standard_settings(${BINARY_NAME})
15+
target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
16+
target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
17+
target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
18+
add_dependencies(${BINARY_NAME} flutter_assemble)

0 commit comments

Comments
 (0)