Skip to content

Commit

Permalink
Merge pull request #27 from Foundation-Devices/happy-new-year
Browse files Browse the repository at this point in the history
2024 housekeeping
  • Loading branch information
icota authored Jan 16, 2024
2 parents c63b3c6 + 9c74126 commit 9b312cf
Show file tree
Hide file tree
Showing 23 changed files with 382 additions and 295 deletions.
51 changes: 29 additions & 22 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# SPDX-FileCopyrightText: 2022 Foundation Devices Inc.
#
# SPDX-License-Identifier: GPL-3.0-or-later

name: Dart
name: Check

on:
push:
Expand All @@ -18,25 +17,33 @@ jobs:
steps:
- uses: actions/checkout@v3

# Note: This workflow uses the latest stable version of the Dart SDK.
# You can specify other versions if desired, see documentation here:
# https://github.com/dart-lang/setup-dart/blob/main/README.md
# - uses: dart-lang/setup-dart@v1
- uses: dart-lang/setup-dart@9a04e6d73cca37bd455e0608d7e5092f881fd603
- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1

- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy

- uses: subosito/flutter-action@v2
with:
channel: 'stable'
flutter-version: '3.16.3'

- name: Install dependencies
run: dart pub get
run: flutter pub get

- name: Verify Dart formatting
run: dart format --output=none --set-exit-if-changed .

- name: Verify Rust formatting
run: cargo fmt --manifest-path rust/Cargo.toml --all -- --check

# Uncomment this step to verify the use of 'dart format' on each commit.
# - name: Verify formatting
# run: dart format --output=none --set-exit-if-changed .
- name: Run Rust tests
run: cargo test --manifest-path rust/Cargo.toml

# Consider passing '--fatal-infos' for slightly stricter analysis.
- name: Analyze project source
run: dart analyze
- name: Analyze Dart project source
run: flutter analyze

# Your project will need to have tests in test/ and a dependency on
# package:test for this step to succeed. Note that Flutter projects will
# want to change this to 'flutter test'.
- name: Run tests
run: dart test
# - name: Run Dart tests
# run: flutter test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ migrate_working_dir/
build/

