From: Caiwen Zhang Date: Fri, 26 Dec 2014 03:21:16 +0000 (+0800) Subject: Update scons build relative documents X-Git-Tag: 1.2.0+RC1~2014^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad40c3bbcf0830033de0f312ebcf6ea2f61cd7ad;p=platform%2Fupstream%2Fiotivity.git Update scons build relative documents Change-Id: I5296365d941d876ec20252282f8bae1cb5d8b7ff Signed-off-by: Caiwen Zhang --- diff --git a/Readme.scons.txt b/Readme.scons.txt index 8956c2d..d0e2458 100644 --- a/Readme.scons.txt +++ b/Readme.scons.txt @@ -1,19 +1,19 @@ -== How to build Iotivity projects == +== How to build IoTivity projects == -Iotivity includes a series of projects. You can find all these projects here: - https://oic-review.01.org/gerrit/#/admin/projects/ +IoTivity includes a series of projects. You can find all these projects here: + https://gerrit.iotivity.org/gerrit/#/admin/projects/ -You can build Iotivity project on Linux / Windows / MAC OSX for various OS( +You can build IoTivity project on Linux / Windows / MAC OSX for various OS( Linux, Tizen, Android, Arduino, Windows, MAC OSX, IOS ...). The output of the build is in: - /out//// + /out//// e.g. oic-resource/out/android/armeabi-v7a/release/. -This document takes oic-resource project as example, the way to build other +This document takes 'iotivity' project as example, the way to build other projects is almost the same. -=== Iotivity project build tool scons === +=== IoTivity project build tool scons === Scons is a cross-platform build tool, its usage is quite similar to GNU make. To build a project, you just require to run following command at the directory @@ -45,7 +45,7 @@ Android: To build for Android, Andorid NDK and SDK are required. Android NDK: http://developer.android.com/tools/sdk/ndk/index.html Android SDK: http://developer.android.com/sdk/index.html -(Note: as in some Iotivity projects, C++11 features are used, recommend Android +(Note: as in some IoTivity projects, C++11 features are used, recommend Android NDK >= r10, according to our test result r10c is the best one currently) Arduino: @@ -79,7 +79,7 @@ guide you to do that.) * 3. External libraries For Android and IOS build, most of the external libraries are provided as binary in oic-utilities project (https://oic-review.01.org/gerrit/oic-utilities). -Please download it in the same directory as other Iotivity projects. If it's +Please download it in the same directory as other IoTivity projects. If it's in different directory, an additional option (OIC_UITLS) will be required. The build command should be: $ scons OIC_UITLS= [other options] [target] @@ -90,42 +90,50 @@ don't need to add this option in command line each time.) $ export OIC_UITLS= -=== Build Iotivity project on Linux(Ubuntu) === +=== Build IoTivity project on Linux(Ubuntu) === -1. Build Iotivity project for Linux +Generally, it's required to specify the target OS and target ARCH, that's to say +tell Scons which OS and which ARCH you'd like build this project for. By default, +the target OS and ARCH is the same as the host. + +Some more options may be required, please care the 'error' notification when build. +For help about how to set an option, please run: + $ scons TARGET_OS=xxx TARGET_ARCH=yyy [XXX=zzz ...] -h + +1. Build IoTivity project for Linux $ cd - $ sudo apt-get install libboost-dev libboost-program-options-dev + $ sudo apt-get install libboost-dev libboost-program-options-dev libexpat1-dev $ scons -2. Build Iotivity project for Android +2. Build IoTivity project for Android $ cd $ scons TARGET_OS=android TARGET_ARCH=xxx (xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard. To see all of its -allowed value, please execute command 'scons TARGET_OS=android -Q -h'. +allowed value, please execute command 'scons TARGET_OS=android -Q -h') Note: Currently as x86_64/arm64_v8a external library binaries aren't provided, you may meet link problem if build executable binary which depends on external library for x86_64/arm64_v8a. -3. Build Iotivity project for Arduino +3. Build IoTivity project for Arduino $ cd $ scons TARGET_OS=arduino TARGET_ARCH=xxx BOARD=yyy (xxx can be avr, arm; yyy is the name of the board, to get its allowed value run: scons TARGET_OS=arduino TARGET_ARCH=xxx -h. You may see a option 'CPU' in the output of above command line, that's due to some boards have different -processor, to specify the processor, add 'CPU=zzz' in the command line. If no +processors, to specify the processor, add 'CPU=zzz' in the command line. If no 'CPU' option exists, that means the board only support one kind of processor, it's unnecessary to specify it) -=== Build Iotivity project on Windows === +=== Build IoTivity project on Windows === -1. Build Iotivity project for Android(It's the same as on Ubuntu) +1. Build IoTivity project for Android(It's the same as on Ubuntu) $ cd $ scons TARGET_OS=android TARGET_ARCH=xxx (xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard ...) -2. Build Iotivity project for Arduino(It's the same as on Ubuntu) +2. Build IoTivity project for Arduino(It's the same as on Ubuntu) $ cd $ scons TARGET_OS=arduino TARGET_ARCH=xxx BOARD=yyy (xxx can be avr, arm; yyy is the name of the board, to get its allowed value @@ -136,7 +144,7 @@ processor, to specify the processor, add 'CPU=zzz' in the command line. If no it's unnecessary to specify it) -Note: Currently most Iotivity project doesn't support Windows, so you can't set +Note: Currently most IoTivity project doesn't support Windows, so you can't set TARGET_OS to 'windows' except the project support Windows. That's to say if the project doesn't support Windows, run: @@ -146,19 +154,19 @@ or run on Windows may always fail. -=== Build Iotivity project on Mac OSX === +=== Build IoTivity project on Mac OSX === -1. Build Iotivity project for Mac OSX +1. Build IoTivity project for Mac OSX $ cd $ scons SYS_VERSION=yyy (yyy is the OSX version, e.g. 10.9) -2. Build Iotivity project for Android(It's the same as on Ubuntu) +2. Build IoTivity project for Android(It's the same as on Ubuntu) $ cd $ scons TARGET_OS=android TARGET_ARCH=xxx (xxx can be x86, armeabi, armeabi-v7a, armeabi-v7a-hard) -3. Build Iotivity project for IOS +3. Build IoTivity project for IOS $ cd $ scons TARGET_OS=ios TARGET_ARCH=xxx SYS_VERSION=yyy (xxx can be i386, x86_64, armv7, armv7s, arm64, yyy is IOS version, e.g. 7.0) @@ -172,16 +180,5 @@ To build: To clean: $ auto_build.sh -c -2) Last sync and test with commit e9403ce6d4d7a1a0ac8d12c5acc876af7f7a8f76 -If you meet build error with newest code, it may due to the scripts are not up -to date. Please try commit 5f16c38a5380e4b5c0d82e2cfea4af5fdc30c9ac or send mail -to . - -3) The build scripts for services have been provided. As the services code is -out of date, it must the sync with newest resource code, otherwise, it can't -pass the build, currently, the build scripts for services aren't enabled. Please -remove the '#' at line 31 in 'SConstruct' file to enable it after the code is -updated. - -4) For Arduino build, the Time library should >=1.3. The old can only be built +2) For Arduino build, the Time library should >=1.3. The old can only be built with Arduino IDE 1.0.x diff --git a/scons_script_how_to.txt b/scons_script_how_to.txt index c210419..5c49533 100644 --- a/scons_script_how_to.txt +++ b/scons_script_how_to.txt @@ -1,6 +1,6 @@ -== How to write iotivity build script == +== How to write IoTivity build script == -Iotivity projects are built with Scons. Scons is a cross-platform build tool, +IoTivity projects are built with Scons. Scons is a cross-platform build tool, it's quite similar to 'make'. 'SConstruct' is the entrance of scons build, it's equivalent to 'Makefile' to 'make'. @@ -80,13 +80,13 @@ cc -o H hello.o In above example, 'target_os' is used. How to get it? -User can build iotivity project on linux / windows / MAC OSX for various +User can build IoTivity project on Linux / Windows / MAC OSX for various targets(Linux, Tizen, Android, Arduino, Windows, MAC OSX, IOS ...). Most -platform specific configures have been done in the common scripts whitch are in +platform specific configures have been done in the common scripts which are in build_common. The common scripts prepare an environment named 'env' with target platform specific configuration. -When write iotivity project build script, you can get this environment as +When write IoTivity project build script, you can get this environment as following: Import('env') @@ -101,25 +101,27 @@ and update its keys. The 'env' environment contains platform specific configuration, besides, there is some common information. You can get the information with following line: env.get('XXX') +or + env['XXX'] -XXX is the information name, below are the extra information added by iotivity +XXX is the information name, below are the extra information added by IoTivity common scrirpts: -BUILD_DIR: the path of the build directory +BUILD_DIR: the path of the build directory, all output are in this directory SRC_DIR: the path of the top directory of the source code OIC_UTILS: the path of oic-utilities project -RELEASE: boolean. True - release build, False - debug build +RELEASE: build type, boolean. True - release build, False - debug build TARGET_OS: the name of the target OS. The possible value depends on the host platform. Bellow is the list of host and possible target OS. (darwin means MAC OSX) - linux: linux / android / arduino -(the line means on linux, you can build the project for linux/android/arduino) + linux: linux / android / arduino / tizen +(the line means on Linux, you can build the project for Linux/Android/Arduino/Tizen) windows: windows / winrt / android / arduino darwin: darwin / ios / android / arduino -TARGET_ARCH: the target CPU arch. Its possible value depend on the target OS +TARGET_ARCH: the target CPU arch. Its possible value depend on the target OS. Bellow list the target OS and allowed CPU architecture. linux: x86 / x86_64 / arm / arm64 -(above line means if the target OS is linux, the CPU arch can be x86/x86_64/arm/arm64) +(above line means if the target OS is Linux, the CPU arch can be x86/x86_64/arm/arm64) android: x86 / x86_64 / armeabi / armeabi-v7a / armeabi-v7a-hard / arm64-v8a windows: x86 / amd64 / arm winrt: arm @@ -138,11 +140,11 @@ InstallTarget(files, name): it takes the same action as AppendTarget, besides, it installs the 'files' to BUILD_DIR. Following functions are only for Arduino: -ImportLib(lib): Arduino IDE includes many libraries. To control the binary size, -by default, no library is used. If your project use some libraries, you can -import the lib with this function. 'lib' is the name of the lib to import. -The include path will be auto added to the environment and the library will be -built and linked into the final binary. +ImportLib(lib): Arduino IDE includes many libraries. By default, no library is +compiled. If your project use some libraries, you can import the library by +this function. 'lib' is the name of the library to import. The 'include' path +will be auto added to the environment and the library will be built and linked +into the final binary. CreateBin('bin', src): For Arduino, after build the program, it's required to be converted into specific format (e.g .hex). This function will genearate the @@ -150,7 +152,8 @@ required .hex (and .eep if target arch is avr) file. UploadHelp(): For different board, the upload command line is different, this function print the recommended upload command line. You can see the recommended -upload command line in the help information. +upload command line in the help information(the output of command "scons +[options] -h") ==== Scripts Hierarchy ==== @@ -191,8 +194,8 @@ SConscript('sub_prj_1n/SConscript') The path is relevant to 'prj_1/SConscript'. You can also use the full path build_dir + 'prj_1/sub_prj_1x/SConscript', but it's not recommended. -Above just to show a usual way to manage subsidiary scripts. You don't need -restrictly follow it. +Above just to show a recommended way to manage subsidiary scripts. You don't +need restrictly follow it. ==== The content of a typical script ==== @@ -219,8 +222,10 @@ Below is an example: ts = new_env.Program('progam_name', [source_list]) # Install the target (optional) + # If it's an important library or daemon to be published new_env.InstallTarget(ts, 'target_name') or + # If is't examples or test program or others will not be published new_env.Alias('target_name', ts) new_env.AppendTarget('target_name')