Skip to content

Commit

Permalink
Fix STEllAR-GROUP#3124: Build hello world client through make tests.u…
Browse files Browse the repository at this point in the history
…nit.build
  • Loading branch information
NK-Nikunj committed Mar 8, 2018
1 parent 69100ee commit 75ae9db
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 173 deletions.
3 changes: 2 additions & 1 deletion circle.yml
Expand Up @@ -18,7 +18,8 @@ general:
dependencies:
pre:
- docker pull ${IMAGE_NAME}
- mkdir build
- mkdir build

override:
- docker run -v $PWD:/hpx -w /hpx/build ${IMAGE_NAME} cmake .. -DCMAKE_BUILD_TYPE=Debug -DHPX_WITH_MALLOC=system -DHPX_WITH_GIT_COMMIT=${CIRCLE_SHA1} -DHPX_WITH_TOOLS=On -DCMAKE_CXX_FLAGS="-fcolor-diagnostics" -DHPX_WITH_TESTS_HEADERS=On -DHPX_WITH_DEPRECATION_WARNINGS=Off -DCMAKE_EXPORT_COMPILE_COMMANDS=On
- docker run -v $PWD:/hpx -w /hpx/build ${IMAGE_NAME} ../tools/clang-tidy.sh -diff-master
Expand Down
2 changes: 1 addition & 1 deletion docs/manual/build_system/using_hpx_pkgconfig.qbk
Expand Up @@ -109,7 +109,7 @@ this example, we'll choose a directory named ''my_hpx_libs''.

``
mkdir ~/my_hpx_libs
mv libhello_world.so ~/my_hpx_libs
mv libhpx_hello_world.so ~/my_hpx_libs
``

