forked from danielsuo/libdocker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modifications made to the docker client (danielsuo#9)
* Created inc director code changes pending * Added an empty example.c in example directory * Create c_cpp_properties.json * Modified gitignore to ignore .vscode and reoved .vscode. * Removed C extern statement from the Header. * Modified the project folder structure Main CMake modified to add .deb package creation options. * Update README.md * Update README.md As example directory is being added, removing the example from readme.md * Added a compile script for compilation Created the CMakeLists.txt for the source directory for building the .so for cdockerinterface * deb package creation added Example executable added compile script added * Reduced the CMake to one level. Moved the compile to a scripts directory simplified the naming of the .so and the executable folder structure of the project simplified * Update README.md Changed the name of the .so and executable. * cpp compatibility Added the cpp compatibility which was removed earlier * Update README.md * Modified naming from cdocker to docker 1. In cmake project name 2. In .so name 3. .deb package name modified to docker_c_sdk 4. executable name changed to docker_example * Update README.md * Update README.md
- Loading branch information
Showing
6 changed files
with
128 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
# IDE | ||
.idea | ||
.vscode | ||
|
||
# CMake | ||
cmake-build-debug | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,82 @@ | ||
# cmake version | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
#cmake policy | ||
cmake_policy(SET CMP0015 NEW) | ||
|
||
# Project name. | ||
project(docker) | ||
|
||
set(CMAKE_C_STANDARD 99) | ||
set(DOCKER_INCLUDE_DIR src PARENT_SCOPE) | ||
# Setting options. | ||
option(EXAMPLE_BUILD "Build using examples" ON) | ||
|
||
set( CMAKE_INSTALL_LIBDIR /usr/lib ) | ||
set( CMAKE_INSTALL_BINDIR /usr/bin ) | ||
|
||
# Set target name and source files | ||
file (GLOB DOCKER_SOURCE_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/**) | ||
find_package(CURL REQUIRED) | ||
|
||
add_library(${PROJECT_NAME} ${DOCKER_SOURCE_FILES}) | ||
|
||
# Install docker.h to the /usr/include directory | ||
install(FILES inc/docker.h PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE DESTINATION /usr/include) | ||
|
||
# Including the headers to be used for building the SDK. | ||
include_directories(${CMAKE_CURRENT_LIST_DIR}/inc) | ||
|
||
# The source files. | ||
SET(SRC_FILES | ||
${CMAKE_CURRENT_LIST_DIR}/src/docker.c | ||
) | ||
|
||
# The cdocker will be created as a .so | ||
add_library( docker SHARED ${SRC_FILES}) | ||
|
||
# Linking with dependencies. | ||
target_link_libraries( | ||
${PROJECT_NAME} | ||
curl | ||
docker | ||
|
||
-lcurl | ||
) | ||
|
||
# Installing in the target file as a library. | ||
INSTALL( | ||
TARGETS docker | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
COMPONENT library | ||
) | ||
|
||
# If example build is enabled. | ||
if(EXAMPLE_BUILD) | ||
include_directories(${CMAKE_SOURCE_DIR}/inc) | ||
|
||
SET( SRC_FILES | ||
${CMAKE_CURRENT_LIST_DIR}/example/example.c | ||
) | ||
|
||
add_executable(docker_example ${SRC_FILES}) | ||
|
||
target_link_libraries( | ||
docker_example | ||
docker | ||
) | ||
|
||
install(TARGETS docker_example RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
endif(EXAMPLE_BUILD) | ||
|
||
# Adding deb package build options. | ||
set(CPACK_PACKAGE_NAME "docker_c_sdk") | ||
set(CDOCKER_VERSION_MAJOR 1) | ||
set(CDOCKER_VERSION_MINOR 0) | ||
set(CDOCKER_VERSION_PATCH 0) | ||
|
||
set(CPACK_PACKAGE_VERSION_MAJOR "${CDOCKER_VERSION_MAJOR}") | ||
set(CPACK_PACKAGE_VERSION_MINOR "${CDOCKER_VERSION_MINOR}") | ||
set(CPACK_PACKAGE_VERSION_PATCH "${CDOCKER_VERSION_PATCH}") | ||
|
||
set(CPACK_DEBIAN_PACKAGE_SHIPBUILDS ON) | ||
|
||
set(CPACK_GENERATOR "DEB") | ||
|
||
set(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) | ||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "schaffung") | ||
|
||
include(CPack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdio.h> | ||
#include "docker.h" | ||
|
||
|
||
int main() | ||
{ | ||
DOCKER *docker = docker_init("v1.25"); | ||
CURLcode response; | ||
|
||
if (docker) | ||
{ | ||
printf("The following are the Docker images present in the system.\n"); | ||
response = docker_get(docker, "http://v1.25/images/json"); | ||
if (response == CURLE_OK) | ||
{ | ||
fprintf(stderr, "%s\n", docker_buffer(docker)); | ||
} | ||
|
||
docker_destroy(docker); | ||
} | ||
else | ||
{ | ||
fprintf(stderr, "ERROR: Failed to get get a docker client!\n"); | ||
} | ||
|
||
return 0; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
if [ -d ../build ]; then | ||
rm -rf ../build | ||
fi | ||
|
||
mkdir ../build | ||
cd ../build | ||
|
||
cmake .. && cmake --build . && cpack | ||
|
||
if [ $? -eq 0 ]; then | ||
echo "Success" | ||
else | ||
echo "Failure" | ||
fi |