Crypto++ NDK build on Windows android


https://www.cryptopp.com/wiki/Android_(Command_Line)

1. Edit  setenv-android.sh (* default arch is arm)
  ANDROID_NDK_ROOT="../../../../android/sdk/ndk-bundle"
  AOSP_TOOLCHAIN_PATH="/cygdrive/d/android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin"

  Ex) Set target is armeabi-v7a
  $ . setenv-android.sh armeabi-v7a

   setenv-android.sh.zip  <== Remove .zip

2. Build
 $ make -f GNUmakefile-cross distclean
 $ make -f GNUmakefile-cross static dynamic

3. strip
$ arm-linux-androideabi-strip --strip-debug libcryptopp.so

4. Install (for deploy include files)
$ make -f GNUmakefile-cross install PREFIX=./install
mkdir -p ./install/include/cryptopp
cp *.h ./install/include/cryptopp
chmod 755 ./install/include/cryptopp
chmod 644 ./install/include/cryptopp/*.h
mkdir -p ./install/lib
cp libcryptopp.a ./install/lib
chmod 644 ./install/lib/libcryptopp.a
cp libcryptopp.so ./install/lib
chmod 755 ./install/lib/libcryptopp.so


live555 Android.mk (kk-4.4.2) android

LOCAL_PATH := $(call my-dir)

basic_sources := $(wildcard $(LOCAL_PATH)/BasicUsageEnvironment/*.cpp)
basic_sources := $(basic_sources:$(LOCAL_PATH)/BasicUsageEnvironment/%=%)

groupsock_cpp_sources := $(wildcard $(LOCAL_PATH)/groupsock/*.cpp)
groupsock_cpp_sources := $(groupsock_cpp_sources:$(LOCAL_PATH)/groupsock/%=%)

groupsock_c_sources := $(wildcard $(LOCAL_PATH)/groupsock/*.c)
groupsock_c_sources := $(groupsock_c_sources:$(LOCAL_PATH)/groupsock/%=%)

livemedia_cpp_sources := $(wildcard $(LOCAL_PATH)/liveMedia/*.cpp)
livemedia_cpp_sources := $(livemedia_cpp_sources:$(LOCAL_PATH)/liveMedia/%=%)

livemedia_c_sources := $(wildcard $(LOCAL_PATH)/liveMedia/*.c)
livemedia_c_sources := $(livemedia_c_sources:$(LOCAL_PATH)/liveMedia/%=%)

env_sources := $(wildcard $(LOCAL_PATH)/UsageEnvironment/*.cpp)
env_sources := $(env_sources:$(LOCAL_PATH)/UsageEnvironment/%=%)

includes := \
$(LOCAL_PATH)/BasicUsageEnvironment/include \
$(LOCAL_PATH)/UsageEnvironment/include \
$(LOCAL_PATH)/groupsock/include \
$(LOCAL_PATH)/liveMedia/include \

include $(CLEAR_VARS)  

#LOCAL_SRC_FILES := $(basic_src)
LOCAL_SRC_FILES := \
$(basic_sources:%=BasicUsageEnvironment/%) \
$(groupsock_cpp_sources:%=groupsock/%) \
$(groupsock_c_sources:%=groupsock/%) \
$(livemedia_cpp_sources:%=liveMedia/%) \
$(livemedia_c_sources:%=liveMedia/%) \
$(env_sources:%=UsageEnvironment/%) \

#LOCAL_MODULE := live555
LOCAL_MODULE := liblive555

LOCAL_SHARED_LIBRARIES += libcutils libstlport libdl

#cflags += -Werror
cppflags += -fexceptions -frtti -DXLOCALE_NOT_USED=1 -DNULL=0 -DNO_SSTREAM=1 -UIP_ADD_SOURCE_MEMBERSHIP

#LOCAL_MODULE_TAGS := eng optional
LOCAL_CFLAGS := $(cflags)
LOCAL_CPPFLAGS := $(cppflags)
LOCAL_C_INCLUDES := external/stlport/stlport bionic/ bionic/libstdc++/include libcore/include
LOCAL_C_INCLUDES += $(includes)
#LOCAL_LDLIBS := 
LOCAL_LDFLAGS := -Wl,-v
LOCAL_LDFLAGS += -Lprebuilts/ndk/7/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a -lstdc++ \
 -Lprebuilts/ndk/7/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a -lsupc++
#LOCAL_SDK_VERSION := 19
#LOCAL_NDK_STL_VARIANT := gnustl_static
#LOCAL_NDK_STL_VARIANT := c++_static
#LOCAL_NDK_STL_VARIANT := stlport_static
#LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
include $(BUILD_SHARED_LIBRARY)


include $(CLEAR_VARS)
#LOCAL_CLANG := true
LOCAL_C_INCLUDES:= \
mediaServer \
$(includes)
LOCAL_SRC_FILES:= \
mediaServer/DynamicRTSPServer.cpp \
mediaServer/live555MediaServer.cpp
LOCAL_MODULE := live555MediaServer
LOCAL_SHARED_LIBRARIES:= liblive555
LOCAL_MODULE_TAGS := eng optional
include $(BUILD_EXECUTABLE)


printk - 옵션설정 linux

커널 디버깅 중 printk 의 옵션을 변경하여 디버그 메세지를 볼 수 있도록 할 수 있다.

$ cat /proc/sys/kernel/printk
$ 7 4 1 7  <== 기본 설정 값으로 printk 의 디버그 메세지는 출력이 되지 않는다.

$ echo "8 4 1 7" > /proc/sys/kernel/printk
or
$ echo 8 > /proc/sys/kernel/printk
설정 시 verbose 옵션이 설정 되어 모든 레벨의 메세지가 출력이 되어
단말(시스템) 실행 시간에 디버그 메세지를 볼 확인 할 수 있다.


커널에서 파일 읽고 쓰기 linux


커널에서 파일 읽기, 쓰기 등이 기술적으로 안되는(좋지않은) 이유 : http://kernelnewbies.org/FAQ/WhyWritingFilesFromKernelIsBad
- 커널 보호를 위해
- 커널 정책상 : 특정 파일 시스템만 읽기 위함

커널에서 파일 읽, 쓰기 가이드 : http://www.linuxjournal.com/article/8110

아래는 위의 기사에서 표기된 예제 이다.

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/syscalls.h>
#include <linux/fcntl.h>
#include <asm/uaccess.h>

static void read_file(char *filename)
{
  int fd;
  char buf[1];

  mm_segment_t old_fs = get_fs();
  set_fs(KERNEL_DS);

  fd = sys_open(filename, O_RDONLY, 0);
  if (fd >= 0) {
    printk(KERN_DEBUG);
    while (sys_read(fd, buf, 1) == 1)
      printk("%c", buf[0]);
    printk("\n");
    sys_close(fd);
  }
 set_fs(old_fs);
}


static void write_file(char *filename, char *data)
{
  struct file *file;
  loff_t pos = 0;
  int fd;

  mm_segment_t old_fs = get_fs();
  set_fs(KERNEL_DS);

  fd = sys_open(filename, O_WRONLY|O_CREAT, 0644);
  if (fd >= 0) {
    sys_write(fd, data, strlen(data));
    file = fget(fd);
    if (file) {
      vfs_write(file, data, strlen(data), &pos);
      fput(file);
    }
   sys_close(fd);
  }
  set_fs(old_fs);
}



다수의 커밋 되돌리기 git


git revert 명령어는 한개의 커밋만 되돌릴 수 있으므로 아래의 명령으로 HEAD 부터 4c279e.. 리비전 앞까지
되돌려 놓을 수 있다.

$ for s in $(git rev-list --topo-order 4c279e..);do git revert --no-edit $s;done
Finished one revert.
[evm 2566bb5] Revert "MediaPlayer.java"
 1 files changed, 1 insertions(+), 1 deletions(-)
Finished one revert.
[evm 043074c] Revert "MediaPlayer.java"
 1 files changed, 1 insertions(+), 1 deletions(-)
Finished one revert.
[evm 49f6a43] Revert "added media url broadcasting"
 1 files changed, 0 insertions(+), 17 deletions(-)
Finished one revert.
[evm bbde836] Revert "added url,scroll,zoom listenner"
 1 files changed, 0 insertions(+), 38 deletions(-)
 mode change 100755 => 100644 core/java/android/webkit/WebView.java
Finished one revert.
[evm 9a9b457] Revert "Surface::getISurface scope move to public for feature of v2ip camera input feature"
 1 files changed, 2 insertions(+), 5 deletions(-)
 mode change 100755 => 100644 include/surfaceflinger/Surface.h
Finished one revert.
[evm 4922780] Revert "Add Keypad_led, Camera_flash, Accelerometer/ALS/Proximity sensor"
 2 files changed, 8 insertions(+), 71 deletions(-)
Finished one revert.
[evm 1507e5f] Revert "HDMI Landscape mode"
 1 files changed, 1 insertions(+), 10 deletions(-)

1 2 3