Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ More information is [available on the wiki](https://github.com/hioa-cs/IncludeOS

### Writing your first service

1. Copy the [./seed](./seed) directory to a convenient location like `~/your_service`. Then, just start implementing the `Service::start` function in the `Service` class, located in [your_service/service.cpp](./seed/service.cpp) (Very simple example provided). This function will be called once the OS is up and running.
2. Update the [CMakeLists.txt](./seed/CMakeLists.txt) to specify the name of your project, enable any needed drivers or plugins, etc.
1. Copy the [./seed/service](./seed/service) directory to a convenient location like `~/your_service`. Then, just start implementing the `Service::start` function in the `Service` class, located in [your_service/service.cpp](./seed/service/service.cpp) (Very simple example provided). This function will be called once the OS is up and running.
2. Update the [CMakeLists.txt](./seed/service/CMakeLists.txt) to specify the name of your project, enable any needed drivers or plugins, etc.

**Example:**

```
$ cp -r seed ~/my_service
$ cp -r seed/service ~/my_service
$ cd ~/my_service
$ emacs service.cpp
... add your code
Expand Down
38 changes: 20 additions & 18 deletions etc/library.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#
#
# CMakeList for IncludeOS library
#

# IncludeOS install location
if (NOT DEFINED ENV{INCLUDEOS_PREFIX})
set(ENV{INCLUDEOS_PREFIX} /usr/local)
endif()

# test compiler
if(CMAKE_COMPILER_IS_GNUCC)
# currently gcc is not supported due to problems cross-compiling a unikernel
Expand All @@ -12,14 +17,10 @@ endif(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_ASM_NASM_OBJECT_FORMAT "elf")
enable_language(ASM_NASM)

# stackrealign is needed to guarantee 16-byte stack alignment for SSE
# the compiler seems to be really dumb in this regard, creating a misaligned stack left and right
set(CAPABS "-mstackrealign -msse3 -fstack-protector-strong")

# Various global defines
# * OS_TERMINATE_ON_CONTRACT_VIOLATION provides classic assert-like output from Expects / Ensures
# * _GNU_SOURCE enables POSIX-extensions in newlib, such as strnlen. ("everything newlib has", ref. cdefs.h)
set(CAPABS "${CAPABS} -DOS_TERMINATE_ON_CONTRACT_VIOLATION -D_GNU_SOURCE -DSERVICE=\"\\\"${BINARY}\\\"\" -DSERVICE_NAME=\"\\\"${SERVICE_NAME}\\\"\"")
set(CAPABS "-msse3 -fstack-protector-strong -DOS_TERMINATE_ON_CONTRACT_VIOLATION -D_GNU_SOURCE")
set(WARNS "-Wall -Wextra") #-pedantic

# configure options
Expand All @@ -32,23 +33,24 @@ if (minimal)
set(OPTIMIZE "-Os")
endif()
if (debug)
set(CAPABS "${CAPABS} -g"
set(CAPABS "${CAPABS} -g")
endif()

# these kinda work with llvm
set(CMAKE_CXX_FLAGS "-MMD -target i686-elf ${CAPABS} ${OPTIMIZE} ${WARNS} -c -m32 -std=c++14 -D_LIBCPP_HAS_NO_THREADS=1")
set(CMAKE_C_FLAGS "-MMD -target i686-elf ${CAPABS} ${OPTIMIZE} ${WARNS} -c -m32")


# includes
include_directories(${LOCAL_INCLUDES})
include_directories(${INCLUDEOS_ROOT}/include/libcxx)
include_directories(${INCLUDEOS_ROOT}/include/api/sys)
include_directories(${INCLUDEOS_ROOT}/include/newlib)
include_directories(${INCLUDEOS_ROOT}/include/api/posix)
include_directories(${INCLUDEOS_ROOT}/include/api)
include_directories(${INCLUDEOS_ROOT}/include/gsl)

# output <- input
add_library(library STATIC ${SOURCES})
set_target_properties(library PROPERTIES OUTPUT_NAME ${LIBRARY_NAME})
include_directories($ENV{INCLUDEOS_PREFIX}/includeos/include/libcxx)
include_directories($ENV{INCLUDEOS_PREFIX}/includeos/api/sys)
include_directories($ENV{INCLUDEOS_PREFIX}/includeos/include/newlib)
include_directories($ENV{INCLUDEOS_PREFIX}/includeos/api/posix)
include_directories($ENV{INCLUDEOS_PREFIX}/includeos/api)
include_directories($ENV{INCLUDEOS_PREFIX}/includeos/include)
include_directories($ENV{INCLUDEOS_PREFIX}/include)

add_library(${LIBRARY_NAME} STATIC ${SOURCES})

#install(TARGETS ${LIBRARY_NAME} DESTINATION includeos/lib)
#install(DIRECTORY ${LIBRARY_HEADERS} DESTINATION includeos/include)
4 changes: 0 additions & 4 deletions seed/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions seed/debug/service.gdb

This file was deleted.

2 changes: 2 additions & 0 deletions seed/library/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/*
lib/
44 changes: 44 additions & 0 deletions seed/library/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
cmake_minimum_required(VERSION 2.8.9)

# IncludeOS install location
if (NOT DEFINED ENV{INCLUDEOS_PREFIX})
set(ENV{INCLUDEOS_PREFIX} /usr/local)
endif()

# Use toolchain (if needed)
set(CMAKE_TOOLCHAIN_FILE $ENV{INCLUDEOS_PREFIX}/includeos/i686-elf-toolchain.cmake)

# Name of your project
project (libseed)

# Name of your IncludeOS library
set(LIBRARY_NAME "seed") # => libseed.a

# Source files to be built into your IncludeOS library
set(SOURCES
# seed.cpp # ...add more here
)

# Necessary includes to build your library
set(LOCAL_INCLUDES
# "include"
)

# include library build script
include($ENV{INCLUDEOS_PREFIX}/includeos/library.cmake)


# INSTALLATION (OPTIONAL):

# If CMAKE_INSTALL_PREFIX is not set, install to source directory
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}") # $ENV{INCLUDEOS_PREFIX}/includeos
endif()

# Where to install library
install(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)

# Where to install library headers
# NOTE: There is a difference between installing a list of files and a directory
# set(LIBRARY_HEADERS "include/seed")
# install(DIRECTORY ${LIBRARY_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include)
File renamed without changes.
8 changes: 0 additions & 8 deletions seed/run.sh

This file was deleted.

1 change: 1 addition & 0 deletions seed/service/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/*
File renamed without changes.
7 changes: 7 additions & 0 deletions seed/service/cmake_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
INSTALL=`pwd`
mkdir -p build
pushd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL
make install
popd
File renamed without changes.
File renamed without changes.