mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
549ed0c5f1
commit
cf2fe7236d
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@ -63,8 +63,8 @@ jobs:
|
||||
run: python3 scripts/run_tests.py benchmark
|
||||
# - name: GCC Build Test
|
||||
# run: g++ -o pocketpy --std=c++17 src/main.cpp
|
||||
# - name: C Binding Test
|
||||
# run: bash run_c_binding_test.sh
|
||||
- name: C Binding Test
|
||||
run: bash run_c_binding_test.sh
|
||||
build_macos:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
|
24
c_bindings/CMakeLists.txt
Normal file
24
c_bindings/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
cmake_minimum_required(VERSION 3.17)
|
||||
|
||||
project(test_c_bindings)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
option(PK_EXPORT_C_API "Export C API" ON)
|
||||
option(PK_BUILD_STATIC_LIB "Build static library" ON)
|
||||
|
||||
add_subdirectory(
|
||||
${CMAKE_CURRENT_LIST_DIR}/../
|
||||
${CMAKE_CURRENT_LIST_DIR}/build/pocketpy/
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_CURRENT_LIST_DIR}/../include
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME} test.c)
|
||||
|
||||
target_link_libraries(
|
||||
${PROJECT_NAME}
|
||||
pocketpy
|
||||
)
|
@ -1,26 +1,14 @@
|
||||
python3 preprocess.py
|
||||
cd c_bindings
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake --build . --config Release
|
||||
|
||||
echo "compiling c++ lib"
|
||||
clang++ -c -o pocketpy_c.o c_bindings/pocketpy_c.cpp -Wfatal-errors -O1 --std=c++17 -Wall -Wno-sign-compare -Wno-unused-variable -fno-rtti -stdlib=libc++ -I src/ -g
|
||||
|
||||
echo "compiling c executable"
|
||||
clang -c -o test.o c_bindings/test.c -Wfatal-errors -Wall -O1 -Wno-sign-compare -Wno-unused-variable -I src/ -g
|
||||
echo "linking"
|
||||
clang++ -o c_binding_test test.o pocketpy_c.o -stdlib=libc++ -g
|
||||
./c_binding_test > binding_test_scratch
|
||||
./test_c_bindings > binding_test_scratch
|
||||
echo "checking results (they should be identical)"
|
||||
diff -q -s binding_test_scratch c_bindings/test_answers.txt
|
||||
diff -q -s binding_test_scratch ../test_answers.txt
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
echo "ERROR: c binding test failed"
|
||||
rm pocketpy_c.o
|
||||
rm test.o
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "cleaning up"
|
||||
rm pocketpy_c.o
|
||||
rm test.o
|
||||
rm binding_test_scratch
|
||||
rm c_binding_test
|
||||
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user