Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: run vfmt over all files #275

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 26 additions & 28 deletions android/android_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,32 @@
// Use of this source code is governed by an MIT license file distributed with this software package
import vab.android

const (
valid_ids = [
'valid.package_id.ok',
'your.org.android',
'your_.org.android',
'your._org.android',
'your.o11rg.android',
'your11.org.android',
'yo11ur.org.android',
'your.org23.android',
'your.org.android23d',
'your.org_.android',
'your.org._android',
'your.org_._android',
'your.org.android_',
'your.org.android32',
'your.1.org.11212e',
]
invalid_ids = [
'_ouch.invalid.package_id',
'1.invalid.package_id',
'abc',
'',
'a.b.10',
'your.org.11212',
'a..b.c',
]
)
const valid_ids = [
'valid.package_id.ok',
'your.org.android',
'your_.org.android',
'your._org.android',
'your.o11rg.android',
'your11.org.android',
'yo11ur.org.android',
'your.org23.android',
'your.org.android23d',
'your.org_.android',
'your.org._android',
'your.org_._android',
'your.org.android_',
'your.org.android32',
'your.1.org.11212e',
]
const invalid_ids = [
'_ouch.invalid.package_id',
'1.invalid.package_id',
'abc',
'',
'a.b.10',
'your.org.11212',
'a..b.c',
]

