Updated Tizen 2.0 SDK source code 2.0alpha master 2.0_alpha submit/master/20120921.080643
authordonghee <donghee.yang@samsung.com>
Tue, 18 Sep 2012 08:06:33 +0000 (17:06 +0900)
committerdonghee <donghee.yang@samsung.com>
Tue, 18 Sep 2012 08:06:33 +0000 (17:06 +0900)
Change-Id: I3c66ef37c6f12e204dd116bc39bcc9a9f91ea876

43 files changed:
Makefile
package/build.linux
package/build.macos [new file with mode: 0644]
package/build.windows
package/pkginfo.manifest
package/remove.linux [deleted file]
package/smart-build-interface.remove.linux [new file with mode: 0644]
package/smart-build-interface.remove.macos [new file with mode: 0644]
package/smart-build-interface.remove.windows [moved from package/remove.windows with 55% similarity]
sbi-build.bat [deleted file]
sbi-make.bat [new file with mode: 0644]
sbi-pack.bat [new file with mode: 0644]
src/cmdline_interpreter.c
src/config_common.c
src/config_common.h
src/execute.c
src/execute_input.c
src/plugin.c
src/plugin_mgt.c
src/plugin_mgt.h
src/rootstrap.c
src/rootstrap_mgt.c
src/rootstrap_mgt.h
src/sbi.c
src/sbi_build.c [deleted file]
src/sbi_config.c
src/sbi_config.h
src/sbi_error.c
src/sbi_make.c [new file with mode: 0644]
src/sbi_pack.c [new file with mode: 0644]
src/sbi_types.c
src/sbi_util.c
src/sbi_util.h
src/sbi_xml.c
src/target.c
src/target_mgt.c
src/target_mgt.h
src/tool.c
src/toolchain.c
src/toolchain_action.c
src/toolchain_mgt.c
src/toolchain_mgt.h
tools/make_pch [new file with mode: 0644]

index 5d9db54..bf43e7e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,15 +8,19 @@ XMLLDFLAGS = `xml2-config --libs`
 CFLAGS += $(XMLCFLAGS)
 
 COMMON_OBJS = bin/sbi_types.o bin/target_mgt.o bin/target.o bin/rootstrap_mgt.o bin/rootstrap.o bin/toolchain_mgt.o bin/toolchain.o bin/tool.o bin/toolchain_action.o bin/execute.o bin/execute_input.o bin/config_common.o bin/sbi_util.o bin/sbi_config.o bin/sbi_error.o
-all: prebuild bin/sbi bin/sbi_build
+all: prebuild bin/sbi bin/sbi_make bin/sbi_pack
 
 prebuild: 
        mkdir -p bin
 
-bin/sbi_build: bin/sbi_build.o $(COMMON_OBJS) bin/plugin_mgt.o bin/plugin.o
-       $(CC) $(LDFLAGS) -o $@ bin/sbi_build.o $(COMMON_OBJS) bin/plugin_mgt.o bin/plugin.o $(XMLLDFLAGS)
-bin/sbi_build.o: ./src/sbi_build.c
-       $(CC) $(CFLAGS) -c -o $@ ./src/sbi_build.c
+bin/sbi_make: bin/sbi_make.o $(COMMON_OBJS) bin/plugin_mgt.o bin/plugin.o
+       $(CC) $(LDFLAGS) -o $@ bin/sbi_make.o $(COMMON_OBJS) bin/plugin_mgt.o bin/plugin.o $(XMLLDFLAGS)
+bin/sbi_make.o: ./src/sbi_make.c
+       $(CC) $(CFLAGS) -c -o $@ ./src/sbi_make.c
+bin/sbi_pack: bin/sbi_pack.o $(COMMON_OBJS) bin/plugin_mgt.o bin/plugin.o
+       $(CC) $(LDFLAGS) -o $@ bin/sbi_pack.o $(COMMON_OBJS) bin/plugin_mgt.o bin/plugin.o $(XMLLDFLAGS)
+bin/sbi_pack.o: ./src/sbi_pack.c
+       $(CC) $(CFLAGS) -c -o $@ ./src/sbi_pack.c
 bin/sbi: bin/sbi.o bin/cmdline_interpreter.o $(COMMON_OBJS) bin/plugin_mgt.o bin/plugin.o
        $(CC) $(LDFLAGS) -o $@ bin/sbi.o $(COMMON_OBJS) bin/cmdline_interpreter.o bin/plugin_mgt.o bin/plugin.o $(XMLLDFLAGS) 
 bin/sbi.o: ./src/sbi.c 
index afdea35..8098a9e 100755 (executable)
@@ -17,15 +17,14 @@ build()
 # install
 install() 
 {
-       BIN_DIR=$SRCDIR/package/smart-build-interface.package.linux/data/SDK/build-system/bin
+       BIN_DIR=$SRCDIR/package/smart-build-interface.package.${TARGET_OS}/data/tools/smart-build-interface/bin
        mkdir -p $BIN_DIR
-       PLUGINS_DIR=$SRCDIR/package/smart-build-interface.package.linux/data/SDK/build-system/plugins
+       PLUGINS_DIR=$SRCDIR/package/smart-build-interface.package.${TARGET_OS}/data/tools/smart-build-interface/plugins
        mkdir -p $PLUGINS_DIR
+       PCH_DIR=$SRCDIR/package/smart-build-interface.package.${TARGET_OS}/data/tools/smart-build-interface/sbi_tools
+       mkdir -p $PCH_DIR
        cp $SRCDIR/bin/sbi $BIN_DIR/
-       cp $SRCDIR/bin/sbi_build $BIN_DIR/
+       cp $SRCDIR/bin/sbi_make $BIN_DIR/
+       cp $SRCDIR/bin/sbi_pack $BIN_DIR/
+       cp $SRCDIR/tools/make_pch $PCH_DIR/
 }
-
-[ "$1" = "clean" ] && clean
-[ "$1" = "build" ] && build
-[ "$1" = "install" ] && install
-echo "success"
diff --git a/package/build.macos b/package/build.macos
new file mode 100644 (file)
index 0000000..8098a9e
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh -xe
+# clean
+clean()
+{
+       make clean
+       rm -rf $SRCDIR/*.zip
+       rm -rf $SRCDIR/*.tar.gz
+       rm -rf $SRCDIR/bin
+}
+
+# build
+build() 
+{
+       make
+}
+
+# install
+install() 
+{
+       BIN_DIR=$SRCDIR/package/smart-build-interface.package.${TARGET_OS}/data/tools/smart-build-interface/bin
+       mkdir -p $BIN_DIR
+       PLUGINS_DIR=$SRCDIR/package/smart-build-interface.package.${TARGET_OS}/data/tools/smart-build-interface/plugins
+       mkdir -p $PLUGINS_DIR
+       PCH_DIR=$SRCDIR/package/smart-build-interface.package.${TARGET_OS}/data/tools/smart-build-interface/sbi_tools
+       mkdir -p $PCH_DIR
+       cp $SRCDIR/bin/sbi $BIN_DIR/
+       cp $SRCDIR/bin/sbi_make $BIN_DIR/
+       cp $SRCDIR/bin/sbi_pack $BIN_DIR/
+       cp $SRCDIR/tools/make_pch $PCH_DIR/
+}
index 71482e1..e020aa4 100755 (executable)
@@ -17,16 +17,16 @@ build()
 # install
 install() 
 {
-       BIN_DIR=$SRCDIR/package/smart-build-interface.package.windows/data/SDK/build-system/bin
+       BIN_DIR=$SRCDIR/package/smart-build-interface.package.${TARGET_OS}/data/tools/smart-build-interface/bin
        mkdir -p $BIN_DIR
-       PLUGINS_DIR=$SRCDIR/package/smart-build-interface.package.windows/data/SDK/build-system/plugins
+       PLUGINS_DIR=$SRCDIR/package/smart-build-interface.package.${TARGET_OS}/data/tools/smart-build-interface/plugins
        mkdir -p $PLUGINS_DIR
+       PCH_DIR=$SRCDIR/package/smart-build-interface.package.${TARGET_OS}/data/tools/smart-build-interface/sbi_tools
+       mkdir -p $PCH_DIR
        cp $SRCDIR/bin/sbi.exe $BIN_DIR/
-       cp $SRCDIR/bin/sbi_build.exe $BIN_DIR/
-       cp $SRCDIR/sbi-build.bat $BIN_DIR/
+       cp $SRCDIR/bin/sbi_make.exe $BIN_DIR/
+       cp $SRCDIR/bin/sbi_pack.exe $BIN_DIR/
+       cp $SRCDIR/sbi-make.bat $BIN_DIR/
+       cp $SRCDIR/sbi-pack.bat $BIN_DIR/
+       cp $SRCDIR/tools/make_pch $PCH_DIR/
 }
-
-[ "$1" = "clean" ] && clean
-[ "$1" = "build" ] && build
-[ "$1" = "install" ] && install
-echo "success"
index a2b1421..27da491 100644 (file)
@@ -1,15 +1,28 @@
-Package : smart-build-interface
-Version : 0.22.1
+Source : smart-build-interface
+Version : 0.99.18
 Maintainer : Taejun Ha <taejun.ha@samsung.com>, Jiil Hyoun <jiil.hyoun@samsung.com>, Donghyuk Yang <donghyuk.yang@samsung.com>, Donghee Yang<donghee.yang@samsung.com>
+
+Package : smart-build-interface
+OS : ubuntu-32
+Build-host-os : ubuntu-32
 Description : smart build interface for Tizen SDK
-OS : linux
-Build-host-os : linux
-Source : smart-build-interface
 
 Package : smart-build-interface
-Version : 0.22.1
-Maintainer : Taejun Ha <taejun.ha@samsung.com>, Jiil Hyoun <jiil.hyoun@samsung.com>, Donghyuk Yang <donghyuk.yang@samsung.com>, Donghee Yang<donghee.yang@samsung.com>
+OS : ubuntu-64
+Build-host-os : ubuntu-64
+Description : smart build interface for Tizen SDK
+
+Package : smart-build-interface
+OS : windows-32
+Build-host-os : windows-32 
+Description : smart build interface for Tizen SDK
+
+Package : smart-build-interface
+OS : windows-64
+Build-host-os : windows-64
+Description : smart build interface for Tizen SDK
+
+Package : smart-build-interface
+OS : macos-64
+Build-host-os : macos-64 
 Description : smart build interface for Tizen SDK
-OS : windows
-Build-host-os : windows 
-Source : smart-build-interface
diff --git a/package/remove.linux b/package/remove.linux
deleted file mode 100644 (file)
index 9d9f481..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh 
-
-rm -f ${INSTALLED_PATH}/SDK/build-system/plugins/*_* 
diff --git a/package/smart-build-interface.remove.linux b/package/smart-build-interface.remove.linux
new file mode 100644 (file)
index 0000000..168ad0a
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh 
+
+rm -rf ${INSTALLED_PATH}/tools/smart-build-interface/sbi.cfg
diff --git a/package/smart-build-interface.remove.macos b/package/smart-build-interface.remove.macos
new file mode 100644 (file)
index 0000000..168ad0a
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh 
+
+rm -rf ${INSTALLED_PATH}/tools/smart-build-interface/sbi.cfg
similarity index 55%
rename from package/remove.windows
rename to package/smart-build-interface.remove.windows
index e044d80..1bd0094 100644 (file)
@@ -1,4 +1,4 @@
 :: delims is a TAB followed by a space
 
 SET installed_path=%INSTALLED_PATH%
-DEL %installed_path%\SDK\build-system\plguins\*_*
+DEL /Q %installed_path%\tools\smart-build-interface\sbi.cfg
diff --git a/sbi-build.bat b/sbi-build.bat
deleted file mode 100644 (file)
index abd1a02..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-@ECHO OFF
-
-IF "%1" == "/?" (
-  echo Usage: sbi-build.bat [configuration name]
-  goto exit
-)
-
-set msyspath=MinGW\msys\1.0\bin
-set mingwpath=MinGW\bin
-@set key=TIZEN_SDK_INSTALLED_PATH
-
-@FOR /F "tokens=1,2 delims==" %%i IN (%localappdata%\.TizenSDK\tizensdkpath) DO @if %%i==%key% (set installed_path=%%j)
-
-echo install_path : %installed_path%
-
-path=%installed_path%\%mingwpath%;%installed_path%\%msyspath%;%path%
-
-IF "%1" == "" (
-  start /b %installed_path%\SDK\build-system\bin\sbi_build.exe
-) ELSE (
-  start /b %installed_path%\SDK\build-system\bin\sbi_build.exe -config %1
-)
-
-:exit
diff --git a/sbi-make.bat b/sbi-make.bat
new file mode 100644 (file)
index 0000000..1ef9ce2
--- /dev/null
@@ -0,0 +1,32 @@
+@ECHO OFF
+
+IF "%1" == "/?" (
+  echo Usage
+  echo "sbi-make.bat [-t|--target <device|emulator>]"
+  echo "sbi-make.bat clean"
+  echo
+  goto exit
+)
+
+set msyspath=tools\mingw\msys\1.0\bin
+set mingwpath=tools\mingw\bin
+:: delims is a TAB followed by a space
+set KEY=TIZEN_SDK_INSTALLED_PATH
+
+REM find sdk path
+set rkey="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
+set rval="Local AppData"
+FOR /f "tokens=3*" %%a IN ('reg query %rkey% /v %rval%') DO (
+    set sdk_conf_path=%%b
+)
+
+REM find cli path
+FOR /f "tokens=1,2 delims==" %%i IN ('type "%sdk_conf_path%\tizen-sdk-data\tizensdkpath"') DO IF %%i==%KEY% (set SDK_PATH=%%j)
+
+echo install_path : %SDK_PATH%
+
+set path=%SDK_PATH%\%mingwpath%;%SDK_PATH%\%msyspath%;%path%
+
+start /b %SDK_PATH%\tools\smart-build-interface\bin\sbi_make.exe %1 %2
+
+:exit
diff --git a/sbi-pack.bat b/sbi-pack.bat
new file mode 100644 (file)
index 0000000..83ef2e3
--- /dev/null
@@ -0,0 +1,31 @@
+@ECHO OFF
+
+IF "%1" == "/?" (
+  echo Usage
+  echo "sbi-pack.bat [-t|--target <device|emulator>]"
+  echo
+  goto exit
+)
+
+set msyspath=tools\mingw\msys\1.0\bin
+set mingwpath=tools\mingw\bin
+:: delims is a TAB followed by a space
+set KEY=TIZEN_SDK_INSTALLED_PATH
+
+REM find sdk path
+set rkey="HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
+set rval="Local AppData"
+FOR /f "tokens=3*" %%a IN ('reg query %rkey% /v %rval%') DO (
+    set sdk_conf_path=%%b
+)
+
+REM find cli path
+FOR /f "tokens=1,2 delims==" %%i IN ('type "%sdk_conf_path%\tizen-sdk-data\tizensdkpath"') DO IF %%i==%KEY% (set SDK_PATH=%%j)
+
+echo install_path : %SDK_PATH%
+
+set path=%SDK_PATH%\%mingwpath%;%SDK_PATH%\%msyspath%;%path%
+
+start /b %SDK_PATH%\tools\smart-build-interface\bin\sbi_pack.exe %*
+
+:exit
index 0b26730..e3472d0 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -23,7 +23,7 @@
  *
  * Contributors:
  * - S-Core Co., Ltd
- */ 
+ */
 
 
 #include <getopt.h>
 #include "sbi_error.h"
 
 typedef enum {
-       CMD_CREATE,
-       CMD_REMOVE,
-       CMD_SELECT,
-       CMD_SHOW,
-       CMD_LIST,
-       CMD_ACTION,
-       CMD_QUERY
+    CMD_CREATE,
+    CMD_REMOVE,
+    CMD_SELECT,
+    CMD_SHOW,
+    CMD_LIST,
+    CMD_ACTION,
+    CMD_QUERY
 } sbi_command_id;
 
 
@@ -63,9 +63,9 @@ typedef struct _sbi_command
 
 
 static sbi_command* create_sbi_command( sbi_command_id cmd_id,
-               const char* rootstrap_id, const char* toolchain_id,
-               const char* target_name, const char* extra_cmd_name,
-               string_list* extra_arguments )
+                                        const char* rootstrap_id, const char* toolchain_id,
+                                        const char* target_name, const char* extra_cmd_name,
+                                        string_list* extra_arguments )
 {
        string* arg;
        sbi_command* new_command = malloc( sizeof( sbi_command ));
@@ -91,15 +91,15 @@ static sbi_command* create_sbi_command( sbi_command_id cmd_id,
 static void remove_sbi_command(  sbi_command* cmd )
 {
        if ( cmd->rootstrap_id != NULL )
-               remove_string( cmd->rootstrap_id );
+       { remove_string( cmd->rootstrap_id ); }
        if ( cmd->toolchain_id != NULL )
-               remove_string( cmd->toolchain_id );
+       { remove_string( cmd->toolchain_id ); }
        if ( cmd->target_name != NULL )
-               remove_string( cmd->target_name );
+       { remove_string( cmd->target_name ); }
        if ( cmd->extra_cmd_name != NULL )
-               remove_string( cmd->extra_cmd_name );
+       { remove_string( cmd->extra_cmd_name ); }
        if ( cmd->extra_arguments != NULL )
-               remove_string_list( cmd->extra_arguments );
+       { remove_string_list( cmd->extra_arguments ); }
 
        free( cmd );
 }
@@ -127,7 +127,7 @@ static int execute_query_cmd( sbi_command* cmd );
 
 
 /* create the environment for interpreting */
-static void create_interpret_environment()
+static void create_interpret_environment( void )
 {
        /* initialize management module */
        initialize_rootstrap_mgt();
@@ -137,12 +137,12 @@ static void create_interpret_environment()
 
 
 /* destroy the environment */
-static void destroy_interpret_environment()
+static void destroy_interpret_environment( void )
 {
        /* free management module  */
-    finalize_target_mgt();
-    finalize_toolchain_mgt();
-    finalize_rootstrap_mgt();
+       finalize_target_mgt();
+       finalize_toolchain_mgt();
+       finalize_rootstrap_mgt();
 }
 
 
@@ -160,7 +160,9 @@ int interpret_command_line( int argc, char* argv[] )
        if ( cmd == NULL )
        {
                ret = -1;
-               goto fini;
+               destroy_interpret_environment();
+    
+               return ret;
        }
 
        /* execute sbi command */
@@ -169,7 +171,6 @@ int interpret_command_line( int argc, char* argv[] )
        /* destroy cmd */
        remove_sbi_command( cmd );
 
-fini:
        destroy_interpret_environment();
 
        return ret;
@@ -216,8 +217,8 @@ static sbi_command* parse_command_line( int argc, char* argv[] )
        }
        else
        {
-                print_usage(USAGE_ALL);
-                ret = NULL;
+               print_usage(USAGE_ALL);
+               ret = NULL;
        }
 
        return ret;
@@ -270,9 +271,10 @@ static sbi_command* parse_create_cmd(int argc, char* argv[])
 {
        static struct option long_options[] =
        {
-       { "root", required_argument, 0, 'r' },
-       { "tool", required_argument, 0, 't' },
-       { 0, 0, 0, 0 } };
+               { "root", required_argument, 0, 'r' },
+               { "tool", required_argument, 0, 't' },
+               { 0, 0, 0, 0 }
+       };
 
        char target_id[MAX_NAME];
        char root_id[MAX_NAME];
@@ -286,7 +288,7 @@ static sbi_command* parse_create_cmd(int argc, char* argv[])
        strcpy(tool_id, "");
 
        while ((op = getopt_long_only(argc, argv, "r:t:", long_options,
-                       &option_index)) != -1)
+                                     &option_index)) != -1)
        {
 
                switch (op)
@@ -307,22 +309,22 @@ static sbi_command* parse_create_cmd(int argc, char* argv[])
 
        /* get target_id, target_id is last element in argv[] */
        if (argc > optind)
-               strncpy(target_id, argv[optind++], MAX_NAME);
+       { strncpy(target_id, argv[optind++], MAX_NAME); }
        else
-               sbi_error(2, "create", 1);
+       { sbi_error(2, "create", 1); }
 
        /* error check */
        if (optind != argc)
-               sbi_error(2, "create", 1);
+       { sbi_error(2, "create", 1); }
 
        if (strlen(root_id) == 0)
-               sbi_error(2, "create", 1);
+       { sbi_error(2, "create", 1); }
 
        if (strlen(tool_id) == 0)
-               sbi_error(2, "create", 1);
+       { sbi_error(2, "create", 1); }
 
        if (strlen(target_id) == 0)
-               sbi_error(2, "create", 1);
+       { sbi_error(2, "create", 1); }
 
        return create_sbi_command( CMD_CREATE, root_id, tool_id, target_id, NULL, NULL );
 }
@@ -337,15 +339,15 @@ static int execute_create_cmd( sbi_command* cmd )
 
        /* if rootstrap is not available, error */
        if (!is_rootstrap_available(rootstrap_id))
-               sbi_error(3, rootstrap_id, 1);
+       { sbi_error(3, rootstrap_id, 1); }
 
        /* if toolchain is not available, error */
        if (!is_toolchain_available(toolchain_id))
-               sbi_error(4, toolchain_id, 1);
+       { sbi_error(4, toolchain_id, 1); }
 
        /* if the target already exists, error */
        if (is_target_available(target_id))
-               sbi_error(1, target_id, 1);
+       { sbi_error(1, target_id, 1); }
 
        /* create target xml file */
        result = create_new_target(target_id,rootstrap_id ,toolchain_id );
@@ -382,13 +384,13 @@ sbi_command* parse_remove_cmd(int argc, char* argv[])
        strcpy(target_id, "");
        /* get target_id, target_id is last element in argv[] */
        if (argc > 1)
-               strncpy(target_id, argv[1], MAX_NAME);
+       { strncpy(target_id, argv[1], MAX_NAME); }
        else
                /* if argc is 1 then argument does not inlcude target name */
-               sbi_error(2, "remove", 1);
+       { sbi_error(2, "remove", 1); }
 
        if (strlen(target_id) == 0)
-               sbi_error(2, "remove", 1);
+       { sbi_error(2, "remove", 1); }
 
        return create_sbi_command( CMD_REMOVE, NULL, NULL, target_id, NULL, NULL );
 }
@@ -401,14 +403,14 @@ static int execute_remove_cmd( sbi_command* cmd )
 
        /* if the target is not available, error */
        if (!is_target_available(target_id))
-               sbi_error(7, target_id, 1);
+       { sbi_error(7, target_id, 1); }
 
        /* remove target  xml */
        remove_target_xml(target_id);
 
        /* change default target */
        if (is_default_target(target_id))
-               reset_default_target();
+       { reset_default_target(); }
 
        /* execute "remove" action, if predefined action is defined */
        if ( is_target_predefined_action_available( target_id, "remove" ) )
@@ -436,12 +438,12 @@ static sbi_command* parse_select_cmd(int argc, char* argv[])
 
        /* get target_name, target_name is last element in argv[] */
        if (argc > 1)
-               strncpy(target_id, argv[1], MAX_NAME);
+       { strncpy(target_id, argv[1], MAX_NAME); }
        else
-               sbi_error(2, "select", 1);
+       { sbi_error(2, "select", 1); }
 
        if (strlen(target_id) == 0)
-               sbi_error(2, "select", 1);
+       { sbi_error(2, "select", 1); }
 
        return create_sbi_command( CMD_SELECT, NULL, NULL, target_id, NULL, NULL );
 }
@@ -453,7 +455,7 @@ static int execute_select_cmd( sbi_command* cmd )
 
        /* if the target is not available, error */
        if (!is_target_available(target_id))
-               sbi_error(7, target_id, 1);
+       { sbi_error(7, target_id, 1); }
 
        /* set default */
        set_default_target(target_id);
@@ -481,16 +483,16 @@ sbi_command* parse_show_cmd(int argc, char* argv[])
        else if (argc == 3)
        {
                if (strncmp(argv[1], "target", 6) == 0 && strlen(argv[1]) == 6)
-                       cmd = create_sbi_command( CMD_SHOW, NULL, NULL, argv[2], NULL, NULL );
+               { cmd = create_sbi_command( CMD_SHOW, NULL, NULL, argv[2], NULL, NULL ); }
                else if (strncmp(argv[1], "tool", 4) == 0 && strlen(argv[1]) == 4)
-                       cmd = create_sbi_command( CMD_SHOW, NULL, argv[2], NULL, NULL, NULL );
+               { cmd = create_sbi_command( CMD_SHOW, NULL, argv[2], NULL, NULL, NULL ); }
                else if (strncmp(argv[1], "root", 4) == 0 && strlen(argv[1]) == 4)
-                       cmd = create_sbi_command( CMD_SHOW, argv[2], NULL, NULL, NULL, NULL );
+               { cmd = create_sbi_command( CMD_SHOW, argv[2], NULL, NULL, NULL, NULL ); }
                else
-                       sbi_error(2, "show", 1);
+               { sbi_error(2, "show", 1); }
        }
        else
