-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mostly copied from pkg-fs.
- Loading branch information
Showing
15 changed files
with
349 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" # Necessary to update action hashs. | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
# Allow up to 3 opened pull requests for github-actions versions. | ||
open-pull-requests-limit: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Zero-Clause BSD License | ||
|
||
# Copyright (C) 2024 Toitware ApS. | ||
|
||
# Permission to use, copy, modify, and/or distribute this software for any | ||
# purpose with or without fee is hereby granted. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
# PERFORMANCE OF THIS SOFTWARE. | ||
|
||
name: CI | ||
|
||
on: | ||
push: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-latest, windows-latest, macos-latest ] | ||
# The versions should contain (at least) the lowest requirement | ||
# and a version that is more up to date. | ||
toit-version: [ v2.0.0-alpha.120, latest ] | ||
include: | ||
- toit-version: v2.0.0-alpha.120 | ||
version-name: old | ||
- toit-version: latest | ||
version-name: new | ||
|
||
name: CI - ${{ matrix.os }} - ${{ matrix.version-name }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: toitlang/action-setup@v1 | ||
with: | ||
toit-version: ${{ matrix.toit-version }} | ||
|
||
- name: Test | ||
run: | | ||
make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Zero-Clause BSD License | ||
|
||
# Copyright (C) 2024 Toitware ApS. | ||
|
||
# Permission to use, copy, modify, and/or distribute this software for any | ||
# purpose with or without fee is hereby granted. | ||
|
||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
# PERFORMANCE OF THIS SOFTWARE. | ||
|
||
name: Publish package | ||
on: | ||
push: | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
- 'v[0-9]+.[0-9]+.[0-9]+-*' | ||
jobs: | ||
create-release: | ||
name: Create new release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Publish | ||
uses: toitlang/[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.packages/ | ||
/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (C) 2022 Toitware ApS. | ||
# Use of this source code is governed by a Zero-Clause BSD license that can | ||
# be found in the tests/LICENSE file. | ||
|
||
cmake_minimum_required(VERSION 3.23) | ||
|
||
project(fs NONE) | ||
|
||
enable_testing() | ||
add_subdirectory(tests) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (C) 2023 Toitware ApS. | ||
# Use of this source code is governed by a Zero-Clause BSD license that can | ||
# be found in the tests/LICENSE file. | ||
|
||
all: test | ||
|
||
.PHONY: build/CMakeCache.txt | ||
build/CMakeCache.txt: | ||
$(MAKE) rebuild-cmake | ||
|
||
install-pkgs: rebuild-cmake | ||
cmake --build build --target install-pkgs | ||
|
||
test: install-pkgs rebuild-cmake | ||
cmake --build build --target check | ||
|
||
# We rebuild the cmake file all the time. | ||
# We use "glob" in the cmakefile, and wouldn't otherwise notice if a new | ||
# file (for example a test) was added or removed. | ||
# It takes <1s on Linux to run cmake, so it doesn't hurt to run it frequently. | ||
rebuild-cmake: | ||
mkdir -p build | ||
# We need to set a build type, otherwise cmake won't run nicely on Windows. | ||
# The build-type is otherwise unused. | ||
cmake -B build -DCMAKE_BUILD_TYPE=Debug | ||
|
||
.PHONY: all test rebuild-cmake install-pkgs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,13 @@ | ||
# pkg-xdg | ||
Package for XDG (Cross-Desktop Group) functionality | ||
# Cross | ||
|
||
A Toit package for cross-platform functionality. | ||
|
||
## References | ||
|
||
- [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) | ||
|
||
## Features and bugs | ||
|
||
Please file feature requests and bugs at the [issue tracker][tracker]. | ||
|
||
[tracker]: https://github.com/toitlang/pkg-cross/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
sdk: ^2.0.0-alpha.120 | ||
prefixes: | ||
host: pkg-host | ||
packages: | ||
pkg-host: | ||
url: github.com/toitlang/pkg-host | ||
name: host | ||
version: 1.11.0 | ||
hash: 7e7df6ac70d98a02f232185add81a06cec0d77e8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name: cross | ||
description: Cross platform functionality, based on XDG (Cross-Desktop Group) specifications. | ||
environment: | ||
sdk: ^2.0.0-alpha.120 | ||
dependencies: | ||
host: | ||
url: github.com/toitlang/pkg-host | ||
version: ^1.11.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// Copyright (C) 2024 Toitware ApS. All rights reserved. | ||
// Use of this source code is governed by an MIT-style license that can be | ||
// found in the package's LICENSE file. | ||
import host.os | ||
import system | ||
|
||
/** | ||
A library for cross-platform functionality, primarily based on XDG | ||
(Cross-Desktop Group) specifications. | ||
The XDG specification defines a set of environment variables that are used to | ||
locate user-specific directories for various purposes. This library provides | ||
access to some of these directories. | ||
This library does not try to be smart about different operating systems. For | ||
example, it does not map the $config-home on macOS to the 'Library/Preferences' | ||
directory. Instead, it uses the \$XDG_CONFIG_HOME environment variable, and, if | ||
that is not set, falls back to the ~/.config directory. For command-line | ||
tools, this is more often the correct behavior. However, care must be taken | ||
when using the \$cache directory. Macos time machine will not back up files in | ||
'~/Library/Caches', but it will back up files in '~/.cache'. A good work-around | ||
is to symlink '~/.cache' to somewhere in '~/Library/Caches'. | ||
The XDG base directory specification is available at | ||
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html | ||
*/ | ||
|
||
/** | ||
Returns the value of the given $xdg-env-var-name. | ||
If the environment variable is not set, then uses the given $fallback which | ||
is assumed to be relative to the user's home. | ||
*/ | ||
from-env_ xdg-env-var-name/string --fallback/string -> string?: | ||
xdg-result := os.env.get xdg-env-var-name | ||
if xdg-result: return xdg-result | ||
|
||
// All fallbacks are relative to the user's home directory. | ||
home := os.env.get "HOME" | ||
if not home and system.platform == system.PLATFORM-WINDOWS: | ||
home = os.env.get "USERPROFILE" | ||
|
||
if not home: throw "Could not determine home directory." | ||
|
||
separator := system.platform == system.PLATFORM-WINDOWS ? "\\" : "/" | ||
return "$home$separator$fallback" | ||
|
||
/** | ||
The base directory relative to which user-specific data files should be stored. | ||
*/ | ||
data-home -> string?: | ||
return from-env_ "XDG_DATA_HOME" --fallback=".local/share" | ||
|
||
/** | ||
The list of additional directories to look for data files in addition to | ||
$data-home. | ||
*/ | ||
data-dirs -> List: | ||
dirs := os.env.get "XDG_DATA_DIRS" | ||
if not dirs: return ["/usr/local/share", "/usr/share"] | ||
return dirs.split ":" | ||
|
||
/** | ||
The base directory relative to which user-specific configuration files should be | ||
stored. | ||
*/ | ||
config-home -> string?: | ||
return from-env_ "XDG_CONFIG_HOME" --fallback=".config" | ||
|
||
/** | ||
A list of additional directories to look for configuration files in addition to | ||
$config-home. | ||
*/ | ||
config-dirs -> List: | ||
dirs := os.env.get "XDG_CONFIG_DIRS" | ||
if not dirs: return ["/etc/xdg"] | ||
return dirs.split ":" | ||
|
||
/** | ||
The base directory relative to which user-specific state files should be stored. | ||
The state directory contains data that should be kept across program invocations, | ||
but is not important or portable enough to be stored in the $data-home. | ||
Examples of data that might be stored in the state directory include: | ||
- logs, recently used files, history, etc. | ||
- the current state of the application on this machine (like the layout, undo history, etc.) | ||
*/ | ||
state-home -> string?: | ||
return from-env_ "XDG_STATE_HOME" --fallback=".local/state" | ||
|
||
/** | ||
The base directory relative to which user-specific non-essential (cached) data | ||
should be stored. | ||
*/ | ||
cache-home -> string?: | ||
return from-env_ "XDG_CACHE_HOME" --fallback=".cache" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Copyright (C) 2023 Toitware ApS. | ||
# Use of this source code is governed by a Zero-Clause BSD license that can | ||
# be found in the tests/LICENSE file. | ||
|
||
file(GLOB TESTS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*_test.toit" "*-test.toit" "*_test_slow.toit" "*-test-slow.toit") | ||
|
||
# Add windows exe extension. | ||
set(TOIT_EXEC "toit.run${CMAKE_EXECUTABLE_SUFFIX}" CACHE FILEPATH "The executable used to run the tests") | ||
set(TPKG_EXEC "toit.pkg${CMAKE_EXECUTABLE_SUFFIX}" CACHE FILEPATH "The executable used to install the packages") | ||
set(TEST_TIMEOUT 40 CACHE STRING "The maximal amount of time each test is allowed to run") | ||
set(SLOW_TEST_TIMEOUT 200 CACHE STRING "The maximal amount of time each slow test is allowed to run") | ||
|
||
message("TPKG: ${TPKG_EXEC}") | ||
add_custom_target( | ||
"install-pkgs" | ||
COMMAND "${TPKG_EXEC}" install | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
|
||
include(ProcessorCount) | ||
ProcessorCount(NUM_CPU) | ||
|
||
# Add a custom target 'check' that runs our unit tests. | ||
add_custom_target( | ||
"check" | ||
COMMAND "${CMAKE_CTEST_COMMAND}" -j${NUM_CPU} --output-on-failure -C Debug | ||
USES_TERMINAL | ||
) | ||
|
||
set(TEST_PREFIX "") | ||
# Tests that fail locally and on toitlang/toit. | ||
include(fail.cmake OPTIONAL) | ||
# Tests that only fail when called with this test runner. | ||
include(fail_pkg.cmake OPTIONAL) | ||
|
||
message("Failing tests: ${FAILING_TESTS}") | ||
message("Skipped tests: ${SKIP_TESTS}") | ||
|
||
foreach(file ${TESTS}) | ||
set(test_name "/tests/${file}") | ||
if("${test_name}" IN_LIST SKIP_TESTS) | ||
continue() | ||
endif() | ||
|
||
add_test( | ||
NAME "${test_name}" | ||
COMMAND "${TOIT_EXEC}" "tests/${file}" | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
) | ||
|
||
if ("${file}" MATCHES "slow.toit") | ||
set_tests_properties(${test_name} PROPERTIES TIMEOUT ${SLOW_TEST_TIMEOUT}) | ||
else() | ||
set_tests_properties(${test_name} PROPERTIES TIMEOUT ${TEST_TIMEOUT}) | ||
endif() | ||
|
||
if ("${test_name}" IN_LIST FAILING_TESTS) | ||
set_tests_properties("${test_name}" PROPERTIES WILL_FAIL TRUE) | ||
endif() | ||
|
||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Zero-Clause BSD License | ||
|
||
Copyright (C) 2023 Toitware ApS | ||
|
||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
sdk: ^2.0.0-alpha.120 | ||
prefixes: | ||
fs: .. | ||
host: pkg-host | ||
packages: | ||
..: | ||
path: .. | ||
prefixes: | ||
host: pkg-host | ||
pkg-host: | ||
url: github.com/toitlang/pkg-host | ||
name: host | ||
version: 1.12.0 | ||
hash: fe5e10c56abc3fca1ef9bcba415e77fd59183cab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dependencies: | ||
cross: | ||
path: .. | ||
host: | ||
url: github.com/toitlang/pkg-host | ||
version: ^1.12.0 |