Skip to content

Commit

Permalink
Tích hợp cgen vào trong cgraph
Browse files Browse the repository at this point in the history
  • Loading branch information
bangoc committed Sep 29, 2022
1 parent c3f3278 commit 7636235
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 12 deletions.
26 changes: 20 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ if (${CMAKE_PROJECT_NAME} STREQUAL cgraph)
include(CTest)
endif()

add_library(bkcgraph STATIC cgraph.c)
target_link_libraries(bkcgraph bkcgen)
add_library(bkcgraph STATIC cgraph.c cgen/all.c)

if(${BUILD_TESTING})
add_subdirectory(tests)
Expand Down Expand Up @@ -63,16 +62,28 @@ endif()

if (${CMAKE_BUILD_TYPE} STREQUAL Release AND
${CMAKE_PROJECT_NAME} STREQUAL cgraph)
set(cgraph_include_dest "include")
set(cgraph_lib_dest "lib")
# Hợp nhất các tệp
set(MERGE_CMD ${CMAKE_CURRENT_BINARY_DIR}/cgen/mega-unit/merge)
MESSAGE(STATUS "MERGE CMD: " ${MERGE_CMD})
execute_process(COMMAND ${MERGE_CMD}
${CMAKE_CURRENT_SOURCE_DIR} cgraph.h bkcgraph.h
${CMAKE_CURRENT_SOURCE_DIR}/cgen all.h bkcgen.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${MERGE_CMD}
${CMAKE_CURRENT_SOURCE_DIR} cgraph.h __bkcgraph.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
set(lines "#include \"bkcgen.h\"\n"
"#include \"__bkcgraph.h\"")
write_file(${CMAKE_CURRENT_BINARY_DIR}/__bkc.h ${lines})
execute_process(COMMAND ${MERGE_CMD}
${CMAKE_CURRENT_BINARY_DIR} __bkc.h bkcgraph.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${MERGE_CMD}
${CMAKE_CURRENT_SOURCE_DIR} cgraph.c bkcgraph.c
${CMAKE_CURRENT_SOURCE_DIR} cgraph.c bkcgraph.c
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

# Đóng gói
set(cgraph_include_dest "include")
set(cgraph_lib_dest "lib")
MESSAGE(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bkcgraph.h DESTINATION "${cgraph_include_dest}")
install(TARGETS bkcgraph DESTINATION "${cgraph_lib_dest}")
Expand All @@ -96,6 +107,9 @@ if (${CMAKE_BUILD_TYPE} STREQUAL Release AND
# To build a debian package
# cmake .. -DCMAKE_BUILD_TYPE=Release
# make -j 2
#
# Chạy lại cmake để hợp nhất tệp
# cmake .. -DCMAKE_BUILD_TYPE=Release
# make package
#
# To install the debian package
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.5
1.1.6
2 changes: 1 addition & 1 deletion cgen
Submodule cgen updated 2 files
+1 −1 VERSION
+9 −2 mega-unit/merge.c
2 changes: 0 additions & 2 deletions cgraph.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef CGRAPH_H_
#define CGRAPH_H_

#include "cgen/base/gtype.h"
#include "cgen/vec/arr.h"
#include "base/cgraph_datatype.h"
#include "base/cgraph_arr.h"
#include "base/cgraph_constants.h"
Expand Down
2 changes: 1 addition & 1 deletion examples/system/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
add_executable(bkcgraph_demo bkcgraph_demo.c)
target_link_libraries(bkcgraph_demo bkcgraph bkcgen)
target_link_libraries(bkcgraph_demo bkcgraph)
3 changes: 2 additions & 1 deletion examples/system/bkcgraph_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

/** @file
* @brief Thử nghiệm sử dụng thư viện bkcgraph ở cấu hình hệ thống.
* Không cần chèn bkcgen bởi vì bkcgen.h đã được đưa vào bkcgraph.h
* để đảm bảo tính tương thích.
*/

#include <bkcgen.h>
#include <bkcgraph.h>

int main() {
Expand Down

0 comments on commit 7636235

Please sign in to comment.