-               sbi_error(2, "show", 1);
+       { sbi_error(2, "show", 1); }
 
        return cmd;
 }
@@ -507,23 +509,23 @@ static int execute_show_cmd( sbi_command* cmd )
        if ( target_id == NULL && rootstrap_id == NULL && toolchain_id == NULL )
        {
                if (does_default_target_exist())
-                       display_target_info( get_default_target() );
+               { display_target_info( get_default_target() ); }
                else
-                       sbi_error(8, NULL, 1);
+               { sbi_error(8, NULL, 1); }
        }
        else if ( target_id != NULL  )
        {
                /* if target is not available, error */
                if ( !is_target_available( target_id ) )
-               sbi_error(24, target_id, 1);
+               { sbi_error(24, target_id, 1); }
 
-           display_target_info( target_id );
+               display_target_info( target_id );
        }
        else if ( toolchain_id != NULL )
        {
                /* if toolchain is not available, error */
                if (!is_toolchain_available(toolchain_id))
-                       sbi_error(4, toolchain_id, 1);
+               { sbi_error(4, toolchain_id, 1); }
 
                display_toolchain_info( toolchain_id );
        }
@@ -531,7 +533,7 @@ static int execute_show_cmd( sbi_command* cmd )
        {
                /* if rootstrap is not available, error */
                if (!is_rootstrap_available(rootstrap_id))
-                       sbi_error(3, rootstrap_id, 1);
+               { sbi_error(3, rootstrap_id, 1); }
 
                display_rootstrap_info( rootstrap_id );
        }
@@ -551,28 +553,28 @@ sbi_command* parse_list_cmd(int argc, char* argv[])
 
        /* input is just 'sbi list' then default value is all */
        if (argc == 1)
-    {
+       {
                cmd = create_sbi_command( CMD_LIST, "YES", "YES", "YES", NULL, NULL );
-    }
-    else if (argc == 2)
-    {
-        if (strncmp(argv[1], "all", 3) == 0 && strlen(argv[1]) == 3)
-        {
-               cmd = create_sbi_command( CMD_LIST, "YES", "YES", "YES", NULL, NULL );
-        }
-        else if (strncmp(argv[1], "target", 6) == 0 && strlen(argv[1]) == 6)
-               cmd = create_sbi_command( CMD_LIST, NULL, NULL, "YES", NULL, NULL );
-        else if (strncmp(argv[1], "root", 4) == 0 && strlen(argv[1]) == 4)
-               cmd = create_sbi_command( CMD_LIST, "YES", NULL, NULL, NULL, NULL );
-        else if (strncmp(argv[1], "tool", 4) == 0 && strlen(argv[1]) == 4)
-               cmd = create_sbi_command( CMD_LIST, NULL, "YES", NULL, NULL, NULL );
-        else
-        {
-            sbi_error(2, "list", 1);
-        }
-    }
-    else
-        sbi_error(2, "list", 1);
+       }
+       else if (argc == 2)
+       {
+               if (strncmp(argv[1], "all", 3) == 0 && strlen(argv[1]) == 3)
+               {
+                       cmd = create_sbi_command( CMD_LIST, "YES", "YES", "YES", NULL, NULL );
+               }
+               else if (strncmp(argv[1], "target", 6) == 0 && strlen(argv[1]) == 6)
+               { cmd = create_sbi_command( CMD_LIST, NULL, NULL, "YES", NULL, NULL ); }
+               else if (strncmp(argv[1], "root", 4) == 0 && strlen(argv[1]) == 4)
+               { cmd = create_sbi_command( CMD_LIST, "YES", NULL, NULL, NULL, NULL ); }
+               else if (strncmp(argv[1], "tool", 4) == 0 && strlen(argv[1]) == 4)
+               { cmd = create_sbi_command( CMD_LIST, NULL, "YES", NULL, NULL, NULL ); }
+               else
+               {
+                       sbi_error(2, "list", 1);
+               }
+       }
+       else
+       { sbi_error(2, "list", 1); }
 
        return cmd;
 }
@@ -597,11 +599,11 @@ static int execute_list_cmd( sbi_command* cmd )
        }
        if ( toolchain_id != NULL )
        {
-        display_toolchain_list();
+               display_toolchain_list();
        }
        if ( rootstrap_id != NULL )
        {
-        display_rootstrap_list();
+               display_rootstrap_list();
        }
 
        return 0;
@@ -619,42 +621,42 @@ sbi_command* parse_action_cmd(int argc, char* argv[])
        sbi_command* cmd = NULL;
        char action_name[MAX_NAME];
        char target_id[MAX_NAME];
-    string_list* arguments = NULL;
-    int cnt = 0;
-    int i = 0;
-
-    strcpy(action_name, "");
-    strcpy(target_id, "");
-
-    if ( argc > 3 && (strcmp(argv[0], "action") == 0) && (strcmp(argv[2], "--") == 0 ) )
-    {
-       strncpy( target_id, argv[1], MAX_NAME);
-       strncpy( action_name, argv[3], MAX_NAME);
-       cnt = 4;
-    }
-    else
-       sbi_error(2, "action", 1);
-       
-    i = cnt;
-    if ( i < argc )
-    {
-       arguments = create_string_list( argv[i] );
-       i++;
-    }
-
-    for (; i < argc ; i++)
-    {
-       assert( arguments != NULL );
-       append_string_to_list( arguments, argv[i] );
-    }
-
-    cmd = create_sbi_command( CMD_ACTION, NULL, NULL, target_id, action_name, arguments );
-
-    /* clean up */
+       string_list* arguments = NULL;
+       int cnt = 0;
+       int i = 0;
+
+       strcpy(action_name, "");
+       strcpy(target_id, "");
+
+       if ( argc > 3 && (strcmp(argv[0], "action") == 0) && (strcmp(argv[2], "--") == 0 ) )
+       {
+               strncpy( target_id, argv[1], MAX_NAME);
+               strncpy( action_name, argv[3], MAX_NAME);
+               cnt = 4;
+       }
+       else
+       { sbi_error(2, "action", 1); }
+
+       i = cnt;
+       if ( i < argc )
+       {
+               arguments = create_string_list( argv[i] );
+               i++;
+       }
+
+       for (; i < argc ; i++)
+       {
+               assert( arguments != NULL );
+               append_string_to_list( arguments, argv[i] );
+       }
+
+       cmd = create_sbi_command( CMD_ACTION, NULL, NULL, target_id, action_name, arguments );
+
+       /* clean up */
        if( arguments != NULL )
-       remove_string_list( arguments );
+       { remove_string_list( arguments ); }
 
-    return cmd;
+       return cmd;
 }
 
 
@@ -667,14 +669,14 @@ static int execute_action_cmd( sbi_command* cmd )
 
        /* if target is not available , error */
        if (!is_target_available(target_id))
-               sbi_error(7, target_id, 1);
+       { sbi_error(7, target_id, 1); }
 
        /* if the action is not available , error */
        if ( !is_target_action_available( target_id, action_cmd) )
-               sbi_error(29, action_cmd, 1);
+       { sbi_error(29, action_cmd, 1); }
 
-    /* ececute action */
-    ret = execute_target_action( target_id, action_cmd, action_arguments );
+       /* ececute action */
+       ret = execute_target_action( target_id, action_cmd, action_arguments );
 
        return ret;
 }
@@ -688,31 +690,31 @@ sbi_command* parse_query_cmd(int argc, char* argv[])
 {
        sbi_command* cmd = NULL;
        char action_name[MAX_NAME];
-    char target_id[MAX_NAME];
-
-    strcpy(target_id, "");
-    strcpy(action_name, "");
-
-    switch(argc)
-    {
-        case 1:
-           sbi_error(2, "query", 1);
-            break;
-        case 2:
-            strncpy( target_id, argv[1], MAX_NAME);
-            cmd = create_sbi_command( CMD_QUERY, NULL, NULL, target_id, NULL, NULL );
-            break;
-
-        case 3:
-            strncpy( target_id, argv[1], MAX_NAME);
-            strncpy( action_name, argv[2], MAX_NAME);
-            cmd = create_sbi_command( CMD_QUERY, NULL, NULL, target_id, action_name, NULL );
-
-            break;
-        default:
-           sbi_error(2, "query", 1);
-            break;
-    }
+       char target_id[MAX_NAME];
+
+       strcpy(target_id, "");
+       strcpy(action_name, "");
+
+       switch(argc)
+       {
+       case 1:
+               sbi_error(2, "query", 1);
+               break;
+       case 2:
+               strncpy( target_id, argv[1], MAX_NAME);
+               cmd = create_sbi_command( CMD_QUERY, NULL, NULL, target_id, NULL, NULL );
+               break;
+
+       case 3:
+               strncpy( target_id, argv[1], MAX_NAME);
+               strncpy( action_name, argv[2], MAX_NAME);
+               cmd = create_sbi_command( CMD_QUERY, NULL, NULL, target_id, action_name, NULL );
+
+               break;
+       default:
+               sbi_error(2, "query", 1);
+               break;
+       }
 
        return cmd;
 }
@@ -725,19 +727,19 @@ static int execute_query_cmd( sbi_command* cmd )
 
        /* if target is not available , error */
        if (!is_target_available(target_id))
-               sbi_error(7, target_id, 1);
+       { sbi_error(7, target_id, 1); }
 
        if( action_cmd != NULL )
        {
                /* if the action is not available , error */
                if ( !is_target_action_available( target_id, action_cmd) )
-                       sbi_error(29, action_cmd, 1);
+               { sbi_error(29, action_cmd, 1); }
 
-        print_target_action_variables( target_id, action_cmd );
+               print_target_action_variables( target_id, action_cmd );
        }
        else
        {
-           print_target_action_list(target_id);
+               print_target_action_list(target_id);
        }
 
        return 0;
index b4bc57a..e45bd13 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -23,7 +23,7 @@
  *
  * Contributors:
  * - S-Core Co., Ltd
- */ 
+ */
 
 #include <stdio.h>
 #include <string.h>
@@ -168,7 +168,7 @@ char* get_key_value_string(const char* key)
        return NULL;
 }
 
-int get_config_size()
+int get_config_size( void )
 {
        return config_size;
 }
index 09f3858..3f8447b 100644 (file)
@@ -39,7 +39,7 @@ int write_config_file(const char* path);
 /* access */
 char* get_key_value_string(const char* key);
 void set_key_value_string(const char* key, const char* value);
-int get_config_size();
+int get_config_size( void );
 char* get_key_string(int idx);
 char* get_value_string(int idx);
 
index 196cdf0..7eef83b 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -23,7 +23,7 @@
  *
  * Contributors:
  * - S-Core Co., Ltd
- */ 
+ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -50,9 +50,9 @@ execute* create_execute_binary_path( char* binary_path, char* description )
        newr->input_list = NULL;
 
        if ( description != NULL )
-               newr->description = (char*)strdup(description);
+       { newr->description = (char*)strdup(description); }
        else
-               newr->description = NULL;
+       { newr->description = NULL; }
 
        newr->next = NULL;
 
@@ -70,9 +70,9 @@ execute* create_execute_script( char* script_name, char* description, char* scri
        newr->input_list = NULL;
 
        if ( description != NULL )
-               newr->description = (char*)strdup(description);
+       { newr->description = (char*)strdup(description); }
        else
-               newr->description = NULL;
+       { newr->description = NULL; }
 
        newr->next = NULL;
 
@@ -90,7 +90,9 @@ execute* append_execute_list( execute* list, execute* src )
 {
        execute* r = list;
        while( r->next != NULL )
+       {
                r=r->next;
+       }
 
        r->next = src;
 
@@ -105,11 +107,11 @@ void remove_execute_list( execute* list )
        {
                execute* prev = r ;
                r=r->next;
-               if ( prev->binary_path != NULL ) free( prev->binary_path );
-               if ( prev->script_name != NULL ) free( prev->script_name );
-               if ( prev->script != NULL ) free( prev->script );
-               if ( prev->description != NULL ) free( prev->description );
-               if ( prev->input_list != NULL ) remove_execute_input_list( prev->input_list );
+               if ( prev->binary_path != NULL ) { free( prev->binary_path ); }
+               if ( prev->script_name != NULL ) { free( prev->script_name ); }
+               if ( prev->script != NULL ) { free( prev->script ); }
+               if ( prev->description != NULL ) { free( prev->description ); }
+               if ( prev->input_list != NULL ) { remove_execute_input_list( prev->input_list ); }
                free( prev );
        }
 }
@@ -130,7 +132,9 @@ static execute_env* append_execute_env( execute_env* list, execute_env* src )
 {
        execute_env* r = list;
        while( r->next != NULL )
+       {
                r=r->next;
+       }
 
        r->next = src;
 
@@ -147,54 +151,54 @@ execute_env* parse_execute_env( string_list* arguments )
        char* value_end = NULL;
        string_list* arg = NULL;
 
-    if( arguments == NULL )
-        return result;
+       if( arguments == NULL )
+       { return result; }
 
-    arg = arguments;
-    for ( ; arg ; arg=arg->next )
-    {
-       char* key = malloc(strchr(arg->str, '=') + 2 ); 
-       char* value = malloc(strlen(arg->str));
-       execute_env* newr;
+       arg = arguments;
+       for ( ; arg ; arg=arg->next )
+       {
+               char* key = malloc(strchr(arg->str, '=') + 2 );
+               char* value = malloc(strlen(arg->str));
+               execute_env* newr;
 
-       assert(arg->str != NULL);
+               assert(arg->str != NULL);
 
-       if ( *arg->str != '-' )
-       {
-               sbi_error(25, arg->str, 0);
-               break;
-       }
+               if ( *arg->str != '-' )
+               {
+                       sbi_error(25, arg->str, 0);
+                       break;
+               }
 
-       key_st = arg->str + 1;
-       value_end = key_st + strlen(arg->str);
-       key_end = strchr(arg->str, '=');
+               key_st = arg->str + 1;
+               value_end = key_st + strlen(arg->str);
+               key_end = strchr(arg->str, '=');
 
-       if ( key_end == NULL )
-       {
-               sbi_error(26, arg->str, 0);
-               break;
-       }
+               if ( key_end == NULL )
+               {
+                       sbi_error(26, arg->str, 0);
+                       break;
+               }
 
-       value_st = key_end + 1;
+               value_st = key_end + 1;
 
-       strncpy( key, key_st, key_end - key_st );
-       key[key_end - key_st ] = '\0';
-       strncpy( value, value_st,  value_end - value_st);
-       value[value_end - value_st ] = '\0';
+               strncpy( key, key_st, key_end - key_st );
+               key[key_end - key_st ] = '\0';
+               strncpy( value, value_st,  value_end - value_st);
+               value[value_end - value_st ] = '\0';
 
-       newr = create_execute_env( key, value );
+               newr = create_execute_env( key, value );
                if ( result  != NULL )
-                       append_execute_env( result, newr );
+               { append_execute_env( result, newr ); }
                else
-                       result = newr;
+               { result = newr; }
 
                free(key);
                free(value);
-       key_st = NULL;
-       key_end = NULL;
-       value_st = NULL;
-       value_end = NULL;
-    }
+               key_st = NULL;
+               key_end = NULL;
+               value_st = NULL;
+               value_end = NULL;
+       }
 
        return result;
 }
@@ -222,7 +226,7 @@ execute* load_execute_list_from_plugin( plugin_tag* action_tag )
        execute* execute_list = NULL;
 
        if ( tag_list == NULL )
-               return NULL;
+       { return NULL; }
 
        for( plugin_tag = tag_list; plugin_tag ; plugin_tag=plugin_tag->next )
        {
@@ -243,28 +247,28 @@ execute* load_execute_list_from_plugin( plugin_tag* action_tag )
                {
                        char* script_contents = load_script_contents_from_plugin( plugin_tag->tag );
 
-            if (script_contents != NULL)
-            {
-                e = create_execute_script( script_name, desc, script_contents );
-                free( script_contents );
-            }
-            else
-               e =  NULL;
-        }
+                       if (script_contents != NULL)
+                       {
+                               e = create_execute_script( script_name, desc, script_contents );
+                               free( script_contents );
+                       }
+                       else
+                       { e =  NULL; }
+               }
                else
-                       e = NULL;
+               { e = NULL; }
 
                /* if creation is successful */
                if ( e != NULL )
                {
                        /* create/set execute input */
-            set_execute_input( e, load_execute_input_list_from_plugin( plugin_tag->tag ) );
+                       set_execute_input( e, load_execute_input_list_from_plugin( plugin_tag->tag ) );
 
-            /* append it to list */
+                       /* append it to list */
                        if ( execute_list != NULL )
-                               append_execute_list( execute_list, e );
+                       { append_execute_list( execute_list, e ); }
                        else
-                               execute_list = e;
+                       { execute_list = e; }
                }
 
                /* remove dynamically allocated string */
@@ -274,7 +278,7 @@ execute* load_execute_list_from_plugin( plugin_tag* action_tag )
        }
 
        /* clean up */
-    remove_plugin_tag_list(tag_list);
+       remove_plugin_tag_list(tag_list);
 
        return execute_list;
 }
@@ -286,13 +290,13 @@ static char* load_script_contents_from_plugin( plugin_tag* execute_tag )
        char *script = NULL;
 
        if ( ptag == NULL )
-               return NULL;
+       { return NULL; }
 
        /* get contents */
        script = get_plugin_tag_value( ptag->tag );
 
        /* clean up */
-    remove_plugin_tag_list(ptag);
+       remove_plugin_tag_list(ptag);
 
        return script;
 }
