Skip to content

Commit

Permalink
Preparation for the port from Rust to LFE/Erlang.
Browse files Browse the repository at this point in the history
  • Loading branch information
oubiwann committed Nov 27, 2023
1 parent 1c2e3ef commit 15088b2
Show file tree
Hide file tree
Showing 18 changed files with 652 additions and 642 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: ci/cd

on:
workflow_dispatch:
push:
branches: [ main, 'release/*' ]
pull_request:
branches: [ main, 'release/*' ]
# Build once a month, just to be sure things are still working
schedule:
- cron: "19 3 26 * *"

jobs:

core-builds:
name: Erlang ${{ matrix.otp_version }} build
runs-on: ubuntu-latest

strategy:
matrix:
otp_version: ['24.3', '25.3', '26.1']

steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp_version }}
rebar3-version: '3.22'
- name: Install Deps
run: sudo apt-get update && sudo apt-get install -y gnuplot
- name: Compile
run: rebar3 compile
- name: Xref Checks
run: rebar3 xref
# - name: Dialyzer
# run: rebar3 dialyzer
- name: Proper Tests
run: rebar3 as test do compile, proper --regressions
# - name: Run Tests
# run: rebar3 ct -c
- name: Run Unit Tests
run: rebar3 as test lfe ltest -tall
# - name: Test Coverage
# run: rebar3 as test do proper -c, cover -v --min_coverage=0

older-builds:
name: Old Erlang ${{ matrix.otp_version }} build
runs-on: ubuntu-20.04

strategy:
matrix:
otp_version: ['21.3', '22.3', '23.3']

steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp_version }}
rebar3-version: '3.15'
- name: Install Deps
run: sudo apt-get update && sudo apt-get install -y gnuplot
- name: Compile
run: rebar3 compile
- name: Xref Checks
run: rebar3 xref
# - name: Dialyzer
# run: rebar3 dialyzer
- name: Compile Tests
run: rebar3 as test compile
- name: Proper Tests
run: rebar3 as test proper --regressions
# - name: Run Tests
# run: rebar3 ct -c
- name: Run Unit Tests
run: rebar3 as test lfe ltest -tall
# - name: Test Coverage
# run: rebar3 as test do proper -c, cover -v --min_coverage=0
27 changes: 0 additions & 27 deletions .github/workflows/rust.yml

This file was deleted.