rust/target/.rustc_info.json
rust/target/debug
8 changes: 8 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ Source: https://github.com/Foundation-Devices/tor
Files: cargokit/*
Copyright: 2022 Matej Knopp
License: MIT

Files: lib/generated*
Copyright: 2024 Foundation Devices Inc.
License: GPL-3.0-or-later

Files: rust/target/*
Copyright: 2024 Foundation Devices Inc.
License: GPL-3.0-or-later
9 changes: 7 additions & 2 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# SPDX-FileCopyrightText: 2022 Foundation Devices Inc.
#
# SPDX-License-Identifier: GPL-3.0-or-later
include: package:flutter_lints/flutter.yaml

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
analyzer:
exclude:
- 'lib/generated*'
- 'cargokit'
3 changes: 0 additions & 3 deletions analysis_options.yaml.license

This file was deleted.

26 changes: 1 addition & 25 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
# 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-lang.github.io/linter/lints/index.html.
#
# 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
avoid_print: false
11 changes: 11 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2022 Foundation Devices Inc.
#
# SPDX-License-Identifier: GPL-3.0-or-later

generate:
dart run ffigen

format:
cargo fmt --manifest-path rust/Cargo.toml && \
dart format . && \
flutter analyze
126 changes: 44 additions & 82 deletions lib/tor_bindings_generated.dart → lib/generated_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,7 @@ class NativeLibrary {
lookup)
: _lookup = lookup;

ffi.Pointer<ffi.Char> tor_last_error_message() {
return _tor_last_error_message();
}

late final _tor_last_error_messagePtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
'tor_last_error_message');
late final _tor_last_error_message =
_tor_last_error_messagePtr.asFunction<ffi.Pointer<ffi.Char> Function()>();

ffi.Pointer<ffi.Int> tor_start(
ffi.Pointer<ffi.Void> tor_start(
int socks_port,
ffi.Pointer<ffi.Char> state_dir,
ffi.Pointer<ffi.Char> cache_dir,
Expand All @@ -42,25 +32,25 @@ class NativeLibrary {

late final _tor_startPtr = _lookup<
ffi.NativeFunction<
ffi.Pointer<ffi.Int> Function(ffi.Uint16, ffi.Pointer<ffi.Char>,
ffi.Pointer<ffi.Void> Function(ffi.Uint16, ffi.Pointer<ffi.Char>,
ffi.Pointer<ffi.Char>)>>('tor_start');
late final _tor_start = _tor_startPtr.asFunction<
ffi.Pointer<ffi.Int> Function(
ffi.Pointer<ffi.Void> Function(
int, ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Char>)>();

bool tor_bootstrap(
ffi.Pointer<ffi.Int> client,
ffi.Pointer<ffi.Void> client,
) {
return _tor_bootstrap(
client,
);
}

late final _tor_bootstrapPtr =
_lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Int>)>>(
_lookup<ffi.NativeFunction<ffi.Bool Function(ffi.Pointer<ffi.Void>)>>(
'tor_bootstrap');
late final _tor_bootstrap =
_tor_bootstrapPtr.asFunction<bool Function(ffi.Pointer<ffi.Int>)>();
_tor_bootstrapPtr.asFunction<bool Function(ffi.Pointer<ffi.Void>)>();

void tor_hello() {
return _tor_hello();
Expand All @@ -69,8 +59,46 @@ class NativeLibrary {
late final _tor_helloPtr =
_lookup<ffi.NativeFunction<ffi.Void Function()>>('tor_hello');
late final _tor_hello = _tor_helloPtr.asFunction<void Function()>();

ffi.Pointer<ffi.Char> tor_last_error_message() {
return _tor_last_error_message();
}

late final _tor_last_error_messagePtr =
_lookup<ffi.NativeFunction<ffi.Pointer<ffi.Char> Function()>>(
'tor_last_error_message');
late final _tor_last_error_message =
_tor_last_error_messagePtr.asFunction<ffi.Pointer<ffi.Char> Function()>();

int tor_get_nofile_limit() {
return _tor_get_nofile_limit();
}

late final _tor_get_nofile_limitPtr =
_lookup<ffi.NativeFunction<ffi.Uint64 Function()>>(
'tor_get_nofile_limit');
late final _tor_get_nofile_limit =
_tor_get_nofile_limitPtr.asFunction<int Function()>();

int tor_set_nofile_limit(
int limit,
) {
return _tor_set_nofile_limit(
limit,
);
}

late final _tor_set_nofile_limitPtr =
_lookup<ffi.NativeFunction<ffi.Uint64 Function(ffi.Uint64)>>(
'tor_set_nofile_limit');
late final _tor_set_nofile_limit =
_tor_set_nofile_limitPtr.asFunction<int Function(int)>();
}

const int true1 = 1;

const int false1 = 0;

const int INT8_MIN = -128;

const int INT16_MIN = -32768;
Expand Down Expand Up @@ -173,72 +201,6 @@ const int WINT_MIN = 0;

const int WINT_MAX = 4294967295;

const int INT8_WIDTH = 8;

const int UINT8_WIDTH = 8;

const int INT16_WIDTH = 16;

const int UINT16_WIDTH = 16;

const int INT32_WIDTH = 32;

const int UINT32_WIDTH = 32;

const int INT64_WIDTH = 64;

const int UINT64_WIDTH = 64;

const int INT_LEAST8_WIDTH = 8;

const int UINT_LEAST8_WIDTH = 8;

const int INT_LEAST16_WIDTH = 16;

const int UINT_LEAST16_WIDTH = 16;

const int INT_LEAST32_WIDTH = 32;

const int UINT_LEAST32_WIDTH = 32;

const int INT_LEAST64_WIDTH = 64;

const int UINT_LEAST64_WIDTH = 64;

const int INT_FAST8_WIDTH = 8;

const int UINT_FAST8_WIDTH = 8;

const int INT_FAST16_WIDTH = 64;

const int UINT_FAST16_WIDTH = 64;

const int INT_FAST32_WIDTH = 64;

const int UINT_FAST32_WIDTH = 64;

const int INT_FAST64_WIDTH = 64;

const int UINT_FAST64_WIDTH = 64;

const int INTPTR_WIDTH = 64;

const int UINTPTR_WIDTH = 64;

const int INTMAX_WIDTH = 64;

const int UINTMAX_WIDTH = 64;

const int PTRDIFF_WIDTH = 64;

const int SIG_ATOMIC_WIDTH = 32;

const int SIZE_WIDTH = 64;

const int WCHAR_WIDTH = 32;

const int WINT_WIDTH = 32;

const int NULL = 0;

const int WNOHANG = 1;
Expand Down
Loading

0 comments on commit 9b312cf

Please sign in to comment.