@@ -303,7 +307,7 @@ static char* load_script_contents_from_plugin( plugin_tag* execute_tag )
 static char* append_arguments( char* cmd, int cmd_size, execute_input* input_list , execute_env * env )
 {
        execute_input *input = input_list;
-    char* value;
+       char* value;
 
        while( input )
        {
@@ -311,28 +315,28 @@ static char* append_arguments( char* cmd, int cmd_size, execute_input* input_lis
                {
                        execute_tag_value* v = parse_tag_value( input );
                        v->id = tag_checker(v->id);
-            if( (value = search_tag(v->id, v->name, v->attr, v->attr_value, v->find_attr)) != 0 )
-            {
-               value = tag_checker(value);
+                       if( (value = search_tag(v->id, v->name, v->attr, v->attr_value, v->find_attr)) != 0 )
+                       {
+                               value = tag_checker(value);
 
                                if ( cmd_size < ( strlen(cmd) + strlen(value) + 3 ) )
                                {
                                        cmd_size = cmd_size + strlen(value) + 3;
                                        cmd = realloc( cmd, cmd_size );
                                }
-               strcat( cmd, " \"");
-                strcat( cmd, value);
-                       strcat( cmd, "\"");
-            }
-            else
-            {
+                               strcat( cmd, " \"");
+                               strcat( cmd, value);
+                               strcat( cmd, "\"");
+                       }
+                       else
+                       {
                                if ( cmd_size < ( strlen(cmd) + 3 ) )
                                {
                                        cmd_size = cmd_size + 3;
                                        cmd = realloc( cmd, cmd_size );
                                }
-                strcat( cmd," \"\"");
-            }
+                               strcat( cmd," \"\"");
+                       }
                }
                else if ( strcmp( input->type, "variable") == 0 )
                {
@@ -355,7 +359,7 @@ static char* append_arguments( char* cmd, int cmd_size, execute_input* input_lis
                                e = e->next;
                        }
                        if ( e == NULL )
-                               sbi_error(27, input->value, 0);
+                       { sbi_error(27, input->value, 0); }
                }
                else if ( strcmp( input->type, "string") == 0 )
                {
@@ -369,7 +373,7 @@ static char* append_arguments( char* cmd, int cmd_size, execute_input* input_lis
                        strcat( cmd, "\"");
                }
                else
-                       sbi_error(28, input->type, 0);
+               { sbi_error(28, input->type, 0); }
 
                /* get next */
                input = input->next;
@@ -386,11 +390,9 @@ char* write_script(char* program, char* script)
 
        /* open config file */
 
-       //fp = fopen(get_script_file(), "w");
        fp = fopen(filename, "w");
        if (fp == NULL)
        {
-               //sprintf(msg, "can't open script file path : %s", get_script_file());
                sprintf(msg, "can't open script file path : %s", filename);
                sbi_error(99, msg, 1);
        }
@@ -403,8 +405,7 @@ char* write_script(char* program, char* script)
        fclose(fp);
 
 #ifndef WIN32
-    //chmod(get_script_file(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP);
-    chmod(filename, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP);
+       chmod(filename, S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP);
 #endif
 
        return filename;
@@ -432,7 +433,11 @@ static int execute_step( execute* ex , execute_env * env)
                script_path = write_script( ex->script_name, ex->script );
 
                /* make cmd */
-               sprintf(cmd, "sh \"%s\"", script_path);
+#ifdef WIN32
+               sprintf(cmd, "%s%s \"%s\"", get_msys_base_dir(), ex->script_name, script_path);
+#else
+               sprintf(cmd, "%s \"%s\"", ex->script_name, script_path);
+#endif
        }
        else
        {
@@ -450,7 +455,7 @@ static int execute_step( execute* ex , execute_env * env)
        /* if script file is written, remove it */
        if ( script_path != NULL )
        {
-               remove_file(script_path);
+               remove_file(script_path);
        }
 
        free(cmd);
@@ -464,21 +469,21 @@ string_list* get_input_variable_list( execute* exe )
        execute_input* input = exe->input_list;
        string_list *list = NULL;
 
-    if( input == NULL )
-        return NULL;
-
-    for( ; input; input = input->next )
-    {
-        if( strcmp(input->type,"variable")==0 )
-        {
-               if ( list != NULL )
-                       append_string_to_list( list, input->value );
-               else
-                       list = create_string( input->value );
-        }
-    }
-
-    return list;
+       if( input == NULL )
+       { return NULL; }
+
+       for( ; input; input = input->next )
+       {
+               if( strcmp(input->type,"variable")==0 )
+               {
+                       if ( list != NULL )
+                       { append_string_to_list( list, input->value ); }
+                       else
+                       { list = create_string( input->value ); }
+               }
+       }
+
+       return list;
 }
 
 
index 5bda67d..edc1125 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -23,7 +23,7 @@
  *
  * Contributors:
  * - S-Core Co., Ltd
- */ 
+ */
 
 #include <stdlib.h>
 #include <string.h>
@@ -45,7 +45,9 @@ execute_input* append_execute_input_list( execute_input* list, execute_input* sr
 {
        execute_input* r = list;
        while( r->next != NULL )
+       {
                r=r->next;
+       }
 
        r->next = src;
 
@@ -77,7 +79,7 @@ execute_input* load_execute_input_list_from_plugin( plugin_tag* execute_tag )
        execute_input* input_list = NULL;
 
        if ( tag_list == NULL )
-               return NULL;
+       { return NULL; }
 
        for( ptag = tag_list; ptag ; ptag=ptag->next )
        {
@@ -93,9 +95,9 @@ execute_input* load_execute_input_list_from_plugin( plugin_tag* execute_tag )
                if ( ei != NULL )
                {
                        if ( input_list != NULL)
-                               append_execute_input_list( input_list, ei );
+                       { append_execute_input_list( input_list, ei ); }
                        else
-                               input_list = ei;
+                       { input_list = ei; }
                }
 
                /* remove dynamically allocated string */
@@ -104,7 +106,7 @@ execute_input* load_execute_input_list_from_plugin( plugin_tag* execute_tag )
        }
 
        /* clean up */
-    remove_plugin_tag_list(tag_list);
+       remove_plugin_tag_list(tag_list);
 
        return input_list;
 }
@@ -132,7 +134,7 @@ execute_tag_value* parse_tag_value( execute_input* input )
        }
 
        if ( *val_st != '\0' )
-               strcpy( val[i], val_st );
+       { strcpy( val[i], val_st ); }
 
        newr->id = (strcmp(val[0], "") == 0) ? NULL : strdup(val[0]);
        newr->name = (strcmp(val[1], "") == 0) ? NULL : strdup(val[1]);
index 16bd97b..cb17310 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -23,7 +23,7 @@
  *
  * Contributors:
  * - S-Core Co., Ltd
- */ 
+ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -37,335 +37,328 @@ static char* query_tag_loop(xmlNode* node, char* name, xmlChar * attr, char* att
 
 plugin* create_plugin( char* file_name )
 {
-    
-    char plugin_id[MAX_FILE_PATH + 1];
-    char* ext;
-    xmlDoc* doc = NULL;
-    plugin* ret = malloc(sizeof(plugin));
-
-    /* file name validation*/
-    if(!does_file_exist(file_name))
-    {
-       return NULL; 
-    }
-
-    /* extension id validation*/
-    doc = xmlReadFile(file_name, NULL, 0);
-    ret->extension_id = query_tag(doc,"extension",NULL,NULL,"point");
-    if (ret->extension_id == NULL) 
-    {
-        xmlFreeDoc(doc);
-        free(ret->extension_id);
-        free(ret);
-        return NULL;
-    }
-
-    /* return plugin */
-    strcpy(plugin_id,file_name);
-    ext = strrchr(plugin_id,'.');
-    ext = '\0';
-    ret->id = strdup(plugin_id);
-    ret->doc = doc;
-    ret->next = NULL;
-    return ret;
+
+       char plugin_id[MAX_FILE_PATH + 1];
+       char* ext;
+       xmlDoc* doc = NULL;
+       plugin* ret = malloc(sizeof(plugin));
+
+       /* file name validation*/
+       if(!does_file_exist(file_name))
+       {
+               return NULL;
+       }
+
+       /* extension id validation*/
+       doc = xmlReadFile(file_name, NULL, 0);
+       ret->extension_id = query_tag(doc,"extension",NULL,NULL,"point");
+       if (ret->extension_id == NULL)
+       {
+               xmlFreeDoc(doc);
+               free(ret->extension_id);
+               free(ret);
+               return NULL;
+       }
+
+       /* return plugin */
+       strcpy(plugin_id,file_name);
+       ext = strrchr(plugin_id,'.');
+       ext = '\0';
+       ret->id = strdup(plugin_id);
+       ret->doc = doc;
+       ret->next = NULL;
+       return ret;
 }
 
 
 plugin* append_plugin( plugin* list, plugin* src )
 {
-    plugin* node = list;
-
-    if(node == NULL)
-    {
-        return src;
-    }
-
-    while(node->next != NULL)
-    {
-        node = node->next;
-    }
-    
-    node->next = src;
-    return list;
+       plugin* node = list;
+
+       if(node == NULL)
+       {
+               return src;
+       }
+
+       while(node->next != NULL)
+       {
+               node = node->next;
+       }
+
+       node->next = src;
+       return list;
 }
 
 
 void remove_plugin( plugin* list )
 {
-    plugin* node = list;
-    plugin* prev;
-
-    while(node != NULL)
-    {
-        prev = node;
-        node = node->next;
-        if(prev->extension_id != NULL)
-        {
-            free(prev->extension_id);
-        }
-        if(prev->id != NULL)
-        {
-            free(prev->id);
-        }
-        if(prev->doc != NULL)
-        {
-            xmlFreeDoc(prev->doc);
-        }
-        free(prev);
-    }
+       plugin* node = list;
+       plugin* prev;
+
+       while(node != NULL)
+       {
+               prev = node;
+               node = node->next;
+               if(prev->extension_id != NULL)
+               {
+                       free(prev->extension_id);
+               }
+               if(prev->id != NULL)
+               {
+                       free(prev->id);
+               }
+               if(prev->doc != NULL)
+               {
+                       xmlFreeDoc(prev->doc);
+               }
+               free(prev);
+       }
 }
 
 plugin_tag_list* create_plugin_tag_list(plugin_tag* tag, char* tag_name)
 {
-    plugin_tag_list* list;
+       plugin_tag_list* list;
 
-    list = malloc( sizeof(plugin_tag_list) );
-    list->tag = xmlCopyNode(tag,1);
-    list->tag_name = strdup(tag_name);
-    list->next = NULL;
-    return list;
+       list = malloc( sizeof(plugin_tag_list) );
+       list->tag = xmlCopyNode(tag,1);
+       list->tag_name = strdup(tag_name);
+       list->next = NULL;
+       return list;
 }
 
 
 plugin_tag_list* append_plugin_tag_list(plugin_tag_list* list, plugin_tag_list* src)
 {
-    plugin_tag_list* node;
+       plugin_tag_list* node;
 
-    if(list == NULL)
-    {
-        return src; 
-    }
+       if(list == NULL)
+       {
+               return src;
+       }
 
-    node = list;
-    while(node->next != NULL)
-    {
-        node = node->next;
-    }
-    node->next = src;
+       node = list;
+       while(node->next != NULL)
+       {
+               node = node->next;
+       }
+       node->next = src;
 
-    return list;
+       return list;
 }
 
 
 void remove_plugin_tag_list(plugin_tag_list* list)
 {
-    plugin_tag_list* node;
-    plugin_tag_list* pre;
-
-    node = list;
-    while(node != NULL)
-    {
-        pre = node;
-        node = node->next;
-        if(pre->tag != NULL)
-        {
-            xmlFreeNodeList(pre->tag);
-        }
-        if(pre->tag_name != NULL)
-        {
-            free(pre->tag_name);
-        }
-        free(pre);
-    }
+       plugin_tag_list* node;
+       plugin_tag_list* pre;
+
+       node = list;
+       while(node != NULL)
+       {
+               pre = node;
+               node = node->next;
+               if(pre->tag != NULL)
+               {
+                       xmlFreeNodeList(pre->tag);
+               }
+               if(pre->tag_name != NULL)
+               {
+                       free(pre->tag_name);
+               }
+               free(pre);
+       }
 }
 
 plugin_tag* search_plugin_first_tag(plugin_tag* tag, const char* tag_name)
 {
-    plugin_tag* node;
-    plugin_tag* ret;
-
-    if( strcmp( (const char*)tag->name,tag_name) == 0)
-    {
-        return tag;
-    }
-
-    node = xmlFirstElementChild(tag);
-    if(node != NULL)
-    {
-        ret = search_plugin_first_tag(node,tag_name);
-        if(ret != NULL)
-        {
-            return ret;
-        }
-    }
-
-    node = xmlNextElementSibling(tag);
-    if(node != NULL)
-    {
-        return search_plugin_first_tag(node, tag_name);
-    }
-
-    return NULL;
+       plugin_tag* node;
+       plugin_tag* ret;
+
+       if( strcmp( (const char*)tag->name,tag_name) == 0)
+       {
+               return tag;
+       }
+
+       node = xmlFirstElementChild(tag);
+       if(node != NULL)
+       {
+               ret = search_plugin_first_tag(node,tag_name);
+               if(ret != NULL)
+               {
+                       return ret;
+               }
+       }
+
+       node = xmlNextElementSibling(tag);
+       if(node != NULL)
+       {
+               return search_plugin_first_tag(node, tag_name);
+       }
+
+       return NULL;
 }
 
 plugin_tag* get_plugin_tag( plugin* plg, char* tag_name )
 {
-    plugin_tag* node;
+       plugin_tag* node;
 
-    node = xmlDocGetRootElement(plg->doc);
-    if(node == NULL)
-    {
-        return NULL;
-    }
+       node = xmlDocGetRootElement(plg->doc);
+       if(node == NULL)
+       {
+               return NULL;
+       }
 
-    return search_plugin_first_tag(node, tag_name);
+       return search_plugin_first_tag(node, tag_name);
 }
 
 plugin_tag_list* get_plugin_subtag_list( plugin_tag* parent_tag, char* tag_name )
 {
-    plugin_tag_list* list = NULL;
-    plugin_tag* node;
-
-    node = xmlFirstElementChild(parent_tag);
-    while( node != NULL)
-    {
-        if(strcmp( (const char*)node->name,tag_name) == 0)
-        {
-            list = append_plugin_tag_list(list, create_plugin_tag_list(node,tag_name));
-        }
-        node = xmlNextElementSibling(node);
-    }
-    return list;
+       plugin_tag_list* list = NULL;
+       plugin_tag* node;
+
+       node = xmlFirstElementChild(parent_tag);
+       while( node != NULL)
+       {
+               if(strcmp( (const char*)node->name,tag_name) == 0)
+               {
+                       list = append_plugin_tag_list(list, create_plugin_tag_list(node,tag_name));
+               }
+               node = xmlNextElementSibling(node);
+       }
+       return list;
 }
 
 char* get_plugin_tag_attribute( plugin_tag* ptag, const char* attr )
 {
        xmlChar * value;
-    char* string;
-
-    value = xmlGetProp(ptag, (const xmlChar *)attr);
-    if(value != NULL )
-    {
-        string = strdup((char*)value);
-        xmlFree(value);
-        return string;
-    }
-    return NULL;
+       char* string;
+
+       value = xmlGetProp(ptag, (const xmlChar *)attr);
+       if(value != NULL )
+       {
+               string = strdup((char*)value);
+               xmlFree(value);
+               return string;
+       }
+       return NULL;
 }
 
 char* get_plugin_tag_value( plugin_tag*ptag )
 {
        xmlChar * value;
-    char* string;
-
-    value = xmlNodeGetContent(ptag);
-    if(value != NULL)
-    {
-        string = strdup((char*)value);
-        xmlFree(value);
-        return string; 
-    }
-    return NULL; 
+       char* string;
+
+       value = xmlNodeGetContent(ptag);
+       if(value != NULL)
+       {
+               string = strdup((char*)value);
+               xmlFree(value);
+               return string;
+       }
+       return NULL;
 }
 
 plugin_tag* get_plugin_sub_tags( plugin_tag* ptag)
 {
-    return xmlFirstElementChild(ptag);
+       return xmlFirstElementChild(ptag);
 }
 
 plugin_writer* create_writer(plugin_doc** doc)
-{ 
-    return xmlNewTextWriterDoc(doc,0); 
+{
+       return xmlNewTextWriterDoc(doc,0);
 }
 
 int start_write_doc(plugin_writer* writer)
-{ 
-    return xmlTextWriterStartDocument(writer,NULL,NULL,NULL); 
+{
+       return xmlTextWriterStartDocument(writer,NULL,NULL,NULL);
 }
 
 int start_write_elm(plugin_writer* writer, const char * name)
 {
-    return xmlTextWriterStartElement(writer,(const xmlChar *)name);
+       return xmlTextWriterStartElement(writer,(const xmlChar *)name);
 }
 
 int write_attr(plugin_writer* writer, const char * name, const char * constant)
-{ 
-    return xmlTextWriterWriteAttribute(writer,(const xmlChar *)name,(const xmlChar *)constant);
+{
+       return xmlTextWriterWriteAttribute(writer,(const xmlChar *)name,(const xmlChar *)constant);
 }
 
 int write_string(plugin_writer* writer, const char * content)
-{ 
-    return xmlTextWriterWriteString(writer,(const xmlChar *)content);
+{
+       return xmlTextWriterWriteString(writer,(const xmlChar *)content);
 }
 
 int end_write_elm(plugin_writer* writer)
-{ 
-    return xmlTextWriterEndElement(writer); 
+{
+       return xmlTextWriterEndElement(writer);
 }
 
 int end_write_doc(plugin_writer* writer)
-{ 
-    return xmlTextWriterEndDocument(writer); 
+{
+       return xmlTextWriterEndDocument(writer);
 }
 
 void free_writer(plugin_writer* writer)
-{ 
-    return xmlFreeTextWriter(writer); 
+{
+       return xmlFreeTextWriter(writer);
 }
 
 void free_doc(plugin_doc* doc)
 {
-    return xmlFreeDoc(doc); 
+       return xmlFreeDoc(doc);
 }
 
 int save_doc_file(plugin_doc* doc,const char* filename)
 {
-    return xmlSaveFile(filename,doc); 
+       return xmlSaveFile(filename,doc);
 }
 
 static char* query_tag_loop(xmlNode* node, char* name, xmlChar * attr, char* attr_value, xmlChar * find_attr  )
 {
-    xmlNode *cur_node = NULL;
-    xmlChar* result;
-    char* ret;
-    char* tmp;
-    char temp[MAX_CMD_LENGTH + 1];
-
-    for (cur_node = node; cur_node; cur_node = xmlNextElementSibling(cur_node))
-    {
-        if(strcmp((const char*)cur_node->name, name) == 0)
-        {
-            if( ( attr == NULL && attr_value == NULL ) ||
-                    ( (tmp = (char*)xmlGetProp(cur_node,attr)) != NULL && strcmp(attr_value,tmp) == 0))
-            {
-                /* find attr is needed */
-                if( find_attr == NULL )
-                {
-                    return NULL;
-                }
-
-                result = xmlGetProp(cur_node,find_attr);
-                if(result == NULL)
-                {
-                    return NULL;
-                }
-
-                ret = strdup((char*)result);
-                if(strchr(ret,' ') != NULL)
-                {
-                    sprintf(temp,"\"%s\"",ret);
-                    free(ret);
-                    ret=strdup(temp);
-                }
-
-                xmlFree(result);
-                return ret;
-            }
-        }
-        ret = query_tag_loop(cur_node->children, name, attr, attr_value, find_attr);
-        if(ret != NULL)
-            return ret;
-    }
-    return NULL;
+       xmlNode *cur_node = NULL;
+       xmlChar* result;
+       char* ret;
+       char* tmp;
+
+       for (cur_node = node; cur_node; cur_node = xmlNextElementSibling(cur_node))
+       {
+               if(strcmp((const char*)cur_node->name, name) == 0)
+               {
+                       if( ( attr == NULL && attr_value == NULL ) ||
+                               ( (tmp = (char*)xmlGetProp(cur_node,attr)) != NULL && strcmp(attr_value,tmp) == 0))
+                       {
+                               /* find attr is needed */
+                               if( find_attr == NULL )
+                               {
+                                       return NULL;
+                               }
+
+                               result = xmlGetProp(cur_node,find_attr);
+                               if(result == NULL)
+                               {
+                                       return NULL;
+                               }
+
+                               ret = strdup((char*)result);
+
+                               xmlFree(result);
+                               return ret;
+                       }
+               }
+               ret = query_tag_loop(cur_node->children, name, attr, attr_value, find_attr);
+               if(ret != NULL)
+               { return ret; }
+       }
+       return NULL;
 }
 
 char* query_tag(xmlDoc* doc, char* name, char* attr, char* attr_value, char* find_attr  )
 {
-    xmlNode *root = NULL;
+       xmlNode *root = NULL;
 
-    if (doc == NULL)
-        return NULL;
+       if (doc == NULL)
+       { return NULL; }
 
-    root = xmlDocGetRootElement(doc);
-    return query_tag_loop(root, name, (xmlChar*)attr, attr_value, (xmlChar*)find_attr);
+       root = xmlDocGetRootElement(doc);
+       return query_tag_loop(root, name, (xmlChar*)attr, attr_value, (xmlChar*)find_attr);
 }
index fb9c8c3..a0bcd0e 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -23,7 +23,7 @@
  *
  * Contributors:
  * - S-Core Co., Ltd
- */ 
+ */
 
 #include <dirent.h>
 #include <string.h>
@@ -37,125 +37,121 @@ static char* plugin_base_dir;
 
 void initialize_plugins(char* plugin_dir)
 {
-       DIR* dir; 
+       DIR* dir;
        struct dirent *entry;
-    //char* plugin_base_dir;
-    char xml_path[MAX_FILE_PATH + 1];
-    //plugin_base_dir = get_plugin_base_dir();
-    plugin_base_dir = plugin_dir;
-
-    dir = opendir(plugin_base_dir);
-    if ( dir == NULL )
-       return;
-
-    while ( (entry = readdir(dir)) != NULL )
-    {
-        int d_name_size;
-
-        d_name_size = strlen( entry->d_name );
-        if ( strcmp( entry->d_name + ( d_name_size - 4 ), ".xml" ) != 0 )
-        {
-            continue;
-        }
+       char xml_path[MAX_FILE_PATH + 1];
+       plugin_base_dir = plugin_dir;
+
+       dir = opendir(plugin_base_dir);
+       if ( dir == NULL )
+       { return; }
+
+       while ( (entry = readdir(dir)) != NULL )
+       {
+               int d_name_size;
+
+               d_name_size = strlen( entry->d_name );
+               if ( strcmp( entry->d_name + ( d_name_size - 4 ), ".xml" ) != 0 )
+               {
+                       continue;
+               }
 #ifdef WIN32
-        sprintf( xml_path, "%s\\%s", plugin_base_dir, entry->d_name);
+               sprintf( xml_path, "%s\\%s", plugin_base_dir, entry->d_name);
 #else
-        sprintf( xml_path, "%s/%s", plugin_base_dir, entry->d_name);
+               sprintf( xml_path, "%s/%s", plugin_base_dir, entry->d_name);
 #endif
-        if (!is_directory(xml_path))
-        {
-            plugins = append_plugin(plugins, create_plugin(xml_path));
-        }
-    }
-    closedir(dir);
+               if (!is_directory(xml_path))
+               {
+                       plugins = append_plugin(plugins, create_plugin(xml_path));
+               }
+       }
+       closedir(dir);
 }
 
 
 plugin* get_plugin_list(char* extention_pid )
 {
-    plugin* node = plugins;
-    plugin* reta = NULL;
-
-    while (node != NULL)
-    {
-       if  (strcmp(node->extension_id, extention_pid ) == 0)
-       {
-               plugin* retp = malloc(sizeof(plugin));
-               memcpy(retp, node, sizeof(plugin));
-               retp->next = NULL;
-               if (reta == NULL)
-                       reta = retp;
-               else
-                       append_plugin(reta, retp);
-       }
-       node = node->next;
-    }
-
-    return reta;
+       plugin* node = plugins;
+       plugin* reta = NULL;
+
+       while (node != NULL)
+       {
+               if  (strcmp(node->extension_id, extention_pid ) == 0)
+               {
+                       plugin* retp = malloc(sizeof(plugin));
+                       memcpy(retp, node, sizeof(plugin));
+                       retp->next = NULL;
+                       if (reta == NULL)
+                       { reta = retp; }
+                       else
+                       { append_plugin(reta, retp); }
+               }
+               node = node->next;
+       }
+
+       return reta;
 }
 
 void remove_plugin_list(plugin_list* list)
 {
-    plugin_list* node;
-    plugin_list* temp;
-    node = list;
-    while(node != NULL)
-    {
-        temp = node;   
-        node = node->next; 
-        free(temp);
-    }
+       plugin_list* node;
+       plugin_list* temp;
+       node = list;
+       while(node != NULL)
+       {
+               temp = node;
+               node = node->next;
+               free(temp);
+       }
 }
 
 char* search_tag(char* plugin_id, char* tag_name, char* attr, char* attr_val, char* find_attr)
 {
-    plugin* p;
-    char* ret;
-    char xml_path[MAX_FILE_PATH +1];
+       plugin* p;
+       char* ret;
+       char xml_path[MAX_FILE_PATH +1];
 
-   // sprintf(xml_path,"%s/%s.xml",get_plugin_base_dir(),tag_checker(plugin_id));
 #ifdef WIN32
-    sprintf(xml_path,"%s\\%s.xml", plugin_base_dir, plugin_id);
+       sprintf(xml_path,"%s\\%s.xml", plugin_base_dir, plugin_id);
 #else
-    sprintf(xml_path,"%s/%s.xml", plugin_base_dir, plugin_id);
+       sprintf(xml_path,"%s/%s.xml", plugin_base_dir, plugin_id);
 #endif
-    p = get_plugin(xml_path);    
-    if(p == NULL)
-    {
-        return NULL;
-    }
-    ret = query_tag(p->doc,tag_name,attr,attr_val,find_attr);
-    //ret = tag_checker(ret);
-
-    return ret;
+       p = get_plugin(xml_path);
+       if(p == NULL)
+       {
+               return NULL;
+       }
+       ret = query_tag(p->doc,tag_name,attr,attr_val,find_attr);
+
+       return ret;
 }
 
 plugin* get_plugin(char* plugin_id )
 {
-    plugin* node = plugins;
-    while( node )
-    {
-       if ( strcmp( node->id, plugin_id ) == 0 )
-               return node;
-        node = node->next;
-    }
-    return NULL;
+       plugin* node = plugins;
+       while( node )
+       {
+               if ( strcmp( node->id, plugin_id ) == 0 )
+               { return node; }
+               node = node->next;
+       }
+       return NULL;
 }
 
 void add_new_plugin( plugin* new_plugin )
 {
-    plugins = append_plugin(plugins, new_plugin);
+       plugins = append_plugin(plugins, new_plugin);
 }
 
 
 void add_target(char* target_xml_path)
-{ 
-    plugins = append_plugin(plugins, create_plugin(target_xml_path));
+{
+       plugins = append_plugin(plugins, create_plugin(target_xml_path));
 }
 
 
 
-void finalize_plugins()
+void finalize_plugins( void )
 {
-    remove_plugin(plugins);
+       remove_plugin(plugins);
 }
index 5ab247b..e525708 100644 (file)
 #define PLUGIN_MGT_H_
 #include "plugin.h"
 
-void initialize_plugins();
+void initialize_plugins( char* plugin_dir );
 plugin* get_plugin_list(char* extention_pid );
 void remove_plugin_list(plugin_list* list);
 plugin* get_plugin(char* plugin_id );
 void add_new_plugin( plugin* new_plugin );
 void add_target(char* target_xml_path);
 char* search_tag(char* plugin_id, char* tag_name, char* attr, char* attr_val, char* find_attr);
-void finalize_plugins();
+void finalize_plugins( void );
 
 
 #endif /* PLUGIN_MGT_H_ */
index 0a934d5..3dad047 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -23,7 +23,7 @@
  *
  * Contributors:
  * - S-Core Co., Ltd
- */ 
+ */
 
 #include <stdlib.h>
 #include <string.h>
@@ -47,7 +47,9 @@ static rootstrap_property* append_rootstrap_property_list( rootstrap_property* l
 {
        rootstrap_property* r = list;
        while( r->next != NULL )
+       {
                r=r->next;
+       }
 
        r->next = src;
 
@@ -60,19 +62,19 @@ static void remove_rootstrap_property_list( rootstrap_property* list )
        rootstrap_property* r = list;
        rootstrap_property* prev;
        while( r != NULL )
-    {
-        prev = r; 
+       {
+               prev = r;
                r=r->next;
-        if(prev->key != NULL)
-        {
-            free(prev->key);
-        }
-        if(prev->value != NULL)
-        {
-            free(prev->value);
-        }
-        free(prev);
-    }
+               if(prev->key != NULL)
+               {
+                       free(prev->key);
+               }
+               if(prev->value != NULL)
+               {
+                       free(prev->value);
+               }
+               free(prev);
+       }
 }
 
 
@@ -82,20 +84,20 @@ rootstrap* create_rootstrap( char* id, char* name, char* version, char* architec
 
        newr->id = (char*)strdup(id);
 
-       if ( name != NULL ) newr->name = (char*)strdup(name);
-       else    newr->name =  (char*)strdup(id);
+       if ( name != NULL ) { newr->name = (char*)strdup(name); }
+       else    { newr->name =  (char*)strdup(id); }
 
-       if ( version != NULL ) newr->version = (char*)strdup(version);
-       else    newr->version =  (char*)strdup("1.0");
+       if ( version != NULL ) { newr->version = (char*)strdup(version); }
+       else    { newr->version =  (char*)strdup("1.0"); }
 
-    if ( architecture != NULL ) newr->architecture =  (char*)strdup( architecture );
-    else newr->architecture = NULL;
-    if ( path != NULL ) newr->path =  (char*)strdup( path );
-    else newr->path = NULL;
-    if ( toolchain_type != NULL ) newr->support_toolchain_type = (char*)strdup( toolchain_type );
-    else newr->support_toolchain_type = NULL;
-    newr->property_list = NULL;
-    newr->next = NULL;
+       if ( architecture != NULL ) { newr->architecture =  (char*)strdup( architecture ); }
+       else { newr->architecture = NULL; }
+       if ( path != NULL ) { newr->path =  (char*)strdup( path ); }
+       else { newr->path = NULL; }
+       if ( toolchain_type != NULL ) { newr->support_toolchain_type = (char*)strdup( toolchain_type ); }
+       else { newr->support_toolchain_type = NULL; }
+       newr->property_list = NULL;
+       newr->next = NULL;
 
        return newr;
 }
@@ -105,7 +107,9 @@ rootstrap* append_rootstrap_list( rootstrap* list, rootstrap* src )
 {
        rootstrap* r = list;
        while( r->next != NULL )
+       {
                r=r->next;
+       }
 
        r->next = src;
 
@@ -120,13 +124,13 @@ void remove_rootstrap_list( rootstrap* list )
        {
                rootstrap* prev = r ;
                r=r->next;
-        if(prev->id != NULL) free( prev->id );
-               if(prev->name != NULL) free( prev->name );
-               if(prev->version != NULL) free( prev->version );
-               if(prev->architecture != NULL) free( prev->architecture );
-               if(prev->path != NULL) free( prev->path );
-               if(prev->support_toolchain_type != NULL) free( prev->support_toolchain_type );
-        remove_rootstrap_property_list(prev->property_list);
+               if(prev->id != NULL) { free( prev->id ); }
+               if(prev->name != NULL) { free( prev->name ); }
+               if(prev->version != NULL) { free( prev->version ); }
+               if(prev->architecture != NULL) { free( prev->architecture ); }
+               if(prev->path != NULL) { free( prev->path ); }
+               if(prev->support_toolchain_type != NULL) { free( prev->support_toolchain_type ); }
+               remove_rootstrap_property_list(prev->property_list);
                free( prev );
        }
 }
@@ -137,9 +141,9 @@ void add_rootstrap_property( rootstrap* r, char* key, char* value )
        rootstrap_property* newr = create_rootstrap_property( key, value );
 
        if ( r->property_list != NULL )
-               append_rootstrap_property_list( r->property_list, newr );
+       { append_rootstrap_property_list( r->property_list, newr ); }
        else
-               r->property_list = newr;
+       { r->property_list = newr; }
 }
 
 
index 6077612..bd9764e 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -23,7 +23,7 @@
  *
  * Contributors:
  * - S-Core Co., Ltd
- */ 
+ */
 
 #include <stdio.h>
 #include <string.h>
@@ -38,7 +38,7 @@
 static rootstrap* rootstrap_list = NULL;
 
 /* init fini */
-void initialize_rootstrap_mgt( )
+void initialize_rootstrap_mgt( void )
 {
        plugin* list = get_plugin_list("rootstrapDefinition");
        plugin* p = list;
@@ -50,23 +50,23 @@ void initialize_rootstrap_mgt( )
                if ( r != NULL )
                {
                        if ( rootstrap_list != NULL )
-                               append_rootstrap_list( rootstrap_list, r );
+                       { append_rootstrap_list( rootstrap_list, r ); }
                        else
-                               rootstrap_list = r;
+                       { rootstrap_list = r; }
                }
        }
        remove_plugin_list(list);
 }
 
 
-void finalize_rootstrap_mgt( )
+void finalize_rootstrap_mgt( void )
 {
        remove_rootstrap_list( rootstrap_list );
 }
 
 
 /* list up all target  */
-string_list* get_all_available_rootstrap_ids( )
+string_list* get_all_available_rootstrap_ids( void )
 {
        string_list *new_list = NULL;
        rootstrap * t = rootstrap_list;
@@ -74,16 +74,16 @@ string_list* get_all_available_rootstrap_ids( )
        for( ; t ; t=t->next )
        {
                if ( new_list != NULL )
-                       append_string_to_list( new_list, t->id );
+               { append_string_to_list( new_list, t->id ); }
                else
-                       new_list = create_string_list( t->id );
+               { new_list = create_string_list( t->id ); }
        }
 
        return new_list;
 }
 
 
-string_list* get_all_available_rootstrap_names( )
+string_list* get_all_available_rootstrap_names( void )
 {
        string_list *new_list = NULL;
        rootstrap * t = rootstrap_list;
@@ -91,9 +91,9 @@ string_list* get_all_available_rootstrap_names( )
        for( ; t ; t=t->next )
        {
                if ( new_list != NULL )
-                       append_string_to_list( new_list, t->name );
+               { append_string_to_list( new_list, t->name ); }
                else
-                       new_list = create_string_list( t->name );
+               { new_list = create_string_list( t->name ); }
        }
 
        return new_list;
@@ -108,7 +108,7 @@ static rootstrap* find_rootstrap( char* rootstrap_id )
        for( ; t ; t=t->next )
        {
                if ( strcmp( t->id, rootstrap_id ) == 0 )
-                       return t;
+               { return t; }
        }
 
        return NULL;
@@ -121,9 +121,9 @@ char* get_rootstrap_name( char* rootstrap_id )
        rootstrap * t = find_rootstrap( rootstrap_id );
 
        if ( t != NULL )
-               return strdup( t->name );
+       { return strdup( t->name ); }
        else
-               return NULL;
+       { return NULL; }
 }
 
 
@@ -132,9 +132,9 @@ char* get_rootstrap_version( char* rootstrap_id )
        rootstrap * t = find_rootstrap( rootstrap_id );
 
        if ( t != NULL )
-               return strdup( t->version );
+       { return strdup( t->version ); }
        else
-               return NULL;
+       { return NULL; }
 }
 
 
@@ -144,16 +144,16 @@ char* get_rootstrap_architecture( char* rootstrap_id )
        rootstrap * t = find_rootstrap( rootstrap_id );
 
        if ( t != NULL )
-    {
-        if(t->architecture != NULL)
-            return strdup( t->architecture );
-        else 
-            return NULL;
-    }
-    else
-    {
-        return NULL;
-    }
+       {
+               if(t->architecture != NULL)
+               { return strdup( t->architecture ); }
+               else
+               { return NULL; }
+       }
+       else
+       {
+               return NULL;
+       }
 }
 
 
@@ -162,9 +162,9 @@ char* get_rootstrap_path( char* rootstrap_id )
        rootstrap * t = find_rootstrap( rootstrap_id );
 
        if ( t != NULL )
-               return strdup( t->path );
+       { return strdup( t->path ); }
        else
-               return NULL;
+       { return NULL; }
 }
 
 
@@ -173,16 +173,16 @@ char* get_rootstrap_support_toolchain_type( char* rootstrap_id )
        rootstrap * t = find_rootstrap( rootstrap_id );
 
        if ( t != NULL )
-    {
-        if(t->support_toolchain_type != NULL)
-            return strdup( t->support_toolchain_type );
-        else
-            return NULL;
-    }
-    else
-    {
-        return NULL;
-    }
+       {
+               if(t->support_toolchain_type != NULL)
+               { return strdup( t->support_toolchain_type ); }
+               else
+               { return NULL; }
+       }
+       else
+       {
+               return NULL;
+       }
 }
 
 string_list* get_rootstrap_property_list( char* rootstrap_id )
@@ -194,9 +194,9 @@ string_list* get_rootstrap_property_list( char* rootstrap_id )
        for( ; r; r = r -> next )
        {
                if ( list != NULL )
-                       append_string_to_list( list, r->key );
+               { append_string_to_list( list, r->key ); }
                else
-                       list = create_string_list( r->key);
+               { list = create_string_list( r->key); }
        }
 
        return list;
@@ -212,7 +212,7 @@ char* get_rootstrap_property_value( char* rootstrap_id, char* key )
        for( ; r; r = r -> next )
        {
                if ( strcmp( r-> key , key) == 0 )
-                       return strdup( r->value );
+               { return strdup( r->value ); }
        }
 
        return NULL;
@@ -224,68 +224,64 @@ int is_rootstrap_available( char* rootstrap_id )
        rootstrap * t = find_rootstrap( rootstrap_id );
 
        if ( t != NULL )
-               return 1;
+       { return 1; }
        else
-               return 0;
+       { return 0; }
 }
 
-void display_rootstrap_list()
+void display_rootstrap_list( void )
 {
        string_list* list = get_all_available_rootstrap_ids();
        string_list* id = list;
 
-       /*
-    SBI_PRINTF(1, "\nAvailable Rootstrap List\n");
-    SBI_PRINTF(1, "------------------------\n");
-    */
-    while ( id != NULL )
-    {
-       SBI_PRINTF(1, "%s\n", id->str );
-        id=id->next;
-    }
-
-    /* remove allocated string */
-    if ( list != NULL ) remove_string_list( list );
+       while ( id != NULL )
+       {
+               SBI_PRINTF(1, "%s\n", id->str );
+               id=id->next;
+       }
+
+       /* remove allocated string */
+       if ( list != NULL ) { remove_string_list( list ); }
 }
 
 void display_rootstrap_info( char* rootstrap_id )
 {
-    if(is_rootstrap_available(rootstrap_id))
-    {
-       char* name =  get_rootstrap_name( rootstrap_id ) ;
-       char* version =  get_rootstrap_version( rootstrap_id ) ;
-       char* architecture =  get_rootstrap_architecture( rootstrap_id ) ;
-       char* path =  tag_checker( get_rootstrap_path( rootstrap_id )  );
-       char* toolchain_type =  get_rootstrap_support_toolchain_type( rootstrap_id ) ;
-       string_list* key_origin;
-       string_list* key;
-        char* value;
-    
-        SBI_PRINTF(1, "NAME=%s\n", name);
-        SBI_PRINTF(1, "VERSION=%s\n",  version);
-        SBI_PRINTF(1, "ARCHITECTURE=%s\n",  architecture );
-        SBI_PRINTF(1, "SYSROOT_PATH=%s\n", path );
-        SBI_PRINTF(1, "SUPPORT_TOOLCHAIN_TYPE=%s\n", toolchain_type );
-    
-       /* other properties */
-       key_origin = get_rootstrap_property_list( rootstrap_id );
-        key = key_origin;
-       for( ; key; key = key->next )
-       {
-            value = tag_checker( get_rootstrap_property_value( rootstrap_id, key->str) );
-            SBI_PRINTF(1, "%s=%s\n", key->str, value);
-            free(value);
-       }
-        remove_string_list(key_origin);
-    
-       free( name );
-       free( version );
-       free( architecture );
-       free( path );
-       free( toolchain_type );
-    }
-    else
-    {
-       SBI_PRINTF(1, "%s rootstrap name is not available",rootstrap_id);
-    }
+       if(is_rootstrap_available(rootstrap_id))
+       {
+               char* name =  get_rootstrap_name( rootstrap_id ) ;
+               char* version =  get_rootstrap_version( rootstrap_id ) ;
+               char* architecture =  get_rootstrap_architecture( rootstrap_id ) ;
+               char* path =  tag_checker( get_rootstrap_path( rootstrap_id )  );
+               char* toolchain_type =  get_rootstrap_support_toolchain_type( rootstrap_id ) ;
+               string_list* key_origin;
+               string_list* key;
+               char* value;
+
+               SBI_PRINTF(1, "NAME=%s\n", name);
+               SBI_PRINTF(1, "VERSION=%s\n",  version);
+               SBI_PRINTF(1, "ARCHITECTURE=%s\n",  architecture );
+               SBI_PRINTF(1, "SYSROOT_PATH=%s\n", path );
+               SBI_PRINTF(1, "SUPPORT_TOOLCHAIN_TYPE=%s\n", toolchain_type );
+
+               /* other properties */
+               key_origin = get_rootstrap_property_list( rootstrap_id );
+               key = key_origin;
+               for( ; key; key = key->next )
+               {
+                       value = tag_checker( get_rootstrap_property_value( rootstrap_id, key->str) );
+                       SBI_PRINTF(1, "%s=%s\n", key->str, value);
+                       free(value);
+               }
+               remove_string_list(key_origin);
+
+               free( name );
+               free( version );
+               free( architecture );
+               free( path );
+               free( toolchain_type );
+       }
+       else
+       {
+               SBI_PRINTF(1, "%s rootstrap name is not available",rootstrap_id);
+       }
 }
index 4dab511..7902212 100644 (file)
 #include "sbi_types.h"
 
 /* init fini */
-void initialize_rootstrap_mgt( );
-void finalize_rootstrap_mgt( );
+void initialize_rootstrap_mgt( void );
+void finalize_rootstrap_mgt( void );
 
 /* list up all target  */
-string_list* get_all_available_rootstrap_ids( );
-string_list* get_all_available_rootstrap_names( );
+string_list* get_all_available_rootstrap_ids( void );
+string_list* get_all_available_rootstrap_names( void );
 
 /* rootstrap */
 char* get_rootstrap_name( char* rootstrap_id );
@@ -48,6 +48,6 @@ char* get_rootstrap_path( char* rootstrap_id );
 string_list* get_rootstrap_property_list( char* rootstrap_id );
 char* get_rootstrap_property_value( char* rootstrap_id, char* key );
 int is_rootstrap_available( char* rootstrap_id );
-void display_rootstrap_list();
+void display_rootstrap_list( void );
 void display_rootstrap_info( char* rootstrap_id );
 #endif
index 0ba6dfe..14d1a0d 100644 (file)
--- a/src/sbi.c
+++ b/src/sbi.c
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -43,7 +43,7 @@ int main(int argc, char* argv[])
 
        /* initialize SBI. If failed, return -1 */
        if ( initialize_sbi(argv[0]) != 0 )
-               exit(-1);
+       { exit(-1); }
 
        /* interpret command line input */
        ret = interpret_command_line( argc , argv );
@@ -53,7 +53,7 @@ int main(int argc, char* argv[])
 
        /* if interpreting failed, return -1 */
        if (ret != 0)
-               exit(-1);
+       { exit(-1); }
 
        exit(0);
 
@@ -68,16 +68,16 @@ static int initialize_sbi(const char* exec_path)
        initialize_sbi_configuration(exec_path);
 
        /* initialize plugins */
-    initialize_plugins(get_plugin_base_dir());
+       initialize_plugins(get_plugin_base_dir());
 
        return 0;
 }
 
 
 /* finish SBI */
-static void finalize_sbi()
+static void finalize_sbi( void )
 {
        /* finalize plugins */
-    finalize_plugins();
+       finalize_plugins();
 }
 
diff --git a/src/sbi_build.c b/src/sbi_build.c
deleted file mode 100644 (file)
index 0f4f7a3..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- *  sbi_build.c
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Taejun Ha <taejun.ha@samsung.com>
- * Jiil Hyoun <jiil.hyoun@samsung.com>
- * Donghyuk Yang <donghyuk.yang@samsung.com>
- * DongHee Yang <donghee.yang@samsung.com>
- * 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * Contributors:
- * - S-Core Co., Ltd
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include "sbi_config.h"
-#include "sbi_types.h"
-#include "sbi_util.h"
-
-#define BUILDDATA_FILE ".build_data"
-#define USAGE_SBIBUILD "sbi_build [-config <configuration name>]"
-#define CONFIG_PREFIX "CB"
-#define DEFAULT_MODE "buildpackage"
-#define MAX_BUF_SIZE 20000
-
-char* get_default_configuration(FILE *fin);
-int ready_configuration(FILE* fin, char* selected_config, string_list** exec_list, char* mode);
-void make_directories(char* pdir_start);
-void make_dir(char* path);
-string_list* create_makefile(FILE *fin, char* config, char* config_dir, char* mode);
-void execute_command(string_list* exec, char* config_dir);
-void print_sbibuild_usage();
-void print_sbibuild_error(char* msg);
-
-int main(int argc, char* argv[]) 
-{
-       FILE *fin;
-
-       char config[MAX_NAME] = {0,};
-       char mode[MAX_NAME] = {0,};
-       char *pconfig;
-
-       int use_default_configuration = 0;
-       int available_config = 0;
-       int arg_count = 1;
-
-       string_list *exec_list;
-
-       /* initialize configuration */
-       initialize_sbi_configuration(argv[0]);
-
-       /* check arguments */
-       while (arg_count <= argc) {
-               if (strncmp(argv[arg_count - 1], "-config", 7) == 0 && strlen(argv[arg_count - 1]) == 7) {
-                       if (arg_count + 1 <= argc) {
-                               strcat(config, argv[arg_count]);
-                               arg_count = arg_count + 2;
-                       } else {
-                               print_sbibuild_usage();
-                               return -1;
-                       }
-               } else if (strncmp(argv[arg_count -1], "-mode", 5) == 0 && strlen(argv[arg_count - 1]) == 5) {
-                       if (arg_count + 1 <= argc) {
-                               strcat(mode, argv[arg_count]);
-                               arg_count = arg_count + 2;
-                       } else {
-                               print_sbibuild_usage();
-                               return -1;
-                       }
-               } else {
-                       arg_count++;
-               }
-       }
-
-       if (!strcmp(config, "")) {
-               use_default_configuration = 1;
-       }
-
-       
-       /* open and read ".build_data" file */
-       fin = fopen(BUILDDATA_FILE, "r");
-
-       if (fin == NULL) {
-               print_sbibuild_error("There is no \".build_data\" file");
-               return -1;
-       }
-
-       /* if useDefault is set, the first configuration is default configuration */
-       if (use_default_configuration) {
-               pconfig = get_default_configuration(fin);
-               strncat(config, pconfig, strlen(pconfig));
-               fclose(fin);
-               fin = fopen(BUILDDATA_FILE, "r");
-       }
-
-       if (!strcmp(mode, "")) {
-               strcat(mode, DEFAULT_MODE);
-       }
-
-       printf("[info] config = %s\n", config);
-       printf("[info] mode = %s\n", mode);
-
-       if (!strcmp(config, "") && use_default_configuration) {
-               print_sbibuild_error("Default configuration does not exist");
-               return -1;
-       }
-
-       /* ready to build configuration */
-       available_config = ready_configuration(fin, config, &exec_list, mode);
-
-       /* close ".build_data" file */
-       fclose(fin);
-
-       if (!available_config) {
-               print_sbibuild_error("The configuration does not exist");
-               return -1;
-       }
-
-       /* execute commands */
-       execute_command(exec_list, config);
-
-       return 0;
-}
-
-/* ready to build configuration (make configuration directory and create makefile) */
-int ready_configuration(FILE* fin, char* config, string_list** exec_list, char* mode)
-{
-       char buf[MAX_LINE_LENGTH] = {0,};
-       char config_path[MAX_NAME] = {0,};
-       char selected_config[MAX_NAME] = {0,};
-       int available_config = 0;
-
-       sprintf(selected_config, "[%s]\n", config);
-
-       while (fgets(buf, sizeof(buf), fin) != NULL) {
-               if (!strcmp(buf, selected_config)) {
-                       available_config = 1;
-                       sprintf(config_path, "%s_%s", CONFIG_PREFIX, config);
-                       if (is_directory(config_path)) {
-                               remove_directory(config_path);
-                       }
-                       make_dir(config_path);
-
-                       /* create_makefile() function returns execution command list */
-                       *exec_list = create_makefile(fin, config, config_path, mode);
-               }
-       }
-
-       return available_config;
-}
-
-/* execute commands */
-void execute_command(string_list* exec, char* config)
-{
-       char cmd[MAX_CMD_LENGTH] = {0,};
-       char sbi_path[MAX_FILE_PATH] = {0,};    
-       char config_absolute_path[MAX_FILE_PATH] = {0,};
-       char config_path[MAX_NAME] = {0,};
-       char current_path[MAX_FILE_PATH] = {0,};
-       char *pstr;
-
-       sprintf(sbi_path, "%s/bin/sbi", get_install_dir());
-       sprintf(config_path, "%s_%s", CONFIG_PREFIX, config);
-       sprintf(current_path, "%s", get_current_path());
-       sprintf(config_absolute_path, "%s/%s", current_path, config_path);
-
-#ifdef WIN32
-       pstr = &config_absolute_path[0];
-       while (*pstr != '\0') {
-               if(*pstr == '\\') {
-                       *pstr = '/';
-               }
-               pstr++;
-       }
-#endif
-
-       for ( ; exec != NULL ; exec = exec->next ) {
-               memset(cmd, 0, MAX_CMD_LENGTH);
-               pstr = (char*)replaceStr(exec->str, "$(SBI_PATH)", sbi_path);
-               pstr = (char*)replaceStr(pstr, "$(CONFIG_PATH)", config_path);
-               SBI_PRINTF( 2, "CMD : %s\n", pstr );
-               int ret = system(pstr);
-               SBI_PRINTF( 2, "return : %d\n", ret );
-               free(pstr);
-       }
-}
-
-/* get default configuration name from ".build_data" file */
-char* get_default_configuration(FILE *fin)
-{
-       char config[MAX_NAME] = {0,};
-       char buf[MAX_LINE_LENGTH] = {0,};
-       char *pStr;
-       int len = 0;
-
-       while (fgets(buf, sizeof(buf), fin) != NULL) {
-               if (buf[0] == '[') {
-                       pStr = strstr(buf, "]\n");
-                       if (pStr != NULL) {
-                               len = pStr-&buf[1];
-                               strncat(config, &buf[1], len);
-                               break;
-                       }
-               }
-       }
-
-       return strdup(config);
-}
-
-/* create "makefile" file */
-string_list* create_makefile(FILE *fin, char* config, char* config_path, char* mode)
-{
-       int file_content = 0;
-       int execution_command = 0;
-       int len = 0;
-
-       char buf[MAX_BUF_SIZE] = {0,};
-       char relative_file_path[MAX_FILE_PATH] = {0,};
-       char absolute_file_path[MAX_FILE_PATH] = {0,};
-       char project_path[MAX_FILE_PATH] = {0,};
-       char makefile_variable_project_path[MAX_FILE_PATH] = {0,};
-       char makefile_variable_rootstrap_path[MAX_FILE_PATH] = {0,};
-       char makefile_variable_config_path[MAX_FILE_PATH] = {0,};
-       char end_config[MAX_NAME] = {0,};
-       char end_tag[MAX_NAME] = {0,};
-       char start_execute_str[MAX_NAME] = {0,};
-
-       char *pfile_start, *ptag_end, *pexecute_start;
-
-       string_list* exec_list = NULL;
-       FILE *fout;
-
-       sprintf(project_path, "%s", get_current_path());
-       sprintf(makefile_variable_rootstrap_path, "ROOTSTRAP_BASE_PATH := %s/rootstraps\n", get_install_dir());
-       sprintf(makefile_variable_project_path, "PROJECT_PATH := %s\n", project_path);
-       sprintf(makefile_variable_config_path, "CONFIG_PATH := %s/%s\n", project_path, config_path);
-       sprintf(end_config, "[/%s]\n", config);
-       sprintf(start_execute_str, "<EXECUTE::%s>", mode);
-
-       while ((fgets(buf, sizeof(buf), fin) != NULL) && strcmp(buf, end_config)) {
-
-               pfile_start = NULL;
-               ptag_end = NULL;
-               pexecute_start = NULL;
-
-               pfile_start = strstr(buf, "<FILE::");
-               //pexecute_start = strstr(buf, "<EXECUTE::");
-               pexecute_start = strstr(buf, start_execute_str);
-               ptag_end = strstr(buf, end_tag);
-
-               /* in case of "<FILE>" tag */
-               if (pfile_start != NULL) {
-                       fout = NULL;
-                       len = strlen(buf) - 9;
-
-                       memset(relative_file_path, 0, MAX_FILE_PATH);
-                       memset(absolute_file_path, 0, MAX_FILE_PATH);
-                       memset(end_tag, 0, MAX_NAME);
-
-                       strncpy(relative_file_path, &pfile_start[7], len);
-                       relative_file_path[len] = '\0';
-                       sprintf(absolute_file_path, "%s/%s", config_path, relative_file_path);
-
-                       chdir(config_path);
-                       /* make directories */
-                       make_directories(relative_file_path);
-                       chdir(project_path);
-
-                       fout = fopen(absolute_file_path, "w");
-                       /* if file is "makefile", write additional variables */
-                       if (!strcmp(relative_file_path, "makefile")) {
-                               fputs(makefile_variable_rootstrap_path, fout);
-                               fputs(makefile_variable_project_path, fout);
-                               fputs(makefile_variable_config_path, fout);
-                       }
-
-                       sprintf(end_tag, "</FILE::%s>", relative_file_path);
-                       file_content = 1;
-
-               /* in case of "<EXECUTE>" tag */
-               } else if (pexecute_start != NULL) {
-                       memset(end_tag, 0, MAX_NAME);
-                       execution_command = 1;
-                       sprintf(end_tag, "</EXECUTE::%s>", mode);
-
-               /* in case of "</EXECUTE>" or "</FILE>" tag  */
-               } else if (ptag_end != NULL) {
-                       if (file_content) {
-                               file_content = 0;
-                               fclose(fout);
-                       } else if (execution_command) {
-                               execution_command = 0;
-                       }
-
-               /* in case of file content */
-               } else if (file_content) {
-                       fputs(buf, fout);
-
-               /* in case of execution command */
-               } else if (execution_command) {
-                       if (exec_list != NULL) {
-                               append_string_to_list(exec_list, buf);
-                       } else {
-                               exec_list = create_string_list(buf);
-                       }
-               }
-               memset(buf, 0, sizeof(buf));
-       }
-
-       return exec_list;
-}
-
-/* create directory structure */
-void make_directories(char* pdir_start)
-{
-       char* pdir_end;
-       char dir[MAX_FILE_PATH] = {0,};
-
-       while ((pdir_end = strstr(pdir_start, "/")) != NULL) {
-               memset(dir, 0, MAX_FILE_PATH);
-               strncpy(dir, pdir_start, pdir_end - pdir_start);
-               make_dir(dir);
-               chdir(dir);
-               if (pdir_end + 1 != NULL) {
-                       pdir_start = pdir_end + 1;
-               } else {
-                       break;
-               }
-       }
-}
-
-/* create directory */
-void make_dir(char* path)
-{
-       if (path == NULL) {
-               return;
-       }
-
-#ifdef WIN32
-       mkdir(path);
-#else
-       mkdir(path, S_IRWXU | S_IRWXO | S_IRWXG);
-#endif
-
-}
-
-/* print usage of sbi_build command */
-void print_sbibuild_usage()
-{
-       SBI_PRINTF(1, "Usage: %s\n", USAGE_SBIBUILD);
-}
-
-/* print error message of sbi_build command */
-void print_sbibuild_error(char* msg)
-{
-       SBI_PRINTF(1, "Error: %s\n", msg);
-}
index 8ed5f9a..2e0db9a 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -57,7 +57,7 @@ static char* global_target_id = NULL;
 static char* global_toolchain_id = NULL;
 static char* global_rootstrap_id = NULL;
 
-char* get_install_bin_dir()
+char* get_install_bin_dir( void )
 {
        char* path = getenv("PATH");
        char vpath[MAX_FILE_PATH];
@@ -155,37 +155,37 @@ char* get_install_dir(void)
        return sbi_install_base_dir;
 }
 
+char* get_msys_base_dir(void)
+{
+       static char sbi_msys_base_dir[MAX_FILE_PATH + 1];
+       sprintf(sbi_msys_base_dir, "%s/../mingw/msys/1.0", sbi_install_base_dir);
+       return sbi_msys_base_dir;
+}
+
 char* get_target_base_dir(void)
 {
        static char sbi_target_base_dir[MAX_FILE_PATH + 1];
-
        sprintf(sbi_target_base_dir, "%s/targets", sbi_install_base_dir);
-
        return sbi_target_base_dir;
 }
 
 char* get_toolchain_base_dir(void)
 {
        static char sbi_toolchain_base_dir[MAX_FILE_PATH + 1];
-
        sprintf(sbi_toolchain_base_dir, "%s/toolchains", sbi_install_base_dir);
-
        return sbi_toolchain_base_dir;
 }
 
 char* get_rootstrap_base_dir(void)
 {
        static char sbi_rootstrap_base_dir[MAX_FILE_PATH + 1];
-
        sprintf(sbi_rootstrap_base_dir, "%s/rootstraps", sbi_install_base_dir);
-
        return sbi_rootstrap_base_dir;
 }
 
 char* get_plugin_base_dir(void)
 {
        static char sbi_plugin_base_dir[MAX_FILE_PATH + 1];
-
 #ifdef WIN32
        sprintf(sbi_plugin_base_dir, "%s\\plugins", sbi_install_base_dir);
 #else
@@ -194,6 +194,19 @@ char* get_plugin_base_dir(void)
        return sbi_plugin_base_dir;
 }
 
+char* get_tmp_dir(void)
+{
+       static char sbi_tmp_dir[MAX_FILE_PATH + 1];
+#ifdef WIN32
+       sprintf(sbi_tmp_dir, "%s\\tmp", sbi_install_base_dir);
+#else
+       sprintf(sbi_tmp_dir, "%s/tmp", sbi_install_base_dir);
+#endif
+       remove_directory(sbi_tmp_dir);
+       make_directory(sbi_tmp_dir);
+       return sbi_tmp_dir;
+}
+
 
 char* get_script_file(void)
 {
@@ -204,12 +217,11 @@ char* get_script_file(void)
        ran = rand();
        sprintf(filename, "%d", ran);
 #ifdef WIN32
-    sprintf(sbi_script_file, "%s\\%s",sbi_install_base_dir, filename);
+       sprintf(sbi_script_file, "%s\\%s",get_tmp_dir(), filename);
 #else
-    ///sprintf(sbi_script_file, "%s/.script",sbi_install_base_dir);
-    sprintf(sbi_script_file, "%s/%s",sbi_install_base_dir, filename);
+       sprintf(sbi_script_file, "%s/%s",get_tmp_dir(), filename);
 #endif
-    return sbi_script_file;
+       return sbi_script_file;
 }
 
 /* default target */
@@ -232,7 +244,7 @@ int set_default_target(char* target_id)
 char* get_default_target(void)
 {
        if (read_sbi_config() == -1)
-               strcpy(sbi_cfg.default_target, "");
+       { strcpy(sbi_cfg.default_target, ""); }
 
        return sbi_cfg.default_target;
 }
@@ -270,17 +282,17 @@ int reset_default_target(void)
 int is_default_target(char* target_id)
 {
        if (strcmp(target_id, get_default_target()) == 0)
-               return 1;
+       { return 1; }
        else
-               return 0;
+       { return 0; }
 }
 
 int does_default_target_exist(void)
 {
        if (strlen(get_default_target()) == 0)
-               return 0;
+       { return 0; }
        else
-               return 1;
+       { return 1; }
 }
 
 static int read_sbi_config(void)
@@ -362,7 +374,7 @@ void initialize_sbi_configuration(const char*exec_path)
 
 void set_target_id(char* id)
 {
-    global_target_id = strdup(id);
+       global_target_id = strdup(id);
 }
 
 void set_rootstrap_id(char* id)
@@ -372,105 +384,111 @@ void set_rootstrap_id(char* id)
 
 void set_toolchain_id(char* id)
 {
-    global_toolchain_id = strdup(id);
+       global_toolchain_id = strdup(id);
 }
 
 void free_toolchain_id(void)
 {
-    if(global_toolchain_id != NULL)
-    {
-        free(global_toolchain_id);
-    }
+       if(global_toolchain_id != NULL)
+       {
+               free(global_toolchain_id);
+       }
 }
 
 void free_rootstrap_id(void)
 {
-    if(global_rootstrap_id != NULL)
-    {
-        free(global_rootstrap_id);
-    }
+       if(global_rootstrap_id != NULL)
+       {
+               free(global_rootstrap_id);
+       }
 }
 
 void free_target_id(void)
 {
-    if(global_target_id != NULL)
-    {
-        free(global_target_id);
-    }
+       if(global_target_id != NULL)
+       {
+               free(global_target_id);
+       }
 }
 
 char* tag_checker(char* tag)
 {
-    char* ret;
-    char* points;
-    char* pointe;
-    char* value ;
-    char temp[MAX_CMD_LENGTH +1];
-
-    ret = tag;
-    if(ret != NULL)
-    {
-        points = ret;
-        value = NULL;
-        while( (points = strchr(points,'#')) != NULL)
-        {
-            if(points[1] == '{' && (pointe = strchr(points, '}')) != NULL)
-            {
-                strncpy(temp,points + 2,pointe-points-2);
-                temp[pointe-points-2] = '\0';
-                if(strcmp(temp,"SBI_HOME")==0)
-                {
-                    value = get_unix_path( get_install_dir() );
-                    if(value == NULL || strcmp(value,"")==0)
-                    {
-                        points = pointe;
-                        continue;
-                    }
-                }
-                else if(strcmp(temp,"ROOTSTRAP")==0)
-                {
-                    value = global_rootstrap_id;
-                    if(value == NULL || strcmp(value,"")==0)
-                    {
-                        points = pointe;
-                        continue;
-                    }
-                }
-                else if(strcmp(temp,"TOOLCHAIN")==0)
-                {
-                    value = global_toolchain_id;
-                    if(value == NULL || strcmp(value,"")==0)
-                    {
-                        points = pointe;
-                        continue;
-                    }
-                }
-                else if(strcmp(temp,"TARGET")==0)
-                {
-                    value = global_target_id;
-                    if(value == NULL || strcmp(value,"")==0)
-                    {
-                        points = pointe;
-                        continue;
-                    }
-                }
-                else
-                {
-                    points = pointe;
-                    continue;
-                }
-
-                strncpy(temp,ret,points-ret);
-                strncpy(temp + (points-ret),value,strlen(value));
-                strncpy(temp + (points-ret) + strlen(value),pointe +1,strlen(pointe+1));
-                (temp + (points-ret) + strlen(value))[strlen(pointe+1)] = '\0';
-                free(ret);
-                ret = strdup(temp);
-                points = ret;
-                value = NULL;
-            }
-        }
-    }
-    return ret;
+       char* ret;
+       char* points;
+       char* pointe;
+       char* value ;
+       char temp[MAX_CMD_LENGTH +1];
+       int need_free_value = 0;
+
+       ret = tag;
+       if(ret != NULL)
+       {
+               points = ret;
+               value = NULL;
+               while( (points = strchr(points,'#')) != NULL)
+               {
+                       need_free_value = 0;                            
+                       if(points[1] == '{' && (pointe = strchr(points, '}')) != NULL)
+                       {
+                               strncpy(temp,points + 2,pointe-points-2);
+                               temp[pointe-points-2] = '\0';
+                               if(strcmp(temp,"SBI_HOME")==0)
+                               {
+                                       value = get_unix_path( get_install_dir() );
+                                       need_free_value = 1;
+                                       if(value == NULL || strcmp(value,"")==0)
+                                       {
+                                               points = pointe;
+                                               continue;
+                                       }
+                               }
+                               else if(strcmp(temp,"ROOTSTRAP")==0)
+                               {
+                                       value = global_rootstrap_id;
+                                       if(value == NULL || strcmp(value,"")==0)
+                                       {
+                                               points = pointe;
+                                               continue;
+                                       }
+                               }
+                               else if(strcmp(temp,"TOOLCHAIN")==0)
+                               {
+                                       value = global_toolchain_id;
+                                       if(value == NULL || strcmp(value,"")==0)
+                                       {
+                                               points = pointe;
+                                               continue;
+                                       }
+                               }
+                               else if(strcmp(temp,"TARGET")==0)
+                               {
+                                       value = global_target_id;
+                                       if(value == NULL || strcmp(value,"")==0)
+                                       {
+                                               points = pointe;
+                                               continue;
+                                       }
+                               }
+                               else
+                               {
+                                       points = pointe;
+                                       continue;
+                               }
+
+                               strncpy(temp,ret,points-ret);
+                               strncpy(temp + (points-ret),value,strlen(value));
+                               strncpy(temp + (points-ret) + strlen(value),pointe +1,strlen(pointe+1));
+                               (temp + (points-ret) + strlen(value))[strlen(pointe+1)] = '\0';
+                               free(ret);
+                               ret = strdup(temp);
+                               points = ret;
+                               if (need_free_value) {
+                                       free(value);
+                               }       
+                               value = NULL;
+                       }
+               }
+       }
+       return ret;
 }
 
index ca0a824..463943a 100644 (file)
@@ -49,11 +49,12 @@ void set_install_base_dir(char* absolue_path);
 
 /* directory */
 char* get_install_dir(void);
+char* get_msys_base_dir(void);
 char* get_target_base_dir(void);
 char* get_toolchain_base_dir(void);
 char* get_rootstrap_base_dir(void);
 char* get_plugin_base_dir(void);
-
+char* get_tmp_dir(void);
 char* get_script_file(void);
 
 /* default target */
index 3c1de5e..8de6ed8 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -97,7 +97,7 @@ void sbi_error(int no, char* arg, int quit)
                break;
        case 3:
                SBI_PRINTF(1,
-                               "ERR003: The target rootstrap \"%s\" does not exist. See following avaiable target rootstraps.\n", arg);
+                          "ERR003: The target rootstrap \"%s\" does not exist. See following avaiable target rootstraps.\n", arg);
                display_rootstrap_list();
 
                if (quit)
@@ -107,14 +107,14 @@ void sbi_error(int no, char* arg, int quit)
                break;
        case 4:
                SBI_PRINTF(1,
-                               "ERR004: The toolchain \"%s\" does not exist. See next avaiable toolchain names.\n", arg);
+                          "ERR004: The toolchain \"%s\" does not exist. See next avaiable toolchain names.\n", arg);
                display_toolchain_list();
                if (quit)
-                       exit(1);
+               { exit(1); }
                break;
        case 5:
                SBI_PRINTF(1,
-                               "ERR005: Invalid target rootstrap configuration. Upgrade is needed.\n");
+                          "ERR005: Invalid target rootstrap configuration. Upgrade is needed.\n");
                if (quit)
                {
                        exit(1);
@@ -129,7 +129,7 @@ void sbi_error(int no, char* arg, int quit)
                break;
        case 7:
                SBI_PRINTF(1,
-                               "ERR007: The target \"%s\" does not exist. See next avaiable target names.\n", arg);
+                          "ERR007: The target \"%s\" does not exist. See next avaiable target names.\n", arg);
                display_target_list();
                if (quit)
                {
@@ -194,7 +194,7 @@ void sbi_error(int no, char* arg, int quit)
                break;
        case 16:
                SBI_PRINTF(1,
-                               "ERR016: Target name must start with alphabet and name only include (alphabet, number, ., _, - )\n");
+                          "ERR016: Target name must start with alphabet and name only include (alphabet, number, ., _, - )\n");
                if (quit)
                {
                        exit(1);
diff --git a/src/sbi_make.c b/src/sbi_make.c
new file mode 100644 (file)
index 0000000..ce04375
--- /dev/null
@@ -0,0 +1,238 @@
+/*
+ *  sbi_make.c
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Taejun Ha <taejun.ha@samsung.com>
+ * Jiil Hyoun <jiil.hyoun@samsung.com>
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <libxml/xmlreader.h>
+#include <libxml/encoding.h>
+#include <libxml/tree.h>
+#include <libxml/xmlwriter.h>
+#include "sbi_config.h"
+#include "sbi_types.h"
+#include "sbi_util.h"
+#include "target_mgt.h"
+#include "rootstrap_mgt.h"
+#include "toolchain_mgt.h"
+#include "plugin_mgt.h"
+
+#define BUILDDATA_FILE "build_data"
+#define USAGE "\tsbi_make [-t|-target <emulator|device>]\n\tsbi_make clean"
+
+char* get_default_target_from_builddata(FILE *fin);
+void print_sbimake_usage( void );
+void print_sbimake_error(char* msg);
+char* get_target_id(FILE *fin, char* ptarget);
+char* get_target(char* target);
+
+int main(int argc, char* argv[])
+{
+       FILE *fin;
+
+       char target[MAX_NAME] = {0,};
+       char cmd[MAX_CMD_LENGTH] = {0,};
+       char msg[MAX_LINE_LENGTH] = {0,};
+       char build_data_file_path[MAX_FILE_PATH] = {0,};
+       char build_config_path[MAX_FILE_PATH] = {0,};
+       char target_file_path[MAX_FILE_PATH] = {0,};
+       char *ptarget;
+       char *ptarget_id;
+       char *prootstrap_id;
+       char *prootstrap_path;
+       char *makeopt = "all";
+
+       int use_default_target = 0;
+       int arg_count = 1;
+
+       /* check arguments */
+    // sbi-make
+    if (argc == 1) {
+    // sbi-make [-t|--target <target>]        
+    } else if ((strncmp(argv[arg_count], "--target", 8) == 0 && strlen(argv[arg_count]) == 8) || 
+                (strncmp(argv[arg_count], "-t", 2) == 0 && strlen(argv[arg_count]) == 2)) {
+        if (arg_count + 1 < argc) {
+            strcat(target, argv[arg_count + 1]);
+        } else {
+            print_sbimake_usage();
+            return -1;
+        }
+    // sbi-make [clean]        
+    } else if (strncmp(argv[arg_count], "clean", 5) == 0 && strlen(argv[arg_count]) == 5) {
+        makeopt = "clean";            
+    // sbi-make [-h|--help]        
+    } else if ((strncmp(argv[arg_count], "--help", 6) == 0 && strlen(argv[arg_count]) == 6) ||
+                (strncmp(argv[arg_count], "-h", 2) == 0 && strlen(argv[arg_count]) == 2)) {
+        print_sbimake_usage();
+        return 0;
+    } else {
+        print_sbimake_usage();
+        return -1;            
+    }
+
+    /* check target */
+       if (!strcmp(target, "")) {
+               use_default_target = 1;
+       } else if (strcmp(target, "emulator") && strcmp(target, "device")) {
+               print_sbimake_error("Target should be \"emulator\" or \"device.\"");
+               print_sbimake_usage();
+               return -1;
+       }
+
+       /* initialize configuration */
+       initialize_sbi_configuration(argv[0]);
+       initialize_plugins(get_plugin_base_dir());
+       initialize_rootstrap_mgt();
+       initialize_toolchain_mgt();
+       initialize_target_mgt();
+
+       /* set build config path */
+       sprintf(build_config_path, "%s", get_current_path());
+       /* set .builddata file path */
+       sprintf(build_data_file_path, "%s/%s", build_config_path, BUILDDATA_FILE);
+
+       /* open and read "build_data" file */
+       fin = fopen(build_data_file_path, "r");
+       if (fin == NULL) {
+               print_sbimake_error("Cannot find \"build_data\" file.");
+               return -1;
+       }
+
+       /* if useDefault is set, the first target is default */
+       if (use_default_target) {
+               ptarget = get_default_target_from_builddata(fin);
+               fclose(fin);
+               fin = fopen(build_data_file_path, "r");
+       } else {
+               ptarget = get_target(target);
+       }
+
+       if (ptarget == NULL) {
+               print_sbimake_error("Failed to get target from build_data file.");
+               return -1;
+       }
+
+       /* get target id */
+       ptarget_id = get_target_id(fin, ptarget);
+       fclose(fin);
+
+       /* check target xml */
+       prootstrap_id = get_rootstrap_id(ptarget_id);
+       prootstrap_path = tag_checker(get_rootstrap_path(prootstrap_id));
+       sprintf(target_file_path, "%s/%s.xml", get_plugin_base_dir(), ptarget_id);
+       if (!does_file_exist(target_file_path)) {
+               sprintf(msg, "%s target does not exist. You should create target first", ptarget_id);
+               print_sbimake_error(msg);
+               print_sbimake_error("Use \"sbi create\" command to create target");
+       }
+
+       /* make build command */
+       sprintf(cmd, "%s/bin/sbi action %s -- make -options=\"%s\"", get_install_dir(), ptarget_id, makeopt);
+
+       /* execute command */
+       system(cmd);
+
+       /* clean up */
+       free(ptarget);
+       free(ptarget_id);
+       free(prootstrap_id);
+       free(prootstrap_path);
+
+       return 0;
+}
+
+char* get_target_id(FILE *fin, char* targetmode)
+{
+       char cmd[MAX_NAME] = {0,};
+       char buf[MAX_LINE_LENGTH] = {0,};
+       char *pStr;
+       int len = 0;
+
+       while (fgets(buf, sizeof(buf), fin) != NULL) {
+               pStr = strstr(buf, targetmode);
+               if (pStr == NULL) {
+                       continue;
+               }
+               len = strlen(targetmode);
+               pStr = buf + len + 1;
+               len = strlen(pStr);
+               strncat(cmd, pStr, len-1);
+               break;
+       }
+       return strdup(cmd);
+}
+
+/* get default targete name from "build_data" file */
+char* get_default_target_from_builddata(FILE *fin)
+{
+       char mode[MAX_NAME] = {0,};
+       char target[MAX_NAME] = {0,};
+       char buf[MAX_LINE_LENGTH] = {0,};
+       char *pStr;
+       char *pStr_;
+       int len = 0;
+
+       while (fgets(buf, sizeof(buf), fin) != NULL) {
+               pStr = strstr(buf, ":");
+               if (pStr == NULL) {
+                       return NULL;
+               }
+               len = pStr - buf;
+               strncat(mode, buf, len);
+
+               if (strcmp(mode, "target") == 0) {
+                       pStr_ = strstr(pStr+1, ":");
+                       len = pStr_ - buf;
+                       strncat(target, buf, len);
+                       break;
+               } else {
+                       return NULL;
+               }
+       }
+       return strdup(target);
+}
+
+/*  get target mode */
+char* get_target(char* ptarget) {
+       char target[MAX_NAME] = {0,};
+       sprintf(target, "target:%s", ptarget);
+       return strdup(target);
+}
+
+
+/* print usage of sbi_make command */
+void print_sbimake_usage( void )
+{
+       printf("Usage: %s\n", USAGE);
+}
+
+/* print error message of sbi_make command */
+void print_sbimake_error(char* msg)
+{
+       printf("Error: %s\n", msg);
+}
diff --git a/src/sbi_pack.c b/src/sbi_pack.c
new file mode 100644 (file)
index 0000000..f6522d8
--- /dev/null
@@ -0,0 +1,388 @@
+/*
+ *  sbi_pack.c
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Taejun Ha <taejun.ha@samsung.com>
+ * Jiil Hyoun <jiil.hyoun@samsung.com>
+ * Donghyuk Yang <donghyuk.yang@samsung.com>
+ * DongHee Yang <donghee.yang@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <libxml/xmlreader.h>
+#include <libxml/encoding.h>
+#include <libxml/tree.h>
+#include <libxml/xmlwriter.h>
+#include "sbi_config.h"
+#include "sbi_types.h"
+#include "sbi_util.h"
+#include "target_mgt.h"
+#include "rootstrap_mgt.h"
+#include "toolchain_mgt.h"
+#include "plugin_mgt.h"
+
+#define BUILDDATA_FILE "build_data"
+#define USAGE "\tsbi_pack [-t|--target <emulator|device>] [--sign_cert_dir <path>] [--sign_author-key <path>] [--sign_author_pwd <passwd>] [--sign_dist_key <path>] [--sign_dist_pwd <passwd>]"
+
+char* get_default_target_from_builddata(FILE* fin);
+void print_sbipack_usage( void );
+void print_sbipack_error(char* msg);
+char* get_target_id(FILE* fin, char* ptarget);
+char* get_target(char* target);
+int get_attr_from_xml(char* xmlfile_path, char* attr, char* name);
+void _get_attr_from_xml(xmlNode* a_node, char* attr, char* name);
+
+int main(int argc, char* argv[])
+{
+       FILE *fin;
+
+       char target[MAX_NAME] = {0,};
+       char cmd[MAX_CMD_LENGTH] = {0,};
+       char msg[MAX_LINE_LENGTH] = {0,};
+       char build_data_file_path[MAX_FILE_PATH] = {0,};
+       char build_config_path[MAX_FILE_PATH] = {0,};
+       char manifest_file_path[MAX_FILE_PATH] = {0,};
+       char target_file_path[MAX_FILE_PATH] = {0,};
+       char pkg_name[MAX_NAME] = {0,};
+       char pkg_id[MAX_NAME] = {0,};
+       char prj_name[MAX_NAME] = {0,};
+       char pkg_ver[] = "1.0.0";
+       char pkg_type[] = "TPK";
+       char sign_cert_dir[MAX_FILE_PATH] = {0,};
+       char *psign_cert_dir;
+       char sign_author_key[MAX_FILE_PATH] = {0,};
+       char *psign_author_key;
+       char sign_author_pwd[MAX_NAME] = {0,};
+       char sign_dist_key[MAX_FILE_PATH] = {0,};
+       char *psign_dist_key;
+       char sign_dist_pwd[MAX_NAME] = {0,};
+
+       char *pbuild_config_path;
+       char *ptarget;
+       char *ptarget_id;
+       char *pkg_arch;
+       char *pStr;
+
+       int use_default_target = 0;
+       int arg_idx = 1;
+
+       memset(prj_name, 0, MAX_NAME);
+
+       /* check arguments */
+    // sbi-pack
+       while( arg_idx < argc )
+       {
+       // sbi-pack [-t|--target <target>]        
+       if ((strncmp(argv[arg_idx], "--target", 8) == 0 && strlen(argv[arg_idx]) == 8) || 
+                (strncmp(argv[arg_idx], "-t", 2) == 0 && strlen(argv[arg_idx]) == 2)) {
+               if (arg_idx + 1 < argc) {
+                               arg_idx += 1;
+               strcat(target, argv[arg_idx]);
+               } else {
+               print_sbipack_usage();
+               return -1;
+               }
+       // [--sign_cert_dir <dir>]        
+       } else if (strncmp(argv[arg_idx], "--sign_cert_dir", 15) == 0 && strlen(argv[arg_idx]) == 15) {
+               if (arg_idx + 1 < argc) {
+                               arg_idx += 1;
+               strcat(sign_cert_dir, argv[arg_idx]);
+               } else {
+               print_sbipack_usage();
+               return -1;
+               }
+       // [--sign_author_key <file_path>]        
+       } else if (strncmp(argv[arg_idx], "--sign_author_key", 17) == 0 && strlen(argv[arg_idx]) == 17) {
+               if (arg_idx + 1 < argc) {
+                               arg_idx += 1;
+               strcat(sign_author_key, argv[arg_idx]);
+               } else {
+               print_sbipack_usage();
+               return -1;
+               }
+       // [--sign_author_pwd <password>]        
+       } else if (strncmp(argv[arg_idx], "--sign_author_pwd", 17) == 0 && strlen(argv[arg_idx]) == 17) {
+               if (arg_idx + 1 < argc) {
+                               arg_idx += 1;
+               strcat(sign_author_pwd, argv[arg_idx]);
+               } else {
+               print_sbipack_usage();
+               return -1;
+               }
+       // [--sign_dist_key <file_path>]        
+       } else if (strncmp(argv[arg_idx], "--sign_dist_key", 15) == 0 && strlen(argv[arg_idx]) == 15) {
+               if (arg_idx + 1 < argc) {
+                               arg_idx += 1;
+               strcat(sign_dist_key, argv[arg_idx]);
+               } else {
+               print_sbipack_usage();
+               return -1;
+               }
+       // [--sign_dist_pwd <passwd>]        
+       } else if (strncmp(argv[arg_idx], "--sign_dist_pwd", 15) == 0 && strlen(argv[arg_idx]) == 15) {
+               if (arg_idx + 1 < argc) {
+                               arg_idx += 1;
+               strcat(sign_dist_pwd, argv[arg_idx]);
+               } else {
+               print_sbipack_usage();
+               return -1;
+               }
+       // sbi-pack [-h|--help]        
+       } else if ((strncmp(argv[arg_idx], "--help", 6) == 0 && strlen(argv[arg_idx]) == 6) ||
+                (strncmp(argv[arg_idx], "-h", 2) == 0 && strlen(argv[arg_idx]) == 2)) {
+               print_sbipack_usage();
+               return 0;
+       } else {
+               printf("Wrong option is used!: %s\n", argv[arg_idx]);
+               print_sbipack_usage();
+               return -1;
+       }
+
+               arg_idx += 1;
+       }
+
+    /* check target */
+       if (!strcmp(target, "")) {
+               use_default_target = 1;
+       } else if (strcmp(target, "emulator") && strcmp(target, "device")) {
+               print_sbipack_error("Target should be \"emulator\" or \"device.\"");
+               print_sbipack_usage();
+               return -1;
+       }
+
+       /* initialize configuration */
+       initialize_sbi_configuration(argv[0]);
+       initialize_plugins(get_plugin_base_dir());
+       initialize_rootstrap_mgt();
+       initialize_toolchain_mgt();
+       initialize_target_mgt();
+
+       /* set build config path */
+       sprintf(build_config_path, "%s", get_current_path());
+       /* set .builddata file path */
+       sprintf(build_data_file_path, "%s/%s", build_config_path, BUILDDATA_FILE);
+       /* set application.xml file path */
+       sprintf(manifest_file_path, "%s/../manifest.xml", build_config_path);
+       /* get package id from manifest.xml */
+       if (!get_attr_from_xml(manifest_file_path, "Id", pkg_id)) {
+               print_sbipack_error("Cannot find manifest.xml. You should execute this command in \"CommandLineBuild\" directory.");
+               return -1;
+       }
+
+       if (!strcmp(pkg_id, "")) {
+               print_sbipack_error("Package ID is null. Pleases check manifest.xml file");
+               return -1;
+       }
+
+       /* get project name from manifest.xml */
+       if (!get_attr_from_xml(manifest_file_path, "Name", prj_name)) {
+               print_sbipack_error("Cannot find manifest.xml. You should execute this command in \"CommandLineBuild\" directory.");
+               return -1;
+       }
+
+       if (!strcmp(prj_name, "")) {
+               print_sbipack_error("Package name is null. Pleases check manifest.xml file");
+               return -1;
+       }
+
+       /* Cleans up memory allocated by the library itself. */
+       xmlCleanupParser();
+
+       /* make package name */
+       sprintf(pkg_name, "org.tizen.%s", pkg_id);
+       
+       /* open and read "build_data" file */
+       fin = fopen(build_data_file_path, "r");
+       if (fin == NULL) {
+               print_sbipack_error("There is no \"build_data\" file");
+               return -1;
+       }
+
+       /* if useDefault is set, the first target is default */
+       if (use_default_target) {
+               ptarget = get_default_target_from_builddata(fin);
+               fclose(fin);
+               // get target
+               pStr = strstr(ptarget, ":") + 1;
+               strncat(target, pStr, strlen(pStr));
+               fin = fopen(build_data_file_path, "r");
+       } else {
+               ptarget = get_target(target);
+       }
+
+       if (ptarget == NULL) {
+               print_sbipack_error("Failed to get target from build_data file.");
+               return -1;
+       }
+
+       /* set architecture */
+       if (!strcmp(target, "emulator")) {
+               pkg_arch = "i386";
+       } else if (!strcmp(target, "device")) {
+               pkg_arch = "armel";
+       }
+
+       /* get packaging info */
+       ptarget_id = get_target_id(fin, ptarget);
+       fclose(fin);
+
+       /* check target */
+       printf("%s\n", ptarget_id);                     
+       sprintf(target_file_path, "%s/%s.xml", get_plugin_base_dir(), ptarget_id);
+       printf("target path : %s\n", target_file_path);
+       if (!does_file_exist(target_file_path)) {
+               sprintf(msg, "%s target does not exist. You should create target first", ptarget_id);
+               print_sbipack_error(msg);
+               print_sbipack_error("Use \"sbi create\" command to create target");
+       }
+       /* make build command */
+#ifdef WIN32
+       pbuild_config_path = get_unix_path(build_config_path);
+       psign_cert_dir = get_unix_path(sign_cert_dir);
+       psign_author_key = get_unix_path(sign_author_key);
+       psign_dist_key = get_unix_path(sign_dist_key);
+#else
+       pbuild_config_path = build_config_path;
+       psign_cert_dir = sign_cert_dir;
+       psign_author_key = sign_author_key;
+       psign_dist_key = sign_dist_key;
+#endif
+       sprintf(cmd, "%s/bin/sbi action %s -- buildpackage -BUILD_DIR=\"\\\"%s\\\"\" -ARCH=%s -PKG_TYPE=%s -PKG_NAME=%s -PRJ_NAME=%s -PKG_VER=%s -SIGN_CERT_DIR=\"\\\"%s\\\"\" -SIGN_AUTHOR_KEY=\"\\\"%s\\\"\" -SIGN_AUTHOR_PWD=%s -SIGN_DIST_KEY=\"\\\"%s\\\"\" -SIGN_DIST_PWD=%s",
+               get_install_dir(), ptarget_id, pbuild_config_path, pkg_arch, pkg_type, pkg_name, prj_name, pkg_ver, psign_cert_dir, psign_author_key, sign_author_pwd, psign_dist_key, sign_dist_pwd);
+
+       /* execute command */
+       system(cmd);
+       free(ptarget);
+       free(ptarget_id);
+#ifdef WIN32
+       free(pbuild_config_path);
+       free(psign_cert_dir);
+       free(psign_author_key);
+       free(psign_dist_key);
+#endif 
+
+       return 0;
+}
+
+/* get value of specified attribute from xml file */
+int get_attr_from_xml(char* xmlfile_path, char* attr, char* name)
+{
+       xmlDoc *doc = NULL;
+       doc = xmlReadFile(xmlfile_path, NULL, 0);
+       if (doc == NULL) {
+               return 0;
+       } else {
+               xmlNode *root_element = xmlDocGetRootElement(doc);
+               _get_attr_from_xml(root_element, attr, name);
+               xmlFreeDoc(doc);
+       }
+
+       return 1;
+}
+
+void _get_attr_from_xml(xmlNode* a_node, char* attr, char* name)
+{
+       xmlNode *cur_node = NULL;
+       for (cur_node = a_node; cur_node; cur_node = cur_node->next) {
+               if (cur_node->type == XML_ELEMENT_NODE && !strcmp((char*)cur_node->name, attr)) {
+                       if (cur_node->children != NULL) {
+                               strncat(name, (char*)cur_node->children->content, strlen((char*)cur_node->children->content));
+                               break;
+                       }
+               }
+               _get_attr_from_xml(cur_node->children, attr, name);
+       }
+}
+
+
+/* get default target name from "build_data" file */
+char* get_default_target_from_builddata(FILE *fin)
+{
+       char mode[MAX_NAME] = {0,};
+       char target[MAX_NAME] = {0,};
+       char buf[MAX_LINE_LENGTH] = {0,};
+       char *pStr;
+       char *pStr_;
+       int len = 0;
+
+       while (fgets(buf, sizeof(buf), fin) != NULL) {
+               memset(mode, 0, MAX_NAME);
+               pStr = strstr(buf, ":");
+               if (pStr == NULL) {
+                       return NULL;
+               }
+               len = pStr - buf;
+               strncat(mode, buf, len);
+               if (strcmp(mode, "target") == 0) {
+                       pStr_ = strstr(pStr+1, ":");
+                       len = pStr_ - buf;
+                       strncat(target, buf, len);
+                       break;
+               } else {
+                       continue;
+               }
+       }
+       return strdup(target);
+}
+
+/*  get target mode */
+char* get_target(char* ptarget) {
+       char target[MAX_NAME] = {0,};
+       sprintf(target, "target:%s", ptarget);
+       return strdup(target);
+}
+
+/* get build command */
+char* get_target_id(FILE *fin, char* ptarget)
+{
+       char cmd[MAX_NAME] = {0,};
+       char buf[MAX_LINE_LENGTH] = {0,};
+       char *pStr;
+       int len = 0;
+
+       while (fgets(buf, sizeof(buf), fin) != NULL) {
+               pStr = strstr(buf, ptarget);
+               if (pStr == NULL) {
+                       continue;
+               }
+               len = strlen(ptarget);
+               pStr = buf + len + 1;
+               len = strlen(pStr);
+               strncat(cmd, pStr, len-1);
+               break;
+       }
+       return strdup(cmd);
+}
+
+/* print usage of sbi_make command */
+void print_sbipack_usage( void )
+{
+       printf("Usage: %s\n", USAGE);
+}
+
+/* print error message of sbi_make command */
+void print_sbipack_error(char* msg)
+{
+       printf("Error: %s\n", msg);
+}
index 7ab66c6..91ffc38 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -52,7 +52,9 @@ string_list* append_string_to_list( string_list* old_list, const char* str )
 
        list = old_list;
        while( list->next != NULL )
+       {
                list = list->next;
+       }
 
        list->next = create_string_list( str );
 
@@ -89,7 +91,7 @@ string_list* append_string_list_to_list(string_list* old_list, string_list* new_
        assert ( old_list != NULL );
 
        if ( new_list == NULL )
-               return old_list;
+       { return old_list; }
 
        for( new_entry = new_list; new_entry; new_entry = new_entry->next )
        {
@@ -97,14 +99,14 @@ string_list* append_string_list_to_list(string_list* old_list, string_list* new_
                while( old_entry->next != NULL )
                {
                        if ( strcmp( old_entry->str, new_entry->str ) == 0 )
-                               break;
+                       { break; }
 
                        old_entry = old_entry->next;
                }
 
                /* already exist, skip */
                if ( old_entry->next != NULL)
-                       continue;
+               { continue; }
 
                old_entry->next = create_string_list( new_entry->str );
        }
@@ -121,9 +123,9 @@ string_list* clone_string_list( string_list* list  )
        for( src = list; src; src = src->next )
        {
                if ( new_list != NULL )
-                       append_string_to_list( new_list, src->str );
+               { append_string_to_list( new_list, src->str ); }
                else
-                       new_list = create_string( src->str );
+               { new_list = create_string( src->str ); }
        }
 
        return new_list;
index 0ad5f96..eb9b2cf 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 char current_path[MAX_FILE_PATH];
 char* create_usage =
-                       "sbi create -root <rootstrap-plugin-id> -tool <toolchain-plugin-id> <target-plugin-id>";
+    "sbi create -root <rootstrap-plugin-id> -tool <toolchain-plugin-id> <target-plugin-id>";
 char* remove_usage =
-                       "sbi remove {all|<target-plugin-id>}";
+    "sbi remove {all|<target-plugin-id>}";
 char* select_usage =
-                       "sbi select <target-plugin-id>";
+    "sbi select <target-plugin-id>";
 char* list_usage =
-                       "sbi list [target|tool|root|*all]";
+    "sbi list [target|tool|root|*all]";
 char* show_usage =
-                       "sbi show [<target-plugin-id>|target <target-plugin-id>|tool <toolchain-plugin-id>|root <rootstrap-plugin-id>]";
+    "sbi show [<target-plugin-id>|target <target-plugin-id>|tool <toolchain-plugin-id>|root <rootstrap-plugin-id>]";
 char* action_usage =
-                       "sbi action <target-plugin-id> -- <action-name> <arguments>";
+    "sbi action <target-plugin-id> -- <action-name> <arguments>";
 char* query_usage =
-                       "sbi query <target-plugin-id> <action-name>";
+    "sbi query <target-plugin-id> <action-name>";
 
 void print_usage(USAGE_TYPE usage_type)
 {
@@ -98,7 +98,7 @@ void print_usage(USAGE_TYPE usage_type)
        exit(1);
 }
 
-char* get_current_path()
+char* get_current_path( void )
 {
        return getcwd(current_path, MAX_FILE_PATH);
 }
@@ -189,6 +189,31 @@ void make_directory(char* path)
 
        strcpy(copy_path, path);
        strcpy(new_path, "");
+#ifdef WIN32
+       dir = strtok(copy_path, "\\");
+       while (dir)
+       {
+               if (strcmp(new_path, ""))
+               {
+                       sprintf(new_path, "%s\\%s", new_path, dir);
+               }
+               else
+               {
+                       strcpy(new_path, dir);
+               }
+
+               if (!does_file_exist(new_path))
+               {
+                       mkdir( new_path );
+               }
+
+               dir = strtok(NULL, "\\");
+               if (dir == NULL)
+               {
+                       break;
+               }
+       }
+#else
        dir = strtok(copy_path, "/");
 
        while (dir)
@@ -197,23 +222,18 @@ void make_directory(char* path)
 
                if (!does_file_exist(new_path))
                {
-#ifdef WIN32
-                       mkdir( new_path );
-#else
                        mkdir(new_path, S_IRWXU);
-#endif
                }
 
                dir = strtok(NULL, "/");
                if (dir == NULL)
+               {
                        break;
+               }
        }
+#endif
 }
 
-/*
- static int remove_path( char* path );
- */
-
 int remove_directory(char* path)
 {
        char cmd[255];
@@ -268,7 +288,7 @@ static int remove_path( char* path )
                        char new_path[MAX_FILE_PATH];
 
                        if( strcmp( entry->d_name, "." ) == 0 ||
-                                       strcmp( entry->d_name, ".." ) == 0 )
+                               strcmp( entry->d_name, ".." ) == 0 )
                        {
                                continue;
                        }
@@ -349,7 +369,7 @@ int get_base_dir(char* path, char* base_dir)
        return 0;
 }
 
