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
# 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"
--- /dev/null
+#!/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/
+}
# 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"
-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
+++ /dev/null
-#!/bin/sh
-
-rm -f ${INSTALLED_PATH}/SDK/build-system/plugins/*_*
--- /dev/null
+#!/bin/sh
+
+rm -rf ${INSTALLED_PATH}/tools/smart-build-interface/sbi.cfg
--- /dev/null
+#!/bin/sh
+
+rm -rf ${INSTALLED_PATH}/tools/smart-build-interface/sbi.cfg
:: 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
+++ /dev/null
-@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
--- /dev/null
+@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
--- /dev/null
+@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
* 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
*
* 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;
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 ));
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 );
}
/* create the environment for interpreting */
-static void create_interpret_environment()
+static void create_interpret_environment( void )
{
/* initialize management module */
initialize_rootstrap_mgt();
/* 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();
}
if ( cmd == NULL )
{
ret = -1;
- goto fini;
+ destroy_interpret_environment();
+
+ return ret;
}
/* execute sbi command */
/* destroy cmd */
remove_sbi_command( cmd );
-fini:
destroy_interpret_environment();
return ret;
}
else
{
- print_usage(USAGE_ALL);
- ret = NULL;
+ print_usage(USAGE_ALL);
+ ret = NULL;
}
return ret;
{
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];
strcpy(tool_id, "");
while ((op = getopt_long_only(argc, argv, "r:t:", long_options,
- &option_index)) != -1)
+ &option_index)) != -1)
{
switch (op)
/* 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 );
}
/* 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 );
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 );
}
/* 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" ) )
/* 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 );
}
/* 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);
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;
}
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 );
}
{
/* 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 );
}
/* 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;
}
}
if ( toolchain_id != NULL )
{
- display_toolchain_list();
+ display_toolchain_list();
}
if ( rootstrap_id != NULL )
{
- display_rootstrap_list();
+ display_rootstrap_list();
}
return 0;
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;
}
/* 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;
}
{
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;
}
/* 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;
* 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
*
* Contributors:
* - S-Core Co., Ltd
- */
+ */
#include <stdio.h>
#include <string.h>
return NULL;
}
-int get_config_size()
+int get_config_size( void )
{
return config_size;
}
/* 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);
* 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
*
* Contributors:
* - S-Core Co., Ltd
- */
+ */
#include <stdio.h>
#include <stdlib.h>
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;
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;
{
execute* r = list;
while( r->next != NULL )
+ {
r=r->next;
+ }
r->next = src;
{
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 );
}
}
{
execute_env* r = list;
while( r->next != NULL )
+ {
r=r->next;
+ }
r->next = src;
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;
}
execute* execute_list = NULL;
if ( tag_list == NULL )
- return NULL;
+ { return NULL; }
for( plugin_tag = tag_list; plugin_tag ; plugin_tag=plugin_tag->next )
{
{
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 */
}
/* clean up */
- remove_plugin_tag_list(tag_list);
+ remove_plugin_tag_list(tag_list);
return execute_list;
}
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;
}
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 )
{
{
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 )
{
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 )
{
strcat( cmd, "\"");
}
else
- sbi_error(28, input->type, 0);
+ { sbi_error(28, input->type, 0); }
/* get next */
input = input->next;
/* 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);
}
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;
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
{
/* if script file is written, remove it */
if ( script_path != NULL )
{
- remove_file(script_path);
+ remove_file(script_path);
}
free(cmd);
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;
}
* 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
*
* Contributors:
* - S-Core Co., Ltd
- */
+ */
#include <stdlib.h>
#include <string.h>
{
execute_input* r = list;
while( r->next != NULL )
+ {
r=r->next;
+ }
r->next = src;
execute_input* input_list = NULL;
if ( tag_list == NULL )
- return NULL;
+ { return NULL; }
for( ptag = tag_list; ptag ; ptag=ptag->next )
{
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 */
}
/* clean up */
- remove_plugin_tag_list(tag_list);
+ remove_plugin_tag_list(tag_list);
return input_list;
}
}
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]);
* 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
*
* Contributors:
* - S-Core Co., Ltd
- */
+ */
#include <stdio.h>
#include <stdlib.h>
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);
}
* 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
*
* Contributors:
* - S-Core Co., Ltd
- */
+ */
#include <dirent.h>
#include <string.h>
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);
}
#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_ */
* 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
*
* Contributors:
* - S-Core Co., Ltd
- */
+ */
#include <stdlib.h>
#include <string.h>
{
rootstrap_property* r = list;
while( r->next != NULL )
+ {
r=r->next;
+ }
r->next = src;
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);
+ }
}
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;
}
{
rootstrap* r = list;
while( r->next != NULL )
+ {
r=r->next;
+ }
r->next = src;
{
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 );
}
}
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; }
}
* 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
*
* Contributors:
* - S-Core Co., Ltd
- */
+ */
#include <stdio.h>
#include <string.h>
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;
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;
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;
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;
for( ; t ; t=t->next )
{
if ( strcmp( t->id, rootstrap_id ) == 0 )
- return t;
+ { return t; }
}
return NULL;
rootstrap * t = find_rootstrap( rootstrap_id );
if ( t != NULL )
- return strdup( t->name );
+ { return strdup( t->name ); }
else
- return NULL;
+ { return NULL; }
}
rootstrap * t = find_rootstrap( rootstrap_id );
if ( t != NULL )
- return strdup( t->version );
+ { return strdup( t->version ); }
else
- return NULL;
+ { return NULL; }
}
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;
+ }
}
rootstrap * t = find_rootstrap( rootstrap_id );
if ( t != NULL )
- return strdup( t->path );
+ { return strdup( t->path ); }
else
- return NULL;
+ { return NULL; }
}
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 )
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;
for( ; r; r = r -> next )
{
if ( strcmp( r-> key , key) == 0 )
- return strdup( r->value );
+ { return strdup( r->value ); }
}
return NULL;
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);
+ }
}
#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 );
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
* 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
/* 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 );
/* if interpreting failed, return -1 */
if (ret != 0)
- exit(-1);
+ { exit(-1); }
exit(0);
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();
}
+++ /dev/null
-/*
- * 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);
-}
* 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
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];
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
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)
{
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 */
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;
}
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)
void set_target_id(char* id)
{
- global_target_id = strdup(id);
+ global_target_id = strdup(id);
}
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;
}
/* 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 */
* 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
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)
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);
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)
{
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);
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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);
+}
* 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
list = old_list;
while( list->next != NULL )
+ {
list = list->next;
+ }
list->next = create_string_list( str );
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 )
{
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 );
}
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;
* 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)
{
exit(1);
}
-char* get_current_path()
+char* get_current_path( void )
{
return getcwd(current_path, MAX_FILE_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)
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];
char new_path[MAX_FILE_PATH];
if( strcmp( entry->d_name, "." ) == 0 ||
- strcmp( entry->d_name, ".." ) == 0 )
+ strcmp( entry->d_name, ".." ) == 0 )
{
continue;
}
return 0;
}
-
+// Return value should be free on caller side
char* get_unix_path( char* absolue_path )
{
static char buf[ 1024 ];
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, ...)
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);
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
* 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
* 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
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 );
{
target* t = list;
while( t->next != NULL )
+ {
t=t->next;
+ }
t->next = src;
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;
}
/* 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 );
* 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
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;
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;
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_target_names( )
+string_list* get_all_available_target_names( void )
{
string_list *new_list = NULL;
target * t = target_list;
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;
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;
}
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;
}
target* t = search_target_id(target_id);
if ( t != NULL)
- target_name = strdup(t->name);
+ { target_name = strdup(t->name); }
return target_name;
}
/* 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;
}
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 )
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;
}
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;
}
/* 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 );
{
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 );
}
#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 );
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 );
* 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
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;
{
tool* r = list;
while( r->next != NULL )
+ {
r=r->next;
+ }
r->next = src;
tool* tool_list = NULL;
if ( tag_list == NULL )
- return NULL;
+ { return NULL; }
for( plugin_tag =tag_list ; plugin_tag ; plugin_tag=plugin_tag->next )
{
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 */
}
/* clean up */
- remove_plugin_tag_list(tag_list);
+ remove_plugin_tag_list(tag_list);
return tool_list;
}
* 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
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;
{
toolchain* r = list;
while( r->next != NULL )
+ {
r=r->next;
+ }
r->next = src;
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 )
{
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 )
{
toolchain_property* t = list;
while( t->next != NULL )
+ {
t=t->next;
+ }
t->next = src;
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; }
}
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;
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;
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;
/* 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;
+ }
}
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");
}
* 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
{
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;
{
toolchain_action* r = list;
while( r->next != NULL )
+ {
r=r->next;
+ }
r->next = src;
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 )
{
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 */
}
/* clean up */
- remove_plugin_tag_list(tag_list);
+ remove_plugin_tag_list(tag_list);
return action_list;
}
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 );
}
* 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
/* init fini */
-void initialize_toolchain_mgt( )
+void initialize_toolchain_mgt( void )
{
plugin* list = get_plugin_list("toolchainDefinition");
plugin* p = list;
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;
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;
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;
for( ; t ; t=t->next )
{
if ( strcmp( t->id, toolchain_id ) == 0 )
- return t;
+ { return t; }
}
return NULL;
toolchain * t = find_toolchain( toolchain_id );
if ( t != NULL )
- return strdup( t->name );
+ { return strdup( t->name ); }
else
- return NULL;
+ { return NULL; }
}
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 )
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 )
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 )
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)
for ( ; list ; list = list->next)
{
if ( (strcmp(list->name, action_name) == 0)
- && (list->predefined == predefined) )
- return 1;
+ && (list->predefined == predefined) )
+ { return 1; }
}
return 0;
/* if not found, error */
if ( t == NULL )
- return -1;
+ { return -1; }
/* execute */
ret = perform_toolchain_action( t, action_name, argument );
/* if not found, error */
if ( t == NULL )
- return;
+ { return; }
/* execute */
print_action_variable_list( t, action_name );
/* if not found, error */
if ( t == NULL )
- return;
+ { return; }
/* execute */
print_action_list( t );
}
-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 );
+ }
}
#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 );
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 );
--- /dev/null
+#!/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;