Skip to content

Commit

Permalink
Merge pull request #24 from festelo/dev
Browse files Browse the repository at this point in the history
Windows support
  • Loading branch information
festelo authored Jul 7, 2023
2 parents 1856b0f + 9366abd commit 783d435
Show file tree
Hide file tree
Showing 87 changed files with 10,814 additions and 129 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,14 @@ jobs:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-29
key: avd-31

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
api-level: 31
arch: x86_64
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
Expand All @@ -234,7 +235,8 @@ jobs:
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
api-level: 31
arch: x86_64
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
Expand All @@ -243,10 +245,9 @@ jobs:

h3_flutter_test_desktop:
runs-on: ${{ matrix.os }}
if: ${{ false }} # disable macos while https://github.com/github/roadmap/issues/620 is open
strategy:
matrix:
os: [macos-latest]
os: [ windows-latest ] # disable macos while https://github.com/github/roadmap/issues/620 is open
steps:
- uses: actions/checkout@v2

Expand Down
3 changes: 3 additions & 0 deletions h3_dart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.6.2
* Rename `libh3lib.lib` file to `h3.so`

## 0.6.1
* Add `holes` param to `H3.polyfill` function (thanks [@iulian0512](https://github.com/iulian0512))
* Update dependencies
Expand Down
2 changes: 1 addition & 1 deletion h3_dart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ There are also few methods ported from JS library [Geojson2H3](https://github.co

Get compiled h3 c library, depending on your platform it may have extension .so, .dll or any.

- You can run `scripts/build_h3.sh` script, the compiled library will be at `h3_ffi/c/h3lib/build/libh3lib.lib`
- You can run `scripts/build_h3.sh` script, the compiled library will be at `h3_ffi/c/h3lib/build/h3.so`

- You can compile it by yourself using C-code placed in `c` folder in this repository. It has small changes comparing to original Uber's code to make it more compatible with iOS and macOS versions of `h3_flutter`. This code is recompiled and used for testing everytime tests are launched, so it should work well.

Expand Down
2 changes: 1 addition & 1 deletion h3_dart/example/ffi/src/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:h3_dart/h3_dart.dart';

void main() {
final h3 = H3Factory().byPath('../../../h3_ffi/c/h3lib/build/libh3lib.lib');
final h3 = H3Factory().byPath('../../../h3_ffi/c/h3lib/build/h3.so');

final isValid = h3.h3IsValid(BigInt.parse('0x85283473fffffff'));
print('0x85283473fffffff is valid hex: $isValid');
Expand Down
4 changes: 2 additions & 2 deletions h3_dart/lib/src/h3_factory.base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:h3_common/h3_common.dart';
abstract class BaseH3Factory {
/// Loads H3 from process, H3 C library must be loaded into this process first.
/// ```dart
/// DynamicLibrary.open('../h3_ffi/c/h3lib/build/libh3lib.lib');
/// DynamicLibrary.open('../h3_ffi/c/h3lib/build/h3.so');
/// final h3 = h3Factory.process();
/// h3.degsToRads(123);
/// ```
Expand All @@ -14,7 +14,7 @@ abstract class BaseH3Factory {

/// Loads H3 using specified [libraryPath]
/// ```dart
/// final h3 = h3Factory.byPath('../h3_ffi/c/h3lib/build/libh3lib.lib');
/// final h3 = h3Factory.byPath('../h3_ffi/c/h3lib/build/h3.so');
/// h3.degsToRads(123);
/// ```
H3 byPath(String libraryPath);
Expand Down
4 changes: 2 additions & 2 deletions h3_dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: h3_dart
description: The package provides Dart version of the H3 Core library, a hexagon-based geographic grid system
version: 0.6.1
version: 0.6.2
homepage: https://github.com/festelo/h3_dart

environment:
sdk: ">=2.14.0 <3.0.0"

dependencies:
ffi: ^2.0.1
h3_ffi: ^0.6.1
h3_ffi: ^0.6.2
h3_web: ^0.6.1
h3_common: ^0.6.1
geojson2h3: ^0.6.1
Expand Down
2 changes: 1 addition & 1 deletion h3_dart/test/h3_dart_vm_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void main() async {
}

expect(
h3Factory.byPath('../h3_ffi/c/h3lib/build/libh3lib.lib'),
h3Factory.byPath('../h3_ffi/c/h3lib/build/h3.so'),
isA<H3Ffi>(),
reason: 'H3Factory.byPath returns H3Ffi',
);
Expand Down
2 changes: 1 addition & 1 deletion h3_dart/test/h3_dart_web_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void main() async {
reason: 'H3Factory.process throws error',
);
expect(
() => h3Factory.byPath('../h3_ffi/c/h3lib/build/libh3lib.lib'),
() => h3Factory.byPath('../h3_ffi/c/h3lib/build/h3.so'),
throwsA(isA<UnsupportedError>()),
reason: 'H3Factory.byPath throws error',
);
Expand Down
4 changes: 4 additions & 0 deletions h3_ffi/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.2
* Flutter for Windows support
* Rename `libh3lib.lib` file to `h3.so`

## 0.6.1
* Add holes support to `polyfill` function (thanks [@iulian0512](https://github.com/iulian0512))
* Fix Android build for `h3_flutter` (thanks [@rtviwe](https://github.com/iulian0512))
Expand Down
2 changes: 1 addition & 1 deletion h3_ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Add `h3_ffi` package to `pubspec.yaml`.

Get compiled h3 library, depending on your platform it may have extension .so, .dll or any.

- You can run `scripts/build_h3.sh` script, the compiled library will be at `h3_ffi/c/h3lib/build/libh3lib.lib`
- You can run `scripts/build_h3.sh` script, the compiled library will be at `h3_ffi/c/h3lib/build/h3.so` (or `h3.dll` for Windows)

- You can compile it by yourself using C-code placed in `c` folder in this repository. It has small changes comparing to original Uber's code to make it more compatible with iOS and macOS versions of `h3_flutter`. This code is recompiled and used for testing everytime tests are launched, so it should work well.

Expand Down
17 changes: 13 additions & 4 deletions h3_ffi/c/h3lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
cmake_minimum_required(VERSION 3.4.1)
project(h3lib)
project(h3)

option(BuildForTests "BuildForTests" OFF)

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

FILE(GLOB CSources *.c)
FILE(GLOB HSources *.h)

add_library( h3lib
add_library( h3

# Sets the library as a shared library.
SHARED
Expand All @@ -13,6 +17,11 @@ add_library( h3lib
${CSources}
${HSources})

if ( NOT ANDROID )
set_target_properties(h3lib PROPERTIES SUFFIX ".lib")
if (BuildForTests OR NOT WIN32)
set_target_properties(h3 PROPERTIES PREFIX "")
set_target_properties(h3 PROPERTIES SUFFIX ".so")
endif()

IF ( WIN32 )
target_compile_definitions(h3 PUBLIC DART_SHARED_LIB)
endif()
2 changes: 1 addition & 1 deletion h3_ffi/example/src/main.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:h3_ffi/h3_ffi.dart';

void main() {
final h3 = H3FfiFactory().byPath('../../h3_ffi/c/h3lib/build/libh3lib.lib');
final h3 = H3FfiFactory().byPath('../../h3_ffi/c/h3lib/build/h3.so');

final isValid = h3.h3IsValid(BigInt.parse('0x85283473fffffff'));
print('0x85283473fffffff is valid hex: $isValid');
Expand Down
4 changes: 2 additions & 2 deletions h3_ffi/lib/src/h3_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class H3FfiFactory {
/// Loads H3 using [dynamicLibrary]
/// ```dart
/// final h3 = h3Factory.process(
/// DynamicLibrary.open('../h3_ffi/c/h3lib/build/libh3lib.lib'),
/// DynamicLibrary.open('../h3_ffi/c/h3lib/build/h3.so'),
/// );
/// h3.degsToRads(123);
/// ```
Expand All @@ -26,7 +26,7 @@ class H3FfiFactory {

/// Loads H3 by [libraryPath]
/// ```dart
/// final h3 = h3Factory.process('../h3_ffi/c/h3lib/build/libh3lib.lib');
/// final h3 = h3Factory.process('../h3_ffi/c/h3lib/build/h3.so');
/// h3.degsToRads(123);
/// ```
H3 byPath(String libraryPath) {
Expand Down
2 changes: 1 addition & 1 deletion h3_ffi/lib/src/h3c_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class H3CFactory {

/// Loads [H3C] by [libraryPath]
/// ```dart
/// final h3c = h3CFactory.byPath('../h3_ffi/c/h3lib/build/libh3lib.lib');
/// final h3c = h3CFactory.byPath('../h3_ffi/c/h3lib/build/h3.so');
/// ```
H3C byPath(String libraryPath) {
return byDynamicLibary(DynamicLibrary.open(libraryPath));
Expand Down
2 changes: 1 addition & 1 deletion h3_ffi/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: h3_ffi
description: The package provides Dart version of the H3 Core library, a hexagon-based geographic grid system
version: 0.6.1
version: 0.6.2
homepage: https://github.com/festelo/h3_dart

environment:
Expand Down
4 changes: 2 additions & 2 deletions h3_ffi/test/h3_ffi_factory_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ void main() {
test('H3FfiFactory', () async {
expect(
H3FfiFactory().byDynamicLibary(
DynamicLibrary.open(p.canonicalize('c/h3lib/build/libh3lib.lib')),
DynamicLibrary.open(p.canonicalize('c/h3lib/build/h3.so')),
),
isA<H3Ffi>(),
reason: 'H3FfiFactory.byDynamicLibary returns H3Ffi instance',
);

expect(
H3FfiFactory().byPath('c/h3lib/build/libh3lib.lib'),
H3FfiFactory().byPath('c/h3lib/build/h3.so'),
isA<H3Ffi>(),
reason: 'H3FfiFactory.byPath returns H3Ffi instance',
);
Expand Down
2 changes: 1 addition & 1 deletion h3_ffi/test/h3_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:collection/collection.dart';
import 'common.dart';

void main() {
final h3 = H3FfiFactory().byPath('c/h3lib/build/libh3lib.lib');
final h3 = H3FfiFactory().byPath('c/h3lib/build/h3.so');

test('h3IsValid', () async {
expect(
Expand Down
30 changes: 15 additions & 15 deletions h3_flutter/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
# This file should be version controlled.

version:
revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
channel: beta
revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
channel: stable

project_type: plugin

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
base_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
- platform: android
create_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
base_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
- platform: ios
create_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
base_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
- platform: linux
create_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
base_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
- platform: macos
create_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
base_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
- platform: web
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
- platform: windows
create_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
base_revision: 25caf1461b8f643092a9f6f5b224453b5c057d10
create_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8
base_revision: 84a1e904f44f9b0e9c4510138010edcc653163f8

# User provided section

Expand Down
4 changes: 4 additions & 0 deletions h3_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.4
* Flutter for Windows support
* Rename `libh3lib.lib` file to `h3.so`

## 0.6.3
* Add `holes` param to `H3.polyfill` function (thanks [@iulian0512](https://github.com/iulian0512))
* Fix web setup readme.
Expand Down
17 changes: 13 additions & 4 deletions h3_flutter/android/src/h3lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
cmake_minimum_required(VERSION 3.4.1)
project(h3lib)
project(h3)

option(BuildForTests "BuildForTests" OFF)

set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

FILE(GLOB CSources *.c)
FILE(GLOB HSources *.h)

add_library( h3lib
add_library( h3

# Sets the library as a shared library.
SHARED
Expand All @@ -13,6 +17,11 @@ add_library( h3lib
${CSources}
${HSources})

if ( NOT ANDROID )
set_target_properties(h3lib PROPERTIES SUFFIX ".lib")
if (BuildForTests OR NOT WIN32)
set_target_properties(h3 PROPERTIES PREFIX "")
set_target_properties(h3 PROPERTIES SUFFIX ".so")
endif()

IF ( WIN32 )
target_compile_definitions(h3 PUBLIC DART_SHARED_LIB)
endif()
2 changes: 1 addition & 1 deletion h3_flutter/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
1 change: 1 addition & 0 deletions h3_flutter/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
restorationScopeId: "h3_flutter_example",
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
Expand Down
Loading

0 comments on commit 783d435

Please sign in to comment.