Skip to content

Commit

Permalink
feat(bindings): update README.md and add CSERIALPORT_DEBUG for log
Browse files Browse the repository at this point in the history
  • Loading branch information
itas109 committed May 15, 2024
1 parent 4a62e50 commit 7e6d9df
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bindings/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cmake version 3.26.4
## Build

```
cd c
cd bindings/c
mkdir bin
cd bin
cmake ..
Expand Down
2 changes: 2 additions & 0 deletions bindings/csharp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ cmake_minimum_required(VERSION 3.8.2)

project(cserialport)

# add_definitions(-DCSERIALPORT_DEBUG) # CSerialPort Debug Mode

# set output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down
2 changes: 1 addition & 1 deletion bindings/csharp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cmake version 3.26.4
## Build

```
cd csharp
cd bindings/csharp
mkdir bin
cd bin
cmake .. -DSWIG_EXECUTABLE=D:/swigwin-4.1.1/swig.exe
Expand Down
2 changes: 2 additions & 0 deletions bindings/java/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ cmake_minimum_required(VERSION 3.8.2)

project(cserialport)

# add_definitions(-DCSERIALPORT_DEBUG) # CSerialPort Debug Mode

# set output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down
2 changes: 1 addition & 1 deletion bindings/java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ cmake version 3.26.4
## Build

```
cd java
cd bindings/java
mkdir bin
cd bin
cmake .. -DSWIG_EXECUTABLE=D:/swigwin-4.1.1/swig.exe
Expand Down
2 changes: 2 additions & 0 deletions bindings/javascript/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ cmake_minimum_required(VERSION 3.8.2)

project(cserialport)

# add_definitions(-DCSERIALPORT_DEBUG) # CSerialPort Debug Mode

# set output directory
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down
1 change: 1 addition & 0 deletions bindings/javascript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ nodejs: 12.22.12
## Build

```
cd bindings/javascript
swig -javascript -c++ -node -outdir generate -I../../include cserialport.i
node-gyp configure build --debug
```
Expand Down
2 changes: 2 additions & 0 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ cmake_minimum_required(VERSION 3.8.2)

project(cserialport)

# add_definitions(-DCSERIALPORT_DEBUG) # CSerialPort Debug Mode

# set output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down
84 changes: 80 additions & 4 deletions bindings/python/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,101 @@
# CSerialPort for Python

```
swig: 4.1.0
cmake: 3.8.2
python: 3.6.8
swig: 4.1.1 (2022-11-30)
cmake: 3.26.4
python: 3.10.11
```

## Install swig && cmake

### windows

- swig

```
$ wget https://sourceforge.net/projects/swig/files/swigwin/swigwin-4.1.1/swigwin-4.1.1.zip
```

- cmake

```
$ wget https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-windows-x86_64.msi
```

### linux

- swig

```
$ wget https://sourceforge.net/projects/swig/files/swig/swig-4.1.1/swig-4.1.1.tar.gz
$ tar zxvf swig-4.1.1.tar.gz
$ cd swig-4.1.1
$ ./configure --without-pcre
$ make
$ sudo make install
$ swig -version
SWIG Version 4.1.1
```

- cmake

```
$ wget https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-x86_64.sh
$ sudo ./cmake-3.26.4-linux-x86_64.sh --prefix=/usr/local --skip-license
$ cmake --version
cmake version 3.26.4
```

## Build

```
cd bindings/python
mkdir bin
cd bin
cmake ..
cmake .. -DSWIG_EXECUTABLE=D:/swigwin-4.1.1/swig.exe
cmake --build . --config Release
```

**Notice:**

```
D:/swigwin-4.1.1/swig.exe should replace with your path to swig.exe
```

or (config swig to path)

```
set path=D:/swigwin-4.1.1;%path%
cmake ..
```

## Run

```
cd bindings/python
cmake -E copy generate/cserialport.py example
cmake -E copy bin/bin/Release/_cserialport.pyd example
python example/main.py
```

### Tree

```
bindings/python $tree
.
+--- bin
| +--- bin
| | +--- Release
| | | +--- _cserialport.pyd
+--- CMakeLists.txt
+--- cserialport.i
+--- example
| +--- cserialport.py
| +--- main.py
| +--- _cserialport.pyd
+--- generate
| +--- cserialport.py
| +--- cserialportPYTHON_wrap.cxx
| +--- cserialportPYTHON_wrap.h
+--- README.md
```

0 comments on commit 7e6d9df

Please sign in to comment.