Update scons build readme and howto document
[platform/upstream/iotivity.git] / Readme.scons.txt
1 == Quick guide: build and run IoTivity projects on Ubuntu ==
2
3 1. Build
4         Go to the top directory of 'iotivity' project(Note: should always run 'scons'
5 command in this directory)
6
7     Install external libraries:
8       $ sudo apt-get install libboost-dev libboost-program-options-dev libexpat1-dev libboost-thread-dev
9
10     Build release binaries:
11       $ scons
12 (Note: C++ sdk requires cereal. Please follow the instruction in the build
13 message to install cereal)
14
15     Build debug binaries:
16       $scons RELEASE=false
17
18     Help:
19       $ scons -h
20
21     Clear:
22       $ scons -c
23
24 2. Run the samples
25       $ export LD_LIBRARY_PATH=<iotivity>/out/linux/x86_64/release
26       Run the c++ samples in <iotivity>/out/linux/x86_64/release/resource/examples
27       Run the c samples in <iotivity>/out/linux/x86_64/release/resource/csdk/stack/samples/linux/SimpleClientServer
28 ('<iotivity>' is the path to 'iotivity' project. If your device is x86, arm,
29 or arm64, please change 'x86_64' to the proper arch)
30
31 == How to build IoTivity projects ==
32
33 IoTivity includes a series of projects. You can find all these projects here:
34     https://gerrit.iotivity.org/gerrit/#/admin/projects/
35
36 You can build IoTivity project on Linux / Windows / MAC OSX for various OS(
37 Linux, Tizen, Android, Arduino, Windows, MAC OSX, IOS ...).
38 The output of the build is in:
39   <top directory of the project>/out/<target_os>/<target_arch>/<build_type>/
40 e.g.
41         iotivity/out/android/armeabi-v7a/release/.
42
43 This document takes 'iotivity' project as example, the way to build other
44 projects is almost the same.
45
46 === IoTivity project build tool scons ===
47
48 Scons is a cross-platform build tool, its usage is quite similar to GNU make.
49 To build a project, you just require to run following command at the directory
50 where a SConstruct file exists(SConstruct is the entrance of scons build, it's
51 equivalent to Makefile of 'make') :
52       $ scons [options] [target]
53
54 In additional, usually the scons build script of a project provides useful help
55 information(include build options). To see the help information:
56       $ scons [options] -h
57
58 Note: If no value is specified for an option, the default value will be used.
59 The change of options value may impact the help information and the behavior
60 of the building.
61
62 Generally, it's required to specify the target OS and target ARCH, that's to say
63 tell Scons which OS and which ARCH you'd like build this project for. By default,
64 the target OS and ARCH is the same as the host.
65
66 Some more options may be required, please care the 'error' notification when build.
67 For help about how to set an option, please run:
68      $ scons TARGET_OS=xxx TARGET_ARCH=yyy [XXX=zzz ...] -h
69
70
71 === Prerequites ===
72
73 * 1. Scons
74
75 Please refer to the following page to install scons:
76    http://www.scons.org/doc/production/HTML/scons-user.html#chap-build-install
77 (Note: on Windows, install Python 2.x before installing scons)
78
79 * 2. IDE/SDK Prerequites
80 To build for some OS (Android / Arduino / IOS ...), an IDE/SDK may be required,
81 please go to the relative page to download and install the required IDE/SDK.
82
83 Android:
84 To build for Android, Andorid NDK and SDK are required.
85   Android NDK: http://developer.android.com/tools/sdk/ndk/index.html
86   Android SDK: http://developer.android.com/sdk/index.html
87 (Note: as in some IoTivity projects, C++11 features are used, recommend Android
88  NDK >= r10)
89
90 Arduino:
91 To build for Arduino, Arduino IDE is required.
92   Arduino IDE: http://arduino.cc/en/Main/Software
93   (Note: recommend install Arduino IDE >=1.5.7)
94
95 Arduino builds are dependent on latest Time library. Download it from here:
96     http://www.pjrc.com/teensy/td_libs_Time.html
97 and extract to <arduino_ide_root>/libraries/
98
99 (Note: If you are using Arduino IDE 1.5.8 BETA on Windows, it may pop up some
100 dll isn't found. please copy relative dll from the IDE directory to
101 C:\Windows\SysWOW64. IDE 1.5.7 doesn't have this issue. Other version IDE isn't
102 tested.)
103
104 Apple:
105 To build for Mac OSX or IOS, Xcode is required.
106   Xcode: https://developer.apple.com/xcode/downloads/
107
108 Java:
109 To build the Java code, JDK is required.
110   JDK: http://www.oracle.com/technetwork/java/javase/downloads/index.html
111 (If the project doesn't include Java code or you wouldn't like build the
112 Java codes, this isn't required)
113
114 (Note: for convenience, suggest add the IDE/SDK path in environment variable,
115 so you don't need to add it in command line each time. The build script will
116 guide you to do that.)
117
118 * 3. External libraries
119 IoTivity project depends on some external libraries, such as boost, expat ...
120 During building, the existence of external library will be checked, if it doesn't
121 exist, the build script will try to download, unpack and build the library or
122 notify user to install it.
123
124 Downloading and unpacking may fail due to network problem or required unpacking
125 tool isn't installed. An message will be displayed, please follow the message
126 to skip it.
127
128
129 === Build IoTivity project on Linux(Ubuntu) ===
130
131 1. Build IoTivity project for Linux
132       $ cd <top directory of the project>
133       $ sudo apt-get install libboost-dev libexpat1-dev libboost-thread-dev
134       $ scons
135
136 2. Build IoTivity project for Android
137       $ cd <top directory of the project>
138       $ scons TARGET_OS=android TARGET_ARCH=xxx
139 (xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard. To see all of its
140 allowed value, please execute command 'scons TARGET_OS=android -Q -h')
141
142 3. Build IoTivity project for Arduino
143       $ cd <top directory of the project>
144       $ scons TARGET_OS=arduino TARGET_ARCH=xxx BOARD=yyy
145 (xxx can be avr, arm; yyy is the name of the board, to get its allowed value
146 run: scons TARGET_OS=arduino TARGET_ARCH=xxx -h. You may see a option 'CPU' in
147 the output of above command line, that's due to some boards have different
148 processors, to specify the processor, add 'CPU=zzz' in the command line. If no
149 'CPU' option exists, that means the board only support one kind of processor,
150 it's unnecessary to specify it)
151
152 4. Build Iotivity project for Tizen
153       $ cd <top directory of the project>
154       $ gbs build -A xxx --packaging-dir tools/tizen/
155 (xxx can be i586 or armv7l, we provide the spec file required by gbs tool at
156 toools/tizen directory. gbs is default build tool for Tizen platfrom, we can
157 refer the following wiki to setup Tizen development environment:
158 https://source.tizen.org/documentation/developer-guide/getting-started-guide)
159
160 === Build IoTivity project on Windows ===
161
162 1. Build IoTivity project for Android(It's the same as on Ubuntu)
163       $ cd <top directory of the project>
164       $ scons TARGET_OS=android TARGET_ARCH=xxx
165 (xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard ...)
166
167 2. Build IoTivity project for Arduino(It's the same as on Ubuntu)
168       $ cd <top directory of the project>
169       $ scons TARGET_OS=arduino TARGET_ARCH=xxx BOARD=yyy
170 (xxx can be avr, arm; yyy is the name of the board, to get its allowed value
171 run: scons TARGET_OS=arduino TARGET_ARCH=xxx -h. You may see a option 'CPU' in
172 the output of above command line, that's due to some boards have different
173 processor, to specify the processor, add 'CPU=zzz' in the command line. If no
174 'CPU' option exists, that means the board only support one kind of processor,
175 it's unnecessary to specify it)
176
177
178 Note: Currently most IoTivity project doesn't support Windows, so you can't set
179 TARGET_OS to 'windows' except the project support Windows.
180
181 That's to say if the project doesn't support Windows, run:
182       $ scons TARGET_OS=windows ....
183 or run on Windows
184       $ scons
185 may always fail.
186
187
188 === Build IoTivity project on Mac OSX ===
189
190 1. Build IoTivity project for Mac OSX
191       $ cd <top directory of the project>
192       $ scons SYS_VERSION=yyy
193 (yyy is the OSX version, e.g. 10.9)
194
195 2. Build IoTivity project for Android(It's the same as on Ubuntu)
196       $ cd <top directory of the project>
197       $ scons TARGET_OS=android TARGET_ARCH=xxx
198 (xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard)
199
200 3. Build IoTivity project for IOS
201       $ cd <top directory of the project>
202       $ scons TARGET_OS=ios TARGET_ARCH=xxx SYS_VERSION=yyy
203 (xxx can be i386, x86_64, armv7, armv7s, arm64, yyy is IOS version, e.g. 7.0)
204
205 Note:
206 1) for convenience, a script (auto_build.sh) is provided to run possible build
207 at once. Following is the usage:
208
209 To build:
210      $ auto_build.sh <path-to-android-ndk>
211 To clean:
212      $ auto_build.sh -c
213
214 2) For Arduino build, the Time library should >=1.3. The old can only be built
215 with Arduino IDE 1.0.x