When I do a "bii cpp:build", I want bii to first build block B, and then it must call the binary produced by block B with some parameters, and when the binary completes, bii should proceed to build block A. I don't want block A to #include anything from block B. Essentially I want to use the output of block B in a cmake add_custom_command during the build process of block A. How can this be achieved?
Asked
Active
Viewed 180 times
2
-
One question: Is the output of binary B source code that biicode should process in block A? Or will you manage yourself with the custom command? You should also take into account that if B is in "deps", it typically only retrieve things depended on (#includes). Probably the best way is to wrap the binary creation and execution in a .cmake file at B, then INCLUDE() such .cmake in your A block CMakeLists.txt. Could you please give more details about the use case of such binary, and how you pretend to "reuse" it? – drodri Jan 18 '15 at 20:40
-
I like your suggestion @drodri, I'll give it a try. The binary produced by block B will be a tool that I intend to use to prepare the environment path variable for successive builds. The tool will read some user-defined settings in a configuration file, or it will determine settings based on the environment. For instance, if the ~/.emscripten file exists, then it will read it and prepare the environment based on the settings in there. I suspect that I should rather look for a pure CMake approach. Other uses of the block B binary, could be to generate html from markdown and similar tasks. – W1M0R Jan 20 '15 at 07:47
-
@drodri, the output of binary B is not source code at the moment, but it may generate code to be used by block A at some point in the future. – W1M0R Jan 20 '15 at 07:51
1 Answers
0
At the momment, "bii" only lets to build at the same compilation time all the blocks inside a project, but you could use a trick, executing, by hand, a modified root CMakeLists.txt.
I assume that your project layout look like this:
your_project
|- bii
|- blocks
|- build
|- cmake
| |- CMakeLists.txt # root CMakeLists.txt
|- deps
Then you should modify that CMakeLists.txt:
Original code
PROJECT( my_project )
cmake_minimum_required(VERSION 3.0)
# inclusion of general biicode macros, biicode.cmake
set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake"
"${CMAKE_HOME_DIRECTORY}/../blocks"
"${CMAKE_HOME_DIRECTORY}/../deps")
INCLUDE(biicode.cmake)
ADD_DEFINITIONS(-DBIICODE)
SET(BIICODE_ENV_DIR C:/Users/Usuario/.biicode)
#artifact to allow upstream configurations
BII_PREBUILD_STEP(blocks/fenix/blockA)
BII_PREBUILD_STEP(blocks/fenix/blockB)
enable_testing()
# Inclusion of the blocks affected by the build
BII_INCLUDE_BLOCK(blocks/fenix/blockA)
BII_INCLUDE_BLOCK(blocks/fenix/blockB)
Replace it by this one:
New code
PROJECT( my_project )
cmake_minimum_required(VERSION 3.0)
# inclusion of general biicode macros, biicode.cmake
set(CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/cmake"
"${CMAKE_HOME_DIRECTORY}/../blocks"
"${CMAKE_HOME_DIRECTORY}/../deps")
INCLUDE(biicode.cmake)
ADD_DEFINITIONS(-DBIICODE)
SET(BIICODE_ENV_DIR C:/Users/Usuario/.biicode)
enable_testing()
IF(BUILD_BLOCK_A)
BII_PREBUILD_STEP(blocks/fenix/blockA)
BII_INCLUDE_BLOCK(blocks/fenix/blockA)
ELSEIF(BUILD_BLOCK_B)
BII_PREBUILD_STEP(blocks/fenix/blockB)
BII_INCLUDE_BLOCK(blocks/fenix/blockB)
ENDIF()
So, delete the your_project/build folder, create a new empty one and execute (my OS is Windows and I'm using "MinGW Makefiles" generator):
your_project$ cd build
your_project/build$ cmake -G "MinGW Makefiles" -DBUILD_BLOCK_B=1 ../cmake
your_project/build$ cmake --build .
your_project/build$ ../bin/your_blockB_executable -your_additional_flags
Then, delete and create it again and build the following blockA:
your_project/build$ cmake -G "MinGW Makefiles" -DBUILD_BLOCK_A=1 ../cmake
your_project/build$ cmake --build .
your_project/build$ ../bin/your_blockA_executable
I hope it helps you! ;)

fenix688
- 2,435
- 2
- 17
- 23
-
Be careful, every bii clean will remove your cmake folder, everything that is there is considered temporary – drodri Jan 18 '15 at 20:37