mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-12-08 16:27:31 +00:00
feat: add build dart script for windows
This commit is contained in:
parent
4ca893950b
commit
38dc934f40
1
.github/workflows/spotube-release-binary.yml
vendored
1
.github/workflows/spotube-release-binary.yml
vendored
@ -55,7 +55,6 @@ jobs:
|
|||||||
- name: Replace version in files
|
- name: Replace version in files
|
||||||
run: |
|
run: |
|
||||||
choco install sed make -y
|
choco install sed make -y
|
||||||
sed -i "s/%{{SPOTUBE_VERSION}}%/${{ env.BUILD_VERSION }}/" windows/runner/Runner.rc
|
|
||||||
sed -i "s/%{{SPOTUBE_VERSION}}%/${{ env.BUILD_VERSION }}/" choco-struct/tools/VERIFICATION.txt
|
sed -i "s/%{{SPOTUBE_VERSION}}%/${{ env.BUILD_VERSION }}/" choco-struct/tools/VERIFICATION.txt
|
||||||
sed -i "s/%{{SPOTUBE_VERSION}}%/${{ env.BUILD_VERSION }}/" choco-struct/spotube.nuspec
|
sed -i "s/%{{SPOTUBE_VERSION}}%/${{ env.BUILD_VERSION }}/" choco-struct/spotube.nuspec
|
||||||
|
|
||||||
|
|||||||
16
.metadata
16
.metadata
@ -1,11 +1,11 @@
|
|||||||
# This file tracks properties of this Flutter project.
|
# This file tracks properties of this Flutter project.
|
||||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||||
#
|
#
|
||||||
# This file should be version controlled.
|
# This file should be version controlled and should not be manually edited.
|
||||||
|
|
||||||
version:
|
version:
|
||||||
revision: eb6d86ee27deecba4a83536aa20f366a6044895c
|
revision: "300451adae589accbece3490f4396f10bdf15e6e"
|
||||||
channel: stable
|
channel: "stable"
|
||||||
|
|
||||||
project_type: app
|
project_type: app
|
||||||
|
|
||||||
@ -13,11 +13,11 @@ project_type: app
|
|||||||
migration:
|
migration:
|
||||||
platforms:
|
platforms:
|
||||||
- platform: root
|
- platform: root
|
||||||
create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
|
create_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||||
base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
|
base_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||||
- platform: macos
|
- platform: windows
|
||||||
create_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
|
create_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||||
base_revision: eb6d86ee27deecba4a83536aa20f366a6044895c
|
base_revision: 300451adae589accbece3490f4396f10bdf15e6e
|
||||||
|
|
||||||
# User provided section
|
# User provided section
|
||||||
|
|
||||||
|
|||||||
4
cli/README.md
Normal file
4
cli/README.md
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
## Spotube Configuration CLI
|
||||||
|
|
||||||
|
This is used for building the project for multiple platforms and having utilities specific for the project.
|
||||||
|
Written in Dart
|
||||||
10
cli/cli.dart
Normal file
10
cli/cli.dart
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import 'package:args/command_runner.dart';
|
||||||
|
|
||||||
|
void main(List<String> args) {
|
||||||
|
final commandRunner = CommandRunner(
|
||||||
|
"cli",
|
||||||
|
"Configuration CLI for Spotube",
|
||||||
|
);
|
||||||
|
|
||||||
|
commandRunner.run(args);
|
||||||
|
}
|
||||||
0
cli/commands/build/android.dart
Normal file
0
cli/commands/build/android.dart
Normal file
41
cli/commands/build/common.dart
Normal file
41
cli/commands/build/common.dart
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:args/command_runner.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
|
import 'package:process_run/shell_run.dart';
|
||||||
|
import 'package:pubspec_parse/pubspec_parse.dart';
|
||||||
|
|
||||||
|
mixin BuildCommandCommonSteps on Command {
|
||||||
|
final shell = Shell();
|
||||||
|
Directory get cwd => Directory.current;
|
||||||
|
|
||||||
|
Pubspec? _pubspec;
|
||||||
|
|
||||||
|
Pubspec get pubspec {
|
||||||
|
if (_pubspec != null) {
|
||||||
|
return _pubspec!;
|
||||||
|
}
|
||||||
|
|
||||||
|
final pubspecFile = File(join(cwd.path, "pubspec.yaml"));
|
||||||
|
_pubspec = Pubspec.parse(pubspecFile.readAsStringSync());
|
||||||
|
|
||||||
|
return _pubspec!;
|
||||||
|
}
|
||||||
|
|
||||||
|
String get versionWithoutBuildNumber {
|
||||||
|
return "${pubspec.version!.major}.${pubspec.version!.minor}.${pubspec.version!.patch}";
|
||||||
|
}
|
||||||
|
|
||||||
|
RegExp get versionVarRegExp =>
|
||||||
|
RegExp(r"\%\{\{SPOTUBE_VERSION\}\}\%", multiLine: true);
|
||||||
|
|
||||||
|
Future<void> bootstrap() async {
|
||||||
|
await shell.run(
|
||||||
|
"""
|
||||||
|
flutter pub get
|
||||||
|
dart run build_runner build --delete-conflicting-outputs
|
||||||
|
dart pub global activate flutter_distributor
|
||||||
|
""",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
0
cli/commands/build/ios.dart
Normal file
0
cli/commands/build/ios.dart
Normal file
0
cli/commands/build/linux.dart
Normal file
0
cli/commands/build/linux.dart
Normal file
0
cli/commands/build/macos.dart
Normal file
0
cli/commands/build/macos.dart
Normal file
105
cli/commands/build/windows.dart
Normal file
105
cli/commands/build/windows.dart
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:args/command_runner.dart';
|
||||||
|
import 'package:path/path.dart';
|
||||||
|
import 'package:crypto/crypto.dart';
|
||||||
|
import 'common.dart';
|
||||||
|
|
||||||
|
class WindowsBuildCommand extends Command with BuildCommandCommonSteps {
|
||||||
|
@override
|
||||||
|
String get description => "Build Windows exe";
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get name => "windows";
|
||||||
|
|
||||||
|
Future<void> innoInstall() async {
|
||||||
|
final innoInstallerPath = join(cwd.path, "build", "installer.exe");
|
||||||
|
const innoVersion = "6.2.0";
|
||||||
|
final innoDependencyPath = join(cwd.path, "build", "inno-depend");
|
||||||
|
|
||||||
|
await shell.run(
|
||||||
|
"""
|
||||||
|
curl -o $innoInstallerPath http://files.jrsoftware.org/is/6/innosetup-$innoVersion.exe
|
||||||
|
git clone https://github.com/DomGries/InnoDependencyInstaller.git $innoDependencyPath
|
||||||
|
$innoInstallerPath /verysilent /allusers /dir=build\\iscc
|
||||||
|
""",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void run() async {
|
||||||
|
stdout.writeln("Replace versions");
|
||||||
|
|
||||||
|
final chocoFiles = [
|
||||||
|
join(cwd.path, "choco-struct", "tools", "VERIFICATION.txt"),
|
||||||
|
join(cwd.path, "choco-struct", "spotube.nuspec"),
|
||||||
|
];
|
||||||
|
|
||||||
|
for (final filePath in chocoFiles) {
|
||||||
|
final file = File(filePath);
|
||||||
|
final content = file.readAsStringSync();
|
||||||
|
final newContent =
|
||||||
|
content.replaceAll(versionVarRegExp, versionWithoutBuildNumber);
|
||||||
|
|
||||||
|
file.writeAsStringSync(newContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
await bootstrap();
|
||||||
|
await innoInstall();
|
||||||
|
|
||||||
|
await shell.run(
|
||||||
|
"flutter_distributor package --platform=windows --targets=exe --skip-clean",
|
||||||
|
);
|
||||||
|
|
||||||
|
final ogExe = File(
|
||||||
|
join(
|
||||||
|
cwd.path,
|
||||||
|
"dist",
|
||||||
|
pubspec.version.toString(),
|
||||||
|
"spotube-${pubspec.version}-windows-setup.exe",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final exePath = join(cwd.path, "dist", "Spotube-windows-x86_64-setup.exe");
|
||||||
|
|
||||||
|
await ogExe.copy(exePath);
|
||||||
|
await ogExe.delete();
|
||||||
|
|
||||||
|
stdout.writeln("✅ Windows exe built at $exePath");
|
||||||
|
|
||||||
|
final exeFile = File(exePath);
|
||||||
|
|
||||||
|
final hash = sha256.convert(exeFile.readAsBytesSync()).toString();
|
||||||
|
|
||||||
|
final chocoVerificationFile = File(chocoFiles.first);
|
||||||
|
|
||||||
|
chocoVerificationFile.writeAsStringSync(
|
||||||
|
chocoVerificationFile.readAsStringSync().replaceAll(
|
||||||
|
RegExp(r"\%\{\{WIN_SHA256\}\}\%"),
|
||||||
|
hash,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final chocoToolsPath = join(cwd.path, "choco-struct", "tools");
|
||||||
|
exeFile.copySync(chocoToolsPath);
|
||||||
|
|
||||||
|
await shell.run(
|
||||||
|
"choco pack ${chocoFiles[1]} --outputdirectory ${join(cwd.path, "dist")}",
|
||||||
|
);
|
||||||
|
|
||||||
|
final chocoNupkg = File(
|
||||||
|
join(cwd.path, "dist", "spotube.$versionWithoutBuildNumber.nupkg"),
|
||||||
|
);
|
||||||
|
|
||||||
|
final distNupkgPath = join(
|
||||||
|
cwd.path,
|
||||||
|
"dist",
|
||||||
|
"Spotube-windows-x86_64.nupkg",
|
||||||
|
);
|
||||||
|
|
||||||
|
await chocoNupkg.copy(distNupkgPath);
|
||||||
|
await chocoNupkg.delete();
|
||||||
|
|
||||||
|
stdout.writeln("✅ Windows nupkg built at $distNupkgPath");
|
||||||
|
}
|
||||||
|
}
|
||||||
22
cli/core/env.dart
Normal file
22
cli/core/env.dart
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
enum BuildChannel {
|
||||||
|
stable,
|
||||||
|
nightly;
|
||||||
|
|
||||||
|
factory BuildChannel.fromEnvironment(String name) {
|
||||||
|
final channel = Platform.environment[name]!;
|
||||||
|
if (channel == "stable") {
|
||||||
|
return BuildChannel.stable;
|
||||||
|
} else if (channel == "nightly") {
|
||||||
|
return BuildChannel.nightly;
|
||||||
|
} else {
|
||||||
|
throw Exception("Invalid channel: $channel");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CliEnv {
|
||||||
|
static final channel = BuildChannel.fromEnvironment("CHANNEL");
|
||||||
|
static final dotenv = Platform.environment["DOTENV"]!;
|
||||||
|
}
|
||||||
@ -1734,6 +1734,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.0.2"
|
version: "5.0.2"
|
||||||
|
process_run:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description:
|
||||||
|
name: process_run
|
||||||
|
sha256: "8d9c6198b98fbbfb511edd42e7364e24d85c163e47398919871b952dc86a423e"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.14.2"
|
||||||
provider:
|
provider:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|||||||
@ -144,6 +144,7 @@ dev_dependencies:
|
|||||||
freezed: ^2.5.2
|
freezed: ^2.5.2
|
||||||
custom_lint: ^0.6.4
|
custom_lint: ^0.6.4
|
||||||
riverpod_lint: ^2.3.10
|
riverpod_lint: ^2.3.10
|
||||||
|
process_run: ^0.14.2
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
uuid: ^4.4.0
|
uuid: ^4.4.0
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
|
# Project-level configuration.
|
||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(spotube LANGUAGES CXX)
|
project(spotube LANGUAGES CXX)
|
||||||
|
|
||||||
|
# The name of the executable created for the application. Change this to change
|
||||||
|
# the on-disk name of your application.
|
||||||
set(BINARY_NAME "spotube")
|
set(BINARY_NAME "spotube")
|
||||||
|
|
||||||
cmake_policy(SET CMP0063 NEW)
|
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
||||||
|
# versions of CMake.
|
||||||
|
cmake_policy(VERSION 3.14...3.25)
|
||||||
|
|
||||||
set(CMAKE_INSTALL_RPATH "$ORIGIN/lib")
|
# Define build configuration option.
|
||||||
|
|
||||||
# Configure build options.
|
|
||||||
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||||
if(IS_MULTICONFIG)
|
if(IS_MULTICONFIG)
|
||||||
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
|
set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release"
|
||||||
@ -20,7 +23,7 @@ else()
|
|||||||
"Debug" "Profile" "Release")
|
"Debug" "Profile" "Release")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
# Define settings for the Profile build mode.
|
||||||
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
|
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
|
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
|
||||||
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
|
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}")
|
||||||
@ -30,6 +33,10 @@ set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}")
|
|||||||
add_definitions(-DUNICODE -D_UNICODE)
|
add_definitions(-DUNICODE -D_UNICODE)
|
||||||
|
|
||||||
# Compilation settings that should be applied to most targets.
|
# Compilation settings that should be applied to most targets.
|
||||||
|
#
|
||||||
|
# Be cautious about adding new options here, as plugins use this function by
|
||||||
|
# default. In most cases, you should add new options to specific targets instead
|
||||||
|
# of modifying this function.
|
||||||
function(APPLY_STANDARD_SETTINGS TARGET)
|
function(APPLY_STANDARD_SETTINGS TARGET)
|
||||||
target_compile_features(${TARGET} PUBLIC cxx_std_17)
|
target_compile_features(${TARGET} PUBLIC cxx_std_17)
|
||||||
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
|
target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100")
|
||||||
@ -38,14 +45,14 @@ function(APPLY_STANDARD_SETTINGS TARGET)
|
|||||||
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
|
target_compile_definitions(${TARGET} PRIVATE "$<$<CONFIG:Debug>:_DEBUG>")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
|
||||||
|
|
||||||
# Flutter library and tool build rules.
|
# Flutter library and tool build rules.
|
||||||
|
set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter")
|
||||||
add_subdirectory(${FLUTTER_MANAGED_DIR})
|
add_subdirectory(${FLUTTER_MANAGED_DIR})
|
||||||
|
|
||||||
# Application build
|
# Application build; see runner/CMakeLists.txt.
|
||||||
add_subdirectory("runner")
|
add_subdirectory("runner")
|
||||||
|
|
||||||
|
|
||||||
# Generated plugin build rules, which manage building the plugins and adding
|
# Generated plugin build rules, which manage building the plugins and adding
|
||||||
# them to the application.
|
# them to the application.
|
||||||
include(flutter/generated_plugins.cmake)
|
include(flutter/generated_plugins.cmake)
|
||||||
@ -80,6 +87,12 @@ if(PLUGIN_BUNDLED_LIBRARIES)
|
|||||||
COMPONENT Runtime)
|
COMPONENT Runtime)
|
||||||
endif()
|
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
|
# Fully re-copy the assets directory on each build to avoid having stale files
|
||||||
# from a previous install.
|
# from a previous install.
|
||||||
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
|
set(FLUTTER_ASSET_DIR_NAME "flutter_assets")
|
||||||
|
|||||||
@ -60,16 +60,16 @@ IDI_APP_ICON ICON "resources\\app_icon.ico"
|
|||||||
// Version
|
// Version
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifdef FLUTTER_BUILD_NUMBER
|
#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
|
||||||
#define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER
|
#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
|
||||||
#else
|
#else
|
||||||
#define VERSION_AS_NUMBER 1,0,0
|
#define VERSION_AS_NUMBER 1,0,0,0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FLUTTER_BUILD_NAME
|
#if defined(FLUTTER_VERSION)
|
||||||
#define VERSION_AS_STRING #FLUTTER_BUILD_NAME
|
#define VERSION_AS_STRING FLUTTER_VERSION
|
||||||
#else
|
#else
|
||||||
#define VERSION_AS_STRING "%{{SPOTUBE_VERSION}}%"
|
#define VERSION_AS_STRING "3.6.0"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
@ -93,7 +93,7 @@ BEGIN
|
|||||||
VALUE "FileDescription", "Spotube" "\0"
|
VALUE "FileDescription", "Spotube" "\0"
|
||||||
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
||||||
VALUE "InternalName", "spotube" "\0"
|
VALUE "InternalName", "spotube" "\0"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2022 oss.krtirtho. All rights reserved." "\0"
|
VALUE "LegalCopyright", "Copyright (C) 2024 oss.krtirtho. All rights reserved." "\0"
|
||||||
VALUE "OriginalFilename", "spotube.exe" "\0"
|
VALUE "OriginalFilename", "spotube.exe" "\0"
|
||||||
VALUE "ProductName", "spotube" "\0"
|
VALUE "ProductName", "spotube" "\0"
|
||||||
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user