-
+// Return value should be free on caller side
 char* get_unix_path( char* absolue_path )
 {
        static char buf[ 1024 ];
@@ -368,43 +388,57 @@ char* get_unix_path( char* absolue_path )
        for( i=0; i < strlen( buf ); i++ )
        {
                if ( buf[i] == '\\' )
-                       buf[i] = '/';
+               { buf[i] = '/'; }
        }
 
-       return buf;
+       return strdup(buf);
 }
 
-char* replaceStr(char* org, char* src, char* dst)
-{
-       char* pSearch = NULL;
-       char *pStartStr = org;
-       char *pEndStr = NULL;
-       char buf[1024] = {0,};
-       char buf2[1024] = {0,};
-       int dstlen = strlen(dst);
-       int srclen = strlen(src);
 
-       strncpy(buf, pStartStr, sizeof(pStartStr));
 
-       pSearch = strstr(pStartStr, src);
+/* get msys path which is compatible with windows */
+char* get_msys_compat_path( char* absolue_path )
+{
+       static char buf[ 1024 ];
+       int i;
 
-       while (pSearch != NULL) {
+       strcpy( buf, absolue_path );
 
-               memset(buf, 0, sizeof(buf));
+       /* change "\" -> "/" for windows support*/
+       for( i=0; i < strlen( buf ); i++ )
+       {
+               if ( buf[i] == '\\' )
+               { buf[i] = '/'; }
+       }
 
-               pEndStr = pSearch+srclen;
-               strncpy(buf, pStartStr, pSearch-pStartStr);
-               strncat(buf, dst, dstlen);
-               strncat(buf, pEndStr, strlen(pEndStr));
+       return buf;
+}
 
-               memset(buf2, 0, sizeof(buf2));
-               strcpy(buf2, buf);
 
-               pStartStr = buf2;
-               pSearch = strstr(pStartStr, src);
+char *replaceAll(char *s, const char *olds, const char *news) {
+       char *result, *sr;
+       size_t i, count = 0;
+       size_t oldlen = strlen(olds);
+       if (oldlen < 1) { return s; }
+       size_t newlen = strlen(news);
+       if (newlen != oldlen) {
+               for (i = 0; s[i] != '\0';) {
+                       if (memcmp(&s[i], olds, oldlen) == 0) { count++, i += oldlen; }
+                       else { i++; }
+               }
+       } else { i = strlen(s); }
+       result = (char *) malloc(i + 1 + count * (newlen - oldlen));
+       if (result == NULL) { return NULL; }
+       sr = result;
+       while (*s) {
+               if (memcmp(s, olds, oldlen) == 0) {
+                       memcpy(sr, news, newlen);
+                       sr += newlen;
+                       s  += oldlen;
+               } else { *sr++ = *s++; }
        }
-
-       return strdup(pStartStr);
+       *sr = '\0';
+       return result;
 }
 
 void SBI_PRINTF(int level, const char *fmt, ...)
index a47812b..8286156 100644 (file)
@@ -42,7 +42,7 @@ typedef enum _USAGE_TYPE
 
 void print_usage(USAGE_TYPE usage_type);
 
-char* get_current_path();
+char* get_current_path( void );
 char* trim(char* str);
 void remove_extension(char* file_name, char* file_name2);
 
@@ -56,7 +56,8 @@ int remove_file(char* path);
 int is_full_path(char* path);
 int get_base_dir(char* path, char* base_dir);
 char* get_unix_path( char* absolue_path );
-char* replaceStr(char* org, char* src, char* dst);
+char* get_msys_compat_path( char* absolue_path );
+char *replaceAll(char *s, const char *olds, const char *news);
 void SBI_PRINTF(int level, const char *fmt, ...);
 
 #endif
index 6026d34..75318b5 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 
 // internal function
 static char* query_tag_loop(xmlNode* node, char* name, xmlChar * attr,
-        char* attr_value, xmlChar * find_attr);
+                            char* attr_value, xmlChar * find_attr);
 static char* query_tag(xmlDoc* doc, char* name, char* attr,
-        char* attr_value, xmlChar * find_attr);
+                       char* attr_value, xmlChar * find_attr);
 
 int sbi_list_using_xml(int list_type)
 {
-    char plugin_base_dir[MAX_FILE_PATH + 1];
-    char target_base_dir[MAX_FILE_PATH + 1];
-    char xml_path[MAX_FILE_PATH + 1];
+       char plugin_base_dir[MAX_FILE_PATH + 1];
+       char target_base_dir[MAX_FILE_PATH + 1];
+       char xml_path[MAX_FILE_PATH + 1];
        struct dirent *entry;
-       DIR* dir; 
-    int i;
-    int target_cnt = 0;
-    int toolchain_cnt = 0;
-    int rootstrap_cnt = 0;
-    int buildsystem_cnt = 0;
-    char* target_list[100];
-    char* toolchain_list[100];
-    char* rootstrap_list[100];
-    char* buildsystem_list[100];
-
-    if (list_type == LIST_ALL || list_type == LIST_TARGET)
-    {
-        char*  target_name;
-        sprintf( target_base_dir, "%s", get_target_base_dir());
-
-       if (!is_directory(target_base_dir))
-       {
-            /* target base dir is not directory */
-            return -1;
-        }
-
-        dir = opendir(target_base_dir);
-        while ( (entry = readdir(dir)) != NULL )
-        {
-            int d_name_size;
-            char* ext;
-    
-            d_name_size = strlen( entry->d_name );
-            if ( strcmp( entry->d_name + ( d_name_size - 4 ), ".xml" ) != 0 )
-                continue;
-               
-            target_name = malloc( 100 );
-            strcpy(target_name, entry->d_name);
-            target_name[strlen(target_name) -4] = '\0';
-            target_list[target_cnt++] = target_name;
-        }
-    }
-
-    if (list_type != LIST_TARGET)
-    {
-        sprintf( plugin_base_dir, "%s", get_plugin_base_dir());
-
-       if (!is_directory(plugin_base_dir))
-       {
-            /* plugin base dir is not directory */
-            return -1;
-        }
-    
-        dir = opendir(plugin_base_dir);
-       while ( (entry = readdir(dir)) != NULL )
-       {
-            int d_name_size;
-            char* ext;
-    
-            d_name_size = strlen( entry->d_name );
-            if ( strcmp( entry->d_name + ( d_name_size - 4 ), ".xml" ) != 0 )
-                continue;
-               
-            sprintf( xml_path, "%s/%s", plugin_base_dir, entry->d_name);
-            if (!is_directory(xml_path))
-            {
-                char* extension_id = NULL;
-                char* list_id = NULL;
-    
-                xmlDoc *doc = NULL;
-                doc = xmlReadFile(xml_path, NULL, 0);
-        
-                extension_id = query_tag( doc, "extension" , NULL, NULL, "point" );
-    
-                if( extension_id == NULL )
-                {
-                    continue;
-                }
-    
-                if( (list_type == LIST_ALL || list_type == LIST_ROOT ) && 
-                        strcmp( extension_id, "rootstrapDefinition" ) == 0)
-                {
-                    list_id = query_tag( doc, "rootstrap", NULL, NULL, "id" );
-    
-                    rootstrap_list[rootstrap_cnt] = list_id;
-                    rootstrap_cnt++;
-                }
-                else if ( (list_type == LIST_ALL || list_type == LIST_TOOL ) &&
-                        strcmp( extension_id, "toolchainDefinition" ) == 0) 
-                {
-                    list_id = query_tag( doc, "toolchain", NULL, NULL, "id" );
-    
-                    toolchain_list[toolchain_cnt] = list_id;
-                    toolchain_cnt++;
-                }
-                else if ( (list_type == LIST_ALL || list_type == LIST_BUILD_SYSTEM ) &&
-                        strcmp( extension_id, "buildSystemDefinition" ) == 0) 
-                {
-                    list_id = query_tag( doc, "buildSystem", NULL, NULL, "id" );
-    
-                    toolchain_list[toolchain_cnt] = list_id;
-                    toolchain_cnt++;
-                }
-            }
-        }
-    }
-
-    if( (list_type == LIST_ALL || list_type == LIST_TARGET ) )
-    {
-        SBI_PRINTF(1, "\nAvailable Target List\n");
-        SBI_PRINTF(1, "------------------------\n");
-        for ( i = 0 ; i < target_cnt ; i++ )
-        {
-            SBI_PRINTF(1,  "%s\n", target_list[i] );
-            free(target_list[i]);
-        }
-    }
-
-    if( (list_type == LIST_ALL || list_type == LIST_ROOT ) )
-    {
-        SBI_PRINTF(1, "\nAvailable Rootstrap List\n");
-        SBI_PRINTF(1, "------------------------\n");
-        for ( i = 0 ; i < rootstrap_cnt ; i++ )
-        {
-            SBI_PRINTF(1,  "%s\n", rootstrap_list[i] );
-        }
-    }
-
-    
-    if( (list_type == LIST_ALL || list_type == LIST_TOOL ) )
-    {
-        SBI_PRINTF(1, "\nAvailable Tool List\n");
-        SBI_PRINTF(1, "------------------------\n");
-        for ( i = 0 ; i < toolchain_cnt ; i++ )
-        {
-            SBI_PRINTF(1,  "%s\n", toolchain_list[i] );
-        }
-    }
-    
-    if( (list_type == LIST_ALL || list_type == LIST_BUILD_SYSTEM ) )
-    {
-        SBI_PRINTF(1, "\nAvailable Build System List\n");
-        SBI_PRINTF(1, "------------------------\n");
-        for ( i = 0 ; i < buildsystem_cnt ; i++ )
-        {
-            SBI_PRINTF(1,  "%s\n", buildsystem_list[i] );
-        }
-    }
-
-    return 1;
+       DIR* dir;
+       int i;
+       int target_cnt = 0;
+       int toolchain_cnt = 0;
+       int rootstrap_cnt = 0;
+       int buildsystem_cnt = 0;
+       char* target_list[100];
+       char* toolchain_list[100];
+       char* rootstrap_list[100];
+       char* buildsystem_list[100];
+
+       if (list_type == LIST_ALL || list_type == LIST_TARGET)
+       {
+               char*  target_name;
+               sprintf( target_base_dir, "%s", get_target_base_dir());
+
+               if (!is_directory(target_base_dir))
+               {
+                       /* target base dir is not directory */
+                       return -1;
+               }
+
+               dir = opendir(target_base_dir);
+               while ( (entry = readdir(dir)) != NULL )
+               {
+                       int d_name_size;
+                       char* ext;
+
+                       d_name_size = strlen( entry->d_name );
+                       if ( strcmp( entry->d_name + ( d_name_size - 4 ), ".xml" ) != 0 )
+                       { continue; }
+
+                       target_name = malloc( 100 );
+                       strcpy(target_name, entry->d_name);
+                       target_name[strlen(target_name) -4] = '\0';
+                       target_list[target_cnt++] = target_name;
+               }
+       }
+
+       if (list_type != LIST_TARGET)
+       {
+               sprintf( plugin_base_dir, "%s", get_plugin_base_dir());
+
+               if (!is_directory(plugin_base_dir))
+               {
+                       /* plugin base dir is not directory */
+                       return -1;
+               }
+
+               dir = opendir(plugin_base_dir);
+               while ( (entry = readdir(dir)) != NULL )
+               {
+                       int d_name_size;
+                       char* ext;
+
+                       d_name_size = strlen( entry->d_name );
+                       if ( strcmp( entry->d_name + ( d_name_size - 4 ), ".xml" ) != 0 )
+                       { continue; }
+
+                       sprintf( xml_path, "%s/%s", plugin_base_dir, entry->d_name);
+                       if (!is_directory(xml_path))
+                       {
+                               char* extension_id = NULL;
+                               char* list_id = NULL;
+
+                               xmlDoc *doc = NULL;
+                               doc = xmlReadFile(xml_path, NULL, 0);
+
+                               extension_id = query_tag( doc, "extension" , NULL, NULL, "point" );
+
+                               if( extension_id == NULL )
+                               {
+                                       continue;
+                               }
+
+                               if( (list_type == LIST_ALL || list_type == LIST_ROOT ) &&
+                                       strcmp( extension_id, "rootstrapDefinition" ) == 0)
+                               {
+                                       list_id = query_tag( doc, "rootstrap", NULL, NULL, "id" );
+
+                                       rootstrap_list[rootstrap_cnt] = list_id;
+                                       rootstrap_cnt++;
+                               }
+                               else if ( (list_type == LIST_ALL || list_type == LIST_TOOL ) &&
+                                         strcmp( extension_id, "toolchainDefinition" ) == 0)
+                               {
+                                       list_id = query_tag( doc, "toolchain", NULL, NULL, "id" );
+
+                                       toolchain_list[toolchain_cnt] = list_id;
+                                       toolchain_cnt++;
+                               }
+                               else if ( (list_type == LIST_ALL || list_type == LIST_BUILD_SYSTEM ) &&
+                                         strcmp( extension_id, "buildSystemDefinition" ) == 0)
+                               {
+                                       list_id = query_tag( doc, "buildSystem", NULL, NULL, "id" );
+
+                                       toolchain_list[toolchain_cnt] = list_id;
+                                       toolchain_cnt++;
+                               }
+                       }
+               }
+       }
+
+       if( (list_type == LIST_ALL || list_type == LIST_TARGET ) )
+       {
+               SBI_PRINTF(1, "\nAvailable Target List\n");
+               SBI_PRINTF(1, "------------------------\n");
+               for ( i = 0 ; i < target_cnt ; i++ )
+               {
+                       SBI_PRINTF(1,  "%s\n", target_list[i] );
+                       free(target_list[i]);
+               }
+       }
+
+       if( (list_type == LIST_ALL || list_type == LIST_ROOT ) )
+       {
+               SBI_PRINTF(1, "\nAvailable Rootstrap List\n");
+               SBI_PRINTF(1, "------------------------\n");
+               for ( i = 0 ; i < rootstrap_cnt ; i++ )
+               {
+                       SBI_PRINTF(1,  "%s\n", rootstrap_list[i] );
+               }
+       }
+
+
+       if( (list_type == LIST_ALL || list_type == LIST_TOOL ) )
+       {
+               SBI_PRINTF(1, "\nAvailable Tool List\n");
+               SBI_PRINTF(1, "------------------------\n");
+               for ( i = 0 ; i < toolchain_cnt ; i++ )
+               {
+                       SBI_PRINTF(1,  "%s\n", toolchain_list[i] );
+               }
+       }
+
+       if( (list_type == LIST_ALL || list_type == LIST_BUILD_SYSTEM ) )
+       {
+               SBI_PRINTF(1, "\nAvailable Build System List\n");
+               SBI_PRINTF(1, "------------------------\n");
+               for ( i = 0 ; i < buildsystem_cnt ; i++ )
+               {
+                       SBI_PRINTF(1,  "%s\n", buildsystem_list[i] );
+               }
+       }
+
+       return 1;
 }
 
 
 static char* query_tag_loop(xmlNode* node, char* name, char* attr, xmlChar * attr_value, char* find_attr  )
 {
-    xmlNode *cur_node = NULL;
-    xmlChar* result;
-    char* ret;
-    char* tmp; 
-    char temp[MAX_CMD_LENGTH + 1];
-    
-    for (cur_node = node; cur_node; cur_node = xmlNextElementSibling(cur_node))
-    {
-        if(strcmp(cur_node->name, name) == 0)
-        {
-            if( ( attr == NULL && attr_value == NULL ) ||
-                    ( (tmp = xmlGetProp(cur_node,attr)) != NULL && strcmp(attr_value,tmp) == 0))
-            {
-                /* find attr is needed */
-                if( find_attr == NULL )
-                {
-                    return NULL;
-                }
-
-                result = xmlGetProp(cur_node,find_attr);
-                if(result == NULL)
-                {
-                    return NULL;
-                }
-
-                ret = strdup(result);
-                if(strchr(ret,' ') != NULL)
-                {
-                    sprintf(temp,"\"%s\"",ret);
-                    free(ret);
-                    ret=strdup(temp);
-                }
-
-                xmlFree(result);
-                return ret;
-            }
-        }
-        ret = query_tag_loop(cur_node->children, name, attr, attr_value, find_attr); 
-        if(ret != NULL)
-            return ret;
-    }
-    return NULL;
+       xmlNode *cur_node = NULL;
+       xmlChar* result;
+       char* ret;
+       char* tmp;
+       char temp[MAX_CMD_LENGTH + 1];
+
+       for (cur_node = node; cur_node; cur_node = xmlNextElementSibling(cur_node))
+       {
+               if(strcmp(cur_node->name, name) == 0)
+               {
+                       if( ( attr == NULL && attr_value == NULL ) ||
+                               ( (tmp = xmlGetProp(cur_node,attr)) != NULL && strcmp(attr_value,tmp) == 0))
+                       {
+                               /* find attr is needed */
+                               if( find_attr == NULL )
+                               {
+                                       return NULL;
+                               }
+
+                               result = xmlGetProp(cur_node,find_attr);
+                               if(result == NULL)
+                               {
+                                       return NULL;
+                               }
+
+                               ret = strdup(result);
+                               if(strchr(ret,' ') != NULL)
+                               {
+                                       sprintf(temp,"\"%s\"",ret);
+                                       free(ret);
+                                       ret=strdup(temp);
+                               }
+
+                               xmlFree(result);
+                               return ret;
+                       }
+               }
+               ret = query_tag_loop(cur_node->children, name, attr, attr_value, find_attr);
+               if(ret != NULL)
+               { return ret; }
+       }
+       return NULL;
 }
 
 static char* query_tag(xmlDoc* doc, char* name, char* attr, char* attr_value, xmlChar * find_attr  )
 {
-    xmlNode *root = NULL;
+       xmlNode *root = NULL;
 
-    if (doc == NULL) 
-        return NULL;
+       if (doc == NULL)
+       { return NULL; }
 
-    root = xmlDocGetRootElement(doc);
-    return query_tag_loop(root, name, attr, attr_value, find_attr);
+       root = xmlDocGetRootElement(doc);
+       return query_tag_loop(root, name, attr, attr_value, find_attr);
 }
 #endif
