Skip to content

Commit

Permalink
maybe fix examples
Browse files Browse the repository at this point in the history
  • Loading branch information
paleolimbot committed Jun 10, 2024
1 parent 97de973 commit 149e6bc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 70 deletions.
27 changes: 10 additions & 17 deletions .github/workflows/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,9 @@ jobs:
- name: Minimal Vendored Example
run: |
cd examples/vendored-minimal
mkdir build && cd build
cmake ../../.. -DNANOARROW_BUNDLE=ON -DNANOARROW_NAMESPACE=ExampleVendored
cmake --build .
cmake --install . --prefix=../src
cd ../src
python3 ../../ci/scripts/bundle.py --source-output-dir=src --include-output-dir=src
cd src
gcc -c library.c nanoarrow.c
ar rcs libexample_vendored_minimal_library.a library.o nanoarrow.o
gcc -o example_vendored_minimal_app app.c libexample_vendored_minimal_library.a
Expand All @@ -85,17 +81,14 @@ jobs:
- name: Ipc Vendored Example
run: |
cd examples/vendored-ipc
mkdir build && cd build
cmake ../../.. -DNANOARROW_BUNDLE=ON -DNANOARROW_NAMESPACE=ExampleVendored
cmake --build .
cmake --install . --prefix=../src/nanoarrow
mkdir ../build_ipc && cd ../build_ipc
cmake ../../../extensions/nanoarrow_ipc -DNANOARROW_IPC_BUNDLE=ON
cmake --build .
cmake --install . --prefix=../src/nanoarrow
cd ../src
python3 ../../ci/scripts/bundle.py \
--source-output-dir=src \
--include-output-dir=src \
--symbol-namespace=MyProject \
--with-ipc \
--with-flatcc
cd src
gcc -c library.c nanoarrow/nanoarrow.c nanoarrow/flatcc.c nanoarrow/nanoarrow_ipc.c -I./nanoarrow -I./nanoarrow/flatcc
ar rcs libexample_vendored_ipc_library.a library.o nanoarrow.o nanoarrow_ipc.o flatcc.o
gcc -o example_vendored_ipc_app app.c libexample_vendored_ipc_library.a
Expand Down
44 changes: 9 additions & 35 deletions examples/vendored-ipc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,52 +29,26 @@ to by another project.

The nanoarrow/ files included in this example are stubs to illustrate
how these files could fit in to a library and/or command-line application project.
The easiest way is to use the pre-generated versions in the dist/ folder of this
repository:
You can generate the bundled versions with the namespace defined using the Python
script `ci/scripts/bundle.py`:

```bash
git clone https://github.com/apache/arrow-nanoarrow.git
cd arrow-nanoarrow/examples/vendored-ipc
mkdir -p src/nanoarrow
cp ../../dist/nanoarrow.h src/nanoarrow/nanoarrow.h
cp ../../dist/nanoarrow.c src/nanoarrow/nanoarrow.c
cp ../../dist/nanoarrow_ipc.h src/nanoarrow/nanoarrow_ipc.h
cp ../../dist/nanoarrow_ipc.c src/nanoarrow/nanoarrow_ipc.c
cp ../../dist/flatcc.c src/nanoarrow/flatcc.c
cp -r ../../dist/flatcc src/nanoarrow/flatcc
```

If you use these, you will have to manually `#define NANOARROW_NAMESPACE MyProject`
in nanoarrow.h.

You can also generate the bundled versions with the namespace defined using `cmake`:

```bash
git clone https://github.com/apache/arrow-nanoarrow.git
cd arrow-nanoarrow/examples/vendored-ipc

# First, build and install nanoarrow
mkdir build
pushd build
cmake ../../.. -DNANOARROW_BUNDLE=ON -DNANOARROW_NAMESPACE=ExampleVendored
cmake --build .
cmake --install . --prefix=../src/nanoarrow
popd

# Then, build and install nanoarrow_ipc
mkdir build_ipc
pushd build_ipc
cmake ../../../extensions/nanoarrow_ipc -DNANOARROW_IPC_BUNDLE=ON
cmake --build .
cmake --install . --prefix=../src/nanoarrow
popd
python ../../ci/scripts/bundle.py \
--source-output-dir=src \
--include-output-dir=src \
--symbol-namespace=MyProject \
--with-ipc \
--with-flatcc
```

Then you can build/link the application/library using the build tool of your choosing:

```bash
cd src
cc -c library.c nanoarrow/nanoarrow.c nanoarrow/flatcc.c nanoarrow/nanoarrow_ipc.c -I./nanoarrow -I./nanoarrow/flatcc
cc -c library.c nanoarrow.c flatcc.c nanoarrow_ipc.c -I.
ar rcs libexample_vendored_ipc_library.a library.o nanoarrow.o nanoarrow_ipc.o flatcc.o
cc -o example_vendored_ipc_app app.c libexample_vendored_ipc_library.a
```
Expand Down
26 changes: 8 additions & 18 deletions examples/vendored-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,18 @@ linked to by another project.

The nanoarrow.c and nanoarrow.h files included in this example are stubs to illustrate
how these files could fit in to a library and/or command-line application project.
The easiest way is to use the pre-generated versions in the dist/ folder of this
repository:

```bash
git clone https://github.com/apache/arrow-nanoarrow.git
cd arrow-nanoarrow/examples/vendored-minimal
cp ../../dist/nanoarrow.h src/nanoarrow.h
cp ../../dist/nanoarrow.c src/nanoarrow.c
```

If you use these, you will have to manually `#define NANOARROW_NAMESPACE MyProject`
manually in nanoarrow.h.

You can also generate the bundled versions with the namespace defined using `cmake`:
You can generate the bundled versions with the namespace defined using the Python
script `ci/scripts/bundle.py`:

```bash
git clone https://github.com/apache/arrow-nanoarrow.git
cd arrow-nanoarrow
mkdir build && cd build
cmake .. -DNANOARROW_BUNDLE=ON -DNANOARROW_NAMESPACE=ExampleVendored
cmake --build .
cmake --install . --prefix=../examples/vendored-minimal/src

cd examples/vendored-minimal
python ../../ci/scripts/bundle.py \
--source-output-dir=src \
--include-output-dir=src \
--symbol-namespace=ExampleVendored
```

Then you can build/link the application/library using the build tool of your choosing:
Expand Down
File renamed without changes.

0 comments on commit 149e6bc

Please sign in to comment.