Commit 640bfb9 1 parent aece964 commit 640bfb9 Copy full SHA for 640bfb9
File tree 9 files changed +26
-19
lines changed
9 files changed +26
-19
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,11 @@ all: target/double
10
10
target :
11
11
mkdir -p $@
12
12
13
- target/double : target/main.o target/libdouble_input.a
13
+ target/double : target/main.o target/debug/ libdouble_input.a
14
14
$(CC ) -o $@ $^ $(LDFLAGS )
15
15
16
- target/libdouble_input.a : src/lib.rs Cargo.toml
16
+ target/debug/ libdouble_input.a : src/lib.rs Cargo.toml
17
17
cargo build
18
- (cd target && ln -nsf debug/libdouble_input-* .a libdouble_input.a)
19
18
20
19
target/main.o : src/main.c | target
21
20
$(CC ) -o $@ -c $<
Original file line number Diff line number Diff line change 4
4
EXT := so
5
5
endif
6
6
7
- all : target/libdouble_input.$(EXT ) node_modules/ffi
7
+ all : target/debug/ libdouble_input.$(EXT ) node_modules/ffi
8
8
node src/main.js
9
9
10
- target/libdouble_input.$(EXT ) : src/lib.rs Cargo.toml
10
+ target/debug/ libdouble_input.$(EXT ) : src/lib.rs Cargo.toml
11
11
cargo build
12
- (cd target && ln -nsf debug/libdouble_input-* $( EXT) libdouble_input.$( EXT) )
13
12
14
13
node_modules/ffi :
15
14
npm install ffi
Original file line number Diff line number Diff line change 1
1
var ffi = require ( 'ffi' ) ;
2
2
3
- var lib = ffi . Library ( 'target/libdouble_input' , {
3
+ var lib = ffi . Library ( 'target/debug/ libdouble_input' , {
4
4
'double_input' : [ 'int' , [ 'int' ] ]
5
5
} ) ;
6
6
Original file line number Diff line number Diff line change 4
4
EXT := so
5
5
endif
6
6
7
- all : target/libdouble_input.so
7
+ all : target/debug/ libdouble_input.$( EXT )
8
8
perl src/main.pl
9
9
10
- target/libdouble_input.so : src/lib.rs Cargo.toml
10
+ target/debug/ libdouble_input.$( EXT ) : src/lib.rs Cargo.toml
11
11
cargo build
12
- (cd target && ln -nsf debug/libdouble_input-* $( EXT) libdouble_input.so)
13
12
14
13
clean :
15
14
rm -rf target
Original file line number Diff line number Diff line change 2
2
use FFI::Raw;
3
3
4
4
my $double_input = FFI::Raw-> new(
5
- " target/libdouble_input.so" ,
5
+ " target/debug/ libdouble_input.so" ,
6
6
' double_input' ,
7
7
FFI::Raw::int , # return value
8
8
FFI::Raw::int # arg #1
Original file line number Diff line number Diff line change 4
4
EXT := so
5
5
endif
6
6
7
- all : target/libdouble_input.so
7
+ all : target/debug/ libdouble_input.$( EXT )
8
8
python src/main.py
9
9
10
- target/libdouble_input.so : src/lib.rs Cargo.toml
10
+ target/debug/ libdouble_input.$( EXT ) : src/lib.rs Cargo.toml
11
11
cargo build
12
- (cd target && ln -nsf debug/libdouble_input-* $( EXT) libdouble_input.so)
13
12
14
13
clean :
15
14
rm -rf target
Original file line number Diff line number Diff line change 1
1
from ctypes import cdll
2
+ from sys import platform
2
3
3
- lib = cdll .LoadLibrary ('target/libdouble_input.so' )
4
+ if platform == "darwin" :
5
+ ext = "dylib"
6
+ else :
7
+ ext = "so"
8
+
9
+ lib = cdll .LoadLibrary ('target/debug/libdouble_input.' + ext )
4
10
double_input = lib .double_input
5
11
6
12
input = 4
Original file line number Diff line number Diff line change 4
4
EXT := so
5
5
endif
6
6
7
- all : target/libdouble_input.so
7
+ all : target/debug/ libdouble_input.$( EXT )
8
8
ruby src/main.rb
9
9
10
- target/libdouble_input.so : src/lib.rs Cargo.toml
10
+ target/debug/ libdouble_input.$( EXT ) : src/lib.rs Cargo.toml
11
11
cargo build
12
- (cd target && ln -nsf debug/libdouble_input-* $( EXT) libdouble_input.so)
13
12
14
13
clean :
15
14
rm -rf target
Original file line number Diff line number Diff line change 1
1
require 'ffi'
2
2
3
+ if RUBY_PLATFORM . include? ( 'darwin' )
4
+ EXT = 'dylib'
5
+ else
6
+ EXT = 'so'
7
+ end
8
+
3
9
module Hello
4
10
extend FFI ::Library
5
- ffi_lib 'target/libdouble_input.so'
11
+ ffi_lib 'target/debug/ libdouble_input.' + EXT
6
12
attach_function :double_input , [ :int ] , :int
7
13
end
8
14
You can’t perform that action at this time.
0 commit comments