Skip to content

Commit

Permalink
Merge pull request #22 from billywhizz/main
Browse files Browse the repository at this point in the history
0.0.13-pre
  • Loading branch information
billywhizz committed Dec 11, 2023
2 parents e65243e + 8f610cd commit 16b5b5d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CCARGS=-std=c++17 -c -fno-omit-frame-pointer -fno-rtti -fno-exceptions
CARGS=-c -fno-omit-frame-pointer
WARN=-Werror -Wpedantic -Wall -Wextra -Wno-unused-parameter
OPT=-O3
VERSION=0.0.12-pre
VERSION=0.0.13-pre
V8_VERSION=1.0.0
RUNTIME=lo
LO_HOME=$(shell pwd)
Expand Down
18 changes: 14 additions & 4 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ async function create_lo_home (path) {
// todo: change these methods to accept objects, not filenames
async function compile_bindings (lib, verbose = false) {
const cwd = getcwd()
const lib_dir = `lib/${lib}`
const binding_path = `${lib_dir}/api.js`
const lib_dir = join(LO_HOME, `lib/${lib}`)
const binding_path = join(LO_HOME, `${lib_dir}/api.js`)

// todo: download the lib if we don't have it internally
console.log(`${AM}compile binding${AD} ${lib} ${AY}in${AD} ${lib_dir}`)
Expand Down Expand Up @@ -129,7 +129,7 @@ async function compile_bindings (lib, verbose = false) {
console.log(`${AY}shared lib ${AD} ${def.name}.so ${AY}with${AG} ${CC}${AD}`)
unlink(`${def.name}.so`)
if (os === 'mac') {
exec2([...LINK.split(' '), '-bundle_loader', '../../lo', ...LARGS, OPT, '-bundle', ...WARN, '-o',
exec2([...LINK.split(' '), '-bundle_loader', LO_PATH, ...LARGS, OPT, '-bundle', ...WARN, '-o',
`${def.name}.so`, `${def.name}.o`,
...(def.obj || []).filter(f => extName(f) === 'a'),
...(def.libs || []).map(l => `-l${l}`),
Expand Down Expand Up @@ -246,7 +246,7 @@ const encoder = new TextEncoder()
const status = new Int32Array(2)

// todo: clean up api so we can pass a config in and run builds through api
const VERSION = getenv('VERSION') || '"0.0.12pre"'
const VERSION = getenv('VERSION') || '"0.0.13pre"'
const RUNTIME = getenv('RUNTIME') || '"lo"'
const TARGET = getenv('TARGET') || 'lo'
const LINK_TYPE = (getenv('LINK_TYPE') || '-rdynamic').split(' ')
Expand Down Expand Up @@ -300,6 +300,16 @@ const LARGS = (getenv('LARGS') || link_args).split(' ')
const so_ext = (os === 'linux' ? 'so' : (os === 'mac' ? 'so' : 'dll'))
config.os = os

let LO_PATH = '../../lo'
if (os === 'mac') {
const { mach } = lo.load('mach')
const max_path = new Uint32Array([1024])
const path_name = lo.ptr(new Uint8Array(1024))
assert(mach.get_executable_path(path_name.ptr, max_path) === 0)
LO_PATH = lo.latin1Decode(path_name.ptr, max_path[0])
console.log(`found lo at ${LO_PATH}`)
}

const runtimes = {
core: {
bindings: [
Expand Down
6 changes: 6 additions & 0 deletions lib/libssl/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,12 @@ const api = {
pointers: ['SSL*'],
result: 'i32'
},
SSL_write_string: {
parameters: ['pointer', 'string', 'i32'],
pointers: ['SSL*'],
result: 'i32',
name: 'SSL_write'
},
SSL_get_version: {
parameters: ['pointer'],
pointers: ['const SSL*'],
Expand Down
5 changes: 3 additions & 2 deletions lib/net/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const api = {
},
write_string: {
parameters: ['i32', 'string', 'i32'],
// we can add an override which reference another parameter and sets the param to a field/property of it
override: [, , { param: 1, fastfield: '->length', slowfield: '.length()' }],
result: 'i32',
name: 'write'
Expand Down Expand Up @@ -142,7 +143,8 @@ const constants = {
IPPROTO_RAW: 'i32',
SIOCSIFFLAGS: 'i32',
SIOCSIFADDR: 'i32',
SIOCSIFNETMASK: 'i32',
SIOCSIFNETMASK: 'i32',
SOCKADDR_LEN: 16
}

const includes = [
Expand All @@ -164,7 +166,6 @@ if (globalThis.lo) {
includes.push('sys/sendfile.h')
includes.push('linux/if_tun.h')
constants.SOCK_NONBLOCK = 'i32'
constants.SOCKADDR_LEN = 16 // todo
constants.SOCK_CLOEXEC = 'i32'
constants.PF_PACKET = 'i32'
constants.ETH_P_ALL = 'i32'
Expand Down
2 changes: 1 addition & 1 deletion lib/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MacTimer {
}

close () {
this.loop.remove(this.fd)
this.loop.remove(this.fd, kevents.EVFILT_TIMER)
}
}

Expand Down

0 comments on commit 16b5b5d

Please sign in to comment.