Commit 70de6f4c2d981458544c7f1d64624dd14e293914

Authored by Victor Cebollada
1 parent 54c17eb0

VCPKG - Solution added to build DALi demo with VCPKG

* Code added to execute a process from Windows or Unix.

Change-Id: Ie28ecb8bb880dfa12f47f033ada3a8b8826e5787
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
build/tizen/demo/CMakeLists.txt
@@ -6,6 +6,7 @@ SET(DEMO_SRCS @@ -6,6 +6,7 @@ SET(DEMO_SRCS
6 ${DEMO_SRCS} 6 ${DEMO_SRCS}
7 "${ROOT_SRC_DIR}/shared/resources-location.cpp" 7 "${ROOT_SRC_DIR}/shared/resources-location.cpp"
8 "${ROOT_SRC_DIR}/shared/dali-table-view.cpp" 8 "${ROOT_SRC_DIR}/shared/dali-table-view.cpp"
  9 + "${ROOT_SRC_DIR}/shared/execute-process-unix.cpp"
9 ) 10 )
10 11
11 ADD_EXECUTABLE(${PROJECT_NAME} ${DEMO_SRCS}) 12 ADD_EXECUTABLE(${PROJECT_NAME} ${DEMO_SRCS})
build/tizen/examples-reel/CMakeLists.txt
@@ -6,6 +6,7 @@ SET(EXAMPLES_REEL_SRCS @@ -6,6 +6,7 @@ SET(EXAMPLES_REEL_SRCS
6 ${EXAMPLES_REEL_SRCS} 6 ${EXAMPLES_REEL_SRCS}
7 "${ROOT_SRC_DIR}/shared/resources-location.cpp" 7 "${ROOT_SRC_DIR}/shared/resources-location.cpp"
8 "${ROOT_SRC_DIR}/shared/dali-table-view.cpp" 8 "${ROOT_SRC_DIR}/shared/dali-table-view.cpp"
  9 + "${ROOT_SRC_DIR}/shared/execute-process-unix.cpp"
9 ) 10 )
10 11
11 ADD_EXECUTABLE(dali-examples ${EXAMPLES_REEL_SRCS}) 12 ADD_EXECUTABLE(dali-examples ${EXAMPLES_REEL_SRCS})
build/tizen/tests-reel/CMakeLists.txt
@@ -6,6 +6,7 @@ SET(TESTS_REEL_SRCS @@ -6,6 +6,7 @@ SET(TESTS_REEL_SRCS
6 ${TESTS_REEL_SRCS} 6 ${TESTS_REEL_SRCS}
7 "${ROOT_SRC_DIR}/shared/resources-location.cpp" 7 "${ROOT_SRC_DIR}/shared/resources-location.cpp"
8 "${ROOT_SRC_DIR}/shared/dali-table-view.cpp" 8 "${ROOT_SRC_DIR}/shared/dali-table-view.cpp"
  9 + "${ROOT_SRC_DIR}/shared/execute-process-unix.cpp"
9 ) 10 )
10 11
11 ADD_EXECUTABLE(dali-tests ${TESTS_REEL_SRCS}) 12 ADD_EXECUTABLE(dali-tests ${TESTS_REEL_SRCS})
shared/dali-table-view.cpp
@@ -20,8 +20,6 @@ @@ -20,8 +20,6 @@
20 20
21 // EXTERNAL INCLUDES 21 // EXTERNAL INCLUDES
22 #include <algorithm> 22 #include <algorithm>
23 -#include <sstream>  
24 -#include <unistd.h>  
25 #include <dali/devel-api/images/distance-field.h> 23 #include <dali/devel-api/images/distance-field.h>
26 #include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h> 24 #include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h>
27 #include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h> 25 #include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>
@@ -29,8 +27,9 @@ @@ -29,8 +27,9 @@
29 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h> 27 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
30 28
31 // INTERNAL INCLUDES 29 // INTERNAL INCLUDES
32 -#include "shared/view.h" 30 +#include "shared/execute-process.h"
33 #include "shared/utility.h" 31 #include "shared/utility.h"
  32 +#include "shared/view.h"
