Skip to content

Commit

Permalink
chore: reverted back to correct aostdio.c updated version for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterFarber committed Aug 8, 2024
1 parent bce4175 commit 3ec2373
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 99 deletions.
13 changes: 12 additions & 1 deletion dev-cli/container/src/aolibc/aostdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// async JS code from C.
EM_ASYNC_JS(int, weavedrive_open, (const char* c_filename, const char* mode), {
const filename = UTF8ToString(Number(c_filename));
if (!Module.WeaveDrive) {
return Promise.resolve(null)
}

const drive = Module.WeaveDrive(Module, FS);
return await drive.open(filename);
});
Expand All @@ -24,6 +28,11 @@ EM_ASYNC_JS(int, weavedrive_read, (int fd, int *dst_ptr, size_t length), {
return Promise.resolve(await drive.read(fd, dst_ptr, length));
});

EM_ASYNC_JS(int, weavedrive_close, (int fd), {
const drive = Module.WeaveDrive(Module, FS);
return drive.close(fd);
});

FILE* fopen(const char* filename, const char* mode) {
AO_LOG( "AO: Called fopen: %s, %s\n", filename, mode);
int fd = weavedrive_open(filename, mode);
Expand All @@ -43,6 +52,8 @@ size_t fread(void* ptr, size_t size, size_t nmemb, FILE* stream) {

int fclose(FILE* stream) {
AO_LOG( "AO: fclose called\n");
int fd = fileno(stream);
weavedrive_close(fd);
return 0; // Returning success, adjust as necessary
}

Expand Down Expand Up @@ -81,4 +92,4 @@ int munmap(void* addr, size_t length) {
AO_LOG("AO: munmap called with addr: %p, length: %zu\n", addr, length);
return 0;
}
*/
*/
95 changes: 0 additions & 95 deletions dev-cli/container/src/aolibc/aostdio_old.c

This file was deleted.

2 changes: 1 addition & 1 deletion dev-cli/deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.1.2",
"version": "0.1.3",
"tasks": {
"cache": "deno cache --lock=deno.lock --lock-write ./src/mod.js",
"build-binaries": "./tools/build.sh",
Expand Down
26 changes: 26 additions & 0 deletions dev-cli/src/commands/exec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* global Deno */

import { Command } from '../deps.js'
import { VERSION } from '../versions.js'

export async function build (_, command) {
const pwd = Deno.cwd()
const p = Deno.run({
cmd: [
'docker',
'run',
'--platform',
'linux/amd64',
'-v',
`${pwd}:/src`,
`p3rmaw3b/ao:${VERSION.IMAGE}`,
command
]
})
await p.status()
}

export const command = new Command()
.description('Build the Lua Project into WASM')
.arguments('<command:string>')
.action(build)
2 changes: 2 additions & 0 deletions dev-cli/src/mod.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { command as Build } from './commands/build.js'
import { command as Publish } from './commands/publish.js'
import { command as Spawn } from './commands/spawn.js'
import { command as Bundler } from './commands/bundler.js'
import { command as Exec } from './commands/exec.js'

const cli = new Command()
.name('ao')
Expand All @@ -24,5 +25,6 @@ const cli = new Command()
.command('publish', Publish)
.command('spawn', Spawn)
.command('bundler', Bundler)
.command('exec', Exec)

await cli.parse(Deno.args)
4 changes: 2 additions & 2 deletions dev-cli/src/versions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable */
export const VERSION = {
"CLI": "0.1.2",
"IMAGE": "0.1.1"
"CLI": "0.1.3",
"IMAGE": "0.1.2"
}

0 comments on commit 3ec2373

Please sign in to comment.