[note __hpx__ libraries have different names in debug and release mode. If you
Expand Down
@@ -1,11 +1,11 @@
# Copyright (c) 2014-2016 Thomas Heller
# Copyright (c) 2014 Thomas Heller
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

cmake_minimum_required(VERSION 3.3.2)

project(test CXX)
project(hello_world_client CXX)

if(EXISTS "${HPX_DIR}")

Expand All @@ -19,16 +19,16 @@ if(EXISTS "${HPX_DIR}")
include_directories(${HPX_INCLUDE_DIRS})
link_directories(${HPX_LIBRARY_DIR})

add_library(test_component SHARED test_component.cpp)
add_library(hello_world_component SHARED hello_world_component.cpp)
hpx_setup_target(
test_component
hello_world_component
TYPE COMPONENT
)

add_executable(test_executable test.cpp)
target_compile_definitions(test_executable PUBLIC -DHPX_DEBUG)
hpx_setup_target(test_executable
DEPENDENCIES test_component
add_executable(hello_world_client hello_world_client.cpp)
target_compile_definitions(hello_world_client PUBLIC -DHPX_DEBUG)
hpx_setup_target(hello_world_client
DEPENDENCIES hello_world_component
COMPONENT_DEPENDENCIES iostreams
)
else()
Expand Down
82 changes: 36 additions & 46 deletions examples/hello_world_component/Makefile
@@ -1,48 +1,38 @@
# Copyright (c) 2012 Steven R. Brandt
# Copyright (c) 2014 Thomas Heller
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# Linux Bash Script for running hello world

PKG_CONFIG_PATH = $(HPX_LOCATION)/lib/pkgconfig
export PKG_CONFIG_PATH

MY_HPX_LIBS = $(HOME)/my_hpx_libs

# Prepare the environment so that we can run the command
LD_LIBRARY_PATH = $(MY_HPX_LIBS)
export LD_LIBRARY_PATH

all : run

# Compile the library
libhello_world.so : hello_world_component.cpp
c++ -o libhello_world.so hello_world_component.cpp `pkg-config --cflags --libs hpx_component` -DHPX_COMPONENT_NAME=hello_world

# Move the library to the library directory
$(MY_HPX_LIBS)/libhello_world.so: libhello_world.so
mkdir -p $(MY_HPX_LIBS)
cp libhello_world.so $(MY_HPX_LIBS)

# Create the hpx.ini file
$(HOME)/.hpx.ini:
echo "[hpx]" > $(HOME)/.hpx.ini
echo "ini_path = \$$[hpx.ini_default_path]:$(MY_HPX_LIBS)" >> $(HOME)/.hpx.ini

# Create the ini file
$(MY_HPX_LIBS)/hello_world.ini:
echo "$(MY_HPX_LIBS)/hello_world.ini" > $(MY_HPX_LIBS)/hello_world.ini
echo "[hpx.components.hello_world]" >> $(MY_HPX_LIBS)/hello_world.ini
echo "name = hello_world" >> $(MY_HPX_LIBS)/hello_world.ini
echo "path = $(MY_HPX_LIBS)" >> $(MY_HPX_LIBS)/hello_world.ini

# Compile the client
hello_world_client: hello_world_client.cpp $(MY_HPX_LIBS)/libhello_world.so
c++ -o hello_world_client hello_world_client.cpp `pkg-config --cflags --libs hpx_application` -lhpx_iostreams -lhello_world -L $(MY_HPX_LIBS)

# Run the client, first add our directory to the LD_LIBRARY_PATH
run: hello_world_client $(HOME)/.hpx.ini $(MY_HPX_LIBS)/hello_world.ini
./hello_world_client

clean:
rm -f hello_world_client libhello_world.so
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

.PHONY: all

ifeq ($(BUILD_TYPE),Debug)
hpx_application = hpx_application_debug
hpx_component = hpx_component_debug
debug_suffix = d
else
hpx_application = hpx_application
hpx_component = hpx_component
debug_suffix =
endif

APP_CFLAGS = $(CXX_FLAGS)
APP_CFLAGS += $(shell PKG_CONFIG_PATH=$(HPX_DIR) $(PKG_CONFIG) --cflags --libs $(hpx_application))
APP_CFLAGS += -lhpx_iostreams$(debug_suffix)
APP_CFLAGS += -DHPX_APPLICATION_NAME=test

COMP_CFLAGS = $(CXX_FLAGS)
COMP_CFLAGS += $(shell PKG_CONFIG_PATH=$(HPX_DIR) $(PKG_CONFIG) --cflags --libs $(hpx_component))
COMP_CFLAGS += -DHPX_COMPONENT_NAME=test_component

ifneq ($(wildcard $(HPX_DIR)/*),)
all: hello_world_client
else
all:
@echo "HPX_DIR=$(HPX_DIR) does not exist. Did you forget to run the install rule?"
endif

hello_world_client: $(SRC_DIR)/hello_world_client.cpp libhello_world_component.so
$(CXX) -o hello_world_client -I$(SRC_DIR)/ $(SRC_DIR)/hello_world_client.cpp $(APP_CFLAGS) libhello_world_component.so

libhello_world_component.so: $(SRC_DIR)/hello_world_component.cpp
$(CXX) -o libhello_world_component.so -fPIC -I$(SRC_DIR)/ $(SRC_DIR)/hello_world_component.cpp $(COMP_CFLAGS)
7 changes: 4 additions & 3 deletions tests/unit/build/CMakeLists.txt
@@ -1,4 +1,5 @@
# Copyright (c) 2014 Thomas Heller
# Copyright (c) 2018 Nikunj Gupta
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -34,7 +35,7 @@ macro(create_cmake_test name hpx_dir)
add_custom_target(${name}.make_configure
COMMAND
"${CMAKE_COMMAND}" -E chdir "${build_dir}" "${CMAKE_COMMAND}"
"${PROJECT_SOURCE_DIR}/tests/unit/build/src"
"${PROJECT_SOURCE_DIR}/examples/hello_world_component"
-DHPX_DIR=${hpx_dir}
${ADDITIONAL_CMAKE_OPTIONS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS_SAFE}
Expand Down Expand Up @@ -75,8 +76,8 @@ macro(create_pkgconfig_test name hpx_dir)
add_custom_target(${name}.make_compile
COMMAND
"${CMAKE_COMMAND}" -E chdir "${build_dir}" make
-f "${PROJECT_SOURCE_DIR}/tests/unit/build/src/Makefile"
SRC_DIR=${PROJECT_SOURCE_DIR}/tests/unit/build/src
-f "${PROJECT_SOURCE_DIR}/examples/hello_world_component/Makefile"
SRC_DIR=${PROJECT_SOURCE_DIR}/examples/hello_world_component
HPX_DIR=${hpx_dir}
CXX=${CMAKE_CXX_COMPILER}
CXX_FLAGS=${CMAKE_CXX_FLAGS_SAFE}
Expand Down
38 changes: 0 additions & 38 deletions tests/unit/build/src/Makefile

This file was deleted.

34 changes: 0 additions & 34 deletions tests/unit/build/src/test.cpp

This file was deleted.

15 changes: 0 additions & 15 deletions tests/unit/build/src/test_component.cpp

This file was deleted.

27 changes: 0 additions & 27 deletions tests/unit/build/src/test_component.hpp

This file was deleted.

0 comments on commit 75ae9db

Please sign in to comment.