Skip to content

Commit

Permalink
Use the gleam build tool
Browse files Browse the repository at this point in the history
  • Loading branch information
tynanbe committed Sep 27, 2022
1 parent 34054ac commit 1b2e468
Show file tree
Hide file tree
Showing 12 changed files with 220 additions and 194 deletions.
4 changes: 0 additions & 4 deletions .formatter.exs

This file was deleted.

49 changes: 29 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,47 @@ name: CI
on:
push:
branches:
- "main"
- main
- "v*.*.*"
pull_request:

jobs:
test:
runs-on: ubuntu-latest
env:
MIX_ENV: test
steps:
- uses: actions/checkout@v2

- run: mv mix.exs mix.exs.ignore
- uses: actions/checkout@v3

- uses: erlef/setup-beam@v1
with:
otp-version: "24.2"
elixir-version: "1.13.1"
gleam-version: "0.19.0"
otp-version: "25.1"
elixir-version: "1.14.0"
gleam-version: "0.23.0"

- uses: actions/setup-node@v3
with:
node-version: 18

- run: mix archive.install hex mix_gleam --force
- uses: charlieegan3/fetch-gh-release-binary@main
with:
owner: rome
repo: tools
version: cli/v0.8.0-next
asset-pattern: linux-x64
install-path: /usr/local/bin/rome
verbose: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: echo "$PWD/build/packages/rad/priv" >> $GITHUB_PATH

- run: mv mix.exs.ignore mix.exs
- run: gleam deps download

- run: sed -i -E 's/# (\{:nx,)/\1/' mix.exs
- uses: actions/cache@v3
with:
path: build/packages
key: ${{ runner.os }}-gleam-${{ hashFiles('**/manifest.toml') }}
restore-keys: ${{ runner.os }}-gleam-

- run: mix deps.get
# TODO: Restore cache once mix_gleam handles deps.update
# - uses: actions/cache@v2
# with:
# path: deps
# key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
# restore-keys: ${{ runner.os }}-mix-
- run: rad format --check

- run: mix gleam.test
- run: rad test
31 changes: 3 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.beam
*.ez

# Ignore package tarball (built via "mix hex.build").
argamak-*.tar

# Temporary files, for example, from tests.
/tmp/

# The directory Gleam will write compiled artifacts to.
/build/
build
erl_crash.dump
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Changelog

## v0.2.0
## Unreleased

- The `space` module gets an updated `d1` function so the dimension size can be
given.
- The `tensor` module gains the `broadcast`, and `broadcast_over` functions for
all compilation targets (JavaScript planned).
- Argamak now uses the `gleam` build tool.

## v0.1.0 - 2022-01-20

Expand Down
31 changes: 24 additions & 7 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
name = "argamak"
version = "0.1.0"
licences = ["Apache-2.0"]
version = "0.2.0-dev"
description = "A tensor library for the Gleam programming language"
repository = { type = "github", user = "tynanbe", repo = "argamak" }
links = [{ title = "Website", href = "https://gleam.run/" }]
licences = ["Apache-2.0"]

[repository]
repo = "argamak"
user = "tynanbe"
type = "github"

[[links]]
href = "https://gleam.run/"
title = "Website"

[dependencies]
gleam_stdlib = "~> 0.19"
gleam_erlang = "~> 0.8"
gleam_erlang = "~> 0.15"
gleam_stdlib = "~> 0.23"
nx = "~> 0.3"

[dev-dependencies]
gleeunit = "~> 0.6"
gleeunit = "~> 0.7"
rad = "~> 0.1"

#[rad]
#targets = ["erlang", "javascript"]

[[rad.formatters]]
name = "javascript"
check = ["rome", "ci", "--indent-style=space", "src", "test"]
run = ["rome", "format", "--indent-style=space", "--write", "src", "test"]
25 changes: 19 additions & 6 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@
# You typically do not need to edit this file