fn test_package_ids() {
for id in valid_ids {
Expand Down
10 changes: 4 additions & 6 deletions android/compile.v
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import vab.android.ndk
import vab.android.util
import crypto.md5

pub const (
supported_target_archs = ndk.supported_archs
default_archs = ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
supported_gles_versions = [3]
default_gles_version = 3
)
pub const supported_target_archs = ndk.supported_archs
pub const default_archs = ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
pub const supported_gles_versions = [3]
pub const default_gles_version = 3

pub struct CompileOptions {
pub:
Expand Down
114 changes: 55 additions & 59 deletions android/env/env.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,69 +10,65 @@ import vab.android.sdk
import vab.android.ndk
import vab.android.util

pub const (
accepted_components = ['auto', 'cmdline-tools', 'platform-tools', 'ndk', 'platforms',
'build-tools', 'bundletool', 'aapt2']
// 6858069 = cmdline-tools;3.0 <- zip structure changes *sigh*
// 6609375 = cmdline-tools;2.1 <- latest that support `sdkmanager --version` *sigh*
// cmdline-tools-bootstrap-url - Replace [XXX] with linux/mac/win
// cmdline-tools - Latest more or less sane version that works with java versions >= 8 ...
// sdk - Latest
// ndk - Works with android.compile(...)
// platform - Google Play minimum
// build-tools - Version where apksigner is included from
default_components = {
'cmdline-tools': {
'name': 'cmdline-tools'
'version': '2.1'
'bootstrap_url': 'https://dl.google.com/android/repository/commandlinetools-[XXX]-6609375_latest.zip'
}
'platform-tools': {
'name': 'platform-tools'
'version': ''
}
'ndk': {
'name': 'ndk'
'version': ndk.min_supported_version
}
'platforms': {
'name': 'platforms'
'version': 'android-' + sdk.min_supported_api_level
}
'build-tools': {
'name': 'build-tools'
'version': sdk.min_supported_build_tools_version
}
'bundletool': {
'name': 'bundletool'
'version': '1.5.0'
'bootstrap_url': 'https://github.com/google/bundletool/releases/download/1.5.0/bundletool-all-1.5.0.jar'
}
'aapt2': {
'name': 'aapt2'
'version': '7.0.0'
'bootstrap_url': 'https://dl.google.com/android/maven2/com/android/tools/build/aapt2/7.0.0-alpha07-7087017/aapt2-7.0.0-alpha07-7087017-[XXX].jar'
}
}

dot_exe = $if windows {
'.exe'
} $else {
''
pub const accepted_components = ['auto', 'cmdline-tools', 'platform-tools', 'ndk', 'platforms',
'build-tools', 'bundletool', 'aapt2']
// 6858069 = cmdline-tools;3.0 <- zip structure changes *sigh*
// 6609375 = cmdline-tools;2.1 <- latest that support `sdkmanager --version` *sigh*
// cmdline-tools-bootstrap-url - Replace [XXX] with linux/mac/win
// cmdline-tools - Latest more or less sane version that works with java versions >= 8 ...
// sdk - Latest
// ndk - Works with android.compile(...)
// platform - Google Play minimum
// build-tools - Version where apksigner is included from
pub const default_components = {
'cmdline-tools': {
'name': 'cmdline-tools'
'version': '2.1'
'bootstrap_url': 'https://dl.google.com/android/repository/commandlinetools-[XXX]-6609375_latest.zip'
}
'platform-tools': {
'name': 'platform-tools'
'version': ''
}
'ndk': {
'name': 'ndk'
'version': ndk.min_supported_version
}
'platforms': {
'name': 'platforms'
'version': 'android-' + sdk.min_supported_api_level
}
'build-tools': {
'name': 'build-tools'
'version': sdk.min_supported_build_tools_version
}
'bundletool': {
'name': 'bundletool'
'version': '1.5.0'
'bootstrap_url': 'https://github.com/google/bundletool/releases/download/1.5.0/bundletool-all-1.5.0.jar'
}
'aapt2': {
'name': 'aapt2'
'version': '7.0.0'
'bootstrap_url': 'https://dl.google.com/android/maven2/com/android/tools/build/aapt2/7.0.0-alpha07-7087017/aapt2-7.0.0-alpha07-7087017-[XXX].jar'
}
)
}

pub const dot_exe = $if windows {
'.exe'
} $else {
''
}

// Possible locations of the `sdkmanager` tool
// https://stackoverflow.com/a/61176718
const (
possible_relative_to_sdk_sdkmanager_paths = [
os.join_path('cmdline-tools', 'latest', 'bin'),
os.join_path('tools', 'latest', 'bin'),
os.join_path('cmdline-tools', 'tools', 'bin'),
os.join_path('tools', 'bin'),
]
work_path = os.join_path(os.temp_dir(), 'vab', 'tmp')
)
const possible_relative_to_sdk_sdkmanager_paths = [
os.join_path('cmdline-tools', 'latest', 'bin'),
os.join_path('tools', 'latest', 'bin'),
os.join_path('cmdline-tools', 'tools', 'bin'),
os.join_path('tools', 'bin'),
]
const work_path = os.join_path(os.temp_dir(), 'vab', 'tmp')

pub enum Dependency {
platform_tools
Expand Down
12 changes: 5 additions & 7 deletions android/ndk/compiler_flags.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@
// Use of this source code is governed by an MIT license file distributed with this software package
module ndk

const (
ndk_21_default_general_flags = ['-g', '-DANDROID', '-fdata-sections', '-ffunction-sections',
'-funwind-tables', '-fstack-protector-strong', '-no-canonical-prefixes']
ndk_21_default_general_ld_flags = ['-Wl,--exclude-libs,libgcc.a',
'-Wl,--exclude-libs,libgcc_real.a', '-Wl,--exclude-libs,libatomic.a']
ndk_supported_cpp_features = ['rtti', 'exceptions', 'no-rtti', 'no-exceptions']
)
const ndk_21_default_general_flags = ['-g', '-DANDROID', '-fdata-sections', '-ffunction-sections',
'-funwind-tables', '-fstack-protector-strong', '-no-canonical-prefixes']
const ndk_21_default_general_ld_flags = ['-Wl,--exclude-libs,libgcc.a',
'-Wl,--exclude-libs,libgcc_real.a', '-Wl,--exclude-libs,libatomic.a']
const ndk_supported_cpp_features = ['rtti', 'exceptions', 'no-rtti', 'no-exceptions']

@[params]
pub struct FlagConfig {
Expand Down
36 changes: 15 additions & 21 deletions android/ndk/ndk.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ import vab.cache
import vab.android.sdk
import vab.android.util

const (
home = os.home_dir()
)
const home = os.home_dir()

pub const (
supported_archs = ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
min_supported_version = min_version_supported_by_vab()
)
pub const supported_archs = ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
pub const min_supported_version = min_version_supported_by_vab()

pub enum CompilerLanguageType {
c
Expand All @@ -31,20 +27,18 @@ pub enum Tool {
// However ANDROID_NDK_ROOT is widely used and the `sdkmanager` has support
// for installing the NDK - and it will do so in a sub-folder (/ndk) of the SDK root.
// This is also referred to as a "Side by side" install.
const (
possible_ndk_paths_windows = [
os.join_path(sdk.root(), 'ndk'),
os.join_path(sdk.root(), 'ndk-bundle'),
]
possible_ndk_paths_macos = [
os.join_path(sdk.root(), 'ndk'),
os.join_path(sdk.root(), 'ndk-bundle'),
]
possible_ndk_paths_linux = [
os.join_path(sdk.root(), 'ndk'),
os.join_path(sdk.root(), 'ndk-bundle'),
]
)
const possible_ndk_paths_windows = [
os.join_path(sdk.root(), 'ndk'),
os.join_path(sdk.root(), 'ndk-bundle'),
]
const possible_ndk_paths_macos = [
os.join_path(sdk.root(), 'ndk'),
os.join_path(sdk.root(), 'ndk-bundle'),
]
const possible_ndk_paths_linux = [
os.join_path(sdk.root(), 'ndk'),
os.join_path(sdk.root(), 'ndk-bundle'),
]

// root will try to detect where the Android NDK is installed. Otherwise return blank
pub fn root() string {
Expand Down
18 changes: 8 additions & 10 deletions android/package.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ import vab.android.env
import vab.android.sdk
import vab.android.util

pub const (
default_app_name = 'V Test App'
default_package_id = 'io.v.android'
default_activity_name = 'VActivity'
default_package_format = 'apk'
default_min_sdk_version = 21
default_base_files_path = get_default_base_files_path()
supported_package_formats = ['apk', 'aab']
supported_lib_folders = ['armeabi', 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
)
pub const default_app_name = 'V Test App'
pub const default_package_id = 'io.v.android'
pub const default_activity_name = 'VActivity'
pub const default_package_format = 'apk'
pub const default_min_sdk_version = 21
pub const default_base_files_path = get_default_base_files_path()
pub const supported_package_formats = ['apk', 'aab']
pub const supported_lib_folders = ['armeabi', 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']

// PackageFormat holds all supported package formats
pub enum PackageFormat {
Expand Down
10 changes: 4 additions & 6 deletions android/sdk/sdk.v
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import semver
import vab.cache
import vab.android.util

pub const (
default_api_level = os.file_name(default_platforms_dir()).all_after('android-')
default_build_tools_version = os.file_name(default_build_tools_dir())
min_supported_api_level = '21'
min_supported_build_tools_version = '26.0.2'
)
pub const default_api_level = os.file_name(default_platforms_dir()).all_after('android-')
pub const default_build_tools_version = os.file_name(default_build_tools_dir())
pub const min_supported_api_level = '21'
pub const min_supported_build_tools_version = '26.0.2'

enum Component {
ndk
Expand Down
4 changes: 1 addition & 3 deletions cache/cache.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ mut:
string_array_cache map[string][]string
}

const (
global_cache = &Cache{}
)
const global_cache = &Cache{}

pub fn get_string(key string) string {
mut c := &Cache(unsafe { nil })
Expand Down
28 changes: 14 additions & 14 deletions cli/cli.v
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import vab.android
import vab.android.sdk
import vab.android.ndk

pub const (
exe_version = version()
exe_name = os.file_name(os.executable())
exe_short_name = os.file_name(os.executable()).replace('.exe', '')
exe_dir = os.dir(os.real_path(os.executable()))
exe_args_description = 'input
pub const exe_version = version()
pub const exe_name = os.file_name(os.executable())
pub const exe_short_name = os.file_name(os.executable()).replace('.exe', '')
pub const exe_dir = os.dir(os.real_path(os.executable()))
pub const exe_args_description = 'input
or: vab <sub-command> [options] input'
exe_description = 'V Android Bootstrapper.

pub const exe_description = 'V Android Bootstrapper.
Compile, package and deploy graphical V apps for Android.

The following flags does the same as if they were passed to the "v" compiler:
Expand All @@ -24,13 +24,13 @@ The following flags does the same as if they were passed to the "v" compiler:

Sub-commands:
doctor Display useful info about your system for bug reports'
exe_git_hash = vab_commit_hash()
work_directory = vab_tmp_work_dir()
cache_directory = vab_cache_dir()
rip_vflags = ['-autofree', '-gc', '-g', '-cg', '-prod', 'run', '-showcc']
subcmds = ['complete', 'test-cleancode']
accepted_input_files = ['.v', '.apk', '.aab']
)

pub const exe_git_hash = vab_commit_hash()
pub const work_directory = vab_tmp_work_dir()
pub const cache_directory = vab_cache_dir()
pub const rip_vflags = ['-autofree', '-gc', '-g', '-cg', '-prod', 'run', '-showcc']
pub const subcmds = ['complete', 'test-cleancode']
pub const accepted_input_files = ['.v', '.apk', '.aab']

pub const vab_env_vars = [
'VAB_FLAGS',
Expand Down
6 changes: 2 additions & 4 deletions cmd/cleancode.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ module main
import os
import vab.vxt

const (
exe_name = os.file_name(os.executable())
exe_dir = os.dir(os.real_path(os.executable()))
)
const exe_name = os.file_name(os.executable())
const exe_dir = os.dir(os.real_path(os.executable()))

pub fn run(args []string) os.Result {
return os.execute(args.join(' '))
Expand Down
Loading
Loading