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

Add mojo-libc package #32

Merged
merged 22 commits into from
Jan 27, 2025
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
33 changes: 33 additions & 0 deletions recipes/libc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Mojo's libc

`mojo-libc` is a library that provides access to the C standard library functions in Mojo.

## Getting Started

The only dependency for `libc` is Mojo.

You can install Mojo following the instructions from the [Modular website](https://www.modular.com/max/mojo).

Once you have created a Mojo project using the `magic` tool,

1. Add `libc` as a dependency:
```toml
[dependencies]
libc = ">=0.1.9"
```
2. Run `magic install` at the root of your project, where `mojoproject.toml` is located

3. `libc` should now be installed as a dependency. You can import libc functions from the library, e.g:
```mojo
from libc import socket
```

## Supported Functionality

### Basic socket connections

See the examples in [examples/sockets/](https://github.com/msaelices/mojo-libc/tree/main/examples/sockets) directory.

### Basic file system operations

See the examples in [examples/files/](https://github.com/msaelices/mojo-libc/tree/main/examples/files) directory.
Binary file added recipes/libc/avatar.jpeg
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 recipes/libc/image.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions recipes/libc/recipe.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
context:
version: "0.1.9"

package:
name: "libc"
version: ${{ version }}

source:
- git: https://github.com/msaelices/mojo-libc.git
rev: 674d0fd35af4e716eb30df18cb1fe25cdddb08cf

build:
number: 0
script:
- mojo package src/libc -o ${PREFIX}/lib/mojo/libc.mojopkg

requirements:
host:
- max == 24.6
run:
- ${{ pin_compatible('max') }}

about:
homepage: https://github.com/msaelices/mojo-libc
license: MIT
license_file: LICENSE
summary: Mojo's libc support
repository: https://github.com/msaelices/mojo-libc

extra:
maintainers:
- msaelices
- crisadamo
project_name: mojo-libc
Loading