Get windows working

This commit is contained in:
Dane Madsen
2023-10-17 19:04:39 +11:00
parent a9caad2aa5
commit 6edc664184
13 changed files with 61 additions and 52 deletions

4
.gitignore vendored
View File

@@ -129,4 +129,6 @@ app.*.symbols
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/dev/ci/**/Gemfile.lock
!.vscode/settings.json
!.vscode/settings.json
.vscode/

View File

@@ -4,8 +4,8 @@
# This file should be version controlled and should not be manually edited.
version:
revision: "ead455963c12b453cdb2358cad34969c76daf180"
channel: "stable"
revision: "fe6553b689e4d2151b0f760ca06927fc284cc0a9"
channel: "beta"
project_type: app
@@ -13,26 +13,26 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: ead455963c12b453cdb2358cad34969c76daf180
base_revision: ead455963c12b453cdb2358cad34969c76daf180
create_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
base_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
- platform: android
create_revision: ead455963c12b453cdb2358cad34969c76daf180
base_revision: ead455963c12b453cdb2358cad34969c76daf180
create_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
base_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
- platform: ios
create_revision: ead455963c12b453cdb2358cad34969c76daf180
base_revision: ead455963c12b453cdb2358cad34969c76daf180
create_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
base_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
- platform: linux
create_revision: ead455963c12b453cdb2358cad34969c76daf180
base_revision: ead455963c12b453cdb2358cad34969c76daf180
create_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
base_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
- platform: macos
create_revision: ead455963c12b453cdb2358cad34969c76daf180
base_revision: ead455963c12b453cdb2358cad34969c76daf180
create_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
base_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
- platform: web
create_revision: ead455963c12b453cdb2358cad34969c76daf180
base_revision: ead455963c12b453cdb2358cad34969c76daf180
create_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
base_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
- platform: windows
create_revision: ead455963c12b453cdb2358cad34969c76daf180
base_revision: ead455963c12b453cdb2358cad34969c76daf180
create_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
base_revision: fe6553b689e4d2151b0f760ca06927fc284cc0a9
# User provided section

View File

@@ -69,10 +69,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.2"
version: "1.18.0"
console:
dependency: transitive
description:
@@ -291,10 +291,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
msix:
dependency: "direct dev"
description:
@@ -544,18 +544,18 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
string_scanner:
dependency: transitive
description:
@@ -584,10 +584,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.dev"
source: hosted
version: "0.6.0"
version: "0.6.1"
typed_data:
dependency: transitive
description:
@@ -672,10 +672,10 @@ packages:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
sha256: "14f1f70c51119012600c5f1f60ca68efda5a9b6077748163c6af2893ec5df8fc"
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
version: "0.2.1-beta"
win32:
dependency: transitive
description:
@@ -717,5 +717,5 @@ packages:
source: hosted
version: "2.1.0"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
dart: ">=3.2.0-157.0.dev <4.0.0"
flutter: ">=3.3.0"

View File

@@ -1,4 +1,5 @@
cmake_minimum_required(VERSION 3.10)
project(maid)
set(BUILD_SHARED_LIBS ON)
add_subdirectory(./llama.cpp)
add_subdirectory(./butler)

View File

@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.9)
cmake_minimum_required(VERSION 3.10)
project(butler VERSION 1.0.0 DESCRIPTION "butler")
add_library(butler SHARED butler.cpp)
target_include_directories(butler PRIVATE ../llama.cpp)
target_link_libraries(butler llama)
set_target_properties(butler PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)

View File

@@ -8,7 +8,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:maid/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {

View File

@@ -8,7 +8,7 @@ set(BINARY_NAME "maid")
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
# versions of CMake.
cmake_policy(SET CMP0063 NEW)
cmake_policy(VERSION 3.14...3.25)
# Define build configuration option.
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
@@ -52,6 +52,7 @@ add_subdirectory(${FLUTTER_MANAGED_DIR})
# Application build; see runner/CMakeLists.txt.
add_subdirectory("runner")
# Generated plugin build rules, which manage building the plugins and adding
# them to the application.
include(flutter/generated_plugins.cmake)
@@ -86,6 +87,12 @@ if(PLUGIN_BUNDLED_LIBRARIES)
COMPONENT Runtime)
endif()
# Copy the native assets provided by the build.dart from all packages.
set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/")
install(DIRECTORY "${NATIVE_ASSETS_DIR}"
DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"
COMPONENT Runtime)
# Fully re-copy the assets directory on each build to avoid having stale files
# from a previous install.
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
@@ -99,8 +106,3 @@ install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}"
install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}"
CONFIGURATIONS Profile;Release
COMPONENT Runtime)
set(BUILD_SHARED_LIBS ON)
add_subdirectory(./llama.cpp)
add_subdirectory(./butler)
install(FILES ${PROJECT_BINARY_DIR}/butler/butler.dll DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime)

View File

@@ -10,6 +10,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake)
# https://github.com/flutter/flutter/issues/57146.
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")
# Set fallback configurations for older versions of the flutter tool.
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
set(FLUTTER_TARGET_PLATFORM "windows-x64")
endif()
# === Flutter Library ===
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")
@@ -92,7 +97,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
windows-x64 $<CONFIG>
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS

View File

@@ -38,8 +38,3 @@ target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
# Run the Flutter tool portions of the build. This must not be removed.
add_dependencies(${BINARY_NAME} flutter_assemble)
set(BUILD_SHARED_LIBS ON)
# Create a binary directory for the llama.cpp project
add_subdirectory(../../src/llama.cpp llama_build)

View File

@@ -89,11 +89,11 @@ BEGIN
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "CompanyName", "com.example" "\0"
VALUE "CompanyName", "com.danemadsen" "\0"
VALUE "FileDescription", "maid" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "maid" "\0"
VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0"
VALUE "LegalCopyright", "Copyright (C) 2023 com.danemadsen. All rights reserved." "\0"
VALUE "OriginalFilename", "maid.exe" "\0"
VALUE "ProductName", "maid" "\0"
VALUE "ProductVersion", VERSION_AS_STRING "\0"

View File

@@ -47,16 +47,17 @@ std::string Utf8FromUtf16(const wchar_t* utf16_string) {
}
int target_length = ::WideCharToMultiByte(
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
-1, nullptr, 0, nullptr, nullptr);
-1, nullptr, 0, nullptr, nullptr)
-1; // remove the trailing null character
int input_length = (int)wcslen(utf16_string);
std::string utf8_string;
if (target_length == 0 || target_length > utf8_string.max_size()) {
if (target_length <= 0 || target_length > utf8_string.max_size()) {
return utf8_string;
}
utf8_string.resize(target_length);
int converted_length = ::WideCharToMultiByte(
CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,
-1, utf8_string.data(),
target_length, nullptr, nullptr);
input_length, utf8_string.data(), target_length, nullptr, nullptr);
if (converted_length == 0) {
return std::string();
}

View File

@@ -60,7 +60,7 @@ class WindowClassRegistrar {
public:
~WindowClassRegistrar() = default;
// Returns the singleton registar instance.
// Returns the singleton registrar instance.
static WindowClassRegistrar* GetInstance() {
if (!instance_) {
instance_ = new WindowClassRegistrar();

View File

@@ -77,7 +77,7 @@ class Win32Window {
// OS callback called by message pump. Handles the WM_NCCREATE message which
// is passed when the non-client area is being created and enables automatic
// non-client DPI scaling so that the non-client area automatically
// responsponds to changes in DPI. All other messages are handled by
// responds to changes in DPI. All other messages are handled by
// MessageHandler.
static LRESULT CALLBACK WndProc(HWND const window,
UINT const message,