packages = [
{ name = "gleam_erlang", version = "0.8.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "AF437B787D8FFE3608BA71AB879FBAAC52B2B3312F09403C27B1847476588313" },
{ name = "gleam_stdlib", version = "0.19.3", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "CA579C2FF0621E93FF6EFEF61BAFFCF0505732BA073F616E28878042F1A1F401" },
{ name = "gleeunit", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "77701A5E5A565727E1EEAC9196FB878D544049B6331CD0305B5A69699135EA1C" },
{ name = "complex", version = "0.4.2", build_tools = ["mix"], requirements = [], otp_app = "complex", source = "hex", outer_checksum = "069A085EF820CE675A2619FD125B963FF4514AF2102C7F7D7965128E5EC0A429" },
{ name = "gleam_erlang", version = "0.15.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "0C22868854FBF76F16D5B8BEFCC58C4EEAB85FF0C37214CFD06C2E3A56ACB2AC" },
{ name = "gleam_http", version = "3.1.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "8E0A96A56CB5870252EACB4860B8BC2AF755F5E13F4AB99970C572C5BB315053" },
{ name = "gleam_httpc", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "8C4ABF3FDA6C512E9B981FE3E242087910DE1952093BAB54D8EABBCD83801F92" },
{ name = "gleam_json", version = "0.5.0", build_tools = ["gleam"], requirements = ["thoas", "gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "E42443C98AA66E30143C24818F2CEA801491C10CE6B1A5EDDF3FC4ABDC7601CB" },
{ name = "gleam_stdlib", version = "0.23.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "6BF84F0A486192488F7A2DF44F90B1964831CB374C05F4856A7A0BB1DD37F68C" },
{ name = "gleeunit", version = "0.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "94DE5571BF62C416123C25F2C0F76E2AAF121F3416D156BFB72A588D0D03B8C6" },
{ name = "glint", version = "0.8.0", build_tools = ["gleam"], requirements = ["snag", "gleam_stdlib"], otp_app = "glint", source = "hex", outer_checksum = "A9A240E130913266E9BC42F65704832233A4E119E476A24062AD34C892FBC971" },
{ name = "nx", version = "0.3.0", build_tools = ["mix"], requirements = ["complex"], otp_app = "nx", source = "hex", outer_checksum = "D08D8962F4379ADE54281AAD84C45CB7EB0118B406FC836F07B94ACC40DF5859" },
{ name = "rad", version = "0.1.3", build_tools = ["gleam"], requirements = ["gleam_httpc", "glint", "gleam_erlang", "shellout", "gleam_stdlib", "gleam_json", "snag", "thoas", "tomerl", "gleam_http"], otp_app = "rad", source = "hex", outer_checksum = "CD62A2D12A426F87388B5EF8D03D85A442FCA8B030956BFC579FF282EE11F400" },
{ name = "shellout", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "310662075CDCB6E3928B03E3FD371B1DDCD691E1C709E606AB02195E36675D4E" },
{ name = "snag", version = "0.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "35C63E478782C58236F1050297C2FDF9806A4DD55C6FAF0B6EC5E54BC119342D" },
{ name = "thoas", version = "0.4.0", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "442296847ACA11DB8D25180693D7CA3073D6D7179F66952F07B16415306513B6" },
{ name = "tomerl", version = "0.5.0", build_tools = ["rebar3"], requirements = [], otp_app = "tomerl", source = "hex", outer_checksum = "2A7FB62F9EBF0E75561B39255638BC2B805B437C86FEC538657E7C3B576979FA" },
]

[requirements]
gleam_erlang = "~> 0.8"
gleam_stdlib = "~> 0.19"
gleeunit = "~> 0.6"
gleam_erlang = "~> 0.15"
gleam_stdlib = "~> 0.23"
gleeunit = "~> 0.7"
nx = "~> 0.3"
rad = "~> 0.1"
57 changes: 0 additions & 57 deletions mix.exs

This file was deleted.

6 changes: 0 additions & 6 deletions mix.lock

This file was deleted.

13 changes: 12 additions & 1 deletion src/argamak/format.gleam
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import argamak/util
import gleam/dynamic

/// Numerical formats for tensors.
///
Expand Down Expand Up @@ -132,6 +131,18 @@ if erlang {
}
}

if javascript {
/// TODO
///
pub opaque type Native {
Native(size: Int)
}

fn do_to_native(format: Format(a)) -> Native {
todo
}
}

/// Converts a `Format` into a `String`.
///
pub fn to_string(format: Format(a)) -> String {
Expand Down
Loading

0 comments on commit 1b2e468

Please sign in to comment.