index 8a3712f..7c4c886 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -39,9 +39,9 @@ target* create_target( char* id, char* name, char* rootstrap_id, char* toolchain
 
        new_target->id = strdup( id );
        if ( name != NULL )
-               new_target->name = (char*)strdup(name);
+       { new_target->name = (char*)strdup(name); }
        else
-               new_target->name =  (char*)strdup(id);
+       { new_target->name =  (char*)strdup(id); }
 
        new_target->rootstrap_id =  (char*)strdup( rootstrap_id );
        new_target->toolchain_id =  (char*)strdup( toolchain_id );
@@ -55,7 +55,9 @@ target* append_target( target* list, target* src )
 {
        target* t = list;
        while( t->next != NULL )
+       {
                t=t->next;
+       }
 
        t->next = src;
 
@@ -95,25 +97,25 @@ plugin * create_target_plugin( target* t )
        rc = write_attr(writer, "point", "targetDefinition");
        rc = start_write_elm(writer, "target");
        rc = write_attr(writer, "id", t->id);
-    rc = write_attr(writer, "name", t->name);
-    rc = write_attr(writer, "rootstrapId", t->rootstrap_id);
-    rc = write_attr(writer, "toolchainId", t->toolchain_id);
-    rc = end_write_elm(writer);
-    rc = end_write_elm(writer);
-    rc = end_write_doc(writer);
+       rc = write_attr(writer, "name", t->name);
+       rc = write_attr(writer, "rootstrapId", t->rootstrap_id);
+       rc = write_attr(writer, "toolchainId", t->toolchain_id);
+       rc = end_write_elm(writer);
+       rc = end_write_elm(writer);
+       rc = end_write_doc(writer);
 
        /* free writer */
-    free_writer(writer);
+       free_writer(writer);
 
        /* save plugin file */
        sprintf( target_xml_path, "%s/%s.xml", get_plugin_base_dir(), t->id);
-    rc = save_doc_file(doc, target_xml_path);
-    free_doc(doc);
+       rc = save_doc_file(doc, target_xml_path);
+       free_doc(doc);
 
-    /* create */
-    new_plugin = create_plugin(target_xml_path);
+       /* create */
+       new_plugin = create_plugin(target_xml_path);
 
-    return new_plugin;
+       return new_plugin;
 }
 
 
@@ -133,15 +135,15 @@ target* load_target_from_plugin( plugin* p )
 
        /* id name */
        if (id == NULL || name == NULL )
-               return NULL;
+       { return NULL; }
 
        /* check toolchain */
        if (toolchain_id == NULL || !is_toolchain_available(toolchain_id))
-               return NULL;
+       { return NULL; }
 
        /* check rootstrap */
        if (rootstrap_id == NULL || !is_rootstrap_available(rootstrap_id) )
-               return NULL;
+       { return NULL; }
 
        /* create */
        new_target = create_target( id, name, rootstrap_id, toolchain_id );
index a593f91..dc6dc34 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -42,7 +42,7 @@ static target* target_list = NULL;
 
 static target* search_target_id( char* target_id );
 
-void initialize_target_mgt( )
+void initialize_target_mgt( void )
 {
        plugin* list = get_plugin_list("targetDefinition");
        plugin* p = list;
@@ -54,16 +54,16 @@ void initialize_target_mgt( )
                if ( t != NULL )
                {
                        if ( target_list != NULL )
-                               append_target( target_list, t );
+                       { append_target( target_list, t ); }
                        else
-                               target_list = t;
+                       { target_list = t; }
                }
        }
        remove_plugin_list(list);
 }
 
 /* list up all target  */
