refactor: update project
- add documentation CMake build script. re-organise document layout for future changes. - move LIBCMO_EXPORT to BMap and rename it to BMAP_EXPORT because only BMap need to use this macro. - fully refactor VTEncoding to make it more like Python - Now language name is platform independent. - Hide implementation detail as possible as I can. - Language mapping are still work in progress. - add code gen for new added universal encoding feature to generate language name mapping in Windows and Iconv respectively. - remove old code of CMake build script. - update VTUtils for new requirement. - remove useless functions. - create LibCmo specific custom exception classes.
This commit is contained in:
38
Scripts/win_build.bat
Normal file
38
Scripts/win_build.bat
Normal file
@ -0,0 +1,38 @@
|
||||
@ECHO OFF
|
||||
:: Check environment
|
||||
SET README_PATH=%CD%\README.md
|
||||
IF EXIST %README_PATH% (
|
||||
REM DO NOTHING
|
||||
) ELSE (
|
||||
ECHO Error: You must run this script at the root folder of this project!
|
||||
EXIT /b
|
||||
)
|
||||
|
||||
:: Create main binary directory
|
||||
MKDIR bin
|
||||
CD bin
|
||||
:: Create build and install folder
|
||||
MKDIR build
|
||||
MKDIR install
|
||||
|
||||
:: Check build doc switch
|
||||
IF NOT "%1"=="NODOC" (
|
||||
SET BUILD_DOC_SWITCH=ON
|
||||
) ELSE (
|
||||
SET BUILD_DOC_SWITCH=OFF
|
||||
)
|
||||
|
||||
:: Build project
|
||||
CD build
|
||||
cmake -G "Visual Studio 16 2019" -A x64 -DNEMO_BUILD_UNVIRT=ON -DNEMO_BUILD_BMAP=ON -DNEMO_BUILD_DOC=%BUILD_DOC_SWITCH% -DSTB_IMAGE_PATH="D:\CppLib\stb" -DYYCC_PATH="J:\YYCCommonplace\bin\cpp20\install\x64_Debug" -DZLIB_HEADER_PATH="D:\zlib" -DZLIB_BINARY_PATH="D:\zlib\contrib\vstudio\vc14\x64\ZlibDllRelease" ../..
|
||||
pause
|
||||
cmake --build . --config Release
|
||||
IF NOT "%1"=="NODOC" (
|
||||
cmake --build . --target NeMoDocuments
|
||||
)
|
||||
cmake --install . --prefix=../install --config Release
|
||||
CD ..
|
||||
|
||||
:: Exit to original path
|
||||
CD ..
|
||||
ECHO Windows CMake Build Done
|
48
Scripts/win_build.py
Normal file
48
Scripts/win_build.py
Normal file
@ -0,0 +1,48 @@
|
||||
import subprocess
|
||||
import os
|
||||
import shutil
|
||||
import argparse
|
||||
|
||||
def get_root_directory() -> str:
|
||||
return os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
def execute_cmd(prog: str, args: tuple[str, ...], cwd: str) -> None:
|
||||
# find program first
|
||||
found_prog = shutil.which(prog)
|
||||
if found_prog is None:
|
||||
raise RuntimeError(f'Fail to find program {prog}')
|
||||
# run command
|
||||
subprocess.run(
|
||||
list((found_prog, ) + args), # program + arguments
|
||||
stdin=subprocess.PIPE, # redirect
|
||||
stdout=subprocess.PIPE, # redirect
|
||||
stderr=subprocess.STDOUT, # stderr use the same output with stdout
|
||||
cwd=cwd, # work directory
|
||||
shell=True, # enable shell feature
|
||||
check=True, # if program failed, raise exception and exit
|
||||
)
|
||||
|
||||
def build(no_doc: bool) -> None:
|
||||
# create directory
|
||||
root_dir: str = get_root_directory()
|
||||
os.makedirs(os.path.join(root_dir, 'Bin', 'build'))
|
||||
os.makedirs(os.path.join(root_dir, 'Bin', 'install'))
|
||||
|
||||
# build project
|
||||
args = [
|
||||
''
|
||||
]
|
||||
|
||||
if __name__ == '__main__':
|
||||
# parse argument
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='LibCmo Windows Build Script',
|
||||
description='LibCmo Windows Build Script'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-d', '--no-doc',
|
||||
action='store_true', dest='no_doc',
|
||||
help='Build LibCmo without documentation.'
|
||||
)
|
||||
args = parser.parse_args()
|
||||
build(args.no_doc)
|
Reference in New Issue
Block a user