39 changes: 35 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
Cargo.lock
/target
**/*.rs.bk
.idea
# erlang
.eunit
*.o
*.beam
*.plt
erl_crash.dump
.concrete/DEV_MODE

# rebar 2.x
.rebar
rel/example_project
ebin/*.beam
deps

# rebar 3
.rebar3
rebar3.crashdump
_build/
_checkouts/
rebar.lock

# emacs
*~
\#*\#
.\#*
.emacs.desktop
.emacs.desktop.lock

# apple
.DS_Store

# misc
/priv/images/drafts/*
/doc/*
/priv/output/*
13 changes: 0 additions & 13 deletions Cargo.toml

This file was deleted.

244 changes: 86 additions & 158 deletions README.md

Large diffs are not rendered by default.

Binary file added priv/images/logo-large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added priv/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{erl_opts, [debug_info]}.

{deps, [
{lfe, "2.1.2"}
]}.

{plugins, [
{rebar3_lfe, "0.4.8"}
]}.

{provider_hooks, [
{pre, [{compile, {lfe, compile}}]}
]}.

{xref_checks,[
undefined_function_calls,undefined_functions,locals_not_used,
deprecated_function_calls,deprecated_functions
]}.

{profiles, [
{test, [
{deps, [
{proper, "1.3.0"},
{ltest, "0.13.4"}
]},
{plugins, [
{rebar3_proper, "0.12.0"}
]},
{eunit_opts, [verbose]},
{erl_opts, [{src_dirs, ["src", "test"]}]}
]}
]}.

{alias, [
{coverage, [
{proper, "-c"},
{cover, "-v --min_coverage=0"}
]},
%% as test
{ltest, [
{lfe, ltest, "-tall"}
]},
{check, [
compile,
%%xref,
%%dialyzer,
ltest,
coverage
]}
]}.
29 changes: 29 additions & 0 deletions src/dirs-lin.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
(defmodule dirs-lin
(export all))

;;extern crate dirs_sys;

;;use std::env;
;;use std::path::PathBuf;

;;pub fn home_dir() -> Option<PathBuf> { dirs_sys::home_dir() }

;;pub fn cache_dir() -> Option<PathBuf> { env::var_os("XDG_CACHE_HOME") .and_then(dirs_sys::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".cache"))) }
;;pub fn config_dir() -> Option<PathBuf> { env::var_os("XDG_CONFIG_HOME").and_then(dirs_sys::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".config"))) }
;;pub fn config_local_dir() -> Option<PathBuf> { config_dir() }
;;pub fn data_dir() -> Option<PathBuf> { env::var_os("XDG_DATA_HOME") .and_then(dirs_sys::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".local/share"))) }
;;pub fn data_local_dir() -> Option<PathBuf> { data_dir() }
;;pub fn preference_dir() -> Option<PathBuf> { config_dir() }
;;pub fn runtime_dir() -> Option<PathBuf> { env::var_os("XDG_RUNTIME_DIR").and_then(dirs_sys::is_absolute_path) }
;;pub fn state_dir() -> Option<PathBuf> { env::var_os("XDG_STATE_HOME") .and_then(dirs_sys::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".local/state"))) }
;;pub fn executable_dir() -> Option<PathBuf> { env::var_os("XDG_BIN_HOME") .and_then(dirs_sys::is_absolute_path).or_else(|| home_dir().map(|h| h.join(".local/bin"))) }

;;pub fn audio_dir() -> Option<PathBuf> { dirs_sys::user_dir("MUSIC") }
;;pub fn desktop_dir() -> Option<PathBuf> { dirs_sys::user_dir("DESKTOP") }
;;pub fn document_dir() -> Option<PathBuf> { dirs_sys::user_dir("DOCUMENTS") }
;;pub fn download_dir() -> Option<PathBuf> { dirs_sys::user_dir("DOWNLOAD") }
;;pub fn font_dir() -> Option<PathBuf> { data_dir().map(|d| d.join("fonts")) }
;;pub fn picture_dir() -> Option<PathBuf> { dirs_sys::user_dir("PICTURES") }
;;pub fn public_dir() -> Option<PathBuf> { dirs_sys::user_dir("PUBLICSHARE") }
;;pub fn template_dir() -> Option<PathBuf> { dirs_sys::user_dir("TEMPLATES") }
;;pub fn video_dir() -> Option<PathBuf> { dirs_sys::user_dir("VIDEOS") }
30 changes: 30 additions & 0 deletions src/dirs-mac.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(defmodule dirs-mac
(export all))

;;extern crate dirs_sys;

;;use std::path::PathBuf;

;;pub fn home_dir() -> Option<PathBuf> { dirs_sys::home_dir() }

;;fn app_support_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Library/Application Support")) }

;;pub fn cache_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Library/Caches")) }
;;pub fn config_dir() -> Option<PathBuf> { app_support_dir() }
;;pub fn config_local_dir() -> Option<PathBuf> { app_support_dir() }
;;pub fn data_dir() -> Option<PathBuf> { app_support_dir() }
;;pub fn data_local_dir() -> Option<PathBuf> { app_support_dir() }
;;pub fn preference_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Library/Preferences")) }
;;pub fn executable_dir() -> Option<PathBuf> { None }
;;pub fn runtime_dir() -> Option<PathBuf> { None }
;;pub fn state_dir() -> Option<PathBuf> { None }

;;pub fn audio_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Music")) }
;;pub fn desktop_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Desktop")) }
;;pub fn document_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Documents")) }
;;pub fn download_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Downloads")) }
;;pub fn font_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Library/Fonts")) }
;;pub fn picture_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Pictures")) }
;;pub fn public_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Public")) }
;;pub fn template_dir() -> Option<PathBuf> { None }
;;pub fn video_dir() -> Option<PathBuf> { home_dir().map(|h| h.join("Movies")) }
28 changes: 28 additions & 0 deletions src/dirs-win.lfe
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(defmodule dirs-win
(export all))

;;extern crate dirs_sys;

;;use std::path::PathBuf;

;;pub fn home_dir() -> Option<PathBuf> { dirs_sys::known_folder_profile() }

;;pub fn cache_dir() -> Option<PathBuf> { data_local_dir() }
;;pub fn config_dir() -> Option<PathBuf> { dirs_sys::known_folder_roaming_app_data() }
;;pub fn config_local_dir() -> Option<PathBuf> { dirs_sys::known_folder_local_app_data() }
;;pub fn data_dir() -> Option<PathBuf> { dirs_sys::known_folder_roaming_app_data() }
;;pub fn data_local_dir() -> Option<PathBuf> { dirs_sys::known_folder_local_app_data() }
;;pub fn executable_dir() -> Option<PathBuf> { None }
;;pub fn preference_dir() -> Option<PathBuf> { dirs_sys::known_folder_local_app_data() }
;;pub fn runtime_dir() -> Option<PathBuf> { None }
;;pub fn state_dir() -> Option<PathBuf> { None }

;;pub fn audio_dir() -> Option<PathBuf> { dirs_sys::known_folder_music() }
;;pub fn desktop_dir() -> Option<PathBuf> { dirs_sys::known_folder_desktop() }
;;pub fn document_dir() -> Option<PathBuf> { dirs_sys::known_folder_documents() }
;;pub fn download_dir() -> Option<PathBuf> { dirs_sys::known_folder_downloads() }
;;pub fn font_dir() -> Option<PathBuf> { None }
;;pub fn picture_dir() -> Option<PathBuf> { dirs_sys::known_folder_pictures() }
;;pub fn public_dir() -> Option<PathBuf> { dirs_sys::known_folder_public()}
;;pub fn template_dir() -> Option<PathBuf> { dirs_sys::known_folder_templates() }
;;pub fn video_dir() -> Option<PathBuf> { dirs_sys::known_folder_videos() }
23 changes: 23 additions & 0 deletions src/dirs.app.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{application, dirs, [
{description, "A port of the Rust `dirs` library to LFE/Erlang"},
{vsn, "0.0.0"},
{registered, []},
{mod, {}},
{applications, [
kernel,
stdlib
]},
{env,[]},
{modules, []},

{licenses, ["Apache 2.0"]},
{links, [
{"GitHub", "https://github.com/lfex/dirs"},
{"Hex", "https://hex.pm/packages/dirs"}
]},
{exclude_files, [
"priv/html/*",
"priv/images/*",
"priv/.DS_Store"
]}
]}.
Loading

0 comments on commit 15088b2

Please sign in to comment.