Update CMakeLists to autogen yunq files.
This commit is contained in:
parent
0dbafbfa66
commit
c8dcc07d7d
|
@ -12,6 +12,41 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS True)
|
||||||
set(BASE_COMPILE_FLAGS "-ffreestanding -fno-rtti -fno-exceptions -mgeneral-regs-only")
|
set(BASE_COMPILE_FLAGS "-ffreestanding -fno-rtti -fno-exceptions -mgeneral-regs-only")
|
||||||
set(BASE_LINK_FLAGS "-nostdlib")
|
set(BASE_LINK_FLAGS "-nostdlib")
|
||||||
|
|
||||||
|
set(PYTHON "${CMAKE_SOURCE_DIR}/yunq/venv/bin/python")
|
||||||
|
set(YUNQ "${CMAKE_SOURCE_DIR}/yunq/yunq.py")
|
||||||
|
|
||||||
|
macro(yunq_gen dir include_dir name)
|
||||||
|
set(file_bundle ${name}_yunq_files)
|
||||||
|
set(target ${name}_yunq)
|
||||||
|
set(${file_bundle}
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${name}.yunq.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${name}.yunq.client.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${name}.yunq.server.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(${target}
|
||||||
|
${${file_bundle}}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${target}
|
||||||
|
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${include_dir}"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${target}
|
||||||
|
mammoth
|
||||||
|
)
|
||||||
|
set_target_properties(${target} PROPERTIES
|
||||||
|
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}"
|
||||||
|
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${${file_bundle}}
|
||||||
|
COMMAND ${PYTHON} ${YUNQ} ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${name}.yunq
|
||||||
|
DEPENDS ${dir}/${name}.yunq
|
||||||
|
)
|
||||||
|
endmacro()
|
||||||
|
|
||||||
add_subdirectory(zion)
|
add_subdirectory(zion)
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
add_subdirectory(sys)
|
add_subdirectory(sys)
|
||||||
|
|
|
@ -22,20 +22,4 @@ set_target_properties(denali PROPERTIES
|
||||||
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(denali_yunq
|
yunq_gen(lib/denali lib denali)
|
||||||
lib/denali/denali.yunq.client.cpp
|
|
||||||
lib/denali/denali.yunq.server.cpp
|
|
||||||
lib/denali/denali.yunq.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(denali_yunq
|
|
||||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
|
||||||
|
|
||||||
target_link_libraries(denali_yunq
|
|
||||||
mammoth)
|
|
||||||
|
|
||||||
set_target_properties(denali_yunq PROPERTIES
|
|
||||||
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}"
|
|
||||||
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
|
||||||
)
|
|
||||||
|
|
|
@ -20,21 +20,5 @@ set_target_properties(yellowstone PROPERTIES
|
||||||
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
yunq_gen(lib/yellowstone lib yellowstone)
|
||||||
|
|
||||||
add_library(yellowstone_yunq
|
|
||||||
lib/yellowstone/yellowstone.yunq.cpp
|
|
||||||
lib/yellowstone/yellowstone.yunq.client.cpp
|
|
||||||
lib/yellowstone/yellowstone.yunq.server.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(yellowstone_yunq
|
|
||||||
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/lib")
|
|
||||||
|
|
||||||
target_link_libraries(yellowstone_yunq
|
|
||||||
mammoth
|
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties(yellowstone_yunq PROPERTIES
|
|
||||||
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}"
|
|
||||||
LINK_FLAGS "${CMAKE_EXE_LINK_FLAGS} ${BASE_LINK_FLAGS}"
|
|
||||||
)
|
|
||||||
|
|
11
yunq/yunq.py
11
yunq/yunq.py
|
@ -12,6 +12,7 @@ def main():
|
||||||
sys.exit("Takes name of file.")
|
sys.exit("Takes name of file.")
|
||||||
|
|
||||||
filename = sys.argv[1]
|
filename = sys.argv[1]
|
||||||
|
filebase = os.path.basename(filename)
|
||||||
|
|
||||||
ast = None
|
ast = None
|
||||||
with open(filename, mode='r') as f:
|
with open(filename, mode='r') as f:
|
||||||
|
@ -35,27 +36,27 @@ def main():
|
||||||
message_impl_tmpl = jinja_env.get_template("message.cpp.jinja")
|
message_impl_tmpl = jinja_env.get_template("message.cpp.jinja")
|
||||||
message_impl_tmpl.globals['Type'] = Type
|
message_impl_tmpl.globals['Type'] = Type
|
||||||
with open(filename + '.cpp', mode='w') as f:
|
with open(filename + '.cpp', mode='w') as f:
|
||||||
message_impl = message_impl_tmpl.render(file=filename, messages=messages)
|
message_impl = message_impl_tmpl.render(file=filebase, messages=messages)
|
||||||
f.write(message_impl)
|
f.write(message_impl)
|
||||||
|
|
||||||
client_header_tmpl = jinja_env.get_template("client.h.jinja")
|
client_header_tmpl = jinja_env.get_template("client.h.jinja")
|
||||||
with open(filename + '.client.h', mode='w') as f:
|
with open(filename + '.client.h', mode='w') as f:
|
||||||
client_header = client_header_tmpl.render(file=filename, interfaces=interfaces)
|
client_header = client_header_tmpl.render(file=filebase, interfaces=interfaces)
|
||||||
f.write(client_header)
|
f.write(client_header)
|
||||||
|
|
||||||
client_impl_tmpl = jinja_env.get_template("client.cpp.jinja")
|
client_impl_tmpl = jinja_env.get_template("client.cpp.jinja")
|
||||||
with open(filename + '.client.cpp', mode='w') as f:
|
with open(filename + '.client.cpp', mode='w') as f:
|
||||||
client_impl = client_impl_tmpl.render(file=filename, interfaces=interfaces)
|
client_impl = client_impl_tmpl.render(file=filebase, interfaces=interfaces)
|
||||||
f.write(client_impl)
|
f.write(client_impl)
|
||||||
|
|
||||||
server_header_tmpl = jinja_env.get_template("server.h.jinja")
|
server_header_tmpl = jinja_env.get_template("server.h.jinja")
|
||||||
with open(filename + '.server.h', mode='w') as f:
|
with open(filename + '.server.h', mode='w') as f:
|
||||||
server_header = server_header_tmpl.render(file=filename, interfaces=interfaces)
|
server_header = server_header_tmpl.render(file=filebase, interfaces=interfaces)
|
||||||
f.write(server_header)
|
f.write(server_header)
|
||||||
|
|
||||||
server_impl_tmpl = jinja_env.get_template("server.cpp.jinja")
|
server_impl_tmpl = jinja_env.get_template("server.cpp.jinja")
|
||||||
with open(filename + '.server.cpp', mode='w') as f:
|
with open(filename + '.server.cpp', mode='w') as f:
|
||||||
server_impl = server_impl_tmpl.render(file=filename, interfaces=interfaces)
|
server_impl = server_impl_tmpl.render(file=filebase, interfaces=interfaces)
|
||||||
f.write(server_impl)
|
f.write(server_impl)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in New Issue