-string_list* get_all_available_target_ids( )
+string_list* get_all_available_target_ids( void )
 {
        string_list *new_list = NULL;
        target * t = target_list;
@@ -71,9 +71,9 @@ string_list* get_all_available_target_ids( )
        for( ; t ; t=t->next )
        {
                if ( new_list != NULL )
-                       append_string_to_list( new_list, t->id );
+               { append_string_to_list( new_list, t->id ); }
                else
-                       new_list = create_string_list( t->id );
+               { new_list = create_string_list( t->id ); }
        }
 
        return new_list;
@@ -81,7 +81,7 @@ string_list* get_all_available_target_ids( )
 
 
 
-string_list* get_all_available_target_names( )
+string_list* get_all_available_target_names( void )
 {
        string_list *new_list = NULL;
        target * t = target_list;
@@ -89,9 +89,9 @@ string_list* get_all_available_target_names( )
        for( ; t ; t=t->next )
        {
                if ( new_list != NULL )
-                       append_string_to_list( new_list, t->name );
+               { append_string_to_list( new_list, t->name ); }
                else
-                       new_list = create_string_list( t->name );
+               { new_list = create_string_list( t->name ); }
        }
 
        return new_list;
@@ -103,7 +103,7 @@ char* get_rootstrap_id( char* target_id )
        target* t = search_target_id(target_id);
 
        if ( t != NULL)
-               rootstrap_id = strdup(t->rootstrap_id);
+       { rootstrap_id = strdup(t->rootstrap_id); }
 
        return rootstrap_id;
 }
@@ -114,7 +114,7 @@ char* get_toolchain_id( char* target_id )
        target* t = search_target_id(target_id);
 
        if ( t != NULL)
-               toolchain_id = strdup(t->toolchain_id);
+       { toolchain_id = strdup(t->toolchain_id); }
 
        return toolchain_id;
 }
