diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml new file mode 100644 index 0000000..0f9f4db --- /dev/null +++ b/.github/workflows/go.yml @@ -0,0 +1,53 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + defaults: + run: + working-directory: ./tool + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + + - name: Set up Dart + uses: dart-lang/setup-dart@v1 + + - name: pub get on fixtures + run: (cd ./generation_test/fixtures && dart pub get) + + - name: Build + run: go build -v ./... + + - name: Test + run: go test -v ./... + test-generated: + runs-on: ubuntu-latest + defaults: + run: + working-directory: ./packages/genq_test + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + - name: Set up Dart + uses: dart-lang/setup-dart@v1 + - name: pub get + run: dart pub get + - name: run_tests.sh + run: ./run_tests.sh diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml new file mode 100644 index 0000000..ae8d2bc --- /dev/null +++ b/.github/workflows/tag.yml @@ -0,0 +1,42 @@ +# .github/workflows/release.yml +name: goreleaser + +on: + pull_request: + push: + # run only against tags + tags: + - "*" + +permissions: + contents: write + # packages: write + # issues: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + # More assembly might be required: Docker logins, GPG, etc. + # It all depends on your needs. + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + # either 'goreleaser' (default) or 'goreleaser-pro' + distribution: goreleaser + version: latest + args: release --clean + workdir: ./tool + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_BREW: ${{ secrets.GH_BREW }} + # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution + # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..27aaed7 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Jan Kuß (jan@kuss.dev) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c1f37a8 --- /dev/null +++ b/README.md @@ -0,0 +1,80 @@ +# genq: Blazing Fast Data Class Generation for Dart + +![](./docs/preview.gif) + +**Tired of waiting for build_runner to churn through your codebase?** + +genq cuts through the wait and generates data classes for your Dart projects in seconds, not minutes. ⚡️ + +Inspired by **freezed**, genq offers a familiar syntax for defining data classes, but with a focus on **lightning-fast performance**. No need to write copyWith, toString, or equals methods by hand - genq does it all for you. + +**Here's what genq brings to the table:** + +* **Reduce Boilerplate:** genq generates the boilerplate code for you, so you can focus on what matters: + * **copyWith:** Create copies of your data classes with modified fields. + * **toString:** Generate human-readable string representations of your data classes. + * **==**: Compare data classes for equality. +* **Speed Demon:** Generate data classes in a flash, even for large projects. +* **Simple and Familiar:** Syntax similar to freezed, making it easy to learn and use. + +## `genq` vs `build_runner` + `freezed` + +`build_runner` + `freezed` 🐌 | `genq` 🚀 +:-------------------------:|:-------------------------: +![build_runner](./docs/freezed.png) | ![genq](./docs/genq.png) + +In this benchmark (located in `./benchmarks`), _count_ is the number of files in the benchmark, containing 250 annotated classes each. So for example, _count=1_ means 250 classes, _count=2_ means 500 classes, and so on. For count 10, `build_runner` and `freezed` took around 46 seconds, while `genq` took 0.11 seconds. **This is a >400x speedup!** + +#### Notes + +1. Never trust a benchmark you didn't falsify yourself. +2. genq is optimized to perform one task and one task only - data class generation, whereas build_runner is built to do a lot more. Take this into account when choosing between the two. + +## Getting started is easy + +### 1. Install + +Install genq via brew using the following command: + +``` +brew install jankuss/genq/genq +``` + +Or download the latest release from the [releases page](https://github.com/jankuss/genq/releases). + +### 2. Add `genq` to your project + +``` +dependencies: + # ... Other dependencies ... + genq: ^0.2.0 +``` + +### 3. Define your data classes + +```dart +import 'package:genq/genq.dart'; + +part 'user.genq.dart'; + +@genq +class User with _$User { + factory User({ + required String name, + required int age, + }) = _User; +} +``` + +### 4. Generate the code + +Run the genq command in your project directory, and you will have your desired data classes generated in no time: + +``` +genq +``` + +## Future Plans + +- [ ] JSON Serialization/Deserialization +- [ ] Extensibility diff --git a/benchmarks/freezed_benchmark/.gitignore b/benchmarks/freezed_benchmark/.gitignore new file mode 100644 index 0000000..b10ad2d --- /dev/null +++ b/benchmarks/freezed_benchmark/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release + +/lib/gen diff --git a/benchmarks/freezed_benchmark/.metadata b/benchmarks/freezed_benchmark/.metadata new file mode 100644 index 0000000..b9d51b4 --- /dev/null +++ b/benchmarks/freezed_benchmark/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "2e9cb0aa71a386a91f73f7088d115c0d96654829" + channel: "[user-branch]" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: android + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: ios + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: linux + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: macos + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: web + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: windows + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/benchmarks/freezed_benchmark/README.md b/benchmarks/freezed_benchmark/README.md new file mode 100644 index 0000000..54960c0 --- /dev/null +++ b/benchmarks/freezed_benchmark/README.md @@ -0,0 +1,16 @@ +# freezed_benchmark + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/benchmarks/freezed_benchmark/analysis_options.yaml b/benchmarks/freezed_benchmark/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/benchmarks/freezed_benchmark/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/benchmarks/freezed_benchmark/android/.gitignore b/benchmarks/freezed_benchmark/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/benchmarks/freezed_benchmark/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/benchmarks/freezed_benchmark/android/app/build.gradle b/benchmarks/freezed_benchmark/android/app/build.gradle new file mode 100644 index 0000000..d8f8a75 --- /dev/null +++ b/benchmarks/freezed_benchmark/android/app/build.gradle @@ -0,0 +1,67 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +android { + namespace "com.example.freezed_benchmark" + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.freezed_benchmark" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies {} diff --git a/benchmarks/freezed_benchmark/android/app/src/debug/AndroidManifest.xml b/benchmarks/freezed_benchmark/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/benchmarks/freezed_benchmark/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/benchmarks/freezed_benchmark/android/app/src/main/AndroidManifest.xml b/benchmarks/freezed_benchmark/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..480ae73 --- /dev/null +++ b/benchmarks/freezed_benchmark/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/benchmarks/freezed_benchmark/android/app/src/main/kotlin/com/example/freezed_benchmark/MainActivity.kt b/benchmarks/freezed_benchmark/android/app/src/main/kotlin/com/example/freezed_benchmark/MainActivity.kt new file mode 100644 index 0000000..fc779d6 --- /dev/null +++ b/benchmarks/freezed_benchmark/android/app/src/main/kotlin/com/example/freezed_benchmark/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.freezed_benchmark + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/benchmarks/freezed_benchmark/android/app/src/main/res/drawable-v21/launch_background.xml b/benchmarks/freezed_benchmark/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/benchmarks/freezed_benchmark/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/benchmarks/freezed_benchmark/android/app/src/main/res/drawable/launch_background.xml b/benchmarks/freezed_benchmark/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/benchmarks/freezed_benchmark/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/benchmarks/freezed_benchmark/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/benchmarks/freezed_benchmark/android/app/src/main/res/values-night/styles.xml b/benchmarks/freezed_benchmark/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/benchmarks/freezed_benchmark/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/benchmarks/freezed_benchmark/android/app/src/main/res/values/styles.xml b/benchmarks/freezed_benchmark/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/benchmarks/freezed_benchmark/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/benchmarks/freezed_benchmark/android/app/src/profile/AndroidManifest.xml b/benchmarks/freezed_benchmark/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/benchmarks/freezed_benchmark/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/benchmarks/freezed_benchmark/android/build.gradle b/benchmarks/freezed_benchmark/android/build.gradle new file mode 100644 index 0000000..e83fb5d --- /dev/null +++ b/benchmarks/freezed_benchmark/android/build.gradle @@ -0,0 +1,30 @@ +buildscript { + ext.kotlin_version = '1.7.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/benchmarks/freezed_benchmark/android/gradle.properties b/benchmarks/freezed_benchmark/android/gradle.properties new file mode 100644 index 0000000..598d13f --- /dev/null +++ b/benchmarks/freezed_benchmark/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G +android.useAndroidX=true +android.enableJetifier=true diff --git a/benchmarks/freezed_benchmark/android/gradle/wrapper/gradle-wrapper.properties b/benchmarks/freezed_benchmark/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..3c472b9 --- /dev/null +++ b/benchmarks/freezed_benchmark/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/benchmarks/freezed_benchmark/android/settings.gradle b/benchmarks/freezed_benchmark/android/settings.gradle new file mode 100644 index 0000000..7cd7128 --- /dev/null +++ b/benchmarks/freezed_benchmark/android/settings.gradle @@ -0,0 +1,29 @@ +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() + + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } + + plugins { + id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false + } +} + +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.3.0" apply false +} + +include ":app" diff --git a/benchmarks/freezed_benchmark/benchmark.json b/benchmarks/freezed_benchmark/benchmark.json new file mode 100644 index 0000000..fb0e04b --- /dev/null +++ b/benchmarks/freezed_benchmark/benchmark.json @@ -0,0 +1,374 @@ +{ + "results": [ + { + "command": "dart run build_runner build --delete-conflicting-outputs", + "mean": 13.466712072640002, + "stddev": 0.07533562356721335, + "median": 13.44997186874, + "user": 17.75577304, + "system": 1.2171556599999998, + "min": 13.31360501424, + "max": 13.58089251424, + "times": [ + 13.44595243124, + 13.43711959724, + 13.31360501424, + 13.45399130624, + 13.43571884824, + 13.429401139240001, + 13.58089251424, + 13.50766780624, + 13.55057151424, + 13.51220055524 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "1" + } + }, + { + "command": "dart run build_runner build --delete-conflicting-outputs", + "mean": 16.91851082284, + "stddev": 0.15656484615528934, + "median": 16.88339555624, + "user": 21.36873834, + "system": 1.2705215600000002, + "min": 16.69191672324, + "max": 17.17582805624, + "times": [ + 16.69191672324, + 16.89269955624, + 16.91190459824, + 16.87409155624, + 16.76770876424, + 16.841633848239997, + 17.15819713924, + 16.85282797224, + 17.17582805624, + 17.018300014239998 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "2" + } + }, + { + "command": "dart run build_runner build --delete-conflicting-outputs", + "mean": 20.13587821434, + "stddev": 0.31494592016240275, + "median": 20.08845299374, + "user": 24.76272944, + "system": 1.3328638599999998, + "min": 19.73404822324, + "max": 20.91741230624, + "times": [ + 20.21031101424, + 20.13896538924, + 20.13196751424, + 20.04493847324, + 19.95515947224, + 20.26797118024, + 20.91741230624, + 20.03939359724, + 19.73404822324, + 19.91861497324 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "3" + } + }, + { + "command": "dart run build_runner build --delete-conflicting-outputs", + "mean": 23.23937497674, + "stddev": 0.2754035449410435, + "median": 23.15877703524, + "user": 27.932229739999997, + "system": 1.34757216, + "min": 22.85699626424, + "max": 23.757246722239998, + "times": [ + 23.06114318024, + 23.461605889239998, + 23.16999963924, + 23.14755443124, + 22.85699626424, + 23.29713909724, + 23.00150888924, + 23.544793723239998, + 23.09576193124, + 23.757246722239998 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "4" + } + }, + { + "command": "dart run build_runner build --delete-conflicting-outputs", + "mean": 29.88569079344, + "stddev": 0.40253476248791403, + "median": 29.79425026424, + "user": 39.525549639999994, + "system": 1.8441521599999997, + "min": 29.31179138924, + "max": 30.65443513924, + "times": [ + 30.394912597239998, + 29.77911493124, + 30.065608556239997, + 29.55179218124, + 29.983392597239998, + 29.65019138924, + 29.31179138924, + 29.80938559724, + 29.65628355624, + 30.65443513924 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "5" + } + }, + { + "command": "dart run build_runner build --delete-conflicting-outputs", + "mean": 33.485602976840006, + "stddev": 0.3500045912196784, + "median": 33.428476951739995, + "user": 43.21705863999999, + "system": 1.8941316599999998, + "min": 33.115750181239996, + "max": 34.10214943124, + "times": [ + 33.115750181239996, + 33.208616681239995, + 34.10214943124, + 33.56048905624, + 33.344264264239996, + 33.60017334724, + 34.02525176424, + 33.51268963924, + 33.13263518124, + 33.25401022224 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "6" + } + }, + { + "command": "dart run build_runner build --delete-conflicting-outputs", + "mean": 33.385826564240006, + "stddev": 0.5877620825344835, + "median": 33.249880764240004, + "user": 38.30508714, + "system": 1.4664690599999997, + "min": 32.852325806239996, + "max": 34.591414847239996, + "times": [ + 32.87216455624, + 32.852325806239996, + 34.03517780624, + 34.591414847239996, + 32.93168701424, + 33.51601268124, + 32.98374884724, + 32.91278380524, + 33.59601305624, + 33.56693722224 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "7" + } + }, + { + "command": "dart run build_runner build --delete-conflicting-outputs", + "mean": 39.858939955939995, + "stddev": 0.38602406947978257, + "median": 39.93389582674, + "user": 49.52548994, + "system": 1.9571441599999997, + "min": 39.137080889239996, + "max": 40.49318555624, + "times": [ + 39.50915768024, + 39.57262180624, + 39.96715276424, + 39.98431805624, + 39.96207184824, + 39.788908681239995, + 40.49318555624, + 40.26918247224, + 39.90571980524, + 39.137080889239996 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "8" + } + }, + { + "command": "dart run build_runner build --delete-conflicting-outputs", + "mean": 40.36258447674, + "stddev": 0.5695063503454199, + "median": 40.46256672274, + "user": 45.27924664, + "system": 1.5897926599999999, + "min": 39.472020847239996, + "max": 41.07617597324, + "times": [ + 39.472020847239996, + 41.07617597324, + 39.54736434724, + 40.38690093124, + 40.40659959824, + 39.83701926424, + 40.51853384724, + 40.84814963924, + 40.55805088924, + 40.97502943024 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "9" + } + }, + { + "command": "dart run build_runner build --delete-conflicting-outputs", + "mean": 46.75611488524, + "stddev": 0.4042753831127133, + "median": 46.75157966024, + "user": 56.56699754, + "system": 2.04468526, + "min": 46.10362413924, + "max": 47.36505568124, + "times": [ + 46.58774297224, + 47.10041605624, + 46.30095659824, + 47.151032931239996, + 46.86472213924, + 46.46310393124, + 47.36505568124, + 46.63843718124, + 46.10362413924, + 46.98605722224 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "10" + } + } + ] +} diff --git a/benchmarks/freezed_benchmark/benchmark.sh b/benchmarks/freezed_benchmark/benchmark.sh new file mode 100755 index 0000000..77c3bb3 --- /dev/null +++ b/benchmarks/freezed_benchmark/benchmark.sh @@ -0,0 +1 @@ +hyperfine --parameter-step-size 1 --parameter-scan count 1 10 --prepare './reset.sh && dart ./bin/gen.dart {count}' 'dart run build_runner build --delete-conflicting-outputs' --export-json ./benchmark.json diff --git a/benchmarks/freezed_benchmark/bin/gen.dart b/benchmarks/freezed_benchmark/bin/gen.dart new file mode 100644 index 0000000..5d815ad --- /dev/null +++ b/benchmarks/freezed_benchmark/bin/gen.dart @@ -0,0 +1,24 @@ +import 'dart:io'; + +void main(List args) { + for (var i = 0; i < int.parse(args[0]); i++) { + final file = File('./lib/gen/gen$i.bench.dart'); + var str = 'import "package:freezed_annotation/freezed_annotation.dart";\n\n'; + str += "part 'gen$i.bench.freezed.dart';\n\n"; + + for (var j = 0; j < 250; j++) { + str += ''' +@freezed +class User$j with _\$User$j { + factory User$j({ + required String name, + required int? age, + required bool registered, + required void Function() test, + }) = _User$j; +}\n\n'''; + + file.writeAsStringSync(str); + } + } +} diff --git a/benchmarks/freezed_benchmark/build.yaml b/benchmarks/freezed_benchmark/build.yaml new file mode 100644 index 0000000..e0c2e2d --- /dev/null +++ b/benchmarks/freezed_benchmark/build.yaml @@ -0,0 +1,9 @@ +targets: + $default: + builders: + # Typically the builder key is just the package name, run + # `dart run build_runner doctor` to check your config. + freezed: + generate_for: + # Example glob for only the Dart files under `lib/models` + - lib/gen/*.bench.dart diff --git a/benchmarks/freezed_benchmark/ios/.gitignore b/benchmarks/freezed_benchmark/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/benchmarks/freezed_benchmark/ios/Flutter/AppFrameworkInfo.plist b/benchmarks/freezed_benchmark/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..9625e10 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 11.0 + + diff --git a/benchmarks/freezed_benchmark/ios/Flutter/Debug.xcconfig b/benchmarks/freezed_benchmark/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/benchmarks/freezed_benchmark/ios/Flutter/Release.xcconfig b/benchmarks/freezed_benchmark/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.pbxproj b/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..ea24c35 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,617 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807E294A63A400263BE5 /* Frameworks */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1430; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = Z4963WA9BJ; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.freezedBenchmark; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = AE0B7B92F70575B8D7E0D07E /* Pods-RunnerTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.freezedBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 89B67EB44CE7B6631473024E /* Pods-RunnerTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.freezedBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 640959BDD8F10B91D80A66BE /* Pods-RunnerTests.profile.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.freezedBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = Z4963WA9BJ; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.freezedBenchmark; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = Z4963WA9BJ; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.freezedBenchmark; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..87131a0 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/freezed_benchmark/ios/Runner.xcworkspace/contents.xcworkspacedata b/benchmarks/freezed_benchmark/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/benchmarks/freezed_benchmark/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/benchmarks/freezed_benchmark/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/benchmarks/freezed_benchmark/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/benchmarks/freezed_benchmark/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/benchmarks/freezed_benchmark/ios/Runner/AppDelegate.swift b/benchmarks/freezed_benchmark/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..70693e4 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..dc9ada4 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..7353c41 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..797d452 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..6ed2d93 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..4cd7b00 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..fe73094 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..321773c Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..797d452 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..502f463 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..0ec3034 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..0ec3034 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..e9f5fea Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..84ac32a Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..8953cba Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..0467bf1 Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/benchmarks/freezed_benchmark/ios/Runner/Base.lproj/LaunchScreen.storyboard b/benchmarks/freezed_benchmark/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/freezed_benchmark/ios/Runner/Base.lproj/Main.storyboard b/benchmarks/freezed_benchmark/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/freezed_benchmark/ios/Runner/Info.plist b/benchmarks/freezed_benchmark/ios/Runner/Info.plist new file mode 100644 index 0000000..b877f43 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Freezed Benchmark + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + freezed_benchmark + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/benchmarks/freezed_benchmark/ios/Runner/Runner-Bridging-Header.h b/benchmarks/freezed_benchmark/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/benchmarks/freezed_benchmark/ios/RunnerTests/RunnerTests.swift b/benchmarks/freezed_benchmark/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..86a7c3b --- /dev/null +++ b/benchmarks/freezed_benchmark/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/benchmarks/freezed_benchmark/lib/main.dart b/benchmarks/freezed_benchmark/lib/main.dart new file mode 100644 index 0000000..8e94089 --- /dev/null +++ b/benchmarks/freezed_benchmark/lib/main.dart @@ -0,0 +1,125 @@ +import 'package:flutter/material.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + // This is the theme of your application. + // + // TRY THIS: Try running your application with "flutter run". You'll see + // the application has a purple toolbar. Then, without quitting the app, + // try changing the seedColor in the colorScheme below to Colors.green + // and then invoke "hot reload" (save your changes or press the "hot + // reload" button in a Flutter-supported IDE, or press "r" if you used + // the command line to start the app). + // + // Notice that the counter didn't reset back to zero; the application + // state is not lost during the reload. To reset the state, use hot + // restart instead. + // + // This works for code too, not just values: Most code changes can be + // tested with just a hot reload. + colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + useMaterial3: true, + ), + home: const MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title}); + + // This widget is the home page of your application. It is stateful, meaning + // that it has a State object (defined below) that contains fields that affect + // how it looks. + + // This class is the configuration for the state. It holds the values (in this + // case the title) provided by the parent (in this case the App widget) and + // used by the build method of the State. Fields in a Widget subclass are + // always marked "final". + + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + int _counter = 0; + + void _incrementCounter() { + setState(() { + // This call to setState tells the Flutter framework that something has + // changed in this State, which causes it to rerun the build method below + // so that the display can reflect the updated values. If we changed + // _counter without calling setState(), then the build method would not be + // called again, and so nothing would appear to happen. + _counter++; + }); + } + + @override + Widget build(BuildContext context) { + // This method is rerun every time setState is called, for instance as done + // by the _incrementCounter method above. + // + // The Flutter framework has been optimized to make rerunning build methods + // fast, so that you can just rebuild anything that needs updating rather + // than having to individually change instances of widgets. + return Scaffold( + appBar: AppBar( + // TRY THIS: Try changing the color here to a specific color (to + // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar + // change color while the other colors stay the same. + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + // Here we take the value from the MyHomePage object that was created by + // the App.build method, and use it to set our appbar title. + title: Text(widget.title), + ), + body: Center( + // Center is a layout widget. It takes a single child and positions it + // in the middle of the parent. + child: Column( + // Column is also a layout widget. It takes a list of children and + // arranges them vertically. By default, it sizes itself to fit its + // children horizontally, and tries to be as tall as its parent. + // + // Column has various properties to control how it sizes itself and + // how it positions its children. Here we use mainAxisAlignment to + // center the children vertically; the main axis here is the vertical + // axis because Columns are vertical (the cross axis would be + // horizontal). + // + // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" + // action in the IDE, or press "p" in the console), to see the + // wireframe for each widget. + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + Text( + '$_counter', + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), // This trailing comma makes auto-formatting nicer for build methods. + ); + } +} diff --git a/benchmarks/freezed_benchmark/linux/.gitignore b/benchmarks/freezed_benchmark/linux/.gitignore new file mode 100644 index 0000000..d3896c9 --- /dev/null +++ b/benchmarks/freezed_benchmark/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/benchmarks/freezed_benchmark/linux/CMakeLists.txt b/benchmarks/freezed_benchmark/linux/CMakeLists.txt new file mode 100644 index 0000000..fb53e1f --- /dev/null +++ b/benchmarks/freezed_benchmark/linux/CMakeLists.txt @@ -0,0 +1,145 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner 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 "freezed_benchmark") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.freezed_benchmark") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# 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) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +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") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/benchmarks/freezed_benchmark/linux/flutter/CMakeLists.txt b/benchmarks/freezed_benchmark/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000..d5bd016 --- /dev/null +++ b/benchmarks/freezed_benchmark/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/benchmarks/freezed_benchmark/linux/flutter/generated_plugin_registrant.cc b/benchmarks/freezed_benchmark/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..e71a16d --- /dev/null +++ b/benchmarks/freezed_benchmark/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/benchmarks/freezed_benchmark/linux/flutter/generated_plugin_registrant.h b/benchmarks/freezed_benchmark/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..e0f0a47 --- /dev/null +++ b/benchmarks/freezed_benchmark/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/benchmarks/freezed_benchmark/linux/flutter/generated_plugins.cmake b/benchmarks/freezed_benchmark/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000..2e1de87 --- /dev/null +++ b/benchmarks/freezed_benchmark/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/benchmarks/freezed_benchmark/linux/main.cc b/benchmarks/freezed_benchmark/linux/main.cc new file mode 100644 index 0000000..e7c5c54 --- /dev/null +++ b/benchmarks/freezed_benchmark/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/benchmarks/freezed_benchmark/linux/my_application.cc b/benchmarks/freezed_benchmark/linux/my_application.cc new file mode 100644 index 0000000..1331a5a --- /dev/null +++ b/benchmarks/freezed_benchmark/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "freezed_benchmark"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "freezed_benchmark"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/benchmarks/freezed_benchmark/linux/my_application.h b/benchmarks/freezed_benchmark/linux/my_application.h new file mode 100644 index 0000000..72271d5 --- /dev/null +++ b/benchmarks/freezed_benchmark/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/benchmarks/freezed_benchmark/macos/.gitignore b/benchmarks/freezed_benchmark/macos/.gitignore new file mode 100644 index 0000000..746adbb --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/benchmarks/freezed_benchmark/macos/Flutter/Flutter-Debug.xcconfig b/benchmarks/freezed_benchmark/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/benchmarks/freezed_benchmark/macos/Flutter/Flutter-Release.xcconfig b/benchmarks/freezed_benchmark/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/benchmarks/freezed_benchmark/macos/Flutter/GeneratedPluginRegistrant.swift b/benchmarks/freezed_benchmark/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..cccf817 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,10 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { +} diff --git a/benchmarks/freezed_benchmark/macos/Runner.xcodeproj/project.pbxproj b/benchmarks/freezed_benchmark/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..0b74f51 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,695 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* freezed_benchmark.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "freezed_benchmark.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* freezed_benchmark.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* freezed_benchmark.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1430; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.freezedBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/freezed_benchmark.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/freezed_benchmark"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.freezedBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/freezed_benchmark.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/freezed_benchmark"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.freezedBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/freezed_benchmark.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/freezed_benchmark"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/benchmarks/freezed_benchmark/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/benchmarks/freezed_benchmark/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/benchmarks/freezed_benchmark/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/benchmarks/freezed_benchmark/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..a76abda --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/freezed_benchmark/macos/Runner.xcworkspace/contents.xcworkspacedata b/benchmarks/freezed_benchmark/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/benchmarks/freezed_benchmark/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/benchmarks/freezed_benchmark/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/benchmarks/freezed_benchmark/macos/Runner/AppDelegate.swift b/benchmarks/freezed_benchmark/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..d53ef64 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a2ec33f --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000..82b6f9d Binary files /dev/null and b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000..13b35eb Binary files /dev/null and b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000..0a3f5fa Binary files /dev/null and b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000..bdb5722 Binary files /dev/null and b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000..f083318 Binary files /dev/null and b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000..326c0e7 Binary files /dev/null and b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000..2f1632c Binary files /dev/null and b/benchmarks/freezed_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/benchmarks/freezed_benchmark/macos/Runner/Base.lproj/MainMenu.xib b/benchmarks/freezed_benchmark/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..80e867a --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/freezed_benchmark/macos/Runner/Configs/AppInfo.xcconfig b/benchmarks/freezed_benchmark/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000..9e402d4 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = freezed_benchmark + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.freezedBenchmark + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2024 com.example. All rights reserved. diff --git a/benchmarks/freezed_benchmark/macos/Runner/Configs/Debug.xcconfig b/benchmarks/freezed_benchmark/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000..36b0fd9 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/benchmarks/freezed_benchmark/macos/Runner/Configs/Release.xcconfig b/benchmarks/freezed_benchmark/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000..dff4f49 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/benchmarks/freezed_benchmark/macos/Runner/Configs/Warnings.xcconfig b/benchmarks/freezed_benchmark/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000..42bcbf4 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/benchmarks/freezed_benchmark/macos/Runner/DebugProfile.entitlements b/benchmarks/freezed_benchmark/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000..dddb8a3 --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/benchmarks/freezed_benchmark/macos/Runner/Info.plist b/benchmarks/freezed_benchmark/macos/Runner/Info.plist new file mode 100644 index 0000000..4789daa --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/benchmarks/freezed_benchmark/macos/Runner/MainFlutterWindow.swift b/benchmarks/freezed_benchmark/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000..3cc05eb --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/benchmarks/freezed_benchmark/macos/Runner/Release.entitlements b/benchmarks/freezed_benchmark/macos/Runner/Release.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/benchmarks/freezed_benchmark/macos/RunnerTests/RunnerTests.swift b/benchmarks/freezed_benchmark/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..5418c9f --- /dev/null +++ b/benchmarks/freezed_benchmark/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import FlutterMacOS +import Cocoa +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/benchmarks/freezed_benchmark/pubspec.lock b/benchmarks/freezed_benchmark/pubspec.lock new file mode 100644 index 0000000..105907b --- /dev/null +++ b/benchmarks/freezed_benchmark/pubspec.lock @@ -0,0 +1,532 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 + url: "https://pub.dev" + source: hosted + version: "64.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + build: + dependency: transitive + description: + name: build + sha256: "80184af8b6cb3e5c1c4ec6d8544d27711700bc3e6d2efad04238c7b5290889f0" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + build_config: + dependency: transitive + description: + name: build_config + sha256: bf80fcfb46a29945b423bd9aad884590fb1dc69b330a4d4700cac476af1708d1 + url: "https://pub.dev" + source: hosted + version: "1.1.1" + build_daemon: + dependency: transitive + description: + name: build_daemon + sha256: "0343061a33da9c5810b2d6cee51945127d8f4c060b7fbdd9d54917f0a3feaaa1" + url: "https://pub.dev" + source: hosted + version: "4.0.1" + build_resolvers: + dependency: transitive + description: + name: build_resolvers + sha256: "339086358431fa15d7eca8b6a36e5d783728cf025e559b834f4609a1fcfb7b0a" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + build_runner: + dependency: "direct dev" + description: + name: build_runner + sha256: "581bacf68f89ec8792f5e5a0b2c4decd1c948e97ce659dc783688c8a88fbec21" + url: "https://pub.dev" + source: hosted + version: "2.4.8" + build_runner_core: + dependency: transitive + description: + name: build_runner_core + sha256: "4ae8ffe5ac758da294ecf1802f2aff01558d8b1b00616aa7538ea9a8a5d50799" + url: "https://pub.dev" + source: hosted + version: "7.3.0" + built_collection: + dependency: transitive + description: + name: built_collection + sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" + url: "https://pub.dev" + source: hosted + version: "5.1.1" + built_value: + dependency: transitive + description: + name: built_value + sha256: fedde275e0a6b798c3296963c5cd224e3e1b55d0e478d5b7e65e6b540f363a0e + url: "https://pub.dev" + source: hosted + version: "8.9.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + code_builder: + dependency: transitive + description: + name: code_builder + sha256: f692079e25e7869c14132d39f223f8eec9830eb76131925143b2129c4bb01b37 + url: "https://pub.dev" + source: hosted + version: "4.10.0" + collection: + dependency: transitive + description: + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" + source: hosted + version: "1.0.6" + dart_style: + dependency: transitive + description: + name: dart_style + sha256: "99e066ce75c89d6b29903d788a7bb9369cf754f7b24bf70bf4b6d6d6b26853b9" + url: "https://pub.dev" + source: hosted + version: "2.3.6" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + freezed: + dependency: "direct dev" + description: + name: freezed + sha256: "57247f692f35f068cae297549a46a9a097100685c6780fe67177503eea5ed4e5" + url: "https://pub.dev" + source: hosted + version: "2.4.7" + freezed_annotation: + dependency: "direct main" + description: + name: freezed_annotation + sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d + url: "https://pub.dev" + source: hosted + version: "2.4.1" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + graphs: + dependency: transitive + description: + name: graphs + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" + source: hosted + version: "2.3.1" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + js: + dependency: transitive + description: + name: js + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + url: "https://pub.dev" + source: hosted + version: "0.7.1" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" + lints: + dependency: transitive + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" + source: hosted + version: "0.5.0" + meta: + dependency: transitive + description: + name: meta + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" + source: hosted + version: "1.10.0" + mime: + dependency: transitive + description: + name: mime + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + url: "https://pub.dev" + source: hosted + version: "1.0.5" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + pubspec_parse: + dependency: transitive + description: + name: pubspec_parse + sha256: c63b2876e58e194e4b0828fcb080ad0e06d051cb607a6be51a9e084f47cb9367 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_gen: + dependency: transitive + description: + name: source_gen + sha256: "14658ba5f669685cd3d63701d01b31ea748310f7ab854e471962670abcf57832" + url: "https://pub.dev" + source: hosted + version: "1.5.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" + source: hosted + version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" + source: hosted + version: "0.6.1" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" +sdks: + dart: ">=3.2.3 <4.0.0" diff --git a/benchmarks/freezed_benchmark/pubspec.yaml b/benchmarks/freezed_benchmark/pubspec.yaml new file mode 100644 index 0000000..8a30fae --- /dev/null +++ b/benchmarks/freezed_benchmark/pubspec.yaml @@ -0,0 +1,93 @@ +name: freezed_benchmark +description: "A new Flutter project." +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.0+1 + +environment: + sdk: '>=3.2.3 <4.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + freezed_annotation: ^2.4.1 + + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + freezed: ^2.4.7 + build_runner: ^2.4.8 + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/benchmarks/freezed_benchmark/reset.sh b/benchmarks/freezed_benchmark/reset.sh new file mode 100755 index 0000000..a500c6c --- /dev/null +++ b/benchmarks/freezed_benchmark/reset.sh @@ -0,0 +1,3 @@ +flutter clean +rm -rf ./lib/gen +mkdir -p ./lib/gen diff --git a/benchmarks/freezed_benchmark/test/widget_test.dart b/benchmarks/freezed_benchmark/test/widget_test.dart new file mode 100644 index 0000000..9cbb2dc --- /dev/null +++ b/benchmarks/freezed_benchmark/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:freezed_benchmark/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/benchmarks/freezed_benchmark/web/favicon.png b/benchmarks/freezed_benchmark/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/benchmarks/freezed_benchmark/web/favicon.png differ diff --git a/benchmarks/freezed_benchmark/web/icons/Icon-192.png b/benchmarks/freezed_benchmark/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/benchmarks/freezed_benchmark/web/icons/Icon-192.png differ diff --git a/benchmarks/freezed_benchmark/web/icons/Icon-512.png b/benchmarks/freezed_benchmark/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/benchmarks/freezed_benchmark/web/icons/Icon-512.png differ diff --git a/benchmarks/freezed_benchmark/web/icons/Icon-maskable-192.png b/benchmarks/freezed_benchmark/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/benchmarks/freezed_benchmark/web/icons/Icon-maskable-192.png differ diff --git a/benchmarks/freezed_benchmark/web/icons/Icon-maskable-512.png b/benchmarks/freezed_benchmark/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/benchmarks/freezed_benchmark/web/icons/Icon-maskable-512.png differ diff --git a/benchmarks/freezed_benchmark/web/index.html b/benchmarks/freezed_benchmark/web/index.html new file mode 100644 index 0000000..41c75d6 --- /dev/null +++ b/benchmarks/freezed_benchmark/web/index.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + freezed_benchmark + + + + + + + + + + diff --git a/benchmarks/freezed_benchmark/web/manifest.json b/benchmarks/freezed_benchmark/web/manifest.json new file mode 100644 index 0000000..4bd98c5 --- /dev/null +++ b/benchmarks/freezed_benchmark/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "freezed_benchmark", + "short_name": "freezed_benchmark", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/benchmarks/freezed_benchmark/windows/.gitignore b/benchmarks/freezed_benchmark/windows/.gitignore new file mode 100644 index 0000000..d492d0d --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/benchmarks/freezed_benchmark/windows/CMakeLists.txt b/benchmarks/freezed_benchmark/windows/CMakeLists.txt new file mode 100644 index 0000000..67901da --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(freezed_benchmark 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 "freezed_benchmark") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_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_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# 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) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +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) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + 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") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/benchmarks/freezed_benchmark/windows/flutter/CMakeLists.txt b/benchmarks/freezed_benchmark/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000..903f489 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# 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") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/benchmarks/freezed_benchmark/windows/flutter/generated_plugin_registrant.cc b/benchmarks/freezed_benchmark/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..8b6d468 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/benchmarks/freezed_benchmark/windows/flutter/generated_plugin_registrant.h b/benchmarks/freezed_benchmark/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/benchmarks/freezed_benchmark/windows/flutter/generated_plugins.cmake b/benchmarks/freezed_benchmark/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..b93c4c3 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/benchmarks/freezed_benchmark/windows/runner/CMakeLists.txt b/benchmarks/freezed_benchmark/windows/runner/CMakeLists.txt new file mode 100644 index 0000000..394917c --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +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) diff --git a/benchmarks/freezed_benchmark/windows/runner/Runner.rc b/benchmarks/freezed_benchmark/windows/runner/Runner.rc new file mode 100644 index 0000000..ea648a9 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "freezed_benchmark" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "freezed_benchmark" "\0" + VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "freezed_benchmark.exe" "\0" + VALUE "ProductName", "freezed_benchmark" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/benchmarks/freezed_benchmark/windows/runner/flutter_window.cpp b/benchmarks/freezed_benchmark/windows/runner/flutter_window.cpp new file mode 100644 index 0000000..955ee30 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/benchmarks/freezed_benchmark/windows/runner/flutter_window.h b/benchmarks/freezed_benchmark/windows/runner/flutter_window.h new file mode 100644 index 0000000..6da0652 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/benchmarks/freezed_benchmark/windows/runner/main.cpp b/benchmarks/freezed_benchmark/windows/runner/main.cpp new file mode 100644 index 0000000..cc49cfc --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"freezed_benchmark", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/benchmarks/freezed_benchmark/windows/runner/resource.h b/benchmarks/freezed_benchmark/windows/runner/resource.h new file mode 100644 index 0000000..66a65d1 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/benchmarks/freezed_benchmark/windows/runner/resources/app_icon.ico b/benchmarks/freezed_benchmark/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000..c04e20c Binary files /dev/null and b/benchmarks/freezed_benchmark/windows/runner/resources/app_icon.ico differ diff --git a/benchmarks/freezed_benchmark/windows/runner/runner.exe.manifest b/benchmarks/freezed_benchmark/windows/runner/runner.exe.manifest new file mode 100644 index 0000000..a42ea76 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/benchmarks/freezed_benchmark/windows/runner/utils.cpp b/benchmarks/freezed_benchmark/windows/runner/utils.cpp new file mode 100644 index 0000000..b2b0873 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -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()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/benchmarks/freezed_benchmark/windows/runner/utils.h b/benchmarks/freezed_benchmark/windows/runner/utils.h new file mode 100644 index 0000000..3879d54 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/benchmarks/freezed_benchmark/windows/runner/win32_window.cpp b/benchmarks/freezed_benchmark/windows/runner/win32_window.cpp new file mode 100644 index 0000000..60608d0 --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/benchmarks/freezed_benchmark/windows/runner/win32_window.h b/benchmarks/freezed_benchmark/windows/runner/win32_window.h new file mode 100644 index 0000000..e901dde --- /dev/null +++ b/benchmarks/freezed_benchmark/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // 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 + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/benchmarks/genq_benchmark/.gitignore b/benchmarks/genq_benchmark/.gitignore new file mode 100644 index 0000000..b10ad2d --- /dev/null +++ b/benchmarks/genq_benchmark/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release + +/lib/gen diff --git a/benchmarks/genq_benchmark/.metadata b/benchmarks/genq_benchmark/.metadata new file mode 100644 index 0000000..b9d51b4 --- /dev/null +++ b/benchmarks/genq_benchmark/.metadata @@ -0,0 +1,45 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "2e9cb0aa71a386a91f73f7088d115c0d96654829" + channel: "[user-branch]" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: android + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: ios + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: linux + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: macos + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: web + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + - platform: windows + create_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + base_revision: 2e9cb0aa71a386a91f73f7088d115c0d96654829 + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/benchmarks/genq_benchmark/README.md b/benchmarks/genq_benchmark/README.md new file mode 100644 index 0000000..1282da3 --- /dev/null +++ b/benchmarks/genq_benchmark/README.md @@ -0,0 +1,16 @@ +# genq_benchmark + +A new Flutter project. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) + +For help getting started with Flutter development, view the +[online documentation](https://docs.flutter.dev/), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/benchmarks/genq_benchmark/analysis_options.yaml b/benchmarks/genq_benchmark/analysis_options.yaml new file mode 100644 index 0000000..0d29021 --- /dev/null +++ b/benchmarks/genq_benchmark/analysis_options.yaml @@ -0,0 +1,28 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at https://dart.dev/lints. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/benchmarks/genq_benchmark/android/.gitignore b/benchmarks/genq_benchmark/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/benchmarks/genq_benchmark/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/benchmarks/genq_benchmark/android/app/build.gradle b/benchmarks/genq_benchmark/android/app/build.gradle new file mode 100644 index 0000000..92f0916 --- /dev/null +++ b/benchmarks/genq_benchmark/android/app/build.gradle @@ -0,0 +1,67 @@ +plugins { + id "com.android.application" + id "kotlin-android" + id "dev.flutter.flutter-gradle-plugin" +} + +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +android { + namespace "com.example.genq_benchmark" + compileSdkVersion flutter.compileSdkVersion + ndkVersion flutter.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.example.genq_benchmark" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdkVersion flutter.minSdkVersion + targetSdkVersion flutter.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies {} diff --git a/benchmarks/genq_benchmark/android/app/src/debug/AndroidManifest.xml b/benchmarks/genq_benchmark/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/benchmarks/genq_benchmark/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/benchmarks/genq_benchmark/android/app/src/main/AndroidManifest.xml b/benchmarks/genq_benchmark/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..cd278a2 --- /dev/null +++ b/benchmarks/genq_benchmark/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff --git a/benchmarks/genq_benchmark/android/app/src/main/kotlin/com/example/genq_benchmark/MainActivity.kt b/benchmarks/genq_benchmark/android/app/src/main/kotlin/com/example/genq_benchmark/MainActivity.kt new file mode 100644 index 0000000..c5a686d --- /dev/null +++ b/benchmarks/genq_benchmark/android/app/src/main/kotlin/com/example/genq_benchmark/MainActivity.kt @@ -0,0 +1,6 @@ +package com.example.genq_benchmark + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/benchmarks/genq_benchmark/android/app/src/main/res/drawable-v21/launch_background.xml b/benchmarks/genq_benchmark/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/benchmarks/genq_benchmark/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/benchmarks/genq_benchmark/android/app/src/main/res/drawable/launch_background.xml b/benchmarks/genq_benchmark/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/benchmarks/genq_benchmark/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..db77bb4 Binary files /dev/null and b/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..17987b7 Binary files /dev/null and b/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..09d4391 Binary files /dev/null and b/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..d5f1c8d Binary files /dev/null and b/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..4d6372e Binary files /dev/null and b/benchmarks/genq_benchmark/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/benchmarks/genq_benchmark/android/app/src/main/res/values-night/styles.xml b/benchmarks/genq_benchmark/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/benchmarks/genq_benchmark/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/benchmarks/genq_benchmark/android/app/src/main/res/values/styles.xml b/benchmarks/genq_benchmark/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..cb1ef88 --- /dev/null +++ b/benchmarks/genq_benchmark/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/benchmarks/genq_benchmark/android/app/src/profile/AndroidManifest.xml b/benchmarks/genq_benchmark/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/benchmarks/genq_benchmark/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/benchmarks/genq_benchmark/android/build.gradle b/benchmarks/genq_benchmark/android/build.gradle new file mode 100644 index 0000000..e83fb5d --- /dev/null +++ b/benchmarks/genq_benchmark/android/build.gradle @@ -0,0 +1,30 @@ +buildscript { + ext.kotlin_version = '1.7.10' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" +} +subprojects { + project.evaluationDependsOn(':app') +} + +tasks.register("clean", Delete) { + delete rootProject.buildDir +} diff --git a/benchmarks/genq_benchmark/android/gradle.properties b/benchmarks/genq_benchmark/android/gradle.properties new file mode 100644 index 0000000..598d13f --- /dev/null +++ b/benchmarks/genq_benchmark/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx4G +android.useAndroidX=true +android.enableJetifier=true diff --git a/benchmarks/genq_benchmark/android/gradle/wrapper/gradle-wrapper.properties b/benchmarks/genq_benchmark/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..3c472b9 --- /dev/null +++ b/benchmarks/genq_benchmark/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip diff --git a/benchmarks/genq_benchmark/android/settings.gradle b/benchmarks/genq_benchmark/android/settings.gradle new file mode 100644 index 0000000..7cd7128 --- /dev/null +++ b/benchmarks/genq_benchmark/android/settings.gradle @@ -0,0 +1,29 @@ +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() + + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") + + repositories { + google() + mavenCentral() + gradlePluginPortal() + } + + plugins { + id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false + } +} + +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.3.0" apply false +} + +include ":app" diff --git a/benchmarks/genq_benchmark/benchmark.json b/benchmarks/genq_benchmark/benchmark.json new file mode 100644 index 0000000..2da1a6a --- /dev/null +++ b/benchmarks/genq_benchmark/benchmark.json @@ -0,0 +1,374 @@ +{ + "results": [ + { + "command": "../../tool/genq --input ./lib", + "mean": 0.048321881559999995, + "stddev": 0.024259211810205496, + "median": 0.040184197660000004, + "user": 0.038521759999999995, + "system": 0.0027921, + "min": 0.03988201116, + "max": 0.11731663616, + "times": [ + 0.11731663616, + 0.039976011160000005, + 0.04005313516, + 0.04194388616, + 0.04002080216, + 0.04235617716, + 0.04134596916, + 0.040315260160000005, + 0.04000892716, + 0.03988201116 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "1" + } + }, + { + "command": "../../tool/genq --input ./lib", + "mean": 0.04434872346, + "stddev": 0.0014637386336549328, + "median": 0.04447028166, + "user": 0.08163795999999998, + "system": 0.0038993, + "min": 0.042558344160000004, + "max": 0.04695142816, + "times": [ + 0.04336863616, + 0.04695142816, + 0.04531638616, + 0.04476084416, + 0.042558344160000004, + 0.04283096916, + 0.04594184416, + 0.04457717816, + 0.042818219160000004, + 0.044363385160000005 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "2" + } + }, + { + "command": "../../tool/genq --input ./lib", + "mean": 0.05092155256000001, + "stddev": 0.0019401978950660446, + "median": 0.05111999016, + "user": 0.13582086, + "system": 0.0057983, + "min": 0.048046552160000006, + "max": 0.053112094160000005, + "times": [ + 0.05181321916, + 0.048242385160000005, + 0.04942271916, + 0.05042676116, + 0.048046552160000006, + 0.05235992716, + 0.052629928160000006, + 0.053112094160000005, + 0.05008201116, + 0.053079928160000005 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "3" + } + }, + { + "command": "../../tool/genq --input ./lib", + "mean": 0.06145983176000001, + "stddev": 0.003039896126445414, + "median": 0.061034761160000006, + "user": 0.20733306, + "system": 0.007410399999999999, + "min": 0.05849546916, + "max": 0.06780130216000001, + "times": [ + 0.05850263616, + 0.060893178160000005, + 0.06117634416000001, + 0.06780130216000001, + 0.06193851016, + 0.06525755216000001, + 0.05988813616, + 0.05849546916, + 0.058692886160000006, + 0.06195230316 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "4" + } + }, + { + "command": "../../tool/genq --input ./lib", + "mean": 0.07000841906000001, + "stddev": 0.0029006514080500935, + "median": 0.06976071916000001, + "user": 0.28296766, + "system": 0.010391800000000001, + "min": 0.06548751016, + "max": 0.07609855216, + "times": [ + 0.06548751016, + 0.07134834416000001, + 0.06959067816, + 0.06993076016000001, + 0.06899446916, + 0.07247634416, + 0.07609855216, + 0.07037221916, + 0.06798134416, + 0.06780396916 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "5" + } + }, + { + "command": "../../tool/genq --input ./lib", + "mean": 0.07802953146, + "stddev": 0.0051901682726712165, + "median": 0.07658465666, + "user": 0.36247655999999995, + "system": 0.0128844, + "min": 0.07188651116, + "max": 0.09063663516, + "times": [ + 0.07367613516, + 0.07639384416, + 0.07981880216000001, + 0.07748980216000001, + 0.08142513516000001, + 0.07188651116, + 0.07628146916, + 0.07677546916, + 0.07591151116, + 0.09063663516 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "6" + } + }, + { + "command": "../../tool/genq --input ./lib", + "mean": 0.08491451486000003, + "stddev": 0.0031358284227339713, + "median": 0.08402898966, + "user": 0.4342156599999999, + "system": 0.0145665, + "min": 0.08045201116, + "max": 0.09106621916, + "times": [ + 0.08045201116, + 0.08369830216, + 0.08196426016000001, + 0.09106621916, + 0.08781938616, + 0.08362413516, + 0.08435967716000001, + 0.08287326116, + 0.08665809416, + 0.08662980216 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "7" + } + }, + { + "command": "../../tool/genq --input ./lib", + "mean": 0.09337516486000001, + "stddev": 0.004274758327821354, + "median": 0.09256253166, + "user": 0.50688236, + "system": 0.0165066, + "min": 0.08701071916, + "max": 0.10094988516, + "times": [ + 0.09308621916000001, + 0.08911996916, + 0.09203884416000001, + 0.09770542716000001, + 0.09596067716000001, + 0.09024355216, + 0.09615996916000001, + 0.08701071916, + 0.10094988516, + 0.09147638616 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "8" + } + }, + { + "command": "../../tool/genq --input ./lib", + "mean": 0.10090306516, + "stddev": 0.003731521524287587, + "median": 0.10180469866, + "user": 0.57461016, + "system": 0.0176319, + "min": 0.09599951116000001, + "max": 0.10757896916000001, + "times": [ + 0.09945221916000001, + 0.09599951116000001, + 0.09696488616, + 0.10284546916000001, + 0.10273346916000001, + 0.10347130316, + 0.09625792716, + 0.10285096916, + 0.10087592816, + 0.10757896916000001 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "9" + } + }, + { + "command": "../../tool/genq --input ./lib", + "mean": 0.10951109416, + "stddev": 0.0038154554604206553, + "median": 0.10858578166, + "user": 0.6329079599999999, + "system": 0.0184781, + "min": 0.10265680216, + "max": 0.11435613616000001, + "times": [ + 0.11322351116000001, + 0.10794413616000001, + 0.10265680216, + 0.10879746916000001, + 0.10658084416000001, + 0.11371834416000001, + 0.11257067716000001, + 0.11435613616000001, + 0.10688892716000001, + 0.10837409416 + ], + "exit_codes": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ], + "parameters": { + "count": "10" + } + } + ] +} diff --git a/benchmarks/genq_benchmark/benchmark.sh b/benchmarks/genq_benchmark/benchmark.sh new file mode 100755 index 0000000..6233a66 --- /dev/null +++ b/benchmarks/genq_benchmark/benchmark.sh @@ -0,0 +1 @@ +hyperfine --parameter-step-size 1 --parameter-scan count 1 10 --prepare './reset.sh && dart ./bin/gen.dart {count}' '../../tool/genq --input ./lib' --export-json ./benchmark.json diff --git a/benchmarks/genq_benchmark/bin/gen.dart b/benchmarks/genq_benchmark/bin/gen.dart new file mode 100644 index 0000000..0eee665 --- /dev/null +++ b/benchmarks/genq_benchmark/bin/gen.dart @@ -0,0 +1,24 @@ +import 'dart:io'; + +void main(List args) { + for (var i = 0; i < int.parse(args[0]); i++) { + final file = File('./lib/gen/gen$i.bench.dart'); + var str = 'import "package:genq/genq.dart";\n\n'; + str += "part 'gen$i.bench.genq.dart';\n\n"; + + for (var j = 0; j < 250; j++) { + str += ''' +@genq +class User$j with _\$User$j { + factory User$j({ + required String name, + required int? age, + required bool registered, + required void Function() test, + }) = _User$j; +}\n\n'''; + + file.writeAsStringSync(str); + } + } +} diff --git a/benchmarks/genq_benchmark/ios/.gitignore b/benchmarks/genq_benchmark/ios/.gitignore new file mode 100644 index 0000000..7a7f987 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/.gitignore @@ -0,0 +1,34 @@ +**/dgph +*.mode1v3 +*.mode2v3 +*.moved-aside +*.pbxuser +*.perspectivev3 +**/*sync/ +.sconsign.dblite +.tags* +**/.vagrant/ +**/DerivedData/ +Icon? +**/Pods/ +**/.symlinks/ +profile +xcuserdata +**/.generated/ +Flutter/App.framework +Flutter/Flutter.framework +Flutter/Flutter.podspec +Flutter/Generated.xcconfig +Flutter/ephemeral/ +Flutter/app.flx +Flutter/app.zip +Flutter/flutter_assets/ +Flutter/flutter_export_environment.sh +ServiceDefinitions.json +Runner/GeneratedPluginRegistrant.* + +# Exceptions to above rules. +!default.mode1v3 +!default.mode2v3 +!default.pbxuser +!default.perspectivev3 diff --git a/benchmarks/genq_benchmark/ios/Flutter/AppFrameworkInfo.plist b/benchmarks/genq_benchmark/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 0000000..9625e10 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + MinimumOSVersion + 11.0 + + diff --git a/benchmarks/genq_benchmark/ios/Flutter/Debug.xcconfig b/benchmarks/genq_benchmark/ios/Flutter/Debug.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/benchmarks/genq_benchmark/ios/Flutter/Release.xcconfig b/benchmarks/genq_benchmark/ios/Flutter/Release.xcconfig new file mode 100644 index 0000000..592ceee --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.pbxproj b/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..3c80948 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,617 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C8085294A63A400263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 97C146E61CF9000F007C117D /* Project object */; + proxyType = 1; + remoteGlobalIDString = 97C146ED1CF9000F007C117D; + remoteInfo = Runner; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 331C8082294A63A400263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C807B294A618700263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + 331C8082294A63A400263BE5 /* RunnerTests */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + 331C8081294A63A400263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, + 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, + ); + path = Runner; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C8080294A63A400263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C807D294A63A400263BE5 /* Sources */, + 331C807E294A63A400263BE5 /* Frameworks */, + 331C807F294A63A400263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C8086294A63A400263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C8081294A63A400263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = YES; + LastUpgradeCheck = 1430; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C8080294A63A400263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 97C146ED1CF9000F007C117D; + }; + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 1100; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + 331C8080294A63A400263BE5 /* RunnerTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C807F294A63A400263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C807D294A63A400263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C8086294A63A400263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 97C146ED1CF9000F007C117D /* Runner */; + targetProxy = 331C8085294A63A400263BE5 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 249021D3217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Profile; + }; + 249021D4217E4FDB00AE95B9 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = Z4963WA9BJ; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.genqBenchmark; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Profile; + }; + 331C8088294A63A400263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = AE0B7B92F70575B8D7E0D07E /* Pods-RunnerTests.debug.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.genqBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Debug; + }; + 331C8089294A63A400263BE5 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 89B67EB44CE7B6631473024E /* Pods-RunnerTests.release.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.genqBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Release; + }; + 331C808A294A63A400263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 640959BDD8F10B91D80A66BE /* Pods-RunnerTests.profile.xcconfig */; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.genqBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Runner.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Runner"; + }; + name = Profile; + }; + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SUPPORTED_PLATFORMS = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = Z4963WA9BJ; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.genqBenchmark; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = Z4963WA9BJ; + ENABLE_BITCODE = NO; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.example.genqBenchmark; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; + SWIFT_VERSION = 5.0; + VERSIONING_SYSTEM = "apple-generic"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C8087294A63A400263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C8088294A63A400263BE5 /* Debug */, + 331C8089294A63A400263BE5 /* Release */, + 331C808A294A63A400263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + 249021D3217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + 249021D4217E4FDB00AE95B9 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/benchmarks/genq_benchmark/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/benchmarks/genq_benchmark/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..87131a0 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/genq_benchmark/ios/Runner.xcworkspace/contents.xcworkspacedata b/benchmarks/genq_benchmark/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/benchmarks/genq_benchmark/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/benchmarks/genq_benchmark/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/benchmarks/genq_benchmark/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/benchmarks/genq_benchmark/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings new file mode 100644 index 0000000..f9b0d7c --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings @@ -0,0 +1,8 @@ + + + + + PreviewsEnabled + + + diff --git a/benchmarks/genq_benchmark/ios/Runner/AppDelegate.swift b/benchmarks/genq_benchmark/ios/Runner/AppDelegate.swift new file mode 100644 index 0000000..70693e4 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner/AppDelegate.swift @@ -0,0 +1,13 @@ +import UIKit +import Flutter + +@UIApplicationMain +@objc class AppDelegate: FlutterAppDelegate { + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } +} diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..d36b1fa --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,122 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + }, + { + "size" : "1024x1024", + "idiom" : "ios-marketing", + "filename" : "Icon-App-1024x1024@1x.png", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png new file mode 100644 index 0000000..dc9ada4 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 0000000..7353c41 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 0000000..797d452 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 0000000..6ed2d93 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 0000000..4cd7b00 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 0000000..fe73094 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 0000000..321773c Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 0000000..797d452 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 0000000..502f463 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 0000000..0ec3034 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 0000000..0ec3034 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 0000000..e9f5fea Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 0000000..84ac32a Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 0000000..8953cba Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 0000000..0467bf1 Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 0000000..0bedcf2 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 0000000..9da19ea Binary files /dev/null and b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 0000000..89c2725 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/benchmarks/genq_benchmark/ios/Runner/Base.lproj/LaunchScreen.storyboard b/benchmarks/genq_benchmark/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f2e259c --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/genq_benchmark/ios/Runner/Base.lproj/Main.storyboard b/benchmarks/genq_benchmark/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 0000000..f3c2851 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/genq_benchmark/ios/Runner/Info.plist b/benchmarks/genq_benchmark/ios/Runner/Info.plist new file mode 100644 index 0000000..b51f2ff --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleDisplayName + Genq Benchmark + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + genq_benchmark + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleSignature + ???? + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + CADisableMinimumFrameDurationOnPhone + + UIApplicationSupportsIndirectInputEvents + + + diff --git a/benchmarks/genq_benchmark/ios/Runner/Runner-Bridging-Header.h b/benchmarks/genq_benchmark/ios/Runner/Runner-Bridging-Header.h new file mode 100644 index 0000000..308a2a5 --- /dev/null +++ b/benchmarks/genq_benchmark/ios/Runner/Runner-Bridging-Header.h @@ -0,0 +1 @@ +#import "GeneratedPluginRegistrant.h" diff --git a/benchmarks/genq_benchmark/ios/RunnerTests/RunnerTests.swift b/benchmarks/genq_benchmark/ios/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..86a7c3b --- /dev/null +++ b/benchmarks/genq_benchmark/ios/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import Flutter +import UIKit +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/benchmarks/genq_benchmark/lib/main.dart b/benchmarks/genq_benchmark/lib/main.dart new file mode 100644 index 0000000..8e94089 --- /dev/null +++ b/benchmarks/genq_benchmark/lib/main.dart @@ -0,0 +1,125 @@ +import 'package:flutter/material.dart'; + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatelessWidget { + const MyApp({super.key}); + + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + // This is the theme of your application. + // + // TRY THIS: Try running your application with "flutter run". You'll see + // the application has a purple toolbar. Then, without quitting the app, + // try changing the seedColor in the colorScheme below to Colors.green + // and then invoke "hot reload" (save your changes or press the "hot + // reload" button in a Flutter-supported IDE, or press "r" if you used + // the command line to start the app). + // + // Notice that the counter didn't reset back to zero; the application + // state is not lost during the reload. To reset the state, use hot + // restart instead. + // + // This works for code too, not just values: Most code changes can be + // tested with just a hot reload. + colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), + useMaterial3: true, + ), + home: const MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatefulWidget { + const MyHomePage({super.key, required this.title}); + + // This widget is the home page of your application. It is stateful, meaning + // that it has a State object (defined below) that contains fields that affect + // how it looks. + + // This class is the configuration for the state. It holds the values (in this + // case the title) provided by the parent (in this case the App widget) and + // used by the build method of the State. Fields in a Widget subclass are + // always marked "final". + + final String title; + + @override + State createState() => _MyHomePageState(); +} + +class _MyHomePageState extends State { + int _counter = 0; + + void _incrementCounter() { + setState(() { + // This call to setState tells the Flutter framework that something has + // changed in this State, which causes it to rerun the build method below + // so that the display can reflect the updated values. If we changed + // _counter without calling setState(), then the build method would not be + // called again, and so nothing would appear to happen. + _counter++; + }); + } + + @override + Widget build(BuildContext context) { + // This method is rerun every time setState is called, for instance as done + // by the _incrementCounter method above. + // + // The Flutter framework has been optimized to make rerunning build methods + // fast, so that you can just rebuild anything that needs updating rather + // than having to individually change instances of widgets. + return Scaffold( + appBar: AppBar( + // TRY THIS: Try changing the color here to a specific color (to + // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar + // change color while the other colors stay the same. + backgroundColor: Theme.of(context).colorScheme.inversePrimary, + // Here we take the value from the MyHomePage object that was created by + // the App.build method, and use it to set our appbar title. + title: Text(widget.title), + ), + body: Center( + // Center is a layout widget. It takes a single child and positions it + // in the middle of the parent. + child: Column( + // Column is also a layout widget. It takes a list of children and + // arranges them vertically. By default, it sizes itself to fit its + // children horizontally, and tries to be as tall as its parent. + // + // Column has various properties to control how it sizes itself and + // how it positions its children. Here we use mainAxisAlignment to + // center the children vertically; the main axis here is the vertical + // axis because Columns are vertical (the cross axis would be + // horizontal). + // + // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint" + // action in the IDE, or press "p" in the console), to see the + // wireframe for each widget. + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text( + 'You have pushed the button this many times:', + ), + Text( + '$_counter', + style: Theme.of(context).textTheme.headlineMedium, + ), + ], + ), + ), + floatingActionButton: FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: const Icon(Icons.add), + ), // This trailing comma makes auto-formatting nicer for build methods. + ); + } +} diff --git a/benchmarks/genq_benchmark/linux/.gitignore b/benchmarks/genq_benchmark/linux/.gitignore new file mode 100644 index 0000000..d3896c9 --- /dev/null +++ b/benchmarks/genq_benchmark/linux/.gitignore @@ -0,0 +1 @@ +flutter/ephemeral diff --git a/benchmarks/genq_benchmark/linux/CMakeLists.txt b/benchmarks/genq_benchmark/linux/CMakeLists.txt new file mode 100644 index 0000000..4ba15ec --- /dev/null +++ b/benchmarks/genq_benchmark/linux/CMakeLists.txt @@ -0,0 +1,145 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.10) +project(runner 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 "genq_benchmark") +# The unique GTK application identifier for this application. See: +# https://wiki.gnome.org/HowDoI/ChooseApplicationID +set(APPLICATION_ID "com.example.genq_benchmark") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(SET CMP0063 NEW) + +# Load bundled libraries from the lib/ directory relative to the binary. +set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") + +# Root filesystem for cross-building. +if(FLUTTER_TARGET_PLATFORM_SYSROOT) + set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +# Define build configuration options. +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") +endif() + +# 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) + target_compile_features(${TARGET} PUBLIC cxx_std_14) + target_compile_options(${TARGET} PRIVATE -Wall -Werror) + target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") + target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +add_subdirectory(${FLUTTER_MANAGED_DIR}) + +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) + +add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") + +# Define the application target. To change its name, change BINARY_NAME above, +# not the value here, or `flutter run` will no longer work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} + "main.cc" + "my_application.cc" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add dependency libraries. Add any application-specific dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter) +target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) + +# Run the Flutter tool portions of the build. This must not be removed. +add_dependencies(${BINARY_NAME} flutter_assemble) + +# Only the install-generated bundle's copy of the executable will launch +# correctly, since the resources must in the right relative locations. To avoid +# people trying to run the unbundled copy, put it in a subdirectory instead of +# the default top-level location. +set_target_properties(${BINARY_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" +) + + +# Generated plugin build rules, which manage building the plugins and adding +# them to the application. +include(flutter/generated_plugins.cmake) + + +# === Installation === +# By default, "installing" just makes a relocatable bundle in the build +# directory. +set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +# Start with a clean build bundle directory every time. +install(CODE " + file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") + " COMPONENT Runtime) + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) + install(FILES "${bundled_library}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endforeach(bundled_library) + +# Copy the native assets provided by the build.dart from all packages. +set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") +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") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") + install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) +endif() diff --git a/benchmarks/genq_benchmark/linux/flutter/CMakeLists.txt b/benchmarks/genq_benchmark/linux/flutter/CMakeLists.txt new file mode 100644 index 0000000..d5bd016 --- /dev/null +++ b/benchmarks/genq_benchmark/linux/flutter/CMakeLists.txt @@ -0,0 +1,88 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.10) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# https://github.com/flutter/flutter/issues/57146. + +# Serves the same purpose as list(TRANSFORM ... PREPEND ...), +# which isn't available in 3.10. +function(list_prepend LIST_NAME PREFIX) + set(NEW_LIST "") + foreach(element ${${LIST_NAME}}) + list(APPEND NEW_LIST "${PREFIX}${element}") + endforeach(element) + set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) +endfunction() + +# === Flutter Library === +# System-level dependencies. +find_package(PkgConfig REQUIRED) +pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) +pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) +pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) + +set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "fl_basic_message_channel.h" + "fl_binary_codec.h" + "fl_binary_messenger.h" + "fl_dart_project.h" + "fl_engine.h" + "fl_json_message_codec.h" + "fl_json_method_codec.h" + "fl_message_codec.h" + "fl_method_call.h" + "fl_method_channel.h" + "fl_method_codec.h" + "fl_method_response.h" + "fl_plugin_registrar.h" + "fl_plugin_registry.h" + "fl_standard_message_codec.h" + "fl_standard_method_codec.h" + "fl_string_codec.h" + "fl_value.h" + "fl_view.h" + "flutter_linux.h" +) +list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") +target_link_libraries(flutter INTERFACE + PkgConfig::GTK + PkgConfig::GLIB + PkgConfig::GIO +) +add_dependencies(flutter flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CMAKE_CURRENT_BINARY_DIR}/_phony_ + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" + ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} +) diff --git a/benchmarks/genq_benchmark/linux/flutter/generated_plugin_registrant.cc b/benchmarks/genq_benchmark/linux/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..e71a16d --- /dev/null +++ b/benchmarks/genq_benchmark/linux/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void fl_register_plugins(FlPluginRegistry* registry) { +} diff --git a/benchmarks/genq_benchmark/linux/flutter/generated_plugin_registrant.h b/benchmarks/genq_benchmark/linux/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..e0f0a47 --- /dev/null +++ b/benchmarks/genq_benchmark/linux/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void fl_register_plugins(FlPluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/benchmarks/genq_benchmark/linux/flutter/generated_plugins.cmake b/benchmarks/genq_benchmark/linux/flutter/generated_plugins.cmake new file mode 100644 index 0000000..2e1de87 --- /dev/null +++ b/benchmarks/genq_benchmark/linux/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/benchmarks/genq_benchmark/linux/main.cc b/benchmarks/genq_benchmark/linux/main.cc new file mode 100644 index 0000000..e7c5c54 --- /dev/null +++ b/benchmarks/genq_benchmark/linux/main.cc @@ -0,0 +1,6 @@ +#include "my_application.h" + +int main(int argc, char** argv) { + g_autoptr(MyApplication) app = my_application_new(); + return g_application_run(G_APPLICATION(app), argc, argv); +} diff --git a/benchmarks/genq_benchmark/linux/my_application.cc b/benchmarks/genq_benchmark/linux/my_application.cc new file mode 100644 index 0000000..1a8e564 --- /dev/null +++ b/benchmarks/genq_benchmark/linux/my_application.cc @@ -0,0 +1,104 @@ +#include "my_application.h" + +#include +#ifdef GDK_WINDOWING_X11 +#include +#endif + +#include "flutter/generated_plugin_registrant.h" + +struct _MyApplication { + GtkApplication parent_instance; + char** dart_entrypoint_arguments; +}; + +G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) + +// Implements GApplication::activate. +static void my_application_activate(GApplication* application) { + MyApplication* self = MY_APPLICATION(application); + GtkWindow* window = + GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); + + // Use a header bar when running in GNOME as this is the common style used + // by applications and is the setup most users will be using (e.g. Ubuntu + // desktop). + // If running on X and not using GNOME then just use a traditional title bar + // in case the window manager does more exotic layout, e.g. tiling. + // If running on Wayland assume the header bar will work (may need changing + // if future cases occur). + gboolean use_header_bar = TRUE; +#ifdef GDK_WINDOWING_X11 + GdkScreen* screen = gtk_window_get_screen(window); + if (GDK_IS_X11_SCREEN(screen)) { + const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); + if (g_strcmp0(wm_name, "GNOME Shell") != 0) { + use_header_bar = FALSE; + } + } +#endif + if (use_header_bar) { + GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); + gtk_widget_show(GTK_WIDGET(header_bar)); + gtk_header_bar_set_title(header_bar, "genq_benchmark"); + gtk_header_bar_set_show_close_button(header_bar, TRUE); + gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); + } else { + gtk_window_set_title(window, "genq_benchmark"); + } + + gtk_window_set_default_size(window, 1280, 720); + gtk_widget_show(GTK_WIDGET(window)); + + g_autoptr(FlDartProject) project = fl_dart_project_new(); + fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); + + FlView* view = fl_view_new(project); + gtk_widget_show(GTK_WIDGET(view)); + gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); + + fl_register_plugins(FL_PLUGIN_REGISTRY(view)); + + gtk_widget_grab_focus(GTK_WIDGET(view)); +} + +// Implements GApplication::local_command_line. +static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { + MyApplication* self = MY_APPLICATION(application); + // Strip out the first argument as it is the binary name. + self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); + + g_autoptr(GError) error = nullptr; + if (!g_application_register(application, nullptr, &error)) { + g_warning("Failed to register: %s", error->message); + *exit_status = 1; + return TRUE; + } + + g_application_activate(application); + *exit_status = 0; + + return TRUE; +} + +// Implements GObject::dispose. +static void my_application_dispose(GObject* object) { + MyApplication* self = MY_APPLICATION(object); + g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); + G_OBJECT_CLASS(my_application_parent_class)->dispose(object); +} + +static void my_application_class_init(MyApplicationClass* klass) { + G_APPLICATION_CLASS(klass)->activate = my_application_activate; + G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; + G_OBJECT_CLASS(klass)->dispose = my_application_dispose; +} + +static void my_application_init(MyApplication* self) {} + +MyApplication* my_application_new() { + return MY_APPLICATION(g_object_new(my_application_get_type(), + "application-id", APPLICATION_ID, + "flags", G_APPLICATION_NON_UNIQUE, + nullptr)); +} diff --git a/benchmarks/genq_benchmark/linux/my_application.h b/benchmarks/genq_benchmark/linux/my_application.h new file mode 100644 index 0000000..72271d5 --- /dev/null +++ b/benchmarks/genq_benchmark/linux/my_application.h @@ -0,0 +1,18 @@ +#ifndef FLUTTER_MY_APPLICATION_H_ +#define FLUTTER_MY_APPLICATION_H_ + +#include + +G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, + GtkApplication) + +/** + * my_application_new: + * + * Creates a new Flutter-based application. + * + * Returns: a new #MyApplication. + */ +MyApplication* my_application_new(); + +#endif // FLUTTER_MY_APPLICATION_H_ diff --git a/benchmarks/genq_benchmark/macos/.gitignore b/benchmarks/genq_benchmark/macos/.gitignore new file mode 100644 index 0000000..746adbb --- /dev/null +++ b/benchmarks/genq_benchmark/macos/.gitignore @@ -0,0 +1,7 @@ +# Flutter-related +**/Flutter/ephemeral/ +**/Pods/ + +# Xcode-related +**/dgph +**/xcuserdata/ diff --git a/benchmarks/genq_benchmark/macos/Flutter/Flutter-Debug.xcconfig b/benchmarks/genq_benchmark/macos/Flutter/Flutter-Debug.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Flutter/Flutter-Debug.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/benchmarks/genq_benchmark/macos/Flutter/Flutter-Release.xcconfig b/benchmarks/genq_benchmark/macos/Flutter/Flutter-Release.xcconfig new file mode 100644 index 0000000..c2efd0b --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Flutter/Flutter-Release.xcconfig @@ -0,0 +1 @@ +#include "ephemeral/Flutter-Generated.xcconfig" diff --git a/benchmarks/genq_benchmark/macos/Flutter/GeneratedPluginRegistrant.swift b/benchmarks/genq_benchmark/macos/Flutter/GeneratedPluginRegistrant.swift new file mode 100644 index 0000000..cccf817 --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Flutter/GeneratedPluginRegistrant.swift @@ -0,0 +1,10 @@ +// +// Generated file. Do not edit. +// + +import FlutterMacOS +import Foundation + + +func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { +} diff --git a/benchmarks/genq_benchmark/macos/Runner.xcodeproj/project.pbxproj b/benchmarks/genq_benchmark/macos/Runner.xcodeproj/project.pbxproj new file mode 100644 index 0000000..29b861a --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,695 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 54; + objects = { + +/* Begin PBXAggregateTarget section */ + 33CC111A2044C6BA0003C045 /* Flutter Assemble */ = { + isa = PBXAggregateTarget; + buildConfigurationList = 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */; + buildPhases = ( + 33CC111E2044C6BF0003C045 /* ShellScript */, + ); + dependencies = ( + ); + name = "Flutter Assemble"; + productName = FLX; + }; +/* End PBXAggregateTarget section */ + +/* Begin PBXBuildFile section */ + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C80D7294CF71000263BE5 /* RunnerTests.swift */; }; + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */; }; + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC10F02044A3C60003C045 /* AppDelegate.swift */; }; + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC10EC2044A3C60003C045; + remoteInfo = Runner; + }; + 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 33CC10E52044A3C60003C045 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 33CC111A2044C6BA0003C045; + remoteInfo = FLX; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 33CC110E2044A8840003C045 /* Bundle Framework */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Bundle Framework"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; + 33CC10ED2044A3C60003C045 /* genq_benchmark.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "genq_benchmark.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; + 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 33CC10F72044A3C60003C045 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = Runner/Info.plist; sourceTree = ""; }; + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainFlutterWindow.swift; sourceTree = ""; }; + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; + 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; + 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; + 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 331C80D2294CF70F00263BE5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EA2044A3C60003C045 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 331C80D6294CF71000263BE5 /* RunnerTests */ = { + isa = PBXGroup; + children = ( + 331C80D7294CF71000263BE5 /* RunnerTests.swift */, + ); + path = RunnerTests; + sourceTree = ""; + }; + 33BA886A226E78AF003329D5 /* Configs */ = { + isa = PBXGroup; + children = ( + 33E5194F232828860026EE4D /* AppInfo.xcconfig */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 333000ED22D3DE5D00554162 /* Warnings.xcconfig */, + ); + path = Configs; + sourceTree = ""; + }; + 33CC10E42044A3C60003C045 = { + isa = PBXGroup; + children = ( + 33FAB671232836740065AC1E /* Runner */, + 33CEB47122A05771004F2AC0 /* Flutter */, + 331C80D6294CF71000263BE5 /* RunnerTests */, + 33CC10EE2044A3C60003C045 /* Products */, + D73912EC22F37F3D000D13A0 /* Frameworks */, + ); + sourceTree = ""; + }; + 33CC10EE2044A3C60003C045 /* Products */ = { + isa = PBXGroup; + children = ( + 33CC10ED2044A3C60003C045 /* genq_benchmark.app */, + 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 33CC11242044D66E0003C045 /* Resources */ = { + isa = PBXGroup; + children = ( + 33CC10F22044A3C60003C045 /* Assets.xcassets */, + 33CC10F42044A3C60003C045 /* MainMenu.xib */, + 33CC10F72044A3C60003C045 /* Info.plist */, + ); + name = Resources; + path = ..; + sourceTree = ""; + }; + 33CEB47122A05771004F2AC0 /* Flutter */ = { + isa = PBXGroup; + children = ( + 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */, + 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, + 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, + 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, + ); + path = Flutter; + sourceTree = ""; + }; + 33FAB671232836740065AC1E /* Runner */ = { + isa = PBXGroup; + children = ( + 33CC10F02044A3C60003C045 /* AppDelegate.swift */, + 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */, + 33E51913231747F40026EE4D /* DebugProfile.entitlements */, + 33E51914231749380026EE4D /* Release.entitlements */, + 33CC11242044D66E0003C045 /* Resources */, + 33BA886A226E78AF003329D5 /* Configs */, + ); + path = Runner; + sourceTree = ""; + }; + D73912EC22F37F3D000D13A0 /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 331C80D4294CF70F00263BE5 /* RunnerTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */; + buildPhases = ( + 331C80D1294CF70F00263BE5 /* Sources */, + 331C80D2294CF70F00263BE5 /* Frameworks */, + 331C80D3294CF70F00263BE5 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 331C80DA294CF71000263BE5 /* PBXTargetDependency */, + ); + name = RunnerTests; + productName = RunnerTests; + productReference = 331C80D5294CF71000263BE5 /* RunnerTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; + 33CC10EC2044A3C60003C045 /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 33CC10E92044A3C60003C045 /* Sources */, + 33CC10EA2044A3C60003C045 /* Frameworks */, + 33CC10EB2044A3C60003C045 /* Resources */, + 33CC110E2044A8840003C045 /* Bundle Framework */, + 3399D490228B24CF009A79C7 /* ShellScript */, + ); + buildRules = ( + ); + dependencies = ( + 33CC11202044C79F0003C045 /* PBXTargetDependency */, + ); + name = Runner; + productName = Runner; + productReference = 33CC10ED2044A3C60003C045 /* genq_benchmark.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 33CC10E52044A3C60003C045 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0920; + LastUpgradeCheck = 1430; + ORGANIZATIONNAME = ""; + TargetAttributes = { + 331C80D4294CF70F00263BE5 = { + CreatedOnToolsVersion = 14.0; + TestTargetID = 33CC10EC2044A3C60003C045; + }; + 33CC10EC2044A3C60003C045 = { + CreatedOnToolsVersion = 9.2; + LastSwiftMigration = 1100; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; + 33CC111A2044C6BA0003C045 = { + CreatedOnToolsVersion = 9.2; + ProvisioningStyle = Manual; + }; + }; + }; + buildConfigurationList = 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 33CC10E42044A3C60003C045; + productRefGroup = 33CC10EE2044A3C60003C045 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 33CC10EC2044A3C60003C045 /* Runner */, + 331C80D4294CF70F00263BE5 /* RunnerTests */, + 33CC111A2044C6BA0003C045 /* Flutter Assemble */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 331C80D3294CF70F00263BE5 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10EB2044A3C60003C045 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, + 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3399D490228B24CF009A79C7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + ); + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; + }; + 33CC111E2044C6BF0003C045 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + Flutter/ephemeral/FlutterInputs.xcfilelist, + ); + inputPaths = ( + Flutter/ephemeral/tripwire, + ); + outputFileListPaths = ( + Flutter/ephemeral/FlutterOutputs.xcfilelist, + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh && touch Flutter/ephemeral/tripwire"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 331C80D1294CF70F00263BE5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 331C80D8294CF71000263BE5 /* RunnerTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 33CC10E92044A3C60003C045 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */, + 33CC10F12044A3C60003C045 /* AppDelegate.swift in Sources */, + 335BBD1B22A9A15E00E9071D /* GeneratedPluginRegistrant.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 331C80DA294CF71000263BE5 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC10EC2044A3C60003C045 /* Runner */; + targetProxy = 331C80D9294CF71000263BE5 /* PBXContainerItemProxy */; + }; + 33CC11202044C79F0003C045 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 33CC111A2044C6BA0003C045 /* Flutter Assemble */; + targetProxy = 33CC111F2044C79F0003C045 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 33CC10F42044A3C60003C045 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 33CC10F52044A3C60003C045 /* Base */, + ); + name = MainMenu.xib; + path = Runner; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 331C80DB294CF71000263BE5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.genqBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/genq_benchmark.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/genq_benchmark"; + }; + name = Debug; + }; + 331C80DC294CF71000263BE5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.genqBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/genq_benchmark.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/genq_benchmark"; + }; + name = Release; + }; + 331C80DD294CF71000263BE5 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + BUNDLE_LOADER = "$(TEST_HOST)"; + CURRENT_PROJECT_VERSION = 1; + GENERATE_INFOPLIST_FILE = YES; + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = com.example.genqBenchmark.RunnerTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/genq_benchmark.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/genq_benchmark"; + }; + name = Profile; + }; + 338D0CE9231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Profile; + }; + 338D0CEA231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Profile; + }; + 338D0CEB231458BD00FA5F75 /* Profile */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Profile; + }; + 33CC10F92044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 33CC10FA2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CODE_SIGN_IDENTITY = "-"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + MACOSX_DEPLOYMENT_TARGET = 10.14; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + }; + name = Release; + }; + 33CC10FC2044A3C60003C045 /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/DebugProfile.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 33CC10FD2044A3C60003C045 /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 33E5194F232828860026EE4D /* AppInfo.xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = Runner/Release.entitlements; + CODE_SIGN_STYLE = Automatic; + COMBINE_HIDPI_IMAGES = YES; + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/../Frameworks", + ); + PROVISIONING_PROFILE_SPECIFIER = ""; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; + 33CC111C2044C6BA0003C045 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Manual; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 33CC111D2044C6BA0003C045 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 331C80DE294CF71000263BE5 /* Build configuration list for PBXNativeTarget "RunnerTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 331C80DB294CF71000263BE5 /* Debug */, + 331C80DC294CF71000263BE5 /* Release */, + 331C80DD294CF71000263BE5 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10E82044A3C60003C045 /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10F92044A3C60003C045 /* Debug */, + 33CC10FA2044A3C60003C045 /* Release */, + 338D0CE9231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC10FB2044A3C60003C045 /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC10FC2044A3C60003C045 /* Debug */, + 33CC10FD2044A3C60003C045 /* Release */, + 338D0CEA231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 33CC111B2044C6BA0003C045 /* Build configuration list for PBXAggregateTarget "Flutter Assemble" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 33CC111C2044C6BA0003C045 /* Debug */, + 33CC111D2044C6BA0003C045 /* Release */, + 338D0CEB231458BD00FA5F75 /* Profile */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 33CC10E52044A3C60003C045 /* Project object */; +} diff --git a/benchmarks/genq_benchmark/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/benchmarks/genq_benchmark/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/benchmarks/genq_benchmark/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/benchmarks/genq_benchmark/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 0000000..0943f40 --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/genq_benchmark/macos/Runner.xcworkspace/contents.xcworkspacedata b/benchmarks/genq_benchmark/macos/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..1d526a1 --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/benchmarks/genq_benchmark/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/benchmarks/genq_benchmark/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/benchmarks/genq_benchmark/macos/Runner/AppDelegate.swift b/benchmarks/genq_benchmark/macos/Runner/AppDelegate.swift new file mode 100644 index 0000000..d53ef64 --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/AppDelegate.swift @@ -0,0 +1,9 @@ +import Cocoa +import FlutterMacOS + +@NSApplicationMain +class AppDelegate: FlutterAppDelegate { + override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..a2ec33f --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_16.png", + "scale" : "1x" + }, + { + "size" : "16x16", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "2x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_32.png", + "scale" : "1x" + }, + { + "size" : "32x32", + "idiom" : "mac", + "filename" : "app_icon_64.png", + "scale" : "2x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_128.png", + "scale" : "1x" + }, + { + "size" : "128x128", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "2x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_256.png", + "scale" : "1x" + }, + { + "size" : "256x256", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "2x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_512.png", + "scale" : "1x" + }, + { + "size" : "512x512", + "idiom" : "mac", + "filename" : "app_icon_1024.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png new file mode 100644 index 0000000..82b6f9d Binary files /dev/null and b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png differ diff --git a/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png new file mode 100644 index 0000000..13b35eb Binary files /dev/null and b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png differ diff --git a/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png new file mode 100644 index 0000000..0a3f5fa Binary files /dev/null and b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png differ diff --git a/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png new file mode 100644 index 0000000..bdb5722 Binary files /dev/null and b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png differ diff --git a/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png new file mode 100644 index 0000000..f083318 Binary files /dev/null and b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png differ diff --git a/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png new file mode 100644 index 0000000..326c0e7 Binary files /dev/null and b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png differ diff --git a/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png new file mode 100644 index 0000000..2f1632c Binary files /dev/null and b/benchmarks/genq_benchmark/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png differ diff --git a/benchmarks/genq_benchmark/macos/Runner/Base.lproj/MainMenu.xib b/benchmarks/genq_benchmark/macos/Runner/Base.lproj/MainMenu.xib new file mode 100644 index 0000000..80e867a --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/Base.lproj/MainMenu.xib @@ -0,0 +1,343 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/benchmarks/genq_benchmark/macos/Runner/Configs/AppInfo.xcconfig b/benchmarks/genq_benchmark/macos/Runner/Configs/AppInfo.xcconfig new file mode 100644 index 0000000..232147d --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/Configs/AppInfo.xcconfig @@ -0,0 +1,14 @@ +// Application-level settings for the Runner target. +// +// This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the +// future. If not, the values below would default to using the project name when this becomes a +// 'flutter create' template. + +// The application's name. By default this is also the title of the Flutter window. +PRODUCT_NAME = genq_benchmark + +// The application's bundle identifier +PRODUCT_BUNDLE_IDENTIFIER = com.example.genqBenchmark + +// The copyright displayed in application information +PRODUCT_COPYRIGHT = Copyright © 2024 com.example. All rights reserved. diff --git a/benchmarks/genq_benchmark/macos/Runner/Configs/Debug.xcconfig b/benchmarks/genq_benchmark/macos/Runner/Configs/Debug.xcconfig new file mode 100644 index 0000000..36b0fd9 --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/Configs/Debug.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Debug.xcconfig" +#include "Warnings.xcconfig" diff --git a/benchmarks/genq_benchmark/macos/Runner/Configs/Release.xcconfig b/benchmarks/genq_benchmark/macos/Runner/Configs/Release.xcconfig new file mode 100644 index 0000000..dff4f49 --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/Configs/Release.xcconfig @@ -0,0 +1,2 @@ +#include "../../Flutter/Flutter-Release.xcconfig" +#include "Warnings.xcconfig" diff --git a/benchmarks/genq_benchmark/macos/Runner/Configs/Warnings.xcconfig b/benchmarks/genq_benchmark/macos/Runner/Configs/Warnings.xcconfig new file mode 100644 index 0000000..42bcbf4 --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/Configs/Warnings.xcconfig @@ -0,0 +1,13 @@ +WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings +GCC_WARN_UNDECLARED_SELECTOR = YES +CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES +CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES +CLANG_WARN_PRAGMA_PACK = YES +CLANG_WARN_STRICT_PROTOTYPES = YES +CLANG_WARN_COMMA = YES +GCC_WARN_STRICT_SELECTOR_MATCH = YES +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES +GCC_WARN_SHADOW = YES +CLANG_WARN_UNREACHABLE_CODE = YES diff --git a/benchmarks/genq_benchmark/macos/Runner/DebugProfile.entitlements b/benchmarks/genq_benchmark/macos/Runner/DebugProfile.entitlements new file mode 100644 index 0000000..dddb8a3 --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/DebugProfile.entitlements @@ -0,0 +1,12 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.cs.allow-jit + + com.apple.security.network.server + + + diff --git a/benchmarks/genq_benchmark/macos/Runner/Info.plist b/benchmarks/genq_benchmark/macos/Runner/Info.plist new file mode 100644 index 0000000..4789daa --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/Info.plist @@ -0,0 +1,32 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + $(FLUTTER_BUILD_NAME) + CFBundleVersion + $(FLUTTER_BUILD_NUMBER) + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + $(PRODUCT_COPYRIGHT) + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/benchmarks/genq_benchmark/macos/Runner/MainFlutterWindow.swift b/benchmarks/genq_benchmark/macos/Runner/MainFlutterWindow.swift new file mode 100644 index 0000000..3cc05eb --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/MainFlutterWindow.swift @@ -0,0 +1,15 @@ +import Cocoa +import FlutterMacOS + +class MainFlutterWindow: NSWindow { + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = self.frame + self.contentViewController = flutterViewController + self.setFrame(windowFrame, display: true) + + RegisterGeneratedPlugins(registry: flutterViewController) + + super.awakeFromNib() + } +} diff --git a/benchmarks/genq_benchmark/macos/Runner/Release.entitlements b/benchmarks/genq_benchmark/macos/Runner/Release.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/benchmarks/genq_benchmark/macos/Runner/Release.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/benchmarks/genq_benchmark/macos/RunnerTests/RunnerTests.swift b/benchmarks/genq_benchmark/macos/RunnerTests/RunnerTests.swift new file mode 100644 index 0000000..5418c9f --- /dev/null +++ b/benchmarks/genq_benchmark/macos/RunnerTests/RunnerTests.swift @@ -0,0 +1,12 @@ +import FlutterMacOS +import Cocoa +import XCTest + +class RunnerTests: XCTestCase { + + func testExample() { + // If you add code to the Runner application, consider adding tests here. + // See https://developer.apple.com/documentation/xctest for more information about using XCTest. + } + +} diff --git a/benchmarks/genq_benchmark/pubspec.lock b/benchmarks/genq_benchmark/pubspec.lock new file mode 100644 index 0000000..d2c6e1f --- /dev/null +++ b/benchmarks/genq_benchmark/pubspec.lock @@ -0,0 +1,195 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d + url: "https://pub.dev" + source: hosted + version: "1.0.6" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + url: "https://pub.dev" + source: hosted + version: "1.3.1" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: a25a15ebbdfc33ab1cd26c63a6ee519df92338a9c10f122adda92938253bef04 + url: "https://pub.dev" + source: hosted + version: "2.0.3" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + genq: + dependency: "direct main" + description: + path: "../../packages/genq" + relative: true + source: path + version: "0.2.0" + lints: + dependency: transitive + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + matcher: + dependency: transitive + description: + name: matcher + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" + source: hosted + version: "0.5.0" + meta: + dependency: transitive + description: + name: meta + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" + source: hosted + version: "1.10.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" + source: hosted + version: "2.1.2" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test_api: + dependency: transitive + description: + name: test_api + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" + source: hosted + version: "0.6.1" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" +sdks: + dart: ">=3.2.3 <4.0.0" diff --git a/benchmarks/genq_benchmark/pubspec.yaml b/benchmarks/genq_benchmark/pubspec.yaml new file mode 100644 index 0000000..06eaf68 --- /dev/null +++ b/benchmarks/genq_benchmark/pubspec.yaml @@ -0,0 +1,91 @@ +name: genq_benchmark +description: "A new Flutter project." +# The following line prevents the package from being accidentally published to +# pub.dev using `flutter pub publish`. This is preferred for private packages. +publish_to: 'none' # Remove this line if you wish to publish to pub.dev + +# The following defines the version and build number for your application. +# A version number is three numbers separated by dots, like 1.2.43 +# followed by an optional build number separated by a +. +# Both the version and the builder number may be overridden in flutter +# build by specifying --build-name and --build-number, respectively. +# In Android, build-name is used as versionName while build-number used as versionCode. +# Read more about Android versioning at https://developer.android.com/studio/publish/versioning +# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. +# Read more about iOS versioning at +# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html +# In Windows, build-name is used as the major, minor, and patch parts +# of the product and file versions while build-number is used as the build suffix. +version: 1.0.0+1 + +environment: + sdk: '>=3.2.3 <4.0.0' + +# Dependencies specify other packages that your package needs in order to work. +# To automatically upgrade your package dependencies to the latest versions +# consider running `flutter pub upgrade --major-versions`. Alternatively, +# dependencies can be manually updated by changing the version numbers below to +# the latest version available on pub.dev. To see which dependencies have newer +# versions available, run `flutter pub outdated`. +dependencies: + flutter: + sdk: flutter + genq: + path: ../../packages/genq + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + + # The "flutter_lints" package below contains a set of recommended lints to + # encourage good coding practices. The lint set provided by the package is + # activated in the `analysis_options.yaml` file located at the root of your + # package. See that file for information about deactivating specific lint + # rules and activating additional ones. + flutter_lints: ^2.0.0 + +# For information on the generic Dart part of this file, see the +# following page: https://dart.dev/tools/pub/pubspec + +# The following section is specific to Flutter packages. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.dev/assets-and-images/#resolution-aware + + # For details regarding adding assets from package dependencies, see + # https://flutter.dev/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.dev/custom-fonts/#from-packages diff --git a/benchmarks/genq_benchmark/reset.sh b/benchmarks/genq_benchmark/reset.sh new file mode 100755 index 0000000..a500c6c --- /dev/null +++ b/benchmarks/genq_benchmark/reset.sh @@ -0,0 +1,3 @@ +flutter clean +rm -rf ./lib/gen +mkdir -p ./lib/gen diff --git a/benchmarks/genq_benchmark/test/widget_test.dart b/benchmarks/genq_benchmark/test/widget_test.dart new file mode 100644 index 0000000..3d50252 --- /dev/null +++ b/benchmarks/genq_benchmark/test/widget_test.dart @@ -0,0 +1,30 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility in the flutter_test package. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:genq_benchmark/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/benchmarks/genq_benchmark/web/favicon.png b/benchmarks/genq_benchmark/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/benchmarks/genq_benchmark/web/favicon.png differ diff --git a/benchmarks/genq_benchmark/web/icons/Icon-192.png b/benchmarks/genq_benchmark/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/benchmarks/genq_benchmark/web/icons/Icon-192.png differ diff --git a/benchmarks/genq_benchmark/web/icons/Icon-512.png b/benchmarks/genq_benchmark/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/benchmarks/genq_benchmark/web/icons/Icon-512.png differ diff --git a/benchmarks/genq_benchmark/web/icons/Icon-maskable-192.png b/benchmarks/genq_benchmark/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/benchmarks/genq_benchmark/web/icons/Icon-maskable-192.png differ diff --git a/benchmarks/genq_benchmark/web/icons/Icon-maskable-512.png b/benchmarks/genq_benchmark/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/benchmarks/genq_benchmark/web/icons/Icon-maskable-512.png differ diff --git a/benchmarks/genq_benchmark/web/index.html b/benchmarks/genq_benchmark/web/index.html new file mode 100644 index 0000000..4331e09 --- /dev/null +++ b/benchmarks/genq_benchmark/web/index.html @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + genq_benchmark + + + + + + + + + + diff --git a/benchmarks/genq_benchmark/web/manifest.json b/benchmarks/genq_benchmark/web/manifest.json new file mode 100644 index 0000000..4d6398f --- /dev/null +++ b/benchmarks/genq_benchmark/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "genq_benchmark", + "short_name": "genq_benchmark", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/benchmarks/genq_benchmark/windows/.gitignore b/benchmarks/genq_benchmark/windows/.gitignore new file mode 100644 index 0000000..d492d0d --- /dev/null +++ b/benchmarks/genq_benchmark/windows/.gitignore @@ -0,0 +1,17 @@ +flutter/ephemeral/ + +# Visual Studio user-specific files. +*.suo +*.user +*.userosscache +*.sln.docstates + +# Visual Studio build-related files. +x64/ +x86/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ diff --git a/benchmarks/genq_benchmark/windows/CMakeLists.txt b/benchmarks/genq_benchmark/windows/CMakeLists.txt new file mode 100644 index 0000000..a0f9012 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/CMakeLists.txt @@ -0,0 +1,108 @@ +# Project-level configuration. +cmake_minimum_required(VERSION 3.14) +project(genq_benchmark 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 "genq_benchmark") + +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. +cmake_policy(VERSION 3.14...3.25) + +# Define build configuration option. +get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(IS_MULTICONFIG) + set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" + CACHE STRING "" FORCE) +else() + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + set(CMAKE_BUILD_TYPE "Debug" CACHE + STRING "Flutter build mode" FORCE) + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS + "Debug" "Profile" "Release") + endif() +endif() +# Define settings for the Profile build mode. +set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_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_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") + +# Use Unicode for all projects. +add_definitions(-DUNICODE -D_UNICODE) + +# 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) + target_compile_features(${TARGET} PUBLIC cxx_std_17) + target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") + target_compile_options(${TARGET} PRIVATE /EHsc) + target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") + target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") +endfunction() + +# Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") +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) + + +# === Installation === +# Support files are copied into place next to the executable, so that it can +# run in place. This is done instead of making a separate bundle (as on Linux) +# so that building and running from within Visual Studio will work. +set(BUILD_BUNDLE_DIR "$") +# Make the "install" step default, as it's required to run. +set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) +endif() + +set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") +set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") + +install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + COMPONENT Runtime) + +install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + +if(PLUGIN_BUNDLED_LIBRARIES) + install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" + DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + 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") +install(CODE " + file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") + " COMPONENT Runtime) +install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" + DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) + +# Install the AOT library on non-Debug builds only. +install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" + CONFIGURATIONS Profile;Release + COMPONENT Runtime) diff --git a/benchmarks/genq_benchmark/windows/flutter/CMakeLists.txt b/benchmarks/genq_benchmark/windows/flutter/CMakeLists.txt new file mode 100644 index 0000000..903f489 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/flutter/CMakeLists.txt @@ -0,0 +1,109 @@ +# This file controls Flutter-level build steps. It should not be edited. +cmake_minimum_required(VERSION 3.14) + +set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") + +# Configuration provided via flutter tool. +include(${EPHEMERAL_DIR}/generated_config.cmake) + +# TODO: Move the rest of this into files in ephemeral. See +# 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") + +# Published to parent scope for install step. +set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) +set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) +set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) +set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) + +list(APPEND FLUTTER_LIBRARY_HEADERS + "flutter_export.h" + "flutter_windows.h" + "flutter_messenger.h" + "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" +) +list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") +add_library(flutter INTERFACE) +target_include_directories(flutter INTERFACE + "${EPHEMERAL_DIR}" +) +target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") +add_dependencies(flutter flutter_assemble) + +# === Wrapper === +list(APPEND CPP_WRAPPER_SOURCES_CORE + "core_implementations.cc" + "standard_codec.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_PLUGIN + "plugin_registrar.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") +list(APPEND CPP_WRAPPER_SOURCES_APP + "flutter_engine.cc" + "flutter_view_controller.cc" +) +list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") + +# Wrapper sources needed for a plugin. +add_library(flutter_wrapper_plugin STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} +) +apply_standard_settings(flutter_wrapper_plugin) +set_target_properties(flutter_wrapper_plugin PROPERTIES + POSITION_INDEPENDENT_CODE ON) +set_target_properties(flutter_wrapper_plugin PROPERTIES + CXX_VISIBILITY_PRESET hidden) +target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) +target_include_directories(flutter_wrapper_plugin PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_plugin flutter_assemble) + +# Wrapper sources needed for the runner. +add_library(flutter_wrapper_app STATIC + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_APP} +) +apply_standard_settings(flutter_wrapper_app) +target_link_libraries(flutter_wrapper_app PUBLIC flutter) +target_include_directories(flutter_wrapper_app PUBLIC + "${WRAPPER_ROOT}/include" +) +add_dependencies(flutter_wrapper_app flutter_assemble) + +# === Flutter tool backend === +# _phony_ is a non-existent file to force this command to run every time, +# since currently there's no way to get a full input/output list from the +# flutter tool. +set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") +set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) +add_custom_command( + OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} + ${PHONY_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E env + ${FLUTTER_TOOL_ENVIRONMENT} + "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" + ${FLUTTER_TARGET_PLATFORM} $ + VERBATIM +) +add_custom_target(flutter_assemble DEPENDS + "${FLUTTER_LIBRARY}" + ${FLUTTER_LIBRARY_HEADERS} + ${CPP_WRAPPER_SOURCES_CORE} + ${CPP_WRAPPER_SOURCES_PLUGIN} + ${CPP_WRAPPER_SOURCES_APP} +) diff --git a/benchmarks/genq_benchmark/windows/flutter/generated_plugin_registrant.cc b/benchmarks/genq_benchmark/windows/flutter/generated_plugin_registrant.cc new file mode 100644 index 0000000..8b6d468 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/flutter/generated_plugin_registrant.cc @@ -0,0 +1,11 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#include "generated_plugin_registrant.h" + + +void RegisterPlugins(flutter::PluginRegistry* registry) { +} diff --git a/benchmarks/genq_benchmark/windows/flutter/generated_plugin_registrant.h b/benchmarks/genq_benchmark/windows/flutter/generated_plugin_registrant.h new file mode 100644 index 0000000..dc139d8 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/flutter/generated_plugin_registrant.h @@ -0,0 +1,15 @@ +// +// Generated file. Do not edit. +// + +// clang-format off + +#ifndef GENERATED_PLUGIN_REGISTRANT_ +#define GENERATED_PLUGIN_REGISTRANT_ + +#include + +// Registers Flutter plugins. +void RegisterPlugins(flutter::PluginRegistry* registry); + +#endif // GENERATED_PLUGIN_REGISTRANT_ diff --git a/benchmarks/genq_benchmark/windows/flutter/generated_plugins.cmake b/benchmarks/genq_benchmark/windows/flutter/generated_plugins.cmake new file mode 100644 index 0000000..b93c4c3 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/flutter/generated_plugins.cmake @@ -0,0 +1,23 @@ +# +# Generated file, do not edit. +# + +list(APPEND FLUTTER_PLUGIN_LIST +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + +set(PLUGIN_BUNDLED_LIBRARIES) + +foreach(plugin ${FLUTTER_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) + target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) + list(APPEND PLUGIN_BUNDLED_LIBRARIES $) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) +endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/benchmarks/genq_benchmark/windows/runner/CMakeLists.txt b/benchmarks/genq_benchmark/windows/runner/CMakeLists.txt new file mode 100644 index 0000000..394917c --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.14) +project(runner LANGUAGES CXX) + +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. +add_executable(${BINARY_NAME} WIN32 + "flutter_window.cpp" + "main.cpp" + "utils.cpp" + "win32_window.cpp" + "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" + "Runner.rc" + "runner.exe.manifest" +) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. +apply_standard_settings(${BINARY_NAME}) + +# Add preprocessor definitions for the build version. +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") +target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") + +# Disable Windows macros that collide with C++ standard library functions. +target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. +target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) +target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") +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) diff --git a/benchmarks/genq_benchmark/windows/runner/Runner.rc b/benchmarks/genq_benchmark/windows/runner/Runner.rc new file mode 100644 index 0000000..4f9acac --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/Runner.rc @@ -0,0 +1,121 @@ +// Microsoft Visual C++ generated resource script. +// +#pragma code_page(65001) +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "winres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (United States) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""winres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_APP_ICON ICON "resources\\app_icon.ico" + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) +#define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD +#else +#define VERSION_AS_NUMBER 1,0,0,0 +#endif + +#if defined(FLUTTER_VERSION) +#define VERSION_AS_STRING FLUTTER_VERSION +#else +#define VERSION_AS_STRING "1.0.0" +#endif + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VERSION_AS_NUMBER + PRODUCTVERSION VERSION_AS_NUMBER + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS VS_FF_DEBUG +#else + FILEFLAGS 0x0L +#endif + FILEOS VOS__WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904e4" + BEGIN + VALUE "CompanyName", "com.example" "\0" + VALUE "FileDescription", "genq_benchmark" "\0" + VALUE "FileVersion", VERSION_AS_STRING "\0" + VALUE "InternalName", "genq_benchmark" "\0" + VALUE "LegalCopyright", "Copyright (C) 2024 com.example. All rights reserved." "\0" + VALUE "OriginalFilename", "genq_benchmark.exe" "\0" + VALUE "ProductName", "genq_benchmark" "\0" + VALUE "ProductVersion", VERSION_AS_STRING "\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + +#endif // English (United States) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED diff --git a/benchmarks/genq_benchmark/windows/runner/flutter_window.cpp b/benchmarks/genq_benchmark/windows/runner/flutter_window.cpp new file mode 100644 index 0000000..955ee30 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/flutter_window.cpp @@ -0,0 +1,71 @@ +#include "flutter_window.h" + +#include + +#include "flutter/generated_plugin_registrant.h" + +FlutterWindow::FlutterWindow(const flutter::DartProject& project) + : project_(project) {} + +FlutterWindow::~FlutterWindow() {} + +bool FlutterWindow::OnCreate() { + if (!Win32Window::OnCreate()) { + return false; + } + + RECT frame = GetClientArea(); + + // The size here must match the window dimensions to avoid unnecessary surface + // creation / destruction in the startup path. + flutter_controller_ = std::make_unique( + frame.right - frame.left, frame.bottom - frame.top, project_); + // Ensure that basic setup of the controller was successful. + if (!flutter_controller_->engine() || !flutter_controller_->view()) { + return false; + } + RegisterPlugins(flutter_controller_->engine()); + SetChildContent(flutter_controller_->view()->GetNativeWindow()); + + flutter_controller_->engine()->SetNextFrameCallback([&]() { + this->Show(); + }); + + // Flutter can complete the first frame before the "show window" callback is + // registered. The following call ensures a frame is pending to ensure the + // window is shown. It is a no-op if the first frame hasn't completed yet. + flutter_controller_->ForceRedraw(); + + return true; +} + +void FlutterWindow::OnDestroy() { + if (flutter_controller_) { + flutter_controller_ = nullptr; + } + + Win32Window::OnDestroy(); +} + +LRESULT +FlutterWindow::MessageHandler(HWND hwnd, UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + // Give Flutter, including plugins, an opportunity to handle window messages. + if (flutter_controller_) { + std::optional result = + flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, + lparam); + if (result) { + return *result; + } + } + + switch (message) { + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; + } + + return Win32Window::MessageHandler(hwnd, message, wparam, lparam); +} diff --git a/benchmarks/genq_benchmark/windows/runner/flutter_window.h b/benchmarks/genq_benchmark/windows/runner/flutter_window.h new file mode 100644 index 0000000..6da0652 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/flutter_window.h @@ -0,0 +1,33 @@ +#ifndef RUNNER_FLUTTER_WINDOW_H_ +#define RUNNER_FLUTTER_WINDOW_H_ + +#include +#include + +#include + +#include "win32_window.h" + +// A window that does nothing but host a Flutter view. +class FlutterWindow : public Win32Window { + public: + // Creates a new FlutterWindow hosting a Flutter view running |project|. + explicit FlutterWindow(const flutter::DartProject& project); + virtual ~FlutterWindow(); + + protected: + // Win32Window: + bool OnCreate() override; + void OnDestroy() override; + LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, + LPARAM const lparam) noexcept override; + + private: + // The project to run. + flutter::DartProject project_; + + // The Flutter instance hosted by this window. + std::unique_ptr flutter_controller_; +}; + +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/benchmarks/genq_benchmark/windows/runner/main.cpp b/benchmarks/genq_benchmark/windows/runner/main.cpp new file mode 100644 index 0000000..579953c --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include + +#include "flutter_window.h" +#include "utils.h" + +int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, + _In_ wchar_t *command_line, _In_ int show_command) { + // Attach to console when present (e.g., 'flutter run') or create a + // new console when running with a debugger. + if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { + CreateAndAttachConsole(); + } + + // Initialize COM, so that it is available for use in the library and/or + // plugins. + ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); + + flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + + FlutterWindow window(project); + Win32Window::Point origin(10, 10); + Win32Window::Size size(1280, 720); + if (!window.Create(L"genq_benchmark", origin, size)) { + return EXIT_FAILURE; + } + window.SetQuitOnClose(true); + + ::MSG msg; + while (::GetMessage(&msg, nullptr, 0, 0)) { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + + ::CoUninitialize(); + return EXIT_SUCCESS; +} diff --git a/benchmarks/genq_benchmark/windows/runner/resource.h b/benchmarks/genq_benchmark/windows/runner/resource.h new file mode 100644 index 0000000..66a65d1 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Runner.rc +// +#define IDI_APP_ICON 101 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/benchmarks/genq_benchmark/windows/runner/resources/app_icon.ico b/benchmarks/genq_benchmark/windows/runner/resources/app_icon.ico new file mode 100644 index 0000000..c04e20c Binary files /dev/null and b/benchmarks/genq_benchmark/windows/runner/resources/app_icon.ico differ diff --git a/benchmarks/genq_benchmark/windows/runner/runner.exe.manifest b/benchmarks/genq_benchmark/windows/runner/runner.exe.manifest new file mode 100644 index 0000000..a42ea76 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/runner.exe.manifest @@ -0,0 +1,20 @@ + + + + + PerMonitorV2 + + + + + + + + + + + + + + + diff --git a/benchmarks/genq_benchmark/windows/runner/utils.cpp b/benchmarks/genq_benchmark/windows/runner/utils.cpp new file mode 100644 index 0000000..b2b0873 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/utils.cpp @@ -0,0 +1,65 @@ +#include "utils.h" + +#include +#include +#include +#include + +#include + +void CreateAndAttachConsole() { + if (::AllocConsole()) { + FILE *unused; + if (freopen_s(&unused, "CONOUT$", "w", stdout)) { + _dup2(_fileno(stdout), 1); + } + if (freopen_s(&unused, "CONOUT$", "w", stderr)) { + _dup2(_fileno(stdout), 2); + } + std::ios::sync_with_stdio(); + FlutterDesktopResyncOutputStreams(); + } +} + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -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()) { + return utf8_string; + } + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + input_length, utf8_string.data(), target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/benchmarks/genq_benchmark/windows/runner/utils.h b/benchmarks/genq_benchmark/windows/runner/utils.h new file mode 100644 index 0000000..3879d54 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/utils.h @@ -0,0 +1,19 @@ +#ifndef RUNNER_UTILS_H_ +#define RUNNER_UTILS_H_ + +#include +#include + +// Creates a console for the process, and redirects stdout and stderr to +// it for both the runner and the Flutter library. +void CreateAndAttachConsole(); + +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + +#endif // RUNNER_UTILS_H_ diff --git a/benchmarks/genq_benchmark/windows/runner/win32_window.cpp b/benchmarks/genq_benchmark/windows/runner/win32_window.cpp new file mode 100644 index 0000000..60608d0 --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/win32_window.cpp @@ -0,0 +1,288 @@ +#include "win32_window.h" + +#include +#include + +#include "resource.h" + +namespace { + +/// Window attribute that enables dark mode window decorations. +/// +/// Redefined in case the developer's machine has a Windows SDK older than +/// version 10.0.22000.0. +/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE +#define DWMWA_USE_IMMERSIVE_DARK_MODE 20 +#endif + +constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; + +/// Registry key for app theme preference. +/// +/// A value of 0 indicates apps should use dark mode. A non-zero or missing +/// value indicates apps should use light mode. +constexpr const wchar_t kGetPreferredBrightnessRegKey[] = + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + +// The number of Win32Window objects that currently exist. +static int g_active_window_count = 0; + +using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); + +// Scale helper to convert logical scaler values to physical using passed in +// scale factor +int Scale(int source, double scale_factor) { + return static_cast(source * scale_factor); +} + +// Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. +// This API is only needed for PerMonitor V1 awareness mode. +void EnableFullDpiSupportIfAvailable(HWND hwnd) { + HMODULE user32_module = LoadLibraryA("User32.dll"); + if (!user32_module) { + return; + } + auto enable_non_client_dpi_scaling = + reinterpret_cast( + GetProcAddress(user32_module, "EnableNonClientDpiScaling")); + if (enable_non_client_dpi_scaling != nullptr) { + enable_non_client_dpi_scaling(hwnd); + } + FreeLibrary(user32_module); +} + +} // namespace + +// Manages the Win32Window's window class registration. +class WindowClassRegistrar { + public: + ~WindowClassRegistrar() = default; + + // Returns the singleton registrar instance. + static WindowClassRegistrar* GetInstance() { + if (!instance_) { + instance_ = new WindowClassRegistrar(); + } + return instance_; + } + + // Returns the name of the window class, registering the class if it hasn't + // previously been registered. + const wchar_t* GetWindowClass(); + + // Unregisters the window class. Should only be called if there are no + // instances of the window. + void UnregisterWindowClass(); + + private: + WindowClassRegistrar() = default; + + static WindowClassRegistrar* instance_; + + bool class_registered_ = false; +}; + +WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; + +const wchar_t* WindowClassRegistrar::GetWindowClass() { + if (!class_registered_) { + WNDCLASS window_class{}; + window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); + window_class.lpszClassName = kWindowClassName; + window_class.style = CS_HREDRAW | CS_VREDRAW; + window_class.cbClsExtra = 0; + window_class.cbWndExtra = 0; + window_class.hInstance = GetModuleHandle(nullptr); + window_class.hIcon = + LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); + window_class.hbrBackground = 0; + window_class.lpszMenuName = nullptr; + window_class.lpfnWndProc = Win32Window::WndProc; + RegisterClass(&window_class); + class_registered_ = true; + } + return kWindowClassName; +} + +void WindowClassRegistrar::UnregisterWindowClass() { + UnregisterClass(kWindowClassName, nullptr); + class_registered_ = false; +} + +Win32Window::Win32Window() { + ++g_active_window_count; +} + +Win32Window::~Win32Window() { + --g_active_window_count; + Destroy(); +} + +bool Win32Window::Create(const std::wstring& title, + const Point& origin, + const Size& size) { + Destroy(); + + const wchar_t* window_class = + WindowClassRegistrar::GetInstance()->GetWindowClass(); + + const POINT target_point = {static_cast(origin.x), + static_cast(origin.y)}; + HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); + UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); + double scale_factor = dpi / 96.0; + + HWND window = CreateWindow( + window_class, title.c_str(), WS_OVERLAPPEDWINDOW, + Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), + Scale(size.width, scale_factor), Scale(size.height, scale_factor), + nullptr, nullptr, GetModuleHandle(nullptr), this); + + if (!window) { + return false; + } + + UpdateTheme(window); + + return OnCreate(); +} + +bool Win32Window::Show() { + return ShowWindow(window_handle_, SW_SHOWNORMAL); +} + +// static +LRESULT CALLBACK Win32Window::WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + if (message == WM_NCCREATE) { + auto window_struct = reinterpret_cast(lparam); + SetWindowLongPtr(window, GWLP_USERDATA, + reinterpret_cast(window_struct->lpCreateParams)); + + auto that = static_cast(window_struct->lpCreateParams); + EnableFullDpiSupportIfAvailable(window); + that->window_handle_ = window; + } else if (Win32Window* that = GetThisFromHandle(window)) { + return that->MessageHandler(window, message, wparam, lparam); + } + + return DefWindowProc(window, message, wparam, lparam); +} + +LRESULT +Win32Window::MessageHandler(HWND hwnd, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept { + switch (message) { + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); + } + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); + } + return 0; + } + + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; + + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; + } + + return DefWindowProc(window_handle_, message, wparam, lparam); +} + +void Win32Window::Destroy() { + OnDestroy(); + + if (window_handle_) { + DestroyWindow(window_handle_); + window_handle_ = nullptr; + } + if (g_active_window_count == 0) { + WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); + } +} + +Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( + GetWindowLongPtr(window, GWLP_USERDATA)); +} + +void Win32Window::SetChildContent(HWND content) { + child_content_ = content; + SetParent(content, window_handle_); + RECT frame = GetClientArea(); + + MoveWindow(content, frame.left, frame.top, frame.right - frame.left, + frame.bottom - frame.top, true); + + SetFocus(child_content_); +} + +RECT Win32Window::GetClientArea() { + RECT frame; + GetClientRect(window_handle_, &frame); + return frame; +} + +HWND Win32Window::GetHandle() { + return window_handle_; +} + +void Win32Window::SetQuitOnClose(bool quit_on_close) { + quit_on_close_ = quit_on_close; +} + +bool Win32Window::OnCreate() { + // No-op; provided for subclasses. + return true; +} + +void Win32Window::OnDestroy() { + // No-op; provided for subclasses. +} + +void Win32Window::UpdateTheme(HWND const window) { + DWORD light_mode; + DWORD light_mode_size = sizeof(light_mode); + LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, + RRF_RT_REG_DWORD, nullptr, &light_mode, + &light_mode_size); + + if (result == ERROR_SUCCESS) { + BOOL enable_dark_mode = light_mode == 0; + DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, + &enable_dark_mode, sizeof(enable_dark_mode)); + } +} diff --git a/benchmarks/genq_benchmark/windows/runner/win32_window.h b/benchmarks/genq_benchmark/windows/runner/win32_window.h new file mode 100644 index 0000000..e901dde --- /dev/null +++ b/benchmarks/genq_benchmark/windows/runner/win32_window.h @@ -0,0 +1,102 @@ +#ifndef RUNNER_WIN32_WINDOW_H_ +#define RUNNER_WIN32_WINDOW_H_ + +#include + +#include +#include +#include + +// A class abstraction for a high DPI-aware Win32 Window. Intended to be +// inherited from by classes that wish to specialize with custom +// rendering and input handling +class Win32Window { + public: + struct Point { + unsigned int x; + unsigned int y; + Point(unsigned int x, unsigned int y) : x(x), y(y) {} + }; + + struct Size { + unsigned int width; + unsigned int height; + Size(unsigned int width, unsigned int height) + : width(width), height(height) {} + }; + + Win32Window(); + virtual ~Win32Window(); + + // Creates a win32 window with |title| that is positioned and sized using + // |origin| and |size|. New windows are created on the default monitor. Window + // sizes are specified to the OS in physical pixels, hence to ensure a + // consistent size this function will scale the inputted width and height as + // as appropriate for the default monitor. The window is invisible until + // |Show| is called. Returns true if the window was created successfully. + bool Create(const std::wstring& title, const Point& origin, const Size& size); + + // Show the current window. Returns true if the window was successfully shown. + bool Show(); + + // Release OS resources associated with window. + void Destroy(); + + // Inserts |content| into the window tree. + void SetChildContent(HWND content); + + // Returns the backing Window handle to enable clients to set icon and other + // window properties. Returns nullptr if the window has been destroyed. + HWND GetHandle(); + + // If true, closing this window will quit the application. + void SetQuitOnClose(bool quit_on_close); + + // Return a RECT representing the bounds of the current client area. + RECT GetClientArea(); + + protected: + // Processes and route salient window messages for mouse handling, + // size change and DPI. Delegates handling of these to member overloads that + // inheriting classes can handle. + virtual LRESULT MessageHandler(HWND window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Called when CreateAndShow is called, allowing subclass window-related + // setup. Subclasses should return false if setup fails. + virtual bool OnCreate(); + + // Called when Destroy is called. + virtual void OnDestroy(); + + private: + friend class WindowClassRegistrar; + + // 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 + // responds to changes in DPI. All other messages are handled by + // MessageHandler. + static LRESULT CALLBACK WndProc(HWND const window, + UINT const message, + WPARAM const wparam, + LPARAM const lparam) noexcept; + + // Retrieves a class instance pointer for |window| + static Win32Window* GetThisFromHandle(HWND const window) noexcept; + + // Update the window frame's theme to match the system theme. + static void UpdateTheme(HWND const window); + + bool quit_on_close_ = false; + + // window handle for top level window. + HWND window_handle_ = nullptr; + + // window handle for hosted content. + HWND child_content_ = nullptr; +}; + +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/docs/freezed.png b/docs/freezed.png new file mode 100644 index 0000000..e0e6658 Binary files /dev/null and b/docs/freezed.png differ diff --git a/docs/genq.png b/docs/genq.png new file mode 100644 index 0000000..37fc066 Binary files /dev/null and b/docs/genq.png differ diff --git a/docs/logo.png b/docs/logo.png new file mode 100644 index 0000000..82687a1 Binary files /dev/null and b/docs/logo.png differ diff --git a/docs/preview.gif b/docs/preview.gif new file mode 100644 index 0000000..bf3cea6 Binary files /dev/null and b/docs/preview.gif differ diff --git a/packages/genq/.gitignore b/packages/genq/.gitignore new file mode 100644 index 0000000..3cceda5 --- /dev/null +++ b/packages/genq/.gitignore @@ -0,0 +1,7 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ + +# Avoid committing pubspec.lock for library packages; see +# https://dart.dev/guides/libraries/private-files#pubspeclock. +pubspec.lock diff --git a/packages/genq/CHANGELOG.md b/packages/genq/CHANGELOG.md new file mode 100644 index 0000000..02ec50f --- /dev/null +++ b/packages/genq/CHANGELOG.md @@ -0,0 +1,7 @@ +## 0.2.0 + +- Add collection dependency to pubspec.yaml + +## 0.1.0 + +- Initial version. diff --git a/packages/genq/LICENSE b/packages/genq/LICENSE new file mode 100644 index 0000000..fd206d1 --- /dev/null +++ b/packages/genq/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Jan Kuß + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/genq/README.md b/packages/genq/README.md new file mode 100644 index 0000000..6f182d4 --- /dev/null +++ b/packages/genq/README.md @@ -0,0 +1,3 @@ +# qenq annotations + +This package contains the annotations for genq. For further information, please visit the [genq](https://github.com/jankuss/genq) repository. diff --git a/packages/genq/analysis_options.yaml b/packages/genq/analysis_options.yaml new file mode 100644 index 0000000..dee8927 --- /dev/null +++ b/packages/genq/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/packages/genq/lib/genq.dart b/packages/genq/lib/genq.dart new file mode 100644 index 0000000..c286e17 --- /dev/null +++ b/packages/genq/lib/genq.dart @@ -0,0 +1,3 @@ +library; + +export 'src/annotation.dart'; diff --git a/packages/genq/lib/src/annotation.dart b/packages/genq/lib/src/annotation.dart new file mode 100644 index 0000000..c97b293 --- /dev/null +++ b/packages/genq/lib/src/annotation.dart @@ -0,0 +1,8 @@ +export 'package:collection/collection.dart' show DeepCollectionEquality; + +class Genq { + const Genq(); +} + +const genq = Genq(); + diff --git a/packages/genq/pubspec.yaml b/packages/genq/pubspec.yaml new file mode 100644 index 0000000..5c9a915 --- /dev/null +++ b/packages/genq/pubspec.yaml @@ -0,0 +1,15 @@ +name: genq +description: Annotations for the genq code generator. +version: 0.2.0 +repository: https://github.com/jankuss/genq + +environment: + sdk: ^3.2.3 + +# Add regular dependencies here. +dependencies: + collection: ^1.18.0 + +dev_dependencies: + lints: ^2.1.0 + test: ^1.24.0 diff --git a/packages/genq_test/.gitignore b/packages/genq_test/.gitignore new file mode 100644 index 0000000..fc7994f --- /dev/null +++ b/packages/genq_test/.gitignore @@ -0,0 +1,4 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ +/genq diff --git a/packages/genq_test/analysis_options.yaml b/packages/genq_test/analysis_options.yaml new file mode 100644 index 0000000..dee8927 --- /dev/null +++ b/packages/genq_test/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/packages/genq_test/lib/test_classes.dart b/packages/genq_test/lib/test_classes.dart new file mode 100644 index 0000000..92cc089 --- /dev/null +++ b/packages/genq_test/lib/test_classes.dart @@ -0,0 +1,32 @@ +import 'package:genq/genq.dart'; + +part 'test_classes.genq.dart'; + +@genq +class User with _$User { + factory User({ + required String username, + required String email, + required int? age, + Address? address, + }) = _User; +} + +@genq +class Address with _$Address { + factory Address({ + required String street, + required int zipCode, + required String city, + }) = _Address; +} + +@genq +class CollectionTests with _$CollectionTests { + factory CollectionTests({ + required List users, + required Map userMap, + required Set userSet, + }) = _CollectionTests; +} + diff --git a/packages/genq_test/lib/test_classes.genq.dart b/packages/genq_test/lib/test_classes.genq.dart new file mode 100644 index 0000000..c67971c --- /dev/null +++ b/packages/genq_test/lib/test_classes.genq.dart @@ -0,0 +1,251 @@ +part of 'test_classes.dart'; + +mixin _$User { + String get username => throw UnimplementedError(); + String get email => throw UnimplementedError(); + int? get age => throw UnimplementedError(); + Address? get address => throw UnimplementedError(); + + $UserCopyWith get copyWith => throw UnimplementedError(); +} + +class _User implements User { + @override + final String username; + + @override + final String email; + + @override + final int? age; + + @override + final Address? address; + + _User({ + required this.username, + required this.email, + required this.age, + this.address, + }); + + @override + $UserCopyWith get copyWith => _$UserCopyWithImpl(this); + + @override + String toString() { + return "User(username: $username, email: $email, age: $age, address: $address)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! User) return false; + if (!identical(other.username, username) && other.username != username) return false; + if (!identical(other.email, email) && other.email != email) return false; + if (!identical(other.age, age) && other.age != age) return false; + if (!identical(other.address, address) && other.address != address) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + username, + email, + age, + address, + ); + } +} + +abstract class $UserCopyWith { + User call({ + String username, + String email, + int? age, + Address? address, + }); +} + +class _$UserCopyWithImpl implements $UserCopyWith { + final _$User value; + + _$UserCopyWithImpl(this.value); + + @override + User call({ + Object? username = genq, + Object? email = genq, + Object? age = genq, + Object? address = genq, + }) { + return User( + username: username == genq ? value.username : username as String, + email: email == genq ? value.email : email as String, + age: age == genq ? value.age : age as int?, + address: address == genq ? value.address : address as Address?, + ); + } +} + +mixin _$Address { + String get street => throw UnimplementedError(); + int get zipCode => throw UnimplementedError(); + String get city => throw UnimplementedError(); + + $AddressCopyWith get copyWith => throw UnimplementedError(); +} + +class _Address implements Address { + @override + final String street; + + @override + final int zipCode; + + @override + final String city; + + _Address({ + required this.street, + required this.zipCode, + required this.city, + }); + + @override + $AddressCopyWith get copyWith => _$AddressCopyWithImpl(this); + + @override + String toString() { + return "Address(street: $street, zipCode: $zipCode, city: $city)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! Address) return false; + if (!identical(other.street, street) && other.street != street) return false; + if (!identical(other.zipCode, zipCode) && other.zipCode != zipCode) return false; + if (!identical(other.city, city) && other.city != city) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + street, + zipCode, + city, + ); + } +} + +abstract class $AddressCopyWith { + Address call({ + String street, + int zipCode, + String city, + }); +} + +class _$AddressCopyWithImpl implements $AddressCopyWith { + final _$Address value; + + _$AddressCopyWithImpl(this.value); + + @override + Address call({ + Object? street = genq, + Object? zipCode = genq, + Object? city = genq, + }) { + return Address( + street: street == genq ? value.street : street as String, + zipCode: zipCode == genq ? value.zipCode : zipCode as int, + city: city == genq ? value.city : city as String, + ); + } +} + +mixin _$CollectionTests { + List get users => throw UnimplementedError(); + Map get userMap => throw UnimplementedError(); + Set get userSet => throw UnimplementedError(); + + $CollectionTestsCopyWith get copyWith => throw UnimplementedError(); +} + +class _CollectionTests implements CollectionTests { + @override + final List users; + + @override + final Map userMap; + + @override + final Set userSet; + + _CollectionTests({ + required this.users, + required this.userMap, + required this.userSet, + }); + + @override + $CollectionTestsCopyWith get copyWith => _$CollectionTestsCopyWithImpl(this); + + @override + String toString() { + return "CollectionTests(users: $users, userMap: $userMap, userSet: $userSet)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! CollectionTests) return false; + if (!const DeepCollectionEquality().equals(other.users, users)) return false; + if (!const DeepCollectionEquality().equals(other.userMap, userMap)) return false; + if (!const DeepCollectionEquality().equals(other.userSet, userSet)) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + users, + userMap, + userSet, + ); + } +} + +abstract class $CollectionTestsCopyWith { + CollectionTests call({ + List users, + Map userMap, + Set userSet, + }); +} + +class _$CollectionTestsCopyWithImpl implements $CollectionTestsCopyWith { + final _$CollectionTests value; + + _$CollectionTestsCopyWithImpl(this.value); + + @override + CollectionTests call({ + Object? users = genq, + Object? userMap = genq, + Object? userSet = genq, + }) { + return CollectionTests( + users: users == genq ? value.users : users as List, + userMap: userMap == genq ? value.userMap : userMap as Map, + userSet: userSet == genq ? value.userSet : userSet as Set, + ); + } +} \ No newline at end of file diff --git a/packages/genq_test/pubspec.lock b/packages/genq_test/pubspec.lock new file mode 100644 index 0000000..45ab6d9 --- /dev/null +++ b/packages/genq_test/pubspec.lock @@ -0,0 +1,388 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" + url: "https://pub.dev" + source: hosted + version: "67.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" + url: "https://pub.dev" + source: hosted + version: "6.4.1" + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + coverage: + dependency: transitive + description: + name: coverage + sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" + url: "https://pub.dev" + source: hosted + version: "1.7.2" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694 + url: "https://pub.dev" + source: hosted + version: "4.0.0" + genq: + dependency: "direct main" + description: + path: "../genq" + relative: true + source: path + version: "0.1.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + js: + dependency: transitive + description: + name: js + sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + url: "https://pub.dev" + source: hosted + version: "0.7.1" + lints: + dependency: "direct dev" + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + url: "https://pub.dev" + source: hosted + version: "0.12.16+1" + meta: + dependency: transitive + description: + name: meta + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + url: "https://pub.dev" + source: hosted + version: "1.12.0" + mime: + dependency: transitive + description: + name: mime + sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2" + url: "https://pub.dev" + source: hosted + version: "1.0.5" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" + source: hosted + version: "1.9.0" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e + url: "https://pub.dev" + source: hosted + version: "1.1.2" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" + url: "https://pub.dev" + source: hosted + version: "0.10.12" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" + source: hosted + version: "2.1.2" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test: + dependency: "direct dev" + description: + name: test + sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073" + url: "https://pub.dev" + source: hosted + version: "1.25.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" + url: "https://pub.dev" + source: hosted + version: "0.7.0" + test_core: + dependency: transitive + description: + name: test_core + sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4" + url: "https://pub.dev" + source: hosted + version: "0.6.0" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: a2662fb1f114f4296cf3f5a50786a2d888268d7776cf681aa17d660ffa23b246 + url: "https://pub.dev" + source: hosted + version: "14.0.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05" + url: "https://pub.dev" + source: hosted + version: "0.4.2" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: "939ab60734a4f8fa95feacb55804fa278de28bdeef38e616dc08e44a84adea23" + url: "https://pub.dev" + source: hosted + version: "2.4.3" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" +sdks: + dart: ">=3.2.3 <4.0.0" diff --git a/packages/genq_test/pubspec.yaml b/packages/genq_test/pubspec.yaml new file mode 100644 index 0000000..84642ab --- /dev/null +++ b/packages/genq_test/pubspec.yaml @@ -0,0 +1,15 @@ +name: genq_test +description: A sample command-line application. +version: 1.0.0 +publish_to: none + +environment: + sdk: ^3.2.3 + +dependencies: + genq: + path: ../genq + +dev_dependencies: + lints: ^2.1.0 + test: ^1.24.0 diff --git a/packages/genq_test/run_tests.sh b/packages/genq_test/run_tests.sh new file mode 100755 index 0000000..feacba8 --- /dev/null +++ b/packages/genq_test/run_tests.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -e + +(cd ../../tool && go build .) +cp ../../tool/genq . + +./genq + +dart test diff --git a/packages/genq_test/test/genq_test_test.dart b/packages/genq_test/test/genq_test_test.dart new file mode 100644 index 0000000..a3c92db --- /dev/null +++ b/packages/genq_test/test/genq_test_test.dart @@ -0,0 +1,254 @@ +import 'package:genq_test/test_classes.dart'; +import 'package:test/test.dart'; + +void main() { + test('copyWith creates a new class with changes applied', () { + final user = User( + username: 'Jan', + email: 'jan@kuss.dev', + age: null, + ); + + final updatedUser = user.copyWith(username: 'Jan Kuß'); + + expect(updatedUser.username, 'Jan Kuß'); + expect(updatedUser.email, 'jan@kuss.dev'); + expect(updatedUser.age, null); + expect(user, isNot(equals(updatedUser))); + }); + + test('copyWith can unset nullable values', () { + final user = User( + username: 'Jan', + email: 'jan@kuss.dev', + age: 55, + address: Address( + street: 'Kussstraße 42', + zipCode: 12345, + city: 'Kussstadt', + ), + ); + + expect(user.age, isNotNull); + expect(user.address, isNotNull); + final updatedUser = user.copyWith(age: null, address: null); + expect(updatedUser.age, null); + expect(updatedUser.address, null); + }); + + test('copyWith can copy deeply', () { + final user = User( + username: 'Jan', + email: 'jan@kuss.dev', + age: 55, + address: Address( + street: 'Kussstraße 42', + zipCode: 12345, + city: 'Kussstadt', + ), + ); + + final updatedUser = user.copyWith( + username: 'Jannik', + address: user.address?.copyWith( + street: 'Kussstraße 43', + zipCode: 12346, + city: 'Kussdorf', + ), + ); + + expect(updatedUser.username, 'Jannik'); + expect(updatedUser.address?.street, 'Kussstraße 43'); + expect(updatedUser.address?.zipCode, 12346); + expect(updatedUser.address?.city, 'Kussdorf'); + }); + + test('empty copyWith creates a new instance that is equal', () { + final user = User( + username: 'Jan', + email: 'jan@kuss.dev', + age: null, + ); + + final updatedUser = user.copyWith(); + expect(identical(user, updatedUser), false); + expect(user, equals(updatedUser)); + }); + + test('== is true for equal objects', () { + final user1 = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + final user2 = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + + expect(user1, equals(user2)); + }); + + test('== is false for not equal objects (differ in age)', () { + final user1 = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + final user2 = User(username: 'Jan', email: 'jan@kuss.dev', age: 52); + + expect(user1, isNot(equals(user2))); + }); + + test('== is false for not equal objects (differ in email)', () { + final user1 = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + final user2 = User(username: 'Jan', email: 'jan@kuss.de', age: 52); + + expect(user1, isNot(equals(user2))); + }); + + test('== is false for not equal objects (differ in name and email)', () { + final user1 = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + final user2 = User(username: 'Jannik', email: 'jannik@kuss.de', age: 52); + + expect(user1, isNot(equals(user2))); + }); + + test('== is true for identical instance', () { + final user1 = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + + expect(user1, equals(user1)); + }); + + test('== is false for different type', () { + final user = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + final address = + Address(street: 'Kussstraße 42', zipCode: 12345, city: 'Kussstadt'); + + expect(user, isNot(equals(address))); + }); + + test('== is true for deeply copied', () { + final address = + Address(street: 'Kussstraße 42', zipCode: 12345, city: 'Kussstadt'); + final user = + User(username: 'Jan', email: 'jan@kuss.dev', age: 42, address: address); + final user2 = user.copyWith(address: address.copyWith()); + + expect(user, equals(user2)); + }); + + test('hashCode is equal for equal objects', () { + final user1 = User( + username: 'Jan', + email: 'max@mustermann.de', + age: 52, + ); + final user2 = User( + username: 'Jan', + email: 'max@mustermann.de', + age: 52, + ); + + expect(user1.hashCode, equals(user2.hashCode)); + }); + + test('hashCode is not equal for differing objects', () { + final user1 = User( + username: 'Max', + email: 'max@mustermann.de', + age: 52, + ); + final user2 = User( + username: 'Max', + email: 'max@mustermann.de', + age: 42, + ); + + expect(user1.hashCode, isNot(equals(user2.hashCode))); + }); + + test('toString returns a string representation', () { + final user1 = User( + username: 'Max', + email: 'max@mustermann.de', + age: 52, + ); + + expect( + user1.toString(), + equals( + "User(username: Max, email: max@mustermann.de, age: 52, address: null)")); + }); + + test('== returns true for same collections', () { + final user = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + final collectionTests1 = CollectionTests( + users: [user], + userMap: {"1": user}, + userSet: { + user, + }, + ); + final collectionTests2 = CollectionTests( + users: [user], + userMap: {"1": user}, + userSet: { + user, + }, + ); + + expect(collectionTests1, equals(collectionTests2)); + }); + + test('== returns false for modified list', () { + final user = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + final collectionTests1 = CollectionTests( + users: [user], + userMap: {"1": user}, + userSet: { + user, + }, + ); + final collectionTests2 = CollectionTests( + users: [user, user], + userMap: {"1": user}, + userSet: { + user, + }, + ); + + expect(collectionTests1, isNot(equals(collectionTests2))); + }); + + test('== returns false for modified map', () { + final user = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + final collectionTests1 = CollectionTests( + users: [user], + userMap: {"1": user}, + userSet: { + user, + }, + ); + final collectionTests2 = CollectionTests( + users: [user], + userMap: {"1": user, "2": user}, + userSet: { + user, + }, + ); + + expect(collectionTests1, isNot(equals(collectionTests2))); + }); + + test('== returns false for modified set', () { + final user = User(username: 'Jan', email: 'jan@kuss.dev', age: 42); + final user2 = User(username: 'Jannik', email: 'jan@kuss.dev', age: 42); + final collectionTests1 = CollectionTests( + users: [user], + userMap: {"1": user}, + userSet: { + user, + }, + ); + final collectionTests2 = CollectionTests( + users: [user], + userMap: {"1": user}, + userSet: { + user, + user2, + }, + ); + + expect(collectionTests1, isNot(equals(collectionTests2))); + }); +} diff --git a/tool/.gitignore b/tool/.gitignore new file mode 100644 index 0000000..cde0123 --- /dev/null +++ b/tool/.gitignore @@ -0,0 +1,2 @@ + +dist/ diff --git a/tool/.goreleaser.yaml b/tool/.goreleaser.yaml new file mode 100644 index 0000000..e5b35c1 --- /dev/null +++ b/tool/.goreleaser.yaml @@ -0,0 +1,58 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 1 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" +brews: + - + name: genq + license: "MIT" + repository: + owner: jankuss + name: homebrew-genq + branch: main + token: "{{ .Env.GH_BREW }}" + pull_request: + # Whether to enable it or not. + enabled: true diff --git a/tool/cli/generate.go b/tool/cli/generate.go new file mode 100644 index 0000000..6bf6283 --- /dev/null +++ b/tool/cli/generate.go @@ -0,0 +1,119 @@ +package cli + +import ( + "fmt" + "genq/generation" + "os" + "os/exec" + "path/filepath" + "strings" + "sync" +) + +func pre(str string) string { + return "> " + str +} + +func PrintError(path string, error generation.GenerateResultError) { + fmt.Println() + fmt.Printf("Error when parsing: %s:%d\n", path, error.Context.Line+1) + fmt.Println(pre(error.Context.LineString)) + + str := "" + for i := 0; i < error.Context.PosInLine-1; i++ { + str = str + " " + } + str = str + "^" + + fmt.Println(pre(str)) + fmt.Println(pre(error.Error.Err.Error())) +} + +type resWithPath struct { + path string + res generation.GenerateResult +} + +func generate(path string, format bool) { + fmt.Println("ℹ️ Generating code for:", path) + messages := make(chan resWithPath) + + wg := sync.WaitGroup{} + totalCount := 0 + filepath.Walk(path, func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + + if info.IsDir() { + return nil + } + + wg.Add(1) + totalCount++ + go func() { + defer wg.Done() + res, err := generation.Generate(path, ReadString) + + if err != nil { + return + } + + if len(res.WriteString) > 0 { + os.WriteFile(res.OutputFile, []byte(strings.Join(res.WriteString, "\n")), 0644) + } + + messages <- resWithPath{ + path: path, + res: res, + } + }() + + return nil + }) + + go func() { + wg.Wait() + close(messages) + }() + + resCount := 0 + genCount := 0 + args := []string{"format"} + fmt.Print("\033[s") + for i := range messages { + genCount += i.res.GenCount + + resCount++ + fmt.Print("\033[u\033[K") + fmt.Printf("📝 Generated %s", i.res.OutputFile) + + if len(i.res.Errors) > 0 { + for _, error := range i.res.Errors { + PrintError(i.path, error) + } + } + + if !i.res.Noop { + args = append(args, i.res.OutputFile) + } + } + + println() + + fmt.Printf("✅ Generated %d data classes\n", genCount) + + if format { + fmt.Printf("ℹ️ Running 'dart format' on %d files\n", len(args)-1) + exec.Command("dart", args...).Run() + } +} + +func ReadString(p string) (string, error) { + b, err := os.ReadFile(p) + if err != nil { + return "", err + } + + return string(b), nil +} diff --git a/tool/cli/root.go b/tool/cli/root.go new file mode 100644 index 0000000..382e24b --- /dev/null +++ b/tool/cli/root.go @@ -0,0 +1,89 @@ +package cli + +import ( + "fmt" + "log" + "os" + + "github.com/fsnotify/fsnotify" + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "genq", + Short: "genq is a blazingly fast code generator for Dart and Flutter", + Run: func(cmd *cobra.Command, args []string) { + inputPath, err := cmd.Flags().GetString("input") + if err != nil { + panic(err) + } + + format, err := cmd.Flags().GetBool("format") + if err != nil { + panic(err) + } + + fmt.Println(" __ _ ___ _ __ __ _ ") + fmt.Println(" / _` |/ _ \\ '_ \\ / _` |") + fmt.Println(" | (_| | __/ | | | (_| |") + fmt.Println(" \\__, |\\___|_| |_|\\__, |") + fmt.Println(" __/ | | |") + fmt.Println(" |___/ |_|") + fmt.Println() + fmt.Println("===================================================") + fmt.Println("Blazingly fast code generator for Dart and Flutter") + fmt.Println("===================================================") + fmt.Println() + + generate(inputPath, format) + + watch, err := cmd.Flags().GetBool("watch") + if err != nil { + panic(err) + } + + if watch { + watcher, err := fsnotify.NewWatcher() + if err != nil { + panic(err) + } + defer watcher.Close() + go func() { + for { + select { + case event, ok := <-watcher.Events: + if !ok { + return + } + if event.Has(fsnotify.Write) || event.Has(fsnotify.Create) || event.Has(fsnotify.Remove) || event.Has(fsnotify.Rename) { + generate(event.Name, format) + } + case err, ok := <-watcher.Errors: + if !ok { + return + } + log.Println("error:", err) + } + } + }() + + err = watcher.Add(inputPath) + if err != nil { + panic(err) + } + fmt.Println("Watching for changes...") + <-make(chan struct{}) + } + }, +} + +func Execute() { + rootCmd.Flags().StringP("input", "i", ".", "The input file or directory to generate code from") + rootCmd.Flags().BoolP("watch", "w", false, "Watch for changes and regenerate code") + rootCmd.Flags().BoolP("format", "f", false, "Format the generated code with dart format") + + if err := rootCmd.Execute(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} diff --git a/tool/generation/generate.go b/tool/generation/generate.go new file mode 100644 index 0000000..82878c3 --- /dev/null +++ b/tool/generation/generate.go @@ -0,0 +1,157 @@ +package generation + +import ( + "fmt" + . "genq/parser" + . "genq/templates" + "path/filepath" + "strings" + "time" +) + +// Given a string and a position, return the line number, the position in the +// line and the string of the line +func GetContextForPosition(input string, pos int) ContextForPosition { + line := 0 + posInLine := 0 + lineString := "" + + for i, value := range input { + if value == '\n' { + lineString = "" + posInLine = 0 + line++ + } else { + lineString = lineString + string(value) + } + + if pos == i { + break + } + + posInLine++ + } + + for _, value := range input[pos+1:] { + if value == '\n' { + break + } + + lineString = lineString + string(value) + } + + return ContextForPosition{ + Line: line, + PosInLine: posInLine, + LineString: lineString, + } +} + +type ContextForPosition struct { + Line int + PosInLine int + LineString string +} + +type GenerateResultError struct { + Error *ParsingError + Context ContextForPosition +} + +type GenerateResult struct { + OutputFile string + Noop bool + Duration time.Duration + Errors []GenerateResultError + WriteString []string + GenCount int +} +type ReadContent func(path string) (string, error) + +func Generate(path string, readContent ReadContent) (GenerateResult, error) { + start := time.Now() + + ext := filepath.Ext(path) + if ext != ".dart" { + return GenerateResult{}, fmt.Errorf("File %s is not a Dart file", path) + } + + if strings.HasSuffix(path, ".genq.dart") { + return GenerateResult{Noop: true}, nil + } + + extLength := len(ext) + + bytes, err := readContent(path) + if err != nil { + return GenerateResult{}, err + } + + str := string(bytes) + + generatorContext := &generatorContext{} + listener := &generatorParserListener{ + generatorContext: generatorContext, + genCount: 0, + } + + parser := NewParser(str) + parseResult := parser.Parse(listener) + generateErrors := []GenerateResultError{} + + if len(parseResult.Errors) > 0 { + for _, value := range parseResult.Errors { + generateErrors = append(generateErrors, GenerateResultError{ + Context: GetContextForPosition(str, value.Pos), + Error: value, + }) + } + } + + if len(generatorContext.outputLines) > 0 { + generatedPath := path[:len(path)-extLength] + ".genq" + ext + partOf := fmt.Sprintf("part of '%s';", filepath.Base(path)) + + allLines := append([]string{partOf, ""}, generatorContext.outputLines...) + + if err != nil { + return GenerateResult{}, err + } + + return GenerateResult{OutputFile: generatedPath, Duration: time.Since(start), Errors: generateErrors, WriteString: allLines, GenCount: listener.genCount}, nil + } + + return GenerateResult{Noop: true, Errors: generateErrors}, nil +} + +type generatorParserListener struct { + generatorContext *generatorContext + genCount int +} + +func (l *generatorParserListener) OnGenqClass(genqClass GenqClass) { + if l.genCount > 0 { + l.generatorContext.addOutput([]string{""}) + } + + l.generatorContext.addOutput(Template([]string{}, genqClass)) + + // JSON Generation is not production ready yet + // if genqClass.HasJsonConstructor { + // l.generatorContext.addOutput([]string{""}) + // l.generatorContext.addOutput(TemplateFromJson([]string{}, genqClass)) + // } + + l.genCount++ +} + +type generatorContext struct { + count int + outputLines []string +} + +func (ctx *generatorContext) addOutput(lines []string) { + for _, line := range lines { + ctx.outputLines = append(ctx.outputLines, line) + } +} diff --git a/tool/generation_test/fixtures/.gitignore b/tool/generation_test/fixtures/.gitignore new file mode 100644 index 0000000..f46c1ec --- /dev/null +++ b/tool/generation_test/fixtures/.gitignore @@ -0,0 +1 @@ +.dart_tool diff --git a/tool/generation_test/fixtures/additional_members/input.dart b/tool/generation_test/fixtures/additional_members/input.dart new file mode 100644 index 0000000..ae9c8fa --- /dev/null +++ b/tool/generation_test/fixtures/additional_members/input.dart @@ -0,0 +1,33 @@ +import 'package:genq/genq.dart'; + +part "input.genq.dart"; + +@genq +class User with _$User { + User._(); + factory User({ + required String name, + required int? age, + required bool registered, + required Address address, + }) = _User; + + String _getIntroduction() { + return "My name is $name and I'm $age years old."; + } + + void printAddress() { + print("${_getIntroduction()} I live at ${address.street} in ${address.zipCode} ${address.city}"); + } +} + +@genq +class Address with _$Address { + factory Address({ + required String street, + required int zipCode, + required String city, + }) = _Address; +} + + diff --git a/tool/generation_test/fixtures/additional_members/input.genq.dart b/tool/generation_test/fixtures/additional_members/input.genq.dart new file mode 100644 index 0000000..903a397 --- /dev/null +++ b/tool/generation_test/fixtures/additional_members/input.genq.dart @@ -0,0 +1,171 @@ +part of 'input.dart'; + +mixin _$User { + String get name => throw UnimplementedError(); + int? get age => throw UnimplementedError(); + bool get registered => throw UnimplementedError(); + Address get address => throw UnimplementedError(); + + $UserCopyWith get copyWith => throw UnimplementedError(); +} + +class _User extends User { + @override + final String name; + + @override + final int? age; + + @override + final bool registered; + + @override + final Address address; + + _User({ + required this.name, + required this.age, + required this.registered, + required this.address, + }) : super._(); + + @override + $UserCopyWith get copyWith => _$UserCopyWithImpl(this); + + @override + String toString() { + return "User(name: $name, age: $age, registered: $registered, address: $address)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! User) return false; + if (!identical(other.name, name) && other.name != name) return false; + if (!identical(other.age, age) && other.age != age) return false; + if (!identical(other.registered, registered) && other.registered != registered) return false; + if (!identical(other.address, address) && other.address != address) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + name, + age, + registered, + address, + ); + } +} + +abstract class $UserCopyWith { + User call({ + String name, + int? age, + bool registered, + Address address, + }); +} + +class _$UserCopyWithImpl implements $UserCopyWith { + final _$User value; + + _$UserCopyWithImpl(this.value); + + @override + User call({ + Object? name = genq, + Object? age = genq, + Object? registered = genq, + Object? address = genq, + }) { + return User( + name: name == genq ? value.name : name as String, + age: age == genq ? value.age : age as int?, + registered: registered == genq ? value.registered : registered as bool, + address: address == genq ? value.address : address as Address, + ); + } +} + +mixin _$Address { + String get street => throw UnimplementedError(); + int get zipCode => throw UnimplementedError(); + String get city => throw UnimplementedError(); + + $AddressCopyWith get copyWith => throw UnimplementedError(); +} + +class _Address implements Address { + @override + final String street; + + @override + final int zipCode; + + @override + final String city; + + _Address({ + required this.street, + required this.zipCode, + required this.city, + }); + + @override + $AddressCopyWith get copyWith => _$AddressCopyWithImpl(this); + + @override + String toString() { + return "Address(street: $street, zipCode: $zipCode, city: $city)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! Address) return false; + if (!identical(other.street, street) && other.street != street) return false; + if (!identical(other.zipCode, zipCode) && other.zipCode != zipCode) return false; + if (!identical(other.city, city) && other.city != city) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + street, + zipCode, + city, + ); + } +} + +abstract class $AddressCopyWith { + Address call({ + String street, + int zipCode, + String city, + }); +} + +class _$AddressCopyWithImpl implements $AddressCopyWith { + final _$Address value; + + _$AddressCopyWithImpl(this.value); + + @override + Address call({ + Object? street = genq, + Object? zipCode = genq, + Object? city = genq, + }) { + return Address( + street: street == genq ? value.street : street as String, + zipCode: zipCode == genq ? value.zipCode : zipCode as int, + city: city == genq ? value.city : city as String, + ); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/class_with_multiple_param/input.dart b/tool/generation_test/fixtures/class_with_multiple_param/input.dart new file mode 100644 index 0000000..84386fd --- /dev/null +++ b/tool/generation_test/fixtures/class_with_multiple_param/input.dart @@ -0,0 +1,12 @@ +import 'package:genq/genq.dart'; + +part "input.genq.dart"; + +@genq +class User with _$User { + factory User({ + required String name, + required int? age, + required bool registered, + }) = _User; +} diff --git a/tool/generation_test/fixtures/class_with_multiple_param/input.genq.dart b/tool/generation_test/fixtures/class_with_multiple_param/input.genq.dart new file mode 100644 index 0000000..61aaa4b --- /dev/null +++ b/tool/generation_test/fixtures/class_with_multiple_param/input.genq.dart @@ -0,0 +1,81 @@ +part of 'input.dart'; + +mixin _$User { + String get name => throw UnimplementedError(); + int? get age => throw UnimplementedError(); + bool get registered => throw UnimplementedError(); + + $UserCopyWith get copyWith => throw UnimplementedError(); +} + +class _User implements User { + @override + final String name; + + @override + final int? age; + + @override + final bool registered; + + _User({ + required this.name, + required this.age, + required this.registered, + }); + + @override + $UserCopyWith get copyWith => _$UserCopyWithImpl(this); + + @override + String toString() { + return "User(name: $name, age: $age, registered: $registered)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! User) return false; + if (!identical(other.name, name) && other.name != name) return false; + if (!identical(other.age, age) && other.age != age) return false; + if (!identical(other.registered, registered) && other.registered != registered) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + name, + age, + registered, + ); + } +} + +abstract class $UserCopyWith { + User call({ + String name, + int? age, + bool registered, + }); +} + +class _$UserCopyWithImpl implements $UserCopyWith { + final _$User value; + + _$UserCopyWithImpl(this.value); + + @override + User call({ + Object? name = genq, + Object? age = genq, + Object? registered = genq, + }) { + return User( + name: name == genq ? value.name : name as String, + age: age == genq ? value.age : age as int?, + registered: registered == genq ? value.registered : registered as bool, + ); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/class_with_single_optional_param/input.dart b/tool/generation_test/fixtures/class_with_single_optional_param/input.dart new file mode 100644 index 0000000..8287a6b --- /dev/null +++ b/tool/generation_test/fixtures/class_with_single_optional_param/input.dart @@ -0,0 +1,10 @@ +import 'package:genq/genq.dart'; + +part "input.genq.dart"; + +@genq +class Test with _$Test { + factory Test({ + required int? param1, + }) = _Test; +} diff --git a/tool/generation_test/fixtures/class_with_single_optional_param/input.genq.dart b/tool/generation_test/fixtures/class_with_single_optional_param/input.genq.dart new file mode 100644 index 0000000..8600f91 --- /dev/null +++ b/tool/generation_test/fixtures/class_with_single_optional_param/input.genq.dart @@ -0,0 +1,61 @@ +part of 'input.dart'; + +mixin _$Test { + int? get param1 => throw UnimplementedError(); + + $TestCopyWith get copyWith => throw UnimplementedError(); +} + +class _Test implements Test { + @override + final int? param1; + + _Test({ + required this.param1, + }); + + @override + $TestCopyWith get copyWith => _$TestCopyWithImpl(this); + + @override + String toString() { + return "Test(param1: $param1)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! Test) return false; + if (!identical(other.param1, param1) && other.param1 != param1) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + param1, + ); + } +} + +abstract class $TestCopyWith { + Test call({ + int? param1, + }); +} + +class _$TestCopyWithImpl implements $TestCopyWith { + final _$Test value; + + _$TestCopyWithImpl(this.value); + + @override + Test call({ + Object? param1 = genq, + }) { + return Test( + param1: param1 == genq ? value.param1 : param1 as int?, + ); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/class_with_single_param/input.dart b/tool/generation_test/fixtures/class_with_single_param/input.dart new file mode 100644 index 0000000..ae5ed94 --- /dev/null +++ b/tool/generation_test/fixtures/class_with_single_param/input.dart @@ -0,0 +1,10 @@ +import 'package:genq/genq.dart'; + +part "input.genq.dart"; + +@genq +class Test with _$Test { + factory Test({ + required int param1, + }) = _Test; +} diff --git a/tool/generation_test/fixtures/class_with_single_param/input.genq.dart b/tool/generation_test/fixtures/class_with_single_param/input.genq.dart new file mode 100644 index 0000000..1e0b89e --- /dev/null +++ b/tool/generation_test/fixtures/class_with_single_param/input.genq.dart @@ -0,0 +1,61 @@ +part of 'input.dart'; + +mixin _$Test { + int get param1 => throw UnimplementedError(); + + $TestCopyWith get copyWith => throw UnimplementedError(); +} + +class _Test implements Test { + @override + final int param1; + + _Test({ + required this.param1, + }); + + @override + $TestCopyWith get copyWith => _$TestCopyWithImpl(this); + + @override + String toString() { + return "Test(param1: $param1)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! Test) return false; + if (!identical(other.param1, param1) && other.param1 != param1) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + param1, + ); + } +} + +abstract class $TestCopyWith { + Test call({ + int param1, + }); +} + +class _$TestCopyWithImpl implements $TestCopyWith { + final _$Test value; + + _$TestCopyWithImpl(this.value); + + @override + Test call({ + Object? param1 = genq, + }) { + return Test( + param1: param1 == genq ? value.param1 : param1 as int, + ); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/collection_types/input.dart b/tool/generation_test/fixtures/collection_types/input.dart new file mode 100644 index 0000000..e1a91aa --- /dev/null +++ b/tool/generation_test/fixtures/collection_types/input.dart @@ -0,0 +1,12 @@ +import 'package:genq/genq.dart'; + +part 'input.genq.dart'; + +@genq +class User with _$User { + factory User({ + required List names, + required Map properties, + required Set ages, + }) = _User; +} diff --git a/tool/generation_test/fixtures/collection_types/input.genq.dart b/tool/generation_test/fixtures/collection_types/input.genq.dart new file mode 100644 index 0000000..932e1bc --- /dev/null +++ b/tool/generation_test/fixtures/collection_types/input.genq.dart @@ -0,0 +1,81 @@ +part of 'input.dart'; + +mixin _$User { + List get names => throw UnimplementedError(); + Map get properties => throw UnimplementedError(); + Set get ages => throw UnimplementedError(); + + $UserCopyWith get copyWith => throw UnimplementedError(); +} + +class _User implements User { + @override + final List names; + + @override + final Map properties; + + @override + final Set ages; + + _User({ + required this.names, + required this.properties, + required this.ages, + }); + + @override + $UserCopyWith get copyWith => _$UserCopyWithImpl(this); + + @override + String toString() { + return "User(names: $names, properties: $properties, ages: $ages)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! User) return false; + if (!const DeepCollectionEquality().equals(other.names, names)) return false; + if (!const DeepCollectionEquality().equals(other.properties, properties)) return false; + if (!const DeepCollectionEquality().equals(other.ages, ages)) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + names, + properties, + ages, + ); + } +} + +abstract class $UserCopyWith { + User call({ + List names, + Map properties, + Set ages, + }); +} + +class _$UserCopyWithImpl implements $UserCopyWith { + final _$User value; + + _$UserCopyWithImpl(this.value); + + @override + User call({ + Object? names = genq, + Object? properties = genq, + Object? ages = genq, + }) { + return User( + names: names == genq ? value.names : names as List, + properties: properties == genq ? value.properties : properties as Map, + ages: ages == genq ? value.ages : ages as Set, + ); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/empty/input.dart b/tool/generation_test/fixtures/empty/input.dart new file mode 100644 index 0000000..42aa652 --- /dev/null +++ b/tool/generation_test/fixtures/empty/input.dart @@ -0,0 +1,8 @@ +import 'package:genq/genq.dart'; + +part 'input.genq.dart'; + +@genq +class User with _$User { + factory User() = _User; +} diff --git a/tool/generation_test/fixtures/empty/input.genq.dart b/tool/generation_test/fixtures/empty/input.genq.dart new file mode 100644 index 0000000..16f33f1 --- /dev/null +++ b/tool/generation_test/fixtures/empty/input.genq.dart @@ -0,0 +1,45 @@ +part of 'input.dart'; + +mixin _$User { + + $UserCopyWith get copyWith => throw UnimplementedError(); +} + +class _User implements User { + _User(); + + @override + $UserCopyWith get copyWith => _$UserCopyWithImpl(this); + + @override + String toString() { + return "User()"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! User) return false; + return true; + } + + @override + int get hashCode { + return runtimeType.hashCode; + } +} + +abstract class $UserCopyWith { + User call(); +} + +class _$UserCopyWithImpl implements $UserCopyWith { + final _$User value; + + _$UserCopyWithImpl(this.value); + + @override + User call() { + return User(); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/enum/input.dart b/tool/generation_test/fixtures/enum/input.dart new file mode 100644 index 0000000..5590d6e --- /dev/null +++ b/tool/generation_test/fixtures/enum/input.dart @@ -0,0 +1,13 @@ +import 'package:genq/genq.dart'; + +part 'input.genq.dart'; + +enum AccountType { free, premium, vip } + +@genq +class Account with _$Account { + factory Account({ + required String email, + required AccountType accountType, + }) = _Account; +} diff --git a/tool/generation_test/fixtures/enum/input.genq.dart b/tool/generation_test/fixtures/enum/input.genq.dart new file mode 100644 index 0000000..6345c6d --- /dev/null +++ b/tool/generation_test/fixtures/enum/input.genq.dart @@ -0,0 +1,71 @@ +part of 'input.dart'; + +mixin _$Account { + String get email => throw UnimplementedError(); + AccountType get accountType => throw UnimplementedError(); + + $AccountCopyWith get copyWith => throw UnimplementedError(); +} + +class _Account implements Account { + @override + final String email; + + @override + final AccountType accountType; + + _Account({ + required this.email, + required this.accountType, + }); + + @override + $AccountCopyWith get copyWith => _$AccountCopyWithImpl(this); + + @override + String toString() { + return "Account(email: $email, accountType: $accountType)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! Account) return false; + if (!identical(other.email, email) && other.email != email) return false; + if (!identical(other.accountType, accountType) && other.accountType != accountType) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + email, + accountType, + ); + } +} + +abstract class $AccountCopyWith { + Account call({ + String email, + AccountType accountType, + }); +} + +class _$AccountCopyWithImpl implements $AccountCopyWith { + final _$Account value; + + _$AccountCopyWithImpl(this.value); + + @override + Account call({ + Object? email = genq, + Object? accountType = genq, + }) { + return Account( + email: email == genq ? value.email : email as String, + accountType: accountType == genq ? value.accountType : accountType as AccountType, + ); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/function_types/input.dart b/tool/generation_test/fixtures/function_types/input.dart new file mode 100644 index 0000000..3d1b835 --- /dev/null +++ b/tool/generation_test/fixtures/function_types/input.dart @@ -0,0 +1,16 @@ +import 'package:genq/genq.dart'; + +part "input.genq.dart"; + +@genq +class User with _$User { + factory User({ + required String name, + required int? age, + required bool registered, + required int Function(String str) a, + required bool Function(int value) Function(String str) b, + required User Function(String str) Function(int value, { required String test }) Function(String str) c, + required void Function(void Function() a, void Function() b) Function(void Function(void Function() d) c) d, + }) = _User; +} diff --git a/tool/generation_test/fixtures/function_types/input.genq.dart b/tool/generation_test/fixtures/function_types/input.genq.dart new file mode 100644 index 0000000..63aff6d --- /dev/null +++ b/tool/generation_test/fixtures/function_types/input.genq.dart @@ -0,0 +1,121 @@ +part of 'input.dart'; + +mixin _$User { + String get name => throw UnimplementedError(); + int? get age => throw UnimplementedError(); + bool get registered => throw UnimplementedError(); + int Function(String str) get a => throw UnimplementedError(); + bool Function(int value) Function(String str) get b => throw UnimplementedError(); + User Function(String str) Function(int value, {String test}) Function(String str) get c => throw UnimplementedError(); + void Function(void Function() a, void Function() b) Function(void Function(void Function() d) c) get d => throw UnimplementedError(); + + $UserCopyWith get copyWith => throw UnimplementedError(); +} + +class _User implements User { + @override + final String name; + + @override + final int? age; + + @override + final bool registered; + + @override + final int Function(String str) a; + + @override + final bool Function(int value) Function(String str) b; + + @override + final User Function(String str) Function(int value, {String test}) Function(String str) c; + + @override + final void Function(void Function() a, void Function() b) Function(void Function(void Function() d) c) d; + + _User({ + required this.name, + required this.age, + required this.registered, + required this.a, + required this.b, + required this.c, + required this.d, + }); + + @override + $UserCopyWith get copyWith => _$UserCopyWithImpl(this); + + @override + String toString() { + return "User(name: $name, age: $age, registered: $registered, a: $a, b: $b, c: $c, d: $d)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! User) return false; + if (!identical(other.name, name) && other.name != name) return false; + if (!identical(other.age, age) && other.age != age) return false; + if (!identical(other.registered, registered) && other.registered != registered) return false; + if (!identical(other.a, a) && other.a != a) return false; + if (!identical(other.b, b) && other.b != b) return false; + if (!identical(other.c, c) && other.c != c) return false; + if (!identical(other.d, d) && other.d != d) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + name, + age, + registered, + a, + b, + c, + d, + ); + } +} + +abstract class $UserCopyWith { + User call({ + String name, + int? age, + bool registered, + int Function(String str) a, + bool Function(int value) Function(String str) b, + User Function(String str) Function(int value, {String test}) Function(String str) c, + void Function(void Function() a, void Function() b) Function(void Function(void Function() d) c) d, + }); +} + +class _$UserCopyWithImpl implements $UserCopyWith { + final _$User value; + + _$UserCopyWithImpl(this.value); + + @override + User call({ + Object? name = genq, + Object? age = genq, + Object? registered = genq, + Object? a = genq, + Object? b = genq, + Object? c = genq, + Object? d = genq, + }) { + return User( + name: name == genq ? value.name : name as String, + age: age == genq ? value.age : age as int?, + registered: registered == genq ? value.registered : registered as bool, + a: a == genq ? value.a : a as int Function(String str), + b: b == genq ? value.b : b as bool Function(int value) Function(String str), + c: c == genq ? value.c : c as User Function(String str) Function(int value, {String test}) Function(String str), + d: d == genq ? value.d : d as void Function(void Function() a, void Function() b) Function(void Function(void Function() d) c), + ); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/generics/input.dart b/tool/generation_test/fixtures/generics/input.dart new file mode 100644 index 0000000..21f729e --- /dev/null +++ b/tool/generation_test/fixtures/generics/input.dart @@ -0,0 +1,10 @@ +import 'package:genq/genq.dart'; + +part 'input.genq.dart'; + +@genq +class User with _$User { + factory User({ + required T data, + }) = _User; +} diff --git a/tool/generation_test/fixtures/generics/input.genq.dart b/tool/generation_test/fixtures/generics/input.genq.dart new file mode 100644 index 0000000..da8976d --- /dev/null +++ b/tool/generation_test/fixtures/generics/input.genq.dart @@ -0,0 +1,58 @@ +part of 'input.dart'; + +mixin _$User { + T get data => throw UnimplementedError(); + + $UserCopyWith get copyWith => throw UnimplementedError(); +} + +class _User implements User { + @override + final T data; + + _User({ + required this.data, + }); + + @override + $UserCopyWith get copyWith => _$UserCopyWithImpl(this); + + @override + String toString() { + return "User(data: $data)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! User) return false; + if (!identical(other.data, data) && other.data != data) return false; + return true; + } + + @override + int get hashCode { + return data.hashCode; + } +} + +abstract class $UserCopyWith { + User call({ + T data, + }); +} + +class _$UserCopyWithImpl implements $UserCopyWith { + final _$User value; + + _$UserCopyWithImpl(this.value); + + @override + User call({ + Object? data = genq, + }) { + return User( + data: data == genq ? value.data : data as T, + ); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/list_fields/input.dart b/tool/generation_test/fixtures/list_fields/input.dart new file mode 100644 index 0000000..882c539 --- /dev/null +++ b/tool/generation_test/fixtures/list_fields/input.dart @@ -0,0 +1,11 @@ +import 'package:genq/genq.dart'; + +part 'input.genq.dart'; + +@genq +class ShoppingCart with _$ShoppingCart { + factory ShoppingCart({ + required String ownerName, + required List items, + }) = _ShoppingCart; +} diff --git a/tool/generation_test/fixtures/list_fields/input.genq.dart b/tool/generation_test/fixtures/list_fields/input.genq.dart new file mode 100644 index 0000000..52aef2d --- /dev/null +++ b/tool/generation_test/fixtures/list_fields/input.genq.dart @@ -0,0 +1,71 @@ +part of 'input.dart'; + +mixin _$ShoppingCart { + String get ownerName => throw UnimplementedError(); + List get items => throw UnimplementedError(); + + $ShoppingCartCopyWith get copyWith => throw UnimplementedError(); +} + +class _ShoppingCart implements ShoppingCart { + @override + final String ownerName; + + @override + final List items; + + _ShoppingCart({ + required this.ownerName, + required this.items, + }); + + @override + $ShoppingCartCopyWith get copyWith => _$ShoppingCartCopyWithImpl(this); + + @override + String toString() { + return "ShoppingCart(ownerName: $ownerName, items: $items)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! ShoppingCart) return false; + if (!identical(other.ownerName, ownerName) && other.ownerName != ownerName) return false; + if (!const DeepCollectionEquality().equals(other.items, items)) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + ownerName, + items, + ); + } +} + +abstract class $ShoppingCartCopyWith { + ShoppingCart call({ + String ownerName, + List items, + }); +} + +class _$ShoppingCartCopyWithImpl implements $ShoppingCartCopyWith { + final _$ShoppingCart value; + + _$ShoppingCartCopyWithImpl(this.value); + + @override + ShoppingCart call({ + Object? ownerName = genq, + Object? items = genq, + }) { + return ShoppingCart( + ownerName: ownerName == genq ? value.ownerName : ownerName as String, + items: items == genq ? value.items : items as List, + ); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/multiple_classes_with_multiple_param/input.dart b/tool/generation_test/fixtures/multiple_classes_with_multiple_param/input.dart new file mode 100644 index 0000000..2e3abb5 --- /dev/null +++ b/tool/generation_test/fixtures/multiple_classes_with_multiple_param/input.dart @@ -0,0 +1,24 @@ +import 'package:genq/genq.dart'; + +part "input.genq.dart"; + +@genq +class User with _$User { + factory User({ + required String name, + required int? age, + required bool registered, + required Address address, + }) = _User; +} + +@genq +class Address with _$Address { + factory Address({ + required String street, + required int zipCode, + required String city, + }) = _Address; +} + + diff --git a/tool/generation_test/fixtures/multiple_classes_with_multiple_param/input.genq.dart b/tool/generation_test/fixtures/multiple_classes_with_multiple_param/input.genq.dart new file mode 100644 index 0000000..12d2d24 --- /dev/null +++ b/tool/generation_test/fixtures/multiple_classes_with_multiple_param/input.genq.dart @@ -0,0 +1,171 @@ +part of 'input.dart'; + +mixin _$User { + String get name => throw UnimplementedError(); + int? get age => throw UnimplementedError(); + bool get registered => throw UnimplementedError(); + Address get address => throw UnimplementedError(); + + $UserCopyWith get copyWith => throw UnimplementedError(); +} + +class _User implements User { + @override + final String name; + + @override + final int? age; + + @override + final bool registered; + + @override + final Address address; + + _User({ + required this.name, + required this.age, + required this.registered, + required this.address, + }); + + @override + $UserCopyWith get copyWith => _$UserCopyWithImpl(this); + + @override + String toString() { + return "User(name: $name, age: $age, registered: $registered, address: $address)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! User) return false; + if (!identical(other.name, name) && other.name != name) return false; + if (!identical(other.age, age) && other.age != age) return false; + if (!identical(other.registered, registered) && other.registered != registered) return false; + if (!identical(other.address, address) && other.address != address) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + name, + age, + registered, + address, + ); + } +} + +abstract class $UserCopyWith { + User call({ + String name, + int? age, + bool registered, + Address address, + }); +} + +class _$UserCopyWithImpl implements $UserCopyWith { + final _$User value; + + _$UserCopyWithImpl(this.value); + + @override + User call({ + Object? name = genq, + Object? age = genq, + Object? registered = genq, + Object? address = genq, + }) { + return User( + name: name == genq ? value.name : name as String, + age: age == genq ? value.age : age as int?, + registered: registered == genq ? value.registered : registered as bool, + address: address == genq ? value.address : address as Address, + ); + } +} + +mixin _$Address { + String get street => throw UnimplementedError(); + int get zipCode => throw UnimplementedError(); + String get city => throw UnimplementedError(); + + $AddressCopyWith get copyWith => throw UnimplementedError(); +} + +class _Address implements Address { + @override + final String street; + + @override + final int zipCode; + + @override + final String city; + + _Address({ + required this.street, + required this.zipCode, + required this.city, + }); + + @override + $AddressCopyWith get copyWith => _$AddressCopyWithImpl(this); + + @override + String toString() { + return "Address(street: $street, zipCode: $zipCode, city: $city)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! Address) return false; + if (!identical(other.street, street) && other.street != street) return false; + if (!identical(other.zipCode, zipCode) && other.zipCode != zipCode) return false; + if (!identical(other.city, city) && other.city != city) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + street, + zipCode, + city, + ); + } +} + +abstract class $AddressCopyWith { + Address call({ + String street, + int zipCode, + String city, + }); +} + +class _$AddressCopyWithImpl implements $AddressCopyWith { + final _$Address value; + + _$AddressCopyWithImpl(this.value); + + @override + Address call({ + Object? street = genq, + Object? zipCode = genq, + Object? city = genq, + }) { + return Address( + street: street == genq ? value.street : street as String, + zipCode: zipCode == genq ? value.zipCode : zipCode as int, + city: city == genq ? value.city : city as String, + ); + } +} \ No newline at end of file diff --git a/tool/generation_test/fixtures/pubspec.lock b/tool/generation_test/fixtures/pubspec.lock new file mode 100644 index 0000000..6c1cc73 --- /dev/null +++ b/tool/generation_test/fixtures/pubspec.lock @@ -0,0 +1,20 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + collection: + dependency: transitive + description: + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + genq: + dependency: "direct main" + description: + path: "../../../packages/genq" + relative: true + source: path + version: "0.1.0" +sdks: + dart: ">=3.2.3 <4.0.0" diff --git a/tool/generation_test/fixtures/pubspec.yaml b/tool/generation_test/fixtures/pubspec.yaml new file mode 100644 index 0000000..500c52c --- /dev/null +++ b/tool/generation_test/fixtures/pubspec.yaml @@ -0,0 +1,14 @@ +name: fixtures +publish_to: none +description: >- + Fixtures for testing the genq package. +version: 1.2.3 +homepage: https://example-pet-store.com/newtify +documentation: https://example-pet-store.com/newtify/docs + +environment: + sdk: '>=3.0.0 <4.0.0' + +dependencies: + genq: + path: ../../../packages/genq diff --git a/tool/generation_test/gen_test.go b/tool/generation_test/gen_test.go new file mode 100644 index 0000000..884b8e6 --- /dev/null +++ b/tool/generation_test/gen_test.go @@ -0,0 +1,50 @@ +package generationtest + +import ( + "testing" +) + +func TestClassWithSingleParam(t *testing.T) { + testGenOutput(t, "class_with_single_param"); +} + +func TestClassWithSingleOptionalParam(t *testing.T) { + testGenOutput(t, "class_with_single_optional_param"); +} + +func TestClassWithMultipleParam(t *testing.T) { + testGenOutput(t, "class_with_multiple_param"); +} + +func TestMultipleClassesWithMultipleParam(t *testing.T) { + testGenOutput(t, "multiple_classes_with_multiple_param"); +} + +func TestAdditionalMembers(t *testing.T) { + testGenOutput(t, "additional_members"); +} + +// Enums are not supported yet +// func TestGenerics(t *testing.T) { +// testGenOutput(t, "generics"); +// } + +func TestListFields(t *testing.T) { + testGenOutput(t, "list_fields"); +} + +func TestEnum(t *testing.T) { + testGenOutput(t, "enum"); +} + +func TestCollectionTypes(t *testing.T) { + testGenOutput(t, "collection_types"); +} + +func TestFunctionTypes(t *testing.T) { + testGenOutput(t, "function_types"); +} + +func TestEmpty(t *testing.T) { + testGenOutput(t, "empty"); +} diff --git a/tool/generation_test/testutil.go b/tool/generation_test/testutil.go new file mode 100644 index 0000000..dc90945 --- /dev/null +++ b/tool/generation_test/testutil.go @@ -0,0 +1,68 @@ +package generationtest + +import ( + "fmt" + . "genq/generation" + "os" + "os/exec" + "strings" + "testing" + + "github.com/google/go-cmp/cmp" +) + +func readInput(path string) string { + b, err := os.ReadFile(path) + + if err != nil { + panic(err) + } + + return strings.Trim(string(b), "\n") +} + +func readOutput(path string) []string { + b, err := os.ReadFile(path) + + if err != nil { + panic(err) + } + + return strings.Split(strings.Trim(string(b), "\n"), "\n") +} + +func testGenOutput(t *testing.T, folder string) { + var read ReadContent = func(path string) (string, error) { + return readInput(fmt.Sprintf("./fixtures/%s/input.dart", folder)), nil + } + + res, err := Generate("./input.dart", read,) + if err != nil { + t.Fatalf("Did not expect error: %s", err) + } + + if len(res.Errors) > 0 { + for _, err := range res.Errors { + t.Fatalf("Error at line %d, pos %d: %s", err.Context.Line, err.Context.PosInLine, err.Error.Err.Error()) + } + } + + if diff := cmp.Diff(readOutput(fmt.Sprintf("./fixtures/%s/input.genq.dart", folder)), res.WriteString); diff != "" { + println("== GENERATED OUTPUT WAS ==") + println(strings.Join(res.WriteString, "\n")) + println("==========================") + + if os.Getenv("UPDATE_FIXTURES") == "1" { + os.WriteFile(fmt.Sprintf("./fixtures/%s/input.genq.dart", folder), []byte(strings.Join(res.WriteString, "\n")), 0644) + } + + t.Fatalf(diff) + } + + cmd := exec.Command("dart", "analyze", fmt.Sprintf("./fixtures/%s/input.genq.dart", folder)) + stdout, err := cmd.Output() + if err != nil { + println(string(stdout)) + t.Fatal(err) + } +} diff --git a/tool/go.mod b/tool/go.mod new file mode 100644 index 0000000..b12cefd --- /dev/null +++ b/tool/go.mod @@ -0,0 +1,13 @@ +module genq + +go 1.20 + +require golang.org/x/sys v0.4.0 // indirect + +require ( + github.com/fsnotify/fsnotify v1.7.0 + github.com/google/go-cmp v0.6.0 + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/spf13/cobra v1.8.0 + github.com/spf13/pflag v1.0.5 // indirect +) diff --git a/tool/go.sum b/tool/go.sum new file mode 100644 index 0000000..968ce3b --- /dev/null +++ b/tool/go.sum @@ -0,0 +1,16 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= +golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/tool/internalgen/gen_tokens.go b/tool/internalgen/gen_tokens.go new file mode 100644 index 0000000..5640631 --- /dev/null +++ b/tool/internalgen/gen_tokens.go @@ -0,0 +1,55 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" +) + +/// This script geneates a tokens.go file from a token_map.json file. This is just +/// a helper script to avoid having to manually write the tokens.go file. +func main() { + file, err := os.ReadFile("./token_map.json") + if err != nil { + panic(err) + } + + tokenMap := []TokenMap{} + + err = json.Unmarshal(file, &tokenMap) + if err != nil { + panic(err) + } + + str := "package parser\n\nimport (\n \"regexp\"\n)\n\n" + + str += "type TokenType string\n\n" + + for _, token := range tokenMap { + str += fmt.Sprintf("const TOKEN_%s TokenType = \"%s\"\n\n", token.Name, token.Name) + str += fmt.Sprintf("var REGEXP_%s = regexp.MustCompile(\"%s\")\n\n", token.Name, token.Regexp) + } + + str += fmt.Sprintf("var TOKEN_MAPPINGS = []TokenMapping{\n") + for _, token := range tokenMap { + str += fmt.Sprintf(" {REGEXP_%s, TOKEN_%s},\n", token.Name, token.Name) + } + str += fmt.Sprintf("}\n\n") + + f, err := os.Create("./parser/tokens.go") + if err != nil { + panic(err) + } + + defer f.Close() + + _, err = f.WriteString(str) + if err != nil { + panic(err) + } +} + +type TokenMap struct { + Name string `json:"type"` + Regexp string `json:"regexp"` +} diff --git a/tool/main.go b/tool/main.go new file mode 100644 index 0000000..3ef9300 --- /dev/null +++ b/tool/main.go @@ -0,0 +1,12 @@ +package main + +import ( + "genq/cli" +) + + + +func main() { + cli.Execute() +} + diff --git a/tool/parser/ast_structures.go b/tool/parser/ast_structures.go new file mode 100644 index 0000000..bd17956 --- /dev/null +++ b/tool/parser/ast_structures.go @@ -0,0 +1,64 @@ +package parser; + +type GenqClass struct { + Name string + HasPrivateConstructor bool + Constructor GenqConstructorSignature + FromJsonConstructor GenqFromJsonConstructor + HasJsonConstructor bool +} + +type GenqTypeReference struct { + Name string + Optional bool + GenericTypes []GenqTypeReference + FunctionType *FunctionType + ReturnType *GenqTypeReference + ParamList GenqParamList + IsFunction bool +} + +type GenqAnnotation struct { + Name string + Params []GenqAnnotationParameter +} + +type GenqAnnotationParameter struct { + Name string + Value GenqValue +} + +type GenqValue struct { + BooleanValue bool + StringValue string +} + +type GenqFromJsonConstructor struct { + ParamType GenqTypeReference + Identifier string +} + +type GenqConstructorSignature struct { + Params []GenqNamedParam +} + +type GenqNamedParam struct { + Required bool + ParamType GenqTypeReference + Name string + Annotation GenqAnnotation +} + +type GenqJsonKeyAnnotation struct { + Name string +} + +type GenqPositionalParam struct { + ParamType GenqTypeReference + Name string +} + +type GenqParamList struct { + PositionalParams []GenqPositionalParam + NamedParams []GenqNamedParam +} diff --git a/tool/parser/ast_tostring.go b/tool/parser/ast_tostring.go new file mode 100644 index 0000000..1a6ce61 --- /dev/null +++ b/tool/parser/ast_tostring.go @@ -0,0 +1,62 @@ +package parser + +import "fmt" + +func (t GenqTypeReference) String() string { + if t.IsFunction { + return fmt.Sprintf("%s Function%s", t.ReturnType.String(), t.ParamList.String()) + } + + str := t.Name + if len(t.GenericTypes) > 0 { + str += "<" + for i, gt := range t.GenericTypes { + str += gt.String() + if i < len(t.GenericTypes)-1 { + str += ", " + } + } + str += ">" + } + if t.Optional { + str += "?" + } + return str +} + +func (t GenqParamList) String() string { + str := "(" + for i, p := range t.PositionalParams { + str += p.ParamType.String() + str += " " + p.Name + if i < len(t.PositionalParams)-1 || len(t.NamedParams) > 0 { + str += ", " + } + } + + if len(t.NamedParams) > 0 { + str += "{" + + for i, p := range t.NamedParams { + str += p.ParamType.String() + str += " " + p.Name + if i < len(t.NamedParams)-1 { + str += ", " + } + } + + str += "}" + } + str += ")" + return str +} + +func (t GenqNamedParam) String() string { + str := "" + if t.Required { + str += "required " + } + str += t.ParamType.String() + str += " " + t.Name + return str +} diff --git a/tool/parser/ast_util.go b/tool/parser/ast_util.go new file mode 100644 index 0000000..9c738e5 --- /dev/null +++ b/tool/parser/ast_util.go @@ -0,0 +1,5 @@ +package parser + +func (t GenqTypeReference) IsCollectionType() bool { + return t.Name == "List" || t.Name == "Set" || t.Name == "Map" +} diff --git a/tool/parser/lexer.go b/tool/parser/lexer.go new file mode 100644 index 0000000..d96f932 --- /dev/null +++ b/tool/parser/lexer.go @@ -0,0 +1,45 @@ +package parser + +const NO_MORE_TOKENS = "NO_MORE_TOKENS" +const UNRECOGNIZED_TOKEN = "UNRECOGNIZED_TOKEN" + +type Lexer struct { + input string + cursor int + restorationPoint int +} + +func newLexer(str string) *Lexer { + return &Lexer{ + input: str, + cursor: 0, + } +} + +func (l *Lexer) hasMoreTokens() bool { + return l.cursor < len(l.input) +} + +func (l *Lexer) nextToken() (TokenType, string) { + if !l.hasMoreTokens() { + return NO_MORE_TOKENS, "" + } + + for _, mapping := range TOKEN_MAPPINGS { + if mapping.regex.MatchString(l.input[l.cursor:]) { + str := mapping.regex.FindString(l.input[l.cursor:]) + l.cursor += len(str) + + if mapping.token == TOKEN_SKIP || mapping.token == TOKEN_SINGLE_LINE_COMMENT { + return l.nextToken() + } + + return mapping.token, str + } + } + + unknownToken := l.input[l.cursor: l.cursor + 1] + l.cursor++ + return UNRECOGNIZED_TOKEN, unknownToken +} + diff --git a/tool/parser/parser.go b/tool/parser/parser.go new file mode 100644 index 0000000..c32d72f --- /dev/null +++ b/tool/parser/parser.go @@ -0,0 +1,705 @@ +// + +package parser + +import "fmt" + +type Parser struct { + lexer *Lexer + lookahead TokenType + lookaheadValue string + + // The current scope is used to keep track of the current level of nesting. + // When a "{" is encountered, the scope is increased by one. When a "}" is + // encountered, the scope is decreased by one. + currentScope int + restorationPoints []restorationPoint +} + +type ParseResult struct { + Errors []*ParsingError +} + +// Parse the input. The listener will be called when nodes are parsed. +// If parsing errors are encountered, they will be returned in the ParseResult. +func (p *Parser) Parse(listener ParserListener) ParseResult { + token, value := p.lexer.nextToken() + p.lookahead = token + p.lookaheadValue = value + + errors := []*ParsingError{} + + for p.lexer.hasMoreTokens() { + // The way genq works is by looking for specific annotations and only parsing + // the nodes that are annotated. This is a simple way to avoid parsing the entire + // file and only focus on the parts that are relevant. + // Thus: We just skip tokens until we encounter an annotation + if p.lookahead != TOKEN_ANNOTATION { + p.eatUntil(TOKEN_ANNOTATION) + continue + } + + // We only parse annotations at the top level. If we are inside a scope, we skip + if p.currentScope > 0 { + p.eat(p.lookahead) + continue + } + + // We found an annotation at the top level. Now lets parse it into a node. + n, err := p.parseAnnotation() + if err != nil { + // If a parsing error is encountered while parsing the annotation, we do not + // want to stop parsing. Instead, we just ignore this annotation and continue + // parsing the rest of the file. + if p.lookahead == TOKEN_ANNOTATION { + p.eat(TOKEN_ANNOTATION) + } + continue + } + + // If the annotation is not a "genq" annotation + if n.Name != "genq" { + continue + } + + // As of now, we are only interested in classes annotated with "genq" and. + // Skip if the next token is not "class" + if p.lookahead != TOKEN_CLASS { + continue + } + + // Finally, we found a class annotated with "genq". Lets parse it. + genqClass, err := p.parseGenqClass() + if err != nil { + // When there was an error parsing the class, we add it to the list of Errors + // and continue parsing the rest of the file. + errors = append(errors, err) + continue + } + + // When the class is successfully parsed, we call the listener with the parsed class. + listener.OnGenqClass(genqClass) + } + + return ParseResult{ + Errors: errors, + } +} + +// ParserListener is an interface for listening to nodes parsed by the parser. +// When a node is parsed, the parser will call the appropriate method on the listener. +type ParserListener interface { + OnGenqClass(genqClass GenqClass) +} + +// NewParser creates a new parser with the given string as input. +func NewParser(str string) *Parser { + return &Parser{ + lexer: newLexer(str), + } +} + +// Marks the restoration point for the parser. Used in combination with "restore". +// In most cases, it is enough to look at the lookahead to determine the path. +// Sometimes though, it is necessary to parse optimistically and check wether or not +// an error occurs. +func (p *Parser) markRestorationPoint() { + // To support multiple restoration points, we keep a stack of restoration points. + p.restorationPoints = append(p.restorationPoints, restorationPoint{ + lookaheadValue: p.lookaheadValue, + lookahead: p.lookahead, + cursor: p.lexer.cursor, + }) +} + +// Restores the parser to the restoration point. +func (p *Parser) restore() { + restorationPoint := p.restorationPoints[len(p.restorationPoints)-1] + + // Remove the last restoration point + p.restorationPoints = p.restorationPoints[:len(p.restorationPoints)-1] + + p.lookahead = restorationPoint.lookahead + p.lookaheadValue = restorationPoint.lookaheadValue + p.lexer.cursor = restorationPoint.cursor +} + +type restorationPoint struct { + lookahead TokenType + lookaheadValue string + cursor int +} + +func (p *Parser) parseAnnotation() (GenqAnnotation, *ParsingError) { + p.eat(TOKEN_ANNOTATION) + annotationName, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqAnnotation{}, err + } + + params := []GenqAnnotationParameter{} + + if p.lookahead == TOKEN_PAREN_START { + // Annotation is an invocation + p.eat(TOKEN_PAREN_START) + + for p.lookahead != TOKEN_PAREN_END { + name, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqAnnotation{}, err + } + + _, err = p.eat(TOKEN_COLON) + if err != nil { + return GenqAnnotation{}, err + } + + value, err := p.parseValue() + if err != nil { + return GenqAnnotation{}, err + } + + if p.lookahead == TOKEN_COMMA { + _, err := p.eat(TOKEN_COMMA) + if err != nil { + return GenqAnnotation{}, err + } + } + + params = append(params, GenqAnnotationParameter{ + Name: name, + Value: value, + }) + } + p.eat(TOKEN_PAREN_END) + } + + return GenqAnnotation{ + Name: annotationName, + Params: params, + }, nil +} + +func (p *Parser) parseValue() (GenqValue, *ParsingError) { + if p.lookahead == TOKEN_SINGLE_STRING || p.lookahead == TOKEN_DOUBLE_STRING { + v, err := p.eat(p.lookahead) + if err != nil { + return GenqValue{}, err + } + + return GenqValue{ + StringValue: v, + }, nil + } + + if p.lookahead == TOKEN_BOOLEAN_TRUE || p.lookahead == TOKEN_BOOLEAN_FALSE { + v, err := p.eat(p.lookahead) + if err != nil { + return GenqValue{}, nil + } + + return GenqValue{ + BooleanValue: v == "true", + }, nil + } + + return GenqValue{}, nil +} + +type FunctionType struct { + ReturnType GenqTypeReference +} + +// Due to dart syntax, it is possible for a type reference to be the return type of a function. +// This function acts as a utility, to check wether or not we just parsed a return type. +// See: https://github.com/dart-lang/language/issues/2972 for more info +func (p *Parser) isReturnTypeOfFunction() bool { + p.markRestorationPoint() + defer p.restore() + + identifier, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return false + } + + _, err = p.eat(TOKEN_PAREN_START) + if err != nil { + return false + } + + if identifier != "Function" { + return false + } + + return true +} + +func (p *Parser) parseTypeReference() (GenqTypeReference, *ParsingError) { + typeIdentifier, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqTypeReference{}, err + } + + genericTypes := []GenqTypeReference{} + if p.lookahead == TOKEN_GENERIC_START { + _, err := p.eat(TOKEN_GENERIC_START) + if err != nil { + return GenqTypeReference{}, nil + } + + for { + if p.lookahead == TOKEN_GENERIC_END { + _, err := p.eat(TOKEN_GENERIC_END) + if err != nil { + return GenqTypeReference{}, err + } + + break + } + + typeRef, err := p.parseTypeReference() + if err != nil { + return GenqTypeReference{}, err + } + + genericTypes = append(genericTypes, typeRef) + + if p.lookahead == TOKEN_COMMA { + _, err := p.eat(TOKEN_COMMA) + + if err != nil { + return GenqTypeReference{}, err + } + } + } + } + + optional := false + if p.lookahead == TOKEN_OPTIONAL { + _, err := p.eat(TOKEN_OPTIONAL) + if err != nil { + return GenqTypeReference{}, err + } + + optional = true + } + + typeRef := GenqTypeReference{ + Name: typeIdentifier, + Optional: optional, + GenericTypes: genericTypes, + IsFunction: false, + } + + for p.isReturnTypeOfFunction() { + p.eat(TOKEN_IDENTIFIER) + paramList, err := p.parseParamList() + + if err != nil { + return GenqTypeReference{}, err + } + + prev := typeRef; + typeRef = GenqTypeReference{ + ReturnType: &prev, + IsFunction: true, + ParamList: paramList, + } + } + + return typeRef, nil +} + +func (p *Parser) parseParamList() (GenqParamList, *ParsingError) { + p.eat(TOKEN_PAREN_START) + + positionalParams := []GenqPositionalParam{} + namedParams := []GenqNamedParam{} + + for (p.lookahead != TOKEN_PAREN_END && p.lookahead != TOKEN_CURLY_START) { + if p.lookahead == TOKEN_IDENTIFIER { + typeRef, err := p.parseTypeReference() + if err != nil { + return GenqParamList{}, err; + } + + name, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqParamList{}, err; + } + + if p.lookahead == TOKEN_COMMA { + _, err := p.eat(TOKEN_COMMA) + if err != nil { + return GenqParamList{}, err; + } + } + + positionalParams = append(positionalParams, GenqPositionalParam{ + ParamType: typeRef, + Name: name, + }) + } + } + + if p.lookahead == TOKEN_CURLY_START { + _, err := p.eat(TOKEN_CURLY_START) + if err != nil { + return GenqParamList{}, err; + } + + for (p.lookahead != TOKEN_CURLY_END) { + namedParam, err := p.parseNamedParam() + if err != nil { + return GenqParamList{}, err; + } + + namedParams = append(namedParams, namedParam) + + if p.lookahead == TOKEN_COMMA { + _, err := p.eat(TOKEN_COMMA) + if err != nil { + return GenqParamList{}, err; + } + } + } + + _, err = p.eat(TOKEN_CURLY_END) + if err != nil { + return GenqParamList{}, err; + } + } + + p.eat(TOKEN_PAREN_END) + + return GenqParamList{ + PositionalParams: positionalParams, + NamedParams: namedParams, + }, nil +} + +func (p *Parser) parseGenqClass() (GenqClass, *ParsingError) { + _, err := p.eat(TOKEN_CLASS) + if err != nil { + return GenqClass{}, err + } + + classIdentifier, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqClass{}, err + } + + err = p.eatUntil(TOKEN_CURLY_START) + if err != nil { + return GenqClass{}, err + } + + _, err = p.eat(TOKEN_CURLY_START) + if err != nil { + return GenqClass{}, err + } + + var genqConstructorSignature GenqConstructorSignature + var jsonConstructorSignature GenqFromJsonConstructor + var hasJsonConstructor bool + hasPrivateConstructor := false + + for { + if !p.lexer.hasMoreTokens() { + break + } + + if p.lookahead == TOKEN_CONST && p.currentScope == 1 { + _, err := p.eat(TOKEN_CONST) + if err != nil { + return GenqClass{}, err + } + } + + if p.lookahead == TOKEN_IDENTIFIER { + cn, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqClass{}, err + } + + if cn == classIdentifier && p.lookahead == TOKEN_DOT { + _, err := p.eat(TOKEN_DOT) + if err != nil { + return GenqClass{}, err + } + + constructorName, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqClass{}, err + } + + if constructorName == "_" { + // This is a private constructor + err := p.eatUntil(TOKEN_SEMICOLON) + if err != nil { + return GenqClass{}, err + } + + _, err = p.eat(TOKEN_SEMICOLON) + if err != nil { + return GenqClass{}, err + } + + hasPrivateConstructor = true + } + } + } else if p.lookahead == TOKEN_CURLY_END { + _, err := p.eat(TOKEN_CURLY_END) + if err != nil { + return GenqClass{}, err + } + + if p.currentScope == 0 { + break + } + } else if p.lookahead == TOKEN_FACTORY { + _, err := p.eat(TOKEN_FACTORY) + if err != nil { + return GenqClass{}, err + } + + cn, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqClass{}, err + } + + if p.lookahead == TOKEN_PAREN_START && cn == classIdentifier { + // Factory matches class name + // This is the chosen constructor + genqConstructorSignature, err = p.parseGenqConstructorSignature() + if err != nil { + return GenqClass{}, err + } + + err := p.eatUntil(TOKEN_SEMICOLON) + if err != nil { + return GenqClass{}, err + } + + _, err = p.eat(TOKEN_SEMICOLON) + if err != nil { + return GenqClass{}, err + } + } else if p.lookahead == TOKEN_DOT { + _, err := p.eat(TOKEN_DOT) + if err != nil { + return GenqClass{}, err + } + + constructorName, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqClass{}, nil + } + + if constructorName == "fromJson" { + if p.lookahead == TOKEN_PAREN_START { + _, err := p.eat(TOKEN_PAREN_START) + if err != nil { + return GenqClass{}, err + } + + paramType, err := p.parseTypeReference() + if err != nil { + return GenqClass{}, err + } + + identifier, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqClass{}, err + } + + _, err = p.eat(TOKEN_PAREN_END) + if err != nil { + return GenqClass{}, err + } + + jsonConstructorSignature = GenqFromJsonConstructor{ + ParamType: paramType, + Identifier: identifier, + } + hasJsonConstructor = true + } + } + + err = p.eatUntil(TOKEN_SEMICOLON) + if err != nil { + return GenqClass{}, err + } + + _, err = p.eat(TOKEN_SEMICOLON) + if err != nil { + return GenqClass{}, err + } + } + } else { + _, err := p.eat(p.lookahead) + if err != nil { + return GenqClass{}, err + } + } + } + + return GenqClass{ + Name: classIdentifier, + Constructor: genqConstructorSignature, + FromJsonConstructor: jsonConstructorSignature, + HasPrivateConstructor: hasPrivateConstructor, + HasJsonConstructor: hasJsonConstructor, + }, nil +} + +func (p *Parser) parseGenqConstructorSignature() (GenqConstructorSignature, *ParsingError) { + _, err := p.eat(TOKEN_PAREN_START) + if err != nil { + return GenqConstructorSignature{}, err + } + + if p.lookahead == TOKEN_PAREN_END { + _, err := p.eat(TOKEN_PAREN_END) + if err != nil { + return GenqConstructorSignature{}, err + } + + return GenqConstructorSignature{ + Params: []GenqNamedParam{}, + }, nil + } + + _, err = p.eat(TOKEN_CURLY_START) + if err != nil { + return GenqConstructorSignature{}, err + } + + params := []GenqNamedParam{} + for p.lookahead != TOKEN_CURLY_END { + namedParam, err := p.parseNamedParam() + if err != nil { + return GenqConstructorSignature{}, err + } + + params = append(params, namedParam) + + if p.lookahead == TOKEN_COMMA { + _, err := p.eat(TOKEN_COMMA) + if err != nil { + return GenqConstructorSignature{}, err + } + } + } + + _, err = p.eat(TOKEN_CURLY_END) + if err != nil { + return GenqConstructorSignature{}, err + } + + return GenqConstructorSignature{ + Params: params, + }, nil +} + +func (p *Parser) parseNamedParam() (GenqNamedParam, *ParsingError) { + required := false + annotation := GenqAnnotation{} + + if p.lookahead == TOKEN_ANNOTATION { + _, err := p.parseAnnotation() + if err != nil { + p.eatUntil(TOKEN_COMMA, TOKEN_PAREN_END) + p.eat(p.lookahead) + } + } + + if p.lookahead == TOKEN_REQUIRED { + _, err := p.eat(TOKEN_REQUIRED) + if err != nil { + return GenqNamedParam{}, nil + } + + required = true + } + + paramType, err := p.parseTypeReference() + if err != nil { + return GenqNamedParam{}, err + } + + paramName, err := p.eat(TOKEN_IDENTIFIER) + if err != nil { + return GenqNamedParam{}, nil + } + + return GenqNamedParam{ + ParamType: paramType, + Name: paramName, + Required: required, + Annotation: annotation, + }, nil +} + +// Eats tokens until one of the given tokens is encountered +func (p *Parser) eatUntil(tokens ...TokenType) *ParsingError { + for !contains(tokens, p.lookahead) { + if !p.lexer.hasMoreTokens() { + return nil + } + + _, err := p.eat(p.lookahead) + if err != nil { + return err + } + } + + return nil +} + +// Moves the parser forward by one token +func (p *Parser) progress() { + if p.lookahead == TOKEN_CURLY_START { + p.currentScope++ + } + + if p.lookahead == TOKEN_CURLY_END { + p.currentScope-- + } + + token, v := p.lexer.nextToken() + p.lookahead = token + p.lookaheadValue = v +} + +// Eats the token currently in the lookahead. If the token does not match the +// expected token, a ParsingError is returned. +func (p *Parser) eat(token TokenType) (string, *ParsingError) { + currentToken := p.lookahead + currentTokenValue := p.lookaheadValue + + if currentToken != token { + return "", &ParsingError{ + Err: fmt.Errorf("Unexpected token: %s (`%s`). Expected %s.", currentToken, currentTokenValue, token), + Pos: p.lexer.cursor - len(p.lookaheadValue), + } + } + + p.progress() + return currentTokenValue, nil +} + +type ParsingError struct { + Pos int + Err error + internal bool +} + +func contains(s []TokenType, e TokenType) bool { + for _, a := range s { + if a == e { + return true + } + } + return false +} diff --git a/tool/parser/token_mapping.go b/tool/parser/token_mapping.go new file mode 100644 index 0000000..5bf5487 --- /dev/null +++ b/tool/parser/token_mapping.go @@ -0,0 +1,9 @@ +package parser + +import "regexp" + +type TokenMapping struct { + regex *regexp.Regexp + token TokenType +} + diff --git a/tool/parser/tokens.go b/tool/parser/tokens.go new file mode 100644 index 0000000..2128b82 --- /dev/null +++ b/tool/parser/tokens.go @@ -0,0 +1,136 @@ +package parser + +import ( + "regexp" +) + +type TokenType string + +const TOKEN_SKIP TokenType = "SKIP" + +var REGEXP_SKIP = regexp.MustCompile("^[\\s+\\n]") + +const TOKEN_SINGLE_LINE_COMMENT TokenType = "SINGLE_LINE_COMMENT" + +var REGEXP_SINGLE_LINE_COMMENT = regexp.MustCompile("^\\/\\/.*") + +const TOKEN_SEMICOLON TokenType = "SEMICOLON" + +var REGEXP_SEMICOLON = regexp.MustCompile("^;") + +const TOKEN_COLON TokenType = "COLON" + +var REGEXP_COLON = regexp.MustCompile("^:") + +const TOKEN_ANNOTATION TokenType = "ANNOTATION" + +var REGEXP_ANNOTATION = regexp.MustCompile("^@") + +const TOKEN_CLASS TokenType = "CLASS" + +var REGEXP_CLASS = regexp.MustCompile("^class") + +const TOKEN_CURLY_START TokenType = "CURLY_START" + +var REGEXP_CURLY_START = regexp.MustCompile("^{") + +const TOKEN_CURLY_END TokenType = "CURLY_END" + +var REGEXP_CURLY_END = regexp.MustCompile("^}") + +const TOKEN_CONST TokenType = "CONST" + +var REGEXP_CONST = regexp.MustCompile("^const") + +const TOKEN_FACTORY TokenType = "FACTORY" + +var REGEXP_FACTORY = regexp.MustCompile("^factory") + +const TOKEN_SINGLE_STRING TokenType = "SINGLE_STRING" + +var REGEXP_SINGLE_STRING = regexp.MustCompile("^'[^']*'") + +const TOKEN_DOUBLE_STRING TokenType = "DOUBLE_STRING" + +var REGEXP_DOUBLE_STRING = regexp.MustCompile("^\"[^\"]*\"") + +const TOKEN_BOOLEAN_TRUE TokenType = "BOOLEAN_TRUE" + +var REGEXP_BOOLEAN_TRUE = regexp.MustCompile("^true") + +const TOKEN_BOOLEAN_FALSE TokenType = "BOOLEAN_FALSE" + +var REGEXP_BOOLEAN_FALSE = regexp.MustCompile("^false") + +const TOKEN_FINAL TokenType = "FINAL" + +var REGEXP_FINAL = regexp.MustCompile("^final") + +const TOKEN_VAR TokenType = "VAR" + +var REGEXP_VAR = regexp.MustCompile("^var") + +const TOKEN_PAREN_START TokenType = "PAREN_START" + +var REGEXP_PAREN_START = regexp.MustCompile("^\\(") + +const TOKEN_PAREN_END TokenType = "PAREN_END" + +var REGEXP_PAREN_END = regexp.MustCompile("^\\)") + +const TOKEN_REQUIRED TokenType = "REQUIRED" + +var REGEXP_REQUIRED = regexp.MustCompile("^required") + +const TOKEN_COMMA TokenType = "COMMA" + +var REGEXP_COMMA = regexp.MustCompile("^,") + +const TOKEN_DOT TokenType = "DOT" + +var REGEXP_DOT = regexp.MustCompile("^\\.") + +const TOKEN_GENERIC_START TokenType = "GENERIC_START" + +var REGEXP_GENERIC_START = regexp.MustCompile("^<") + +const TOKEN_GENERIC_END TokenType = "GENERIC_END" + +var REGEXP_GENERIC_END = regexp.MustCompile("^>") + +const TOKEN_OPTIONAL TokenType = "OPTIONAL" + +var REGEXP_OPTIONAL = regexp.MustCompile("^\\?") + +const TOKEN_IDENTIFIER TokenType = "IDENTIFIER" + +var REGEXP_IDENTIFIER = regexp.MustCompile("^[a-zA-Z_][a-zA-Z0-9_]*") + +var TOKEN_MAPPINGS = []TokenMapping{ + {REGEXP_SKIP, TOKEN_SKIP}, + {REGEXP_SINGLE_LINE_COMMENT, TOKEN_SINGLE_LINE_COMMENT}, + {REGEXP_SEMICOLON, TOKEN_SEMICOLON}, + {REGEXP_COLON, TOKEN_COLON}, + {REGEXP_ANNOTATION, TOKEN_ANNOTATION}, + {REGEXP_CLASS, TOKEN_CLASS}, + {REGEXP_CURLY_START, TOKEN_CURLY_START}, + {REGEXP_CURLY_END, TOKEN_CURLY_END}, + {REGEXP_CONST, TOKEN_CONST}, + {REGEXP_FACTORY, TOKEN_FACTORY}, + {REGEXP_SINGLE_STRING, TOKEN_SINGLE_STRING}, + {REGEXP_DOUBLE_STRING, TOKEN_DOUBLE_STRING}, + {REGEXP_BOOLEAN_TRUE, TOKEN_BOOLEAN_TRUE}, + {REGEXP_BOOLEAN_FALSE, TOKEN_BOOLEAN_FALSE}, + {REGEXP_FINAL, TOKEN_FINAL}, + {REGEXP_VAR, TOKEN_VAR}, + {REGEXP_PAREN_START, TOKEN_PAREN_START}, + {REGEXP_PAREN_END, TOKEN_PAREN_END}, + {REGEXP_REQUIRED, TOKEN_REQUIRED}, + {REGEXP_COMMA, TOKEN_COMMA}, + {REGEXP_DOT, TOKEN_DOT}, + {REGEXP_GENERIC_START, TOKEN_GENERIC_START}, + {REGEXP_GENERIC_END, TOKEN_GENERIC_END}, + {REGEXP_OPTIONAL, TOKEN_OPTIONAL}, + {REGEXP_IDENTIFIER, TOKEN_IDENTIFIER}, +} + diff --git a/tool/templates/copywith.go b/tool/templates/copywith.go new file mode 100644 index 0000000..e8c7ce4 --- /dev/null +++ b/tool/templates/copywith.go @@ -0,0 +1,49 @@ +package templates + +import "fmt" +import . "genq/parser" + +func templateCopyWith(str []string, params GenqClass) []string { + str = append(str, fmt.Sprintf("abstract class $%sCopyWith {", params.Name)) + + if len(params.Constructor.Params) > 0 { + str = append(str, indent(2, fmt.Sprintf("%s call({", params.Name))) + for _, param := range params.Constructor.Params { + str = append(str, indent(4, fmt.Sprintf("%s %s,", param.ParamType.String(), param.Name))) + } + str = append(str, indent(2, fmt.Sprintf("});"))) + } else { + str = append(str, indent(2, fmt.Sprintf("%s call();", params.Name))) + } + + str = append(str, fmt.Sprintf("}")) + str = append(str, "") + + str = append(str, fmt.Sprintf("class _$%sCopyWithImpl implements $%sCopyWith {", params.Name, params.Name)) + str = append(str, indent(2, fmt.Sprintf("final _$%s value;", params.Name))) + str = append(str, "") + str = append(str, indent(2, fmt.Sprintf("_$%sCopyWithImpl(this.value);", params.Name))) + str = append(str, "") + str = append(str, indent(2, fmt.Sprintf("@override"))) + if len(params.Constructor.Params) > 0 { + str = append(str, indent(2, fmt.Sprintf("%s call({", params.Name))) + for _, param := range params.Constructor.Params { + str = append(str, indent(4, fmt.Sprintf("Object? %s = genq,", param.Name))) + } + str = append(str, indent(2, fmt.Sprintf("}) {"))) + + str = append(str, indent(4, fmt.Sprintf("return %s(", params.Name))) + for _, param := range params.Constructor.Params { + str = append(str, indent(6, fmt.Sprintf("%s: %s == genq ? value.%s : %s as %s,", param.Name, param.Name, param.Name, param.Name, param.ParamType.String()))) + } + str = append(str, indent(4, fmt.Sprintf(");"))) + + str = append(str, indent(2, fmt.Sprintf("}"))) + } else { + str = append(str, indent(2, fmt.Sprintf("%s call() {", params.Name))) + str = append(str, indent(4, fmt.Sprintf("return %s();", params.Name))) + str = append(str, indent(2, fmt.Sprintf("}"))) + } + str = append(str, fmt.Sprintf("}")) + return str +} diff --git a/tool/templates/json.go b/tool/templates/json.go new file mode 100644 index 0000000..aeb4f25 --- /dev/null +++ b/tool/templates/json.go @@ -0,0 +1,73 @@ +package templates + +import ( + "fmt" + . "genq/parser" +) + + +func typeFromJsonNullable(typeRef GenqTypeReference, valueName string) string { + str := typeFromJson(typeRef, valueName) + + if typeRef.Optional { + return valueName + " == null ? null : (" + str + " as " + typeRef.String() + ")" + } else { + return str + " as " + typeRef.String() + } +} + +func typeFromJson(typeRef GenqTypeReference, valueName string) string { + if typeRef.Name == "String" { + return valueName + } + + if typeRef.Name == "int" { + return valueName + } + + if typeRef.Name == "double" { + return valueName + } + + if typeRef.Name == "bool" { + return valueName + } + + if typeRef.Name == "num" { + return valueName + } + + if typeRef.Name == "List" { + return "List.of(" + valueName + ").map((e) => " + typeFromJsonNullable(typeRef.GenericTypes[0], "e") + ").toList()" + } + + if typeRef.Name == "Set" { + return "Set.of(" + valueName + ").map((e) => " + typeFromJsonNullable(typeRef.GenericTypes[0], "e") + ").toSet()" + } + + // By default, we assume it's a class with a static member/factory method called fromJson + return typeRef.Name + ".fromJson(" + valueName + ")" +} + +func templateFromJson(str []string, params GenqClass) []string { + str = append(str, fmt.Sprintf("%s _$%sFromJson(Map json) {", params.Name, params.Name)) + str = append(str, indent(2, fmt.Sprintf("return %s(", params.Name))) + for _, param := range params.Constructor.Params { + + jsonKey := param.Name + if param.Annotation.Name == "JsonKey" { + for _, annotationParam := range param.Annotation.Params { + if annotationParam.Name == "name" { + jsonKey = annotationParam.Value.StringValue + } + } + } + + convName := typeFromJsonNullable(param.ParamType, "json['"+jsonKey+"']") + str = append(str, indent(4, fmt.Sprintf("%s: %s,", param.Name, convName))) + } + str = append(str, indent(2, fmt.Sprintf(");"))) + str = append(str, fmt.Sprintf("}")) + + return str +} diff --git a/tool/templates/scaffold.go b/tool/templates/scaffold.go new file mode 100644 index 0000000..76e6af0 --- /dev/null +++ b/tool/templates/scaffold.go @@ -0,0 +1,123 @@ +package templates + +import ( + "fmt" + . "genq/parser" +) + +func extendsOrImplements(params GenqClass) string { + if params.HasPrivateConstructor { + return "extends" + } else { + return "implements" + } +} + +func templateMixin(str []string, params GenqClass) []string { + str = append(str, fmt.Sprintf("mixin _$%s {", params.Name)) + for _, param := range params.Constructor.Params { + str = append(str, indent(2, fmt.Sprintf("%s get %s => throw UnimplementedError();", param.ParamType.String(), param.Name))) + } + str = append(str, "") + str = append(str, indent(2, fmt.Sprintf("$%sCopyWith get copyWith => throw UnimplementedError();", params.Name))) + str = append(str, fmt.Sprintf("}")) + + return str +} + +func templateConstructor(str []string, params GenqClass) []string { + str = append(str, fmt.Sprintf("class _%s %s %s {", params.Name, extendsOrImplements(params), params.Name)) + + for _, param := range params.Constructor.Params { + str = append(str, indent(2, fmt.Sprintf("@override"))) + str = append(str, indent(2, fmt.Sprintf("final %s %s;", param.ParamType.String(), param.Name))) + str = append(str, "") + } + + if len(params.Constructor.Params) > 0 { + str = append(str, indent(2, fmt.Sprintf("_%s({", params.Name))) + for _, param := range params.Constructor.Params { + if param.Required { + str = append(str, indent(4, fmt.Sprintf("required this.%s,", param.Name))) + } else { + str = append(str, indent(4, fmt.Sprintf("this.%s,", param.Name))) + } + } + if params.HasPrivateConstructor { + str = append(str, indent(2, fmt.Sprintf("}) : super._();"))) + } else { + str = append(str, indent(2, fmt.Sprintf("});"))) + } + } else { + if params.HasPrivateConstructor { + str = append(str, indent(2, fmt.Sprintf("_%s() : super._();", params.Name))) + } else { + str = append(str, indent(2, fmt.Sprintf("_%s();", params.Name))) + } + } + + // copyWith + str = append(str, "") + str = append(str, indent(2, fmt.Sprintf("@override"))) + str = append(str, indent(2, fmt.Sprintf("$%sCopyWith get copyWith => _$%sCopyWithImpl(this);", params.Name, params.Name))) + str = append(str, "") + + str = append(str, indent(2, fmt.Sprintf("@override"))) + str = append(str, indent(2, fmt.Sprintf("String toString() {"))) + + toStringParams := "" + for i, param := range params.Constructor.Params { + if i == len(params.Constructor.Params)-1 { + toStringParams += fmt.Sprintf("%s: $%s", param.Name, param.Name) + } else { + toStringParams += fmt.Sprintf("%s: $%s, ", param.Name, param.Name) + } + } + + str = append(str, indent(4, fmt.Sprintf("return \"%s(%s)\";", params.Name, toStringParams))) + str = append(str, indent(2, fmt.Sprintf("}"))) + str = append(str, "") + + str = append(str, indent(2, fmt.Sprintf("@override"))) + str = append(str, indent(2, fmt.Sprintf("bool operator ==(Object other) {"))) + str = templateEqualityBody(str, params) + str = append(str, indent(2, fmt.Sprintf("}"))) + + str = append(str, "") + str = append(str, indent(2, fmt.Sprintf("@override"))) + str = append(str, indent(2, fmt.Sprintf("int get hashCode {"))) + + if len(params.Constructor.Params) > 0 { + str = append(str, indent(4, fmt.Sprintf("return Object.hash("))) + str = append(str, indent(6, "runtimeType,")) + for _, param := range params.Constructor.Params { + str = append(str, indent(6, fmt.Sprintf("%s,", param.Name))) + } + str = append(str, indent(4, fmt.Sprintf(");"))) + } else { + str = append(str, indent(4, fmt.Sprintf("return runtimeType.hashCode;"))) + } + + str = append(str, indent(2, fmt.Sprintf("}"))) + + str = append(str, "}") + + return str +} + +func templateEqualityBody(str []string, params GenqClass) []string { + str = append(str, indent(4, fmt.Sprintf("if (identical(this, other)) return true;"))) + str = append(str, indent(4, fmt.Sprintf("if (other is! %s) return false;", params.Name))) + + for _, param := range params.Constructor.Params { + if param.ParamType.IsCollectionType() { + str = append(str, indent(4, fmt.Sprintf("if (!const DeepCollectionEquality().equals(other.%s, %s)) return false;", param.Name, param.Name))); + } else { + str = append(str, indent(4, fmt.Sprintf("if (!identical(other.%s, %s) && other.%s != %s) return false;", param.Name, param.Name, param.Name, param.Name))) + } + } + + str = append(str, indent(4, fmt.Sprintf("return true;"))) + + return str +} diff --git a/tool/templates/template_constructor_test.go b/tool/templates/template_constructor_test.go new file mode 100644 index 0000000..47631d9 --- /dev/null +++ b/tool/templates/template_constructor_test.go @@ -0,0 +1,104 @@ +package templates + +import "testing" + +func TestDefaultTemplateConstructor(t *testing.T) { + actual := []string{} + + parsed := getFirstGenqClass(` + @genq + class TestClazz { + factory TestClazz({ + required String name, + required int age, + required List friends, + }); + }`) + + actual = templateConstructor(actual, parsed) + expect := getNormalized(` +class _TestClazz implements TestClazz { + @override + final String name; + + @override + final int age; + + @override + final List friends; + + _TestClazz({ + required this.name, + required this.age, + required this.friends, + }); + + @override + $TestClazzCopyWith get copyWith => _$TestClazzCopyWithImpl(this); + + @override + String toString() { + return "TestClazz(name: $name, age: $age, friends: $friends)"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! TestClazz) return false; + if (!identical(other.name, name) && other.name != name) return false; + if (!identical(other.age, age) && other.age != age) return false; + if (!const DeepCollectionEquality().equals(other.friends, friends)) return false; + return true; + } + + @override + int get hashCode { + return Object.hash( + runtimeType, + name, + age, + friends, + ); + } +}`) + + compare(t, actual, expect) +} + +func TestEmpty(t *testing.T) { + actual := []string{} + + parsed := getFirstGenqClass(` + @genq + class TestClazz { + factory TestClazz(); + }`) + + actual = templateConstructor(actual, parsed) + expect := getNormalized(` +class _TestClazz implements TestClazz { + _TestClazz(); + + @override + $TestClazzCopyWith get copyWith => _$TestClazzCopyWithImpl(this); + + @override + String toString() { + return "TestClazz()"; + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) return true; + if (other is! TestClazz) return false; + return true; + } + + @override + int get hashCode { + return runtimeType.hashCode; + } +}`) + + compare(t, actual, expect) +} diff --git a/tool/templates/template_mixin_test.go b/tool/templates/template_mixin_test.go new file mode 100644 index 0000000..27130a9 --- /dev/null +++ b/tool/templates/template_mixin_test.go @@ -0,0 +1,32 @@ +package templates + +import ( + "testing" +) + +func TestDefaultTemplateMixin(t *testing.T) { + actual := []string{} + + parsed := getFirstGenqClass(` + @genq + class TestClazz { + factory TestClazz({ + required String name, + required int age, + required List friends, + }); + }`); + actual = templateMixin(actual, parsed) + + expect := getNormalized(` +mixin _$TestClazz { + String get name => throw UnimplementedError(); + int get age => throw UnimplementedError(); + List get friends => throw UnimplementedError(); + + $TestClazzCopyWith get copyWith => throw UnimplementedError(); +}`) + + compare(t, actual, expect) +} + diff --git a/tool/templates/templates.go b/tool/templates/templates.go new file mode 100644 index 0000000..02c51f0 --- /dev/null +++ b/tool/templates/templates.go @@ -0,0 +1,13 @@ +package templates + +import . "genq/parser" + +func Template(str []string, params GenqClass) []string { + str = templateMixin(str, params) + str = append(str, "") + str = templateConstructor(str, params) + str = append(str, "") + str = templateCopyWith(str, params) + + return str +} diff --git a/tool/templates/testutil.go b/tool/templates/testutil.go new file mode 100644 index 0000000..bc33c5f --- /dev/null +++ b/tool/templates/testutil.go @@ -0,0 +1,35 @@ +package templates + +import ( + "genq/parser" + "strings" + "testing" + + "github.com/google/go-cmp/cmp" +) + +func getNormalized(str string) []string { + return strings.Split(strings.Trim(str, "\n "), "\n") +} + +func getFirstGenqClass(str string) parser.GenqClass { + p := parser.NewParser(str) + listener := &testParserListener{} + p.Parse(listener) + + return listener.genqClass +} + +func compare(t *testing.T, actual []string, expect []string) { + if !cmp.Equal(actual, expect) { + t.Fatalf(cmp.Diff(expect, actual)) + } +} + +type testParserListener struct { + genqClass parser.GenqClass +} + +func (l *testParserListener) OnGenqClass(genqClass parser.GenqClass) { + l.genqClass = genqClass +} diff --git a/tool/templates/util.go b/tool/templates/util.go new file mode 100644 index 0000000..8e36954 --- /dev/null +++ b/tool/templates/util.go @@ -0,0 +1,7 @@ +package templates + +import "strings" + +func indent(num int, str string) string { + return strings.Repeat(" ", num) + str +} diff --git a/tool/token_map.json b/tool/token_map.json new file mode 100644 index 0000000..baca7c4 --- /dev/null +++ b/tool/token_map.json @@ -0,0 +1,27 @@ +[ + { "type": "SKIP", "regexp": "^[\\\\s+\\\\n]" }, + { "type": "SINGLE_LINE_COMMENT", "regexp": "^\\\\/\\\\/.*" }, + { "type": "SEMICOLON", "regexp": "^;" }, + { "type": "COLON", "regexp": "^:" }, + { "type": "ANNOTATION", "regexp": "^@" }, + { "type": "CLASS", "regexp": "^class" }, + { "type": "CURLY_START", "regexp": "^{" }, + { "type": "CURLY_END", "regexp": "^}" }, + { "type": "CONST", "regexp": "^const" }, + { "type": "FACTORY", "regexp": "^factory" }, + { "type": "SINGLE_STRING", "regexp": "^'[^']*'" }, + { "type": "DOUBLE_STRING", "regexp": "^\\\"[^\\\"]*\\\"" }, + { "type": "BOOLEAN_TRUE", "regexp": "^true" }, + { "type": "BOOLEAN_FALSE", "regexp": "^false" }, + { "type": "FINAL", "regexp": "^final" }, + { "type": "VAR", "regexp": "^var" }, + { "type": "PAREN_START", "regexp": "^\\\\(" }, + { "type": "PAREN_END", "regexp": "^\\\\)" }, + { "type": "REQUIRED", "regexp": "^required" }, + { "type": "COMMA", "regexp": "^," }, + { "type": "DOT", "regexp": "^\\\\." }, + { "type": "GENERIC_START", "regexp": "^<" }, + { "type": "GENERIC_END", "regexp": "^>" }, + { "type": "OPTIONAL", "regexp": "^\\\\?" }, + { "type": "IDENTIFIER", "regexp": "^[a-zA-Z_][a-zA-Z0-9_]*" } +]