The Cangjie standard library can be built in Ubuntu/MacOS (x86_64, aarch64) environments. Before building, you need to set up the compilation environment. For details, please check the Build dependency tool.
Before building the standard library, you need to first build the runtime in this repository and cangjie_compiler. For detailed build instructions for runtime and cangjie_compiler, please refer to their respective project build guides.
-
Configure cjc
source <path to the source-built cjc, e.g., ..../output/envsetup.sh>
You can verify if cjc is configured successfully using the command below. If version information appears, it indicates that cjc is configured successfully.
cjc -v
-
Build Commands
Download the source code
git clone https://gitcode.com/Cangjie/cangjie_runtime.git
Enter the std directory, compile the standard library source code by executing the
build.pyscript, which supports three functions: build, clean, and install.cd std python3 build.py clean python3 build.py build -t release --target-lib=<path to runtime build output directory> --target-lib=<path to openssl lib> python3 build.py install
build.py cleancommand is used to clear temporary files in the workspace;build.py buildcommand starts the compilation:-tor--build-type,specifies the type of build artifact, which can be eitherreleaseordebug;--target-libspecifies the openssl lib directory and the output directory for runtime binary artifacts(By default, it is under runtime/output)
build.py installcommand installs the build artifacts to theoutputdirectory.--prefixspecifies the installation path (optional), by default it installs in the std/output directory
The output directory structure is as follows:
output
├── lib #std static lib
├── modules #std cjo file
└── runtime #std dynamic lib
The build functionality of build.py provides the following additional options:
--target: Specifies the build platform, defaults to native build, supported targets are shown below(For cross-compilation, please refer to Cangjie SDK Integration Build Guide):native(default value)ohos-aarch64: Cross-compile for ohos(ohos-aarch64)ohos-x86_64: Cross-compile for ohos(ohos-x86_64)windows-x86_64: Cross-compile Windows from Linux
--target-toolchain: Specifies the path to compilation tools (required for cross-compilation)--target-sysroot: Specifies the directory of target system libraries (required for cross-compilation)--build-args: cjc build options (optional)--jobs(-j): maximum number of concurrent build tasks--hwasan:Building the HWASAN version of std (for OHOS cross-compilation)--cjlib-sanitizer-support: Build sanitizer version of cangjie std library. Valid values:asan,tsanorhwasan.
The install functionality of build.py provides the following additional options:
--prefix: Specifies the installation directory--host: Specifies which target platform to install for
You can also refer to build.py or use the --help option to learn more about compilation options:
python3 build.py --help
python3 build.py build --help
python3 build.py install --help