@@ -125,7 +125,7 @@ char* get_target_name( char* target_id )
        target* t = search_target_id(target_id);
 
        if ( t != NULL)
-               target_name = strdup(t->name);
+       { target_name = strdup(t->name); }
 
        return target_name;
 }
@@ -146,16 +146,16 @@ int create_new_target(  char* target_id, char* rootstrap_id, char* toolchain_id
        /* create target */
        p = create_target_plugin( new_target );
        if ( p == NULL )
-               return -1;
+       { return -1; }
 
-    add_new_plugin( p );
+       add_new_plugin( p );
        if ( target_list != NULL ) {
                append_target( target_list, new_target);
        } else {
                target_list = new_target;
        }
 
-    return 0;
+       return 0;
 }
 
 
@@ -197,33 +197,29 @@ int is_target_available( char* target_id )
        int result = 0;
 
        if ( t != NULL)
-               result = 1;
+       { result = 1; }
 
        return result;
 }
 
-void finalize_target_mgt( )
+void finalize_target_mgt( void )
 {
        remove_target( target_list );
 }
 
-void display_target_list()
+void display_target_list( void )
 {
        string_list* list = get_all_available_target_ids();
        string_list* id = list;
 
-       /*
-    SBI_PRINTF(1, "\nAvailable Target List\n");
-    SBI_PRINTF(1, "------------------------\n");
-    */
-    while ( id != NULL )
-    {
-        SBI_PRINTF(1,  "%s\n", id->str );
-        id=id->next;
-    }
-
-    /* remove allocated string */
-    if ( list != NULL ) remove_string_list( list );
+       while ( id != NULL )
+       {
+               SBI_PRINTF(1,  "%s\n", id->str );
+               id=id->next;
+       }
+
+       /* remove allocated string */
+       if ( list != NULL ) { remove_string_list( list ); }
 }
 
 void display_target_info( char* target_id )
@@ -250,10 +246,10 @@ int is_target_predefined_action_available( char* target_id, char* action_name )
        char* toolchain_id = get_toolchain_id( target_id );
 
        if ( toolchain_id != NULL       && is_toolchain_action_available( toolchain_id, action_name, 1 ) )
-               ret = 1;
+       { ret = 1; }
 
        if ( toolchain_id != NULL )
-               free( toolchain_id );
+       { free( toolchain_id ); }
 
        return ret;
 }
@@ -265,12 +261,12 @@ int is_target_action_available( char* target_id, char* action_cmd )
        char* toolchain_id = get_toolchain_id( target_id );
 
        if ( toolchain_id != NULL       && (
-                       is_toolchain_action_available( toolchain_id, action_cmd, 1 ) ||
-                       is_toolchain_action_available( toolchain_id, action_cmd, 0 ) ) )
-               ret = 1;
+                   is_toolchain_action_available( toolchain_id, action_cmd, 1 ) ||
+                   is_toolchain_action_available( toolchain_id, action_cmd, 0 ) ) )
+       { ret = 1; }
 
        if ( toolchain_id != NULL )
-               free( toolchain_id );
+       { free( toolchain_id ); }
 
        return ret;
 }
@@ -285,22 +281,22 @@ int execute_target_action( char* target_id, char* action_cmd, string_list* argum
 
        /* check */
        if ( !is_target_action_available( target_id, action_cmd ) )
-               return -1;
+       { return -1; }
 
-    /* set basic action environment */
-    set_target_id(target_id);
-    set_toolchain_id(toolchain_id);
-    set_rootstrap_id(rootstrap_id);
+       /* set basic action environment */
+       set_target_id(target_id);
+       set_toolchain_id(toolchain_id);
+       set_rootstrap_id(rootstrap_id);
 
-    /* execute */
+       /* execute */
        ret = execute_toolchain_action( toolchain_id, action_cmd, arguments );
 
        /* release environment */
-    free_toolchain_id();
-    free_rootstrap_id();
-    free_target_id();
+       free_toolchain_id();
+       free_rootstrap_id();
+       free_target_id();
 
-    /* free */
+       /* free */
        free( toolchain_id );
        free( rootstrap_id );
 
@@ -324,10 +320,10 @@ void print_target_action_list(char* target_id)
 {
        char*toolchain_id = get_toolchain_id(target_id);
 
-    /* print */
-    print_toolchain_action_list(toolchain_id);
+       /* print */
+       print_toolchain_action_list(toolchain_id);
 
-    /* free */
+       /* free */
        free( toolchain_id );
 }
 
index e551403..9f2933c 100644 (file)
 #include "sbi_types.h"
 
 /* init fini */
-void initialize_target_mgt( );
-void finalize_target_mgt( );
+void initialize_target_mgt( void );
+void finalize_target_mgt( void );
 
 /* list up all target  */
-string_list* get_all_available_target_ids( );
-string_list* get_all_available_target_names( );
+string_list* get_all_available_target_ids( void );
+string_list* get_all_available_target_names( void );
 
 /* create/remove target xml */
 int create_new_target( char* target_id, char* rootstrap_id, char* toolchain_id );
@@ -49,7 +49,7 @@ char* get_rootstrap_id( char* target_id );
 char* get_toolchain_id( char* target_id );
 
 /* functions */
-void display_target_list();
+void display_target_list( void );
 void display_target_info( char* target_id );
 int is_target_available( char* target_id );
 
index cc3a88b..4a3658f 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -34,19 +34,19 @@ tool* create_tool( char* name, char* path, char* version, char* desc )
        tool *newr = (tool*)malloc( sizeof(tool ) );
 
        if ( name != NULL )
-               newr->name = (char*)strdup(name);
+       { newr->name = (char*)strdup(name); }
        else
-               newr->name =  (char*)strdup(name);
+       { newr->name =  (char*)strdup(name); }
 
        newr->path =  (char*)strdup( path );
        if ( version != NULL )
-               newr->version =  (char*)strdup( version );
+       { newr->version =  (char*)strdup( version ); }
        else
-               newr->version =  (char*)strdup( " " );
+       { newr->version =  (char*)strdup( " " ); }
        if ( desc != NULL )
-               newr->description =  (char*)strdup( desc );
+       { newr->description =  (char*)strdup( desc ); }
        else
-               newr->description =  (char*)strdup( " ");
+       { newr->description =  (char*)strdup( " "); }
        newr->next = NULL;
 
        return newr;
@@ -57,7 +57,9 @@ tool* append_tool_list( tool* list, tool* src )
 {
        tool* r = list;
        while( r->next != NULL )
+       {
                r=r->next;
+       }
 
        r->next = src;
 
@@ -89,7 +91,7 @@ tool* load_tool_list_from_plugin( plugin_tag* toolchain_tag )
        tool* tool_list = NULL;
 
        if ( tag_list == NULL )
-               return NULL;
+       { return NULL; }
 
        for( plugin_tag =tag_list ; plugin_tag ; plugin_tag=plugin_tag->next )
        {
@@ -107,9 +109,9 @@ tool* load_tool_list_from_plugin( plugin_tag* toolchain_tag )
                if ( t != NULL )
                {
                        if ( tool_list != NULL )
-                               append_tool_list( tool_list, t );
+                       { append_tool_list( tool_list, t ); }
                        else
-                               tool_list = t;
+                       { tool_list = t; }
                }
 
                /* remove dynamically allocated string */
@@ -120,7 +122,7 @@ tool* load_tool_list_from_plugin( plugin_tag* toolchain_tag )
        }
 
        /* clean up */
-    remove_plugin_tag_list(tag_list);
+       remove_plugin_tag_list(tag_list);
 
        return tool_list;
 }
index e34c516..1cbef1a 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -40,19 +40,19 @@ toolchain* create_toolchain( char* id, char* name, char* version, char* architec
 
        newr->id = strdup( id );
 
-       if ( name != NULL ) newr->name = (char*)strdup(name);
-       else newr->name =  (char*)strdup(id);
-
-       if ( version != NULL ) newr->version = (char*)strdup(version);
-       else newr->version =  (char*)strdup("1.0");
-    
-    if( architecture != NULL ) newr->architecture =  (char*)strdup( architecture );
-    else  newr->architecture = NULL;
-    if( path != NULL ) newr->path =  (char*)strdup( path );
-    else  newr->path = NULL;
-    if( toolchain_type != NULL ) newr->toolchain_type =  (char*)strdup( toolchain_type );
-    else  newr->toolchain_type = NULL;
-    newr->property_list = NULL;
+       if ( name != NULL ) { newr->name = (char*)strdup(name); }
+       else { newr->name =  (char*)strdup(id); }
+
+       if ( version != NULL ) { newr->version = (char*)strdup(version); }
+       else { newr->version =  (char*)strdup("1.0"); }
+
+       if( architecture != NULL ) { newr->architecture =  (char*)strdup( architecture ); }
+       else  { newr->architecture = NULL; }
+       if( path != NULL ) { newr->path =  (char*)strdup( path ); }
+       else  { newr->path = NULL; }
+       if( toolchain_type != NULL ) { newr->toolchain_type =  (char*)strdup( toolchain_type ); }
+       else  { newr->toolchain_type = NULL; }
+       newr->property_list = NULL;
        newr->tool_list = NULL;
        newr->action_list = NULL;
        newr->next = NULL;
@@ -65,7 +65,9 @@ toolchain* append_toolchain_list( toolchain* list, toolchain* src )
 {
        toolchain* r = list;
        while( r->next != NULL )
+       {
                r=r->next;
+       }
 
        r->next = src;
 
@@ -77,19 +79,19 @@ void remove_toolchain_property_list( toolchain_property* list )
        toolchain_property* t = list;
        toolchain_property* prev;
        while( t != NULL )
-    {
-        prev = t; 
+       {
+               prev = t;
                t=t->next;
-        if(prev->key != NULL)
-        {
-            free(prev->key);
-        }
-        if(prev->value != NULL)
-        {
-            free(prev->value);
-        }
-        free(prev);
-    }
+               if(prev->key != NULL)
+               {
+                       free(prev->key);
+               }
+               if(prev->value != NULL)
+               {
+                       free(prev->value);
+               }
+               free(prev);
+       }
 }
 
 void remove_toolchain_list( toolchain* list )
@@ -99,44 +101,44 @@ void remove_toolchain_list( toolchain* list )
        {
                toolchain* prev = r ;
                r=r->next;
-        if(prev->id != NULL)
-        {
-            free( prev->id );
-        }
-        if(prev->name != NULL)
-        {
-            free( prev->name );
-        }
-        if(prev->version != NULL)
-        {
-            free( prev->version );
-        }
-        if(prev->architecture != NULL)
-        {
-            free( prev->architecture );
-        }
-        if(prev->path != NULL)
-        {
-            free( prev->path );
-        }
-        if(prev->toolchain_type != NULL)
-        {
-            free( prev->toolchain_type );
-        }
-        if(prev->property_list != NULL)
-        {
-            remove_toolchain_property_list(prev->property_list);
-        }
-        if(prev->tool_list != NULL)
-        {
-            remove_tool_list( prev->tool_list );
-        }
-        if(prev->action_list != NULL)
-        {
-            remove_toolchain_action_list( prev->action_list );
-        }
-        free( prev );
-    }
+               if(prev->id != NULL)
+               {
+                       free( prev->id );
+               }
+               if(prev->name != NULL)
+               {
+                       free( prev->name );
+               }
+               if(prev->version != NULL)
+               {
+                       free( prev->version );
+               }
+               if(prev->architecture != NULL)
+               {
+                       free( prev->architecture );
+               }
+               if(prev->path != NULL)
+               {
+                       free( prev->path );
+               }
+               if(prev->toolchain_type != NULL)
+               {
+                       free( prev->toolchain_type );
+               }
+               if(prev->property_list != NULL)
+               {
+                       remove_toolchain_property_list(prev->property_list);
+               }
+               if(prev->tool_list != NULL)
+               {
+                       remove_tool_list( prev->tool_list );
+               }
+               if(prev->action_list != NULL)
+               {
+                       remove_toolchain_action_list( prev->action_list );
+               }
+               free( prev );
+       }
 }
 
 static toolchain_property* create_toolchain_property( char* key, char* value )
@@ -154,7 +156,9 @@ static toolchain_property* append_toolchain_property_list( toolchain_property* l
 {
        toolchain_property* t = list;
        while( t->next != NULL )
+       {
                t=t->next;
+       }
 
        t->next = src;
 
@@ -166,9 +170,9 @@ void add_toolchain_property( toolchain* t, char* key, char* value )
        toolchain_property* newr = create_toolchain_property( key, value );
 
        if ( t->property_list != NULL )
-               append_toolchain_property_list( t->property_list, newr );
+       { append_toolchain_property_list( t->property_list, newr ); }
        else
-               t->property_list = newr;
+       { t->property_list = newr; }
 }
 
 
@@ -189,12 +193,12 @@ string_list* get_tool_list( toolchain*tc )
                string_list* newl = create_string_list( t->name );
 
                if ( list != NULL )
-        {
+               {
                        append_string_to_list( list,  newl->str);
-            remove_string_list(newl);
-        }
+                       remove_string_list(newl);
+               }
                else
-                       list = newl;
+               { list = newl; }
        }
 
        return list;
@@ -208,7 +212,7 @@ char* get_tool_path( toolchain*tc, char* tool_name )
        for(t = tc->tool_list; t != NULL; t = t->next )
        {
                if ( strcmp( t->name, tool_name ) == 0 )
-                       return t->path;
+               { return t->path; }
        }
 
        return NULL;
@@ -222,7 +226,7 @@ char* get_tool_version( toolchain*tc, char* tool_name )
        for(t = tc->tool_list; t != NULL; t = t->next )
        {
                if ( strcmp( t->name, tool_name ) == 0 )
-                       return t->version;
+               { return t->version; }
        }
 
        return NULL;
