Skip to content

Commit

Permalink
Add mojo-libc package (#32)
Browse files Browse the repository at this point in the history
* Add new mojo-libc package

Signed-off-by: Manuel Saelices <[email protected]>

* Add tests

* Add avatar and Mojo image

* Fix github link

Signed-off-by: Manuel Saelices <[email protected]>

* Add the extra section to the recipe.yaml

Signed-off-by: Manuel Saelices <[email protected]>

* Update libc revision to the one that includes the LICENSE

Signed-off-by: Manuel Saelices <[email protected]>

* Fix recipe script

Signed-off-by: Manuel Saelices <[email protected]>

* Fix the paths in the build recipe

Signed-off-by: Manuel Saelices <[email protected]>

* Pin Max 24.6 version

* Add main() function to the tests

Signed-off-by: Manuel Saelices <[email protected]>

* Fix test file

Signed-off-by: Manuel Saelices <[email protected]>

* Remove test as it's broken

---------

Signed-off-by: Manuel Saelices <[email protected]>
Co-authored-by: Caroline Frasca <[email protected]>
  • Loading branch information
msaelices and carolinefrasca authored Jan 27, 2025
1 parent 4c0c2c6 commit 7d7d08b
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
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

0 comments on commit 7d7d08b

Please sign in to comment.