34 33
35 using namespace Dali; 34 using namespace Dali;
36 using namespace Dali::Toolkit; 35 using namespace Dali::Toolkit;
@@ -621,14 +620,8 @@ void DaliTableView::OnPressedAnimationFinished( Dali::Animation&amp; source ) @@ -621,14 +620,8 @@ void DaliTableView::OnPressedAnimationFinished( Dali::Animation&amp; source )
621 { 620 {
622 std::string name = mPressedActor.GetName(); 621 std::string name = mPressedActor.GetName();
623 622
624 - std::stringstream stream;  
625 - stream << DEMO_EXAMPLE_BIN << name.c_str();  
626 - pid_t pid = fork();  
627 - if( pid == 0)  
628 - {  
629 - execlp( stream.str().c_str(), name.c_str(), NULL );  
630 - DALI_ASSERT_ALWAYS(false && "exec failed!");  
631 - } 623 + ExecuteProcess( name );
  624 +
632 mPressedActor.Reset(); 625 mPressedActor.Reset();
633 } 626 }
634 } 627 }
shared/execute-process-unix.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + */
  17 +
  18 + // FILE HEADER
  19 +#include "execute-process.h"
  20 +
  21 + // EXTERNAL INCLUDES
  22 +#include <sstream>
  23 +#include <unistd.h>
  24 +#include <dali/public-api/common/dali-common.h>
  25 +
  26 +void ExecuteProcess( const std::string& processName )
  27 +{
  28 + std::stringstream stream;
  29 + stream << DEMO_EXAMPLE_BIN << processName.c_str();
  30 + pid_t pid = fork();
  31 + if( pid == 0)
  32 + {
  33 + execlp( stream.str().c_str(), processName.c_str(), NULL );
  34 + DALI_ASSERT_ALWAYS(false && "exec failed!");
  35 + }
  36 +}
shared/execute-process-win.cpp 0 → 100644
  1 +/*
  2 + * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + */
  17 +
  18 + // FILE HEADER
  19 +#include "execute-process.h"
  20 +
  21 + // EXTERNAL INCLUDES
  22 +#include <windows.h>
  23 +#include <dali/public-api/common/dali-common.h>
  24 +
  25 +namespace
  26 +{
  27 +const std::string PATH_SEPARATOR( "\\" );
  28 +}
  29 +
  30 +void ExecuteProcess( const std::string& processName )
  31 +{
  32 + char currentPath[MAX_PATH];
  33 + DWORD numberOfCharacters = GetCurrentDirectory( MAX_PATH, currentPath );
  34 +
  35 + if( 0u == numberOfCharacters )
  36 + {
  37 + DALI_ASSERT_ALWAYS( !"Failed to retrieve the current working directory" );
  38 + }
  39 +
  40 + currentPath[numberOfCharacters] = '\0';
  41 +
  42 + const std::string processPathName = std::string( currentPath ) + PATH_SEPARATOR + DEMO_EXAMPLE_BIN + PATH_SEPARATOR + processName + ".exe";
  43 +
  44 + STARTUPINFO info = { sizeof( info ) };
  45 + PROCESS_INFORMATION processInfo;
  46 + if( CreateProcess( processPathName.c_str(), nullptr, nullptr, nullptr, TRUE, 0, nullptr, nullptr, &info, &processInfo ) )
  47 + {
  48 + WaitForSingleObject( processInfo.hProcess, INFINITE );
  49 + CloseHandle( processInfo.hProcess );
  50 + CloseHandle( processInfo.hThread );
  51 + }
  52 +}
shared/execute-process.h 0 → 100644
  1 +#ifndef DALI_DEMO_EXECUTE_PROCESS_H
  2 +#define DALI_DEMO_EXECUTE_PROCESS_H
  3 +
  4 +/*
  5 + * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  6 + *
  7 + * Licensed under the Apache License, Version 2.0 (the "License");
  8 + * you may not use this file except in compliance with the License.
  9 + * You may obtain a copy of the License at
  10 + *
  11 + * http://www.apache.org/licenses/LICENSE-2.0
  12 + *
  13 + * Unless required by applicable law or agreed to in writing, software
  14 + * distributed under the License is distributed on an "AS IS" BASIS,
  15 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16 + * See the License for the specific language governing permissions and
  17 + * limitations under the License.
  18 + *
  19 + */
  20 +
  21 + // EXTERNAL INCLUDES
  22 +#include <string>
  23 +
  24 +void ExecuteProcess( const std::string& processName );
  25 +
  26 +
  27 +#endif // DALI_DEMO_EXECUTE_PROCESS_H