@@ -274,44 +278,44 @@ int perform_toolchain_action(  toolchain*tc, char* action_name, string_list *arg
 /* print action list */
 void print_action_list( toolchain* t )
 {
-    toolchain_action* action;
+       toolchain_action* action;
 
        if ( t == NULL )
-    {
-        return;
-    }
-    action = t->action_list;
-    while(action != NULL)
-    {
-       string_list *var_list = NULL;
-       string *var = NULL;
-
-       /* ignore predefined */
-        if(action->predefined == 1 )
+       {
+               return;
+       }
+       action = t->action_list;
+       while(action != NULL)
+       {
+               string_list *var_list = NULL;
+               string *var = NULL;
+
+               /* ignore predefined */
+               if(action->predefined == 1 )
                {
                        /* skip current */
                        action = action->next;
-               continue;
+                       continue;
                }
 
-        /* get */
-        var_list = get_toolchain_action_variable_list( action );
+               /* get */
+               var_list = get_toolchain_action_variable_list( action );
 
-        /* print */
-        SBI_PRINTF(1, "%s", action->name );
-        for( var = var_list; var; var = var->next )
-        {
-               SBI_PRINTF(1, " %s", var->str );
-        }
-        SBI_PRINTF(1, "\n");
+               /* print */
+               SBI_PRINTF(1, "%s", action->name );
+               for( var = var_list; var; var = var->next )
+               {
+                       SBI_PRINTF(1, " %s", var->str );
+               }
+               SBI_PRINTF(1, "\n");
 
-        /* clean up */
+               /* clean up */
                if ( var_list != NULL )
-               remove_string_list( var_list );
+               { remove_string_list( var_list ); }
 
-        /* get next */
-        action = action->next;
-    }
+               /* get next */
+               action = action->next;
+       }
 }
 
 
@@ -323,16 +327,16 @@ void print_action_variable_list( toolchain* t, char* action_cmd )
        string *var = NULL;
 
        if ( action == NULL )
-               return;
+       { return; }
 
-    /* get */
-    var_list = get_toolchain_action_variable_list( action );
+       /* get */
+       var_list = get_toolchain_action_variable_list( action );
 
-    for( var = var_list; var; var = var->next )
-    {
-       SBI_PRINTF(1, " %s", var->str );
-    }
-    SBI_PRINTF(1, "\n");
+       for( var = var_list; var; var = var->next )
+       {
+               SBI_PRINTF(1, " %s", var->str );
+       }
+       SBI_PRINTF(1, "\n");
 }
 
 
index d8ca657..e66adc2 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -36,31 +36,31 @@ toolchain_action* create_toolchain_action( char* name, char* predefined, char* d
 {
        toolchain_action *newr = (toolchain_action*)malloc( sizeof(toolchain_action ) );
 
-    if ( name != NULL )
-           newr->name = (char*)strdup(name);
-    else
-    {
-        sbi_error(30, "", 0);
-        free(newr);
-        return NULL;
-    }
-
-    if ( predefined != NULL )
-    {
-        if ( strcmp(predefined, "YES") == 0)
-            newr->predefined = 1;
-        else
-            newr->predefined = 0;
-    }
-    else 
-    {
-        newr->predefined = 0;
-    }
+       if ( name != NULL )
+       { newr->name = (char*)strdup(name); }
+       else
+       {
+               sbi_error(30, "", 0);
+               free(newr);
+               return NULL;
+       }
+
+       if ( predefined != NULL )
+       {
+               if ( strcmp(predefined, "YES") == 0)
+               { newr->predefined = 1; }
+               else
+               { newr->predefined = 0; }
+       }
+       else
+       {
+               newr->predefined = 0;
+       }
 
        if ( description != NULL )
-               newr->description =  (char*)strdup( description );
+       { newr->description =  (char*)strdup( description ); }
        else
-               newr->description =  (char*)strdup( " " );
+       { newr->description =  (char*)strdup( " " ); }
 
        newr->next = NULL;
 
@@ -76,7 +76,9 @@ toolchain_action* append_toolchain_action_list( toolchain_action* list, toolchai
 {
        toolchain_action* r = list;
        while( r->next != NULL )
+       {
                r=r->next;
+       }
 
        r->next = src;
 
@@ -107,7 +109,7 @@ toolchain_action* load_toolchain_action_list_from_plugin( plugin_tag* toolchain_
        toolchain_action* action_list = NULL;
 
        if ( tag_list == NULL )
-               return NULL;
+       { return NULL; }
 
        for( plugin_tag=tag_list ; plugin_tag ; plugin_tag=plugin_tag->next )
        {
@@ -127,9 +129,9 @@ toolchain_action* load_toolchain_action_list_from_plugin( plugin_tag* toolchain_
                        set_execute( action, execute_list );
 
                        if ( action_list != NULL )
-                               append_toolchain_action_list( action_list, action );
+                       { append_toolchain_action_list( action_list, action ); }
                        else
-                               action_list = action;
+                       { action_list = action; }
                }
 
                /* remove dynamically allocated string */
@@ -139,7 +141,7 @@ toolchain_action* load_toolchain_action_list_from_plugin( plugin_tag* toolchain_
        }
 
        /* clean up */
-    remove_plugin_tag_list(tag_list);
+       remove_plugin_tag_list(tag_list);
 
        return action_list;
 }
@@ -158,9 +160,9 @@ string_list* get_toolchain_action_variable_list( toolchain_action* action )
                if ( var_list != NULL )
                {
                        if ( result_list != NULL )
-                               append_string_list_to_list( result_list, var_list );
+                       { append_string_list_to_list( result_list, var_list ); }
                        else
-                               result_list = clone_string_list( var_list );
+                       { result_list = clone_string_list( var_list ); }
 
                        remove_string_list( var_list );
                }
index 98386e0..179e1af 100644 (file)
@@ -8,7 +8,7 @@
  * Jiil Hyoun <jiil.hyoun@samsung.com>
  * Donghyuk Yang <donghyuk.yang@samsung.com>
  * DongHee Yang <donghee.yang@samsung.com>
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -41,7 +41,7 @@ static toolchain* toolchain_list = NULL;
 
 
 /* init fini */
-void initialize_toolchain_mgt( )
+void initialize_toolchain_mgt( void )
 {
        plugin* list = get_plugin_list("toolchainDefinition");
        plugin* p = list;
@@ -53,23 +53,23 @@ void initialize_toolchain_mgt( )
                if ( tc != NULL )
                {
                        if ( toolchain_list != NULL )
-                               append_toolchain_list( toolchain_list, tc );
+                       { append_toolchain_list( toolchain_list, tc ); }
                        else
-                               toolchain_list = tc;
+                       { toolchain_list = tc; }
                }
        }
        remove_plugin_list(list);
 }
 
 
-void finalize_toolchain_mgt( )
+void finalize_toolchain_mgt( void )
 {
        remove_toolchain_list( toolchain_list );
 }
 
 
 /* list up all target  */
-string_list* get_all_available_toolchain_ids( )
+string_list* get_all_available_toolchain_ids( void )
 {
        string_list *new_list = NULL;
        toolchain * t = toolchain_list;
@@ -77,16 +77,16 @@ string_list* get_all_available_toolchain_ids( )
        for( ; t ; t=t->next )
        {
                if ( new_list != NULL )
-                       append_string_to_list( new_list, t->id );
+               { append_string_to_list( new_list, t->id ); }
                else
-                       new_list = create_string_list( t->id );
+               { new_list = create_string_list( t->id ); }
        }
 
        return new_list;
 }
 
 
-string_list* get_all_available_toolchain_names( )
+string_list* get_all_available_toolchain_names( void )
 {
        string_list *new_list = NULL;
        toolchain * t = toolchain_list;
@@ -94,9 +94,9 @@ string_list* get_all_available_toolchain_names( )
        for( ; t ; t=t->next )
        {
                if ( new_list != NULL )
-                       append_string_to_list( new_list, t->name );
+               { append_string_to_list( new_list, t->name ); }
                else
-                       new_list = create_string_list( t->name );
+               { new_list = create_string_list( t->name ); }
        }
 
        return new_list;
@@ -111,7 +111,7 @@ static toolchain* find_toolchain( char* toolchain_id )
        for( ; t ; t=t->next )
        {
                if ( strcmp( t->id, toolchain_id ) == 0 )
-                       return t;
+               { return t; }
        }
 
        return NULL;
@@ -124,9 +124,9 @@ char* get_toolchain_name( char* toolchain_id )
        toolchain * t = find_toolchain( toolchain_id );
 
        if ( t != NULL )
-               return strdup( t->name );
+       { return strdup( t->name ); }
        else
-               return NULL;
+       { return NULL; }
 }
 
 
@@ -135,18 +135,19 @@ char* get_toolchain_version( char* toolchain_id )
        toolchain * t = find_toolchain( toolchain_id );
 
        if ( t != NULL )
-               return strdup( t->version );
+       { return strdup( t->version ); }
        else
-               return NULL;
+       { return NULL; }
 }
 
 
 char* get_toolchain_architecture( char* toolchain_id )
 {
-       toolchain * t = find_toolchain( toolchain_id ); if ( t != NULL )
-               return strdup( t->architecture );
+       toolchain * t = find_toolchain( toolchain_id );
+       if ( t != NULL )
+       { return strdup( t->architecture ); }
        else
-               return NULL;
+       { return NULL; }
 }
 
 char* get_toolchain_path( char* toolchain_id )
@@ -154,30 +155,30 @@ char* get_toolchain_path( char* toolchain_id )
        toolchain * t = find_toolchain( toolchain_id );
 
        if ( t != NULL )
-               return strdup( t->path );
+       { return strdup( t->path ); }
        else
-               return NULL;
+       { return NULL; }
 }
 
 char* get_toolchain_toolchain_type( char* toolchain_id )
 {
-    toolchain * t = find_toolchain( toolchain_id );
-
-    if ( t != NULL )
-    {
-        if(t->toolchain_type != NULL)
-        {
-            return strdup( t->toolchain_type );
-        }
-        else
-        { 
-            return NULL;
-        }
-    }
-    else
-    {
-        return NULL;
-    }
+       toolchain * t = find_toolchain( toolchain_id );
+
+       if ( t != NULL )
+       {
+               if(t->toolchain_type != NULL)
+               {
+                       return strdup( t->toolchain_type );
+               }
+               else
+               {
+                       return NULL;
+               }
+       }
+       else
+       {
+               return NULL;
+       }
 }
 
 string_list* get_toolchain_property_list( char* toolchain_id )
@@ -185,36 +186,36 @@ string_list* get_toolchain_property_list( char* toolchain_id )
        toolchain * t = find_toolchain( toolchain_id );
        toolchain_property* r;
        string_list * list= NULL;
-    if(t != NULL)
-    {
-        r = t->property_list;
-        for( ; r; r = r -> next )
-        {
-            if ( list != NULL )
-                append_string_to_list( list, r->key );
-            else
-                list = create_string_list( r->key);
-        }
-
-           return list;
-    }
-    return NULL;
+       if(t != NULL)
+       {
+               r = t->property_list;
+               for( ; r; r = r -> next )
+               {
+                       if ( list != NULL )
+                       { append_string_to_list( list, r->key ); }
+                       else
+                       { list = create_string_list( r->key); }
+               }
+
+               return list;
+       }
+       return NULL;
 }
 
 char* get_toolchain_property_value( char* toolchain_id, char* key )
 {
        toolchain * t = find_toolchain( toolchain_id );
        toolchain_property* r;
-    if(t != NULL)
-    {
-        r = t->property_list;
-        for( ; r; r = r -> next )
-        {
-            if ( strcmp( r->key , key) == 0 )
-                return strdup( r->value );
-        }
-    }
-    return NULL;
+       if(t != NULL)
+       {
+               r = t->property_list;
+               for( ; r; r = r -> next )
+               {
+                       if ( strcmp( r->key , key) == 0 )
+                       { return strdup( r->value ); }
+               }
+       }
+       return NULL;
 }
 
 int is_toolchain_available( char* toolchain_id )
@@ -222,9 +223,9 @@ int is_toolchain_available( char* toolchain_id )
        toolchain * t = find_toolchain( toolchain_id );
 
        if ( t != NULL )
-               return 1;
+       { return 1; }
        else
-               return 0;
+       { return 0; }
 }
 
 int is_toolchain_action_available( char* toolchain_id, char* action_name, int predefined)
@@ -242,8 +243,8 @@ int is_toolchain_action_available( char* toolchain_id, char* action_name, int pr
        for ( ; list ; list = list->next)
        {
                if ( (strcmp(list->name, action_name) == 0)
-                               && (list->predefined == predefined) )
-                       return 1;
+                       && (list->predefined == predefined) )
+               { return 1; }
        }
 
        return 0;
@@ -285,7 +286,7 @@ int execute_toolchain_action( char* toolchain_id, char* action_name, string_list
 
        /* if not found, error */
        if ( t == NULL )
-               return -1;
+       { return -1; }
 
        /* execute */
        ret = perform_toolchain_action( t, action_name, argument );
@@ -300,7 +301,7 @@ void print_toolchain_action_variable_list( char* toolchain_id, char* action_name
 
        /* if not found, error */
        if ( t == NULL )
-               return;
+       { return; }
 
        /* execute */
        print_action_variable_list( t, action_name );
@@ -315,7 +316,7 @@ void print_toolchain_action_list( char* toolchain_id )
 
        /* if not found, error */
        if ( t == NULL )
-               return;
+       { return; }
 
        /* execute */
        print_action_list( t );
@@ -324,83 +325,80 @@ void print_toolchain_action_list( char* toolchain_id )
 }
 
 
-void display_toolchain_list()
+void display_toolchain_list( void )
 {
        string_list* list = get_all_available_toolchain_ids();
        string_list* id = list;
 
-    /*
-    SBI_PRINTF(1, "\nAvailable Toolchain List\n");
-    SBI_PRINTF(1, "------------------------\n");
-    */
-    while ( id != NULL )
-    {
-        SBI_PRINTF(1,  "%s\n", id->str );
-        id=id->next;
-    }
-
-    if ( list != NULL ) remove_string_list( list );
+       while ( id != NULL )
+       {
+               SBI_PRINTF(1,  "%s\n", id->str );
+               id=id->next;
+       }
+
+       if ( list != NULL ) { remove_string_list( list ); }
 }
 
 
 void display_toolchain_info( char* toolchain_id )
 {
-    if(is_toolchain_available(toolchain_id))
-    {
-        char* name =  get_toolchain_name( toolchain_id ) ;
-        char* version =  get_toolchain_version( toolchain_id ) ;
-        char* architecture =  get_toolchain_architecture( toolchain_id ) ;
-        char* path =  get_toolchain_path( toolchain_id ) ;
-        char* toolchain_type =  get_toolchain_toolchain_type( toolchain_id ) ;
-        char* value;
-        string_list* tool_origin;
-        string_list* tool;
-        string_list* key_origin;
-        string_list* key;
-
-        SBI_PRINTF(1, "NAME=%s\n", name);
-        SBI_PRINTF(1, "VERSION=%s\n",  version);
-        SBI_PRINTF(1, "ARCHITECTURE=%s\n",  architecture );
-        SBI_PRINTF(1, "TOOLCHAIN_PATH=%s\n",  path );
-        SBI_PRINTF(1, "TOOLCHAIN_TYPE=%s\n",  toolchain_type );
-    
-       /* other properties */
-       key_origin = get_toolchain_property_list( toolchain_id );
-        key = key_origin;
-       for( ; key; key = key->next )
-       {
-            value = tag_checker( get_toolchain_property_value( toolchain_id, key->str) );
-            SBI_PRINTF(1, "%s=%s\n", key->str, value );
-            if(value !=NULL)
-                free(value);
-       }
-        if(key_origin != NULL)
-            remove_string_list(key_origin);
-    
-       /* display tools */
-       tool_origin = get_toolchain_tool_list( toolchain_id );
-        tool = tool_origin;
-       for( ;  tool != NULL; tool = tool->next )
-       {
-               char* path = tag_checker( get_toolchain_tool_path( toolchain_id, tool->str ) );
-               char* t_version = get_toolchain_tool_version( toolchain_id, tool->str );
-    
-               SBI_PRINTF(1, "TOOL_%s_PATH=%s\n", tool->str, path );
-               SBI_PRINTF(1, "TOOL_%s_VERSION=%s\n", tool->str, t_version );
-               free( path );
-               free( t_version );
-       }
-        if(tool_origin != NULL)
-            remove_string_list(tool_origin);
-    
-       free( name );
-       free( version );
-       free( architecture );
-       free( path );
-       free( toolchain_type );
-    }
-    else
-    {
-        SBI_PRINTF(1, "%s is not available toolchain name\n",toolchain_id );
-    }
+       if(is_toolchain_available(toolchain_id))
+       {
+               char* name =  get_toolchain_name( toolchain_id ) ;
+               char* version =  get_toolchain_version( toolchain_id ) ;
+               char* architecture =  get_toolchain_architecture( toolchain_id ) ;
+               char* path =  get_toolchain_path( toolchain_id ) ;
+               char* toolchain_type =  get_toolchain_toolchain_type( toolchain_id ) ;
+               char* value;
+               string_list* tool_origin;
+               string_list* tool;
+               string_list* key_origin;
+               string_list* key;
+
+               SBI_PRINTF(1, "NAME=%s\n", name);
+               SBI_PRINTF(1, "VERSION=%s\n",  version);
+               SBI_PRINTF(1, "ARCHITECTURE=%s\n",  architecture );
+               SBI_PRINTF(1, "TOOLCHAIN_PATH=%s\n",  path );
+               SBI_PRINTF(1, "TOOLCHAIN_TYPE=%s\n",  toolchain_type );
+
+               /* other properties */
+               key_origin = get_toolchain_property_list( toolchain_id );
+               key = key_origin;
+               for( ; key; key = key->next )
+               {
+                       value = tag_checker( get_toolchain_property_value( toolchain_id, key->str) );
+                       SBI_PRINTF(1, "%s=%s\n", key->str, value );
+                       if(value !=NULL)
+                       { free(value); }
+               }
+               if(key_origin != NULL)
+               { remove_string_list(key_origin); }
+
+               /* display tools */
+               tool_origin = get_toolchain_tool_list( toolchain_id );
+               tool = tool_origin;
+               for( ;  tool != NULL; tool = tool->next )
+               {
+
+                       char* tool_path = tag_checker( get_toolchain_tool_path( toolchain_id, tool->str ) );
+                       char* t_version = get_toolchain_tool_version( toolchain_id, tool->str );
+
+                       SBI_PRINTF(1, "TOOL_%s_PATH=%s\n", tool->str, tool_path );
+                       SBI_PRINTF(1, "TOOL_%s_VERSION=%s\n", tool->str, t_version );
+                       free( tool_path );
+                       free( t_version );
+               }
+               if(tool_origin != NULL)
+               { remove_string_list(tool_origin); }
+
+               free( name );
+               free( version );
+               free( architecture );
+               free( path );
+               free( toolchain_type );
+       }
+       else
+       {
+               SBI_PRINTF(1, "%s is not available toolchain name\n",toolchain_id );
+       }
 }
index 6312b30..2e61045 100644 (file)
 #define MAX_TOOLS 50
 
 /* init fini */
-void initialize_toolchain_mgt( );
-void finalize_toolchain_mgt( );
+void initialize_toolchain_mgt( void );
+void finalize_toolchain_mgt( void );
 
 /* list up all target  */
-string_list* get_all_available_toolchain_ids( );
-string_list* get_all_available_toolchain_names( );
+string_list* get_all_available_toolchain_ids( void );
+string_list* get_all_available_toolchain_names( void );
 
 /* toolchain */
 char* get_toolchain_name( char* toolchain_id );
@@ -48,7 +48,7 @@ char* get_toolchain_architecture( char* toolchain_id );
 char* get_toolchain_path( char* toolchain_id );
 char* get_toolchain_toolchain_type( char* toolchain_id );
 int is_toolchain_available( char* toolchain_id );
-void display_toolchain_list();
+void display_toolchain_list( void );
 void display_toolchain_info( char* toolchain_id );
 
 string_list* get_toolchain_tool_list( char* toolchain_id );
diff --git a/tools/make_pch b/tools/make_pch
new file mode 100644 (file)
index 0000000..85219f8
--- /dev/null
@@ -0,0 +1,160 @@
+#!/usr/bin/perl 
+use strict;
+use warnings;
+
+use List::Util qw/first/;
+use File::Basename;
+use File::Spec;
+
+# generate boolean variables
+use constant false => 0;
+use constant true  => 1;
+
+my $PCH = "pch.h";
+my $PCH_PATH = "../inc/$PCH";
+my $PCH_GCH = "pch/$PCH.gch";
+my $SUBDIR_PATH = "src/subdir.mk";
+my $makefile = 'makefile';
+my ($find_include, $find_clean, $find_gch_o_rule, $find_gch_rule) = (false, false, false, false);
+my @makefile_contents;
+my @makefile_contents2;
+
+# insert line contents
+my $dep_line = "CPP_DEPS += $PCH_GCH.d";
+my $clean_line = "\trm -f $PCH_GCH $PCH_GCH.d";
+my $gch_o_rule = "\$(OBJS):%.o:$PCH_GCH";
+my $gch_rule = "$PCH_GCH: $PCH_PATH ../.cproject ../.project";
+
+my $modified_string = "# Already modified for pch using pch_generator script";
+# compiler_name 
+my $compiler_name;
+
+# check argument 
+if ($#ARGV != 0){
+       die "Usage : pch_generator <compiler_name>\n";
+}
+else {
+       $compiler_name = $ARGV[0];
+}
+
+# if stdafx file does not exist then skip 
+unless (-e $PCH_PATH) {
+       print "PCH file does not exist\n";
+       exit;
+}
+
+# pch path generate
+unless (-e dirname($PCH_GCH)) {
+       mkdir dirname($PCH_GCH), 0755 || die "can't create directory";
+}
+               
+# open makefile
+open FP, '<', $makefile or die "Cannot open make file [$makefile] : $!\n"; 
+
+# read makefile and save array
+while (<FP>) {
+       # remove new line
+       $_ =~ s/\r\n/\n/;
+       chomp($_);
+
+       # save file contents in @makefile_contents array
+       push (@makefile_contents, $_); 
+}
+
+close FP;
+
+# check alread translated
+if ($makefile_contents[0] eq $modified_string) {
+       print "Skip translate for pch because already translated\n";
+       exit;
+} 
+else {
+       # modifying file is contain modified_string
+       push (@makefile_contents2, $modified_string);
+}
+
+
+# insert line
+while (@makefile_contents > 0) {
+       $_ = shift @makefile_contents;
+       push(@makefile_contents2, $_);  
+
+       if ( $_ eq "-include objects.mk" ) {
+               push(@makefile_contents2, $dep_line);   
+               $find_include = true;
+       }
+
+       if ( $_ =~ /^clean:/ ) {
+               push(@makefile_contents2, $clean_line); 
+               $find_clean= true;
+       }
+}
+
+# error check
+if (not $find_include){
+       die "ERROR! cannot find subdir.mk include line\n";
+}
+if (not $find_clean){
+       die "ERROR! couldn't find clean: line in makefile\n";
+}
+
+unless ($find_gch_o_rule) {
+       push(@makefile_contents2, "");
+       push(@makefile_contents2, $gch_o_rule);
+       push(@makefile_contents2, "");
+}
+
+unless ($find_gch_rule) {
+       my $cmd;
+       open FP, '<', $SUBDIR_PATH or die "Cannot open [$SUBDIR_PATH] file!\n"; 
+       my @subdir_contents;
+       my $compiler_reg = $compiler_name;
+       $compiler_reg =~ s/\./\\\./g;
+       $compiler_reg =~ s/\+/\\\+/g;
+       while (<FP>){
+               # remove new line
+               $_ =~ s/\r\n/\n/;
+               chomp($_);
+
+               if ( $_ =~ /^(\t$compiler_reg.*)$/) {
+                       my $dir = dirname($PCH_GCH);
+                       # save subdir compiler line for makefile
+                       $cmd = $_;
+
+                       # modified subdir contetnts
+                       $_ =~ s/-D_DEBUG/-D_DEBUG -I\"$dir\"/;
+                       $find_gch_rule = true;
+               }
+                       
+               push(@subdir_contents, $_);     
+       }
+       close FP;
+
+       # rewrite subdir file 
+       open FP, '>', $SUBDIR_PATH or die "Cannot open [$SUBDIR_PATH] file!\n"; 
+       print FP join "\n", @subdir_contents;
+       close FP;
+
+       # error check
+       if (not $find_gch_rule) {
+               die "cannot find $compiler_name command in subdir.mk\n";
+       }
+
+       # change MF, MT option
+       $cmd =~ s/-MF"[^"]*"/-MF\"$PCH_GCH.d\"/;
+       $cmd =~ s/-MT"[^"]*"/-MT\"$PCH_GCH.d\"/;
+
+       push(@makefile_contents2, "");
+       push(@makefile_contents2, $gch_rule);
+       push(@makefile_contents2, "\t\@echo \'Building gch file: \$\@\'");
+       push(@makefile_contents2, $cmd);
+       push(@makefile_contents2, "\t\@echo \'Finished generate gch file: \$\@\'");
+       push(@makefile_contents2, "\t\@echo \' \'");
+       push(@makefile_contents2, "");
+}
+
+# rewrite makefile
+open FP, '>', $makefile or die "Cannot open makefile [$makefile] : $!\n"; 
+
+print FP join "\n", @makefile_contents2;
+close FP;