目录

How to install cangjie on Linux mint 22.1

概述

仓颉编程语言是一款面向全场景智能的新一代编程语言,主打原生智能化、天生全场景、高性能、强安全。主要应用于鸿蒙原生应用及服务应用等场景中,为开发者提供良好的编程体验。

今天,我们介绍一下仓颉语言在Linux mint 22.1上的安装。

下载

考虑到截止目前为止还没有一个可用的长期稳定版本,所以,我们这里下载半年更新版。

对于PC电脑来说,目前基本上都是x64架构,也称为AMD64架构,所以,我们选择下载Cangjie-0.53.18-linux_x64.tar.gz

解压

下载结束以后,我们将其解压到用户目录下的目录.cangjie中。

bash 复制代码
tar -zxvf Cangjie-0.53.18-linux_x64.tar.gz
mv cangjie ~/.cangjie

配置

解压后的目录结构如下:

bash 复制代码
lwk@qwfys:~$ ll .cangjie/
total 48
drwxr-x---  8 lwk lwk 4096 Mar 16 18:10 ./
drwxr-x--- 38 lwk lwk 4096 Mar 16 18:30 ../
drwxr-x---  2 lwk lwk 4096 Feb 28  2023 bin/
-rwxr-x---  1 lwk lwk 1458 Feb 28  2023 envsetup.sh*
drwxr-x---  4 lwk lwk 4096 Feb 28  2023 lib/
drwxr-x---  4 lwk lwk 4096 Feb 28  2023 modules/
-rwxr-x---  1 lwk lwk 9078 Feb 28  2023 README.md*
drwxr-x---  3 lwk lwk 4096 Feb 28  2023 runtime/
drwxr-x---  4 lwk lwk 4096 Feb 28  2023 third_party/
drwxr-x---  5 lwk lwk 4096 Feb 28  2023 tools/
lwk@qwfys:~$

envsetup.sh是一个环境变量初始化脚本,执行命令

bash 复制代码
source ~/.cangjie/envsetup.sh

以后,在当前会话中,就可以正常使用仓颉的命令行工具了。

为方便每次登录账号以后,系统都能自动帮我们完成仓颉语言环境变量的初始化工作,我们其添加到用户目录的.bashrc文件的末尾。命令如下:

bash 复制代码
tee -a ~/.bashrc <<-EOF
export CANGJIE_DIR="$HOME/.cangjie"
[[ -s "$HOME/.cangjie/envsetup.sh" ]] && source "$HOME/.cangjie/envsetup.sh"
EOF

查看

通过上述配置,我们退出当前账号,重新登录一次,就可以正常使用了。

cjc

查看一下cjc命令是否可以正常使用。

bash 复制代码
lwk@qwfys:~$ cjc --help
Usage:
      cjc [option] file...

Options:
  --diagnostic-format <value> Diagnostic format. Candidate modes: 
    <value>=json                
    <value>=noColor             
    <value>=default             
  --scan-dependency           Get the package(s) which the current package depends on
  --no-sub-pkg                The package doesn't have sub-packages
  --cfg <value>               User defined contion to compile
  --debug-macro               Enable debug macro
  --parallel-macro-expansion  Enable parallel macro expansion
  -g                          Enable compile debug version target
  --trimpath <value>          Remove a specified path prefix in debuginfo
  -s, --strip-all             Strip the symbol table from executable and dynamic library
  --test                      Enable compile test
  --mock <value>              Specify whether mock features are enabled, or disabled, or a runtime exception is thrown when trying to use mock features
    <value>=on                  
    <value>=off                 
    <value>=runtime-error       
  -o, --output <value>        Specify product name or output directory when compiling a package
  --output-dir <value>        Specify output directory (it affects '--output' option)
  --static-std                Statically link packages of the std module
  --dy-std                    Dynamically link packages of the std module
  --static-libs               Statically link packages of other modules except std
  --dy-libs                   Dynamically link packages of other modules except std
  --lto <value>               Enable LTO to either 'full' or 'thin' (Not available for Windows target)
    <value>=full                
    <value>=thin                
  --profile-compile-time      Print time spent of all phases in the compilation
  --profile-compile-memory    Print memory usage of all phases in the compilation
  --fchir-constant-propagation
                              Enable constant propagation optimizaion in CHIR
  --fno-chir-constant-propagation
                              Disable constant propagation optimizaion in CHIR
  --fchir-function-inlining   Enable function inlining optimizaion in CHIR
  --fno-chir-function-inlining
                              Disable function inlining optimizaion in CHIR
  --fchir-devirtualization    Enable devirtualization optimizaion in CHIR
  --fno-chir-devirtualization Disable devirtualization optimizaion in CHIR
  --sanitizer-coverage-inline-8bit-counters
                              Enable sanitizer-coverage-inline-8bit-counters in CHIR
  --sanitizer-coverage-inline-bool-flag
                              Enable sanitizer-coverage-inline-bool-flag in CHIR
  --sanitizer-coverage-trace-pc-guard
                              Enable sanitizer-coverage-trace-pc-guard in CHIR
  --sanitizer-coverage-pc-table
                              Enable sanitizer-coverage-pc-table in CHIR
  --sanitizer-coverage-stack-depth
                              Enable sanitizer-coverage-stack-depth in CHIR
  --sanitizer-coverage-trace-compares
                              Enable sanitizer-coverage-trace-compares in CHIR
  --sanitizer-coverage-trace-memcmp
                              Enable sanitizer-coverage-trace-memcmp in CHIR
  --sanitizer-coverage-level=0
                              sancov level 0
  --sanitizer-coverage-level=1
                              sancov level 1
  --sanitizer-coverage-level=2
                              sancov level 2
  --sanitizer-coverage-level <value>
                              Set sanitizer-coverage level
  --int-overflow <value>      Specify default integer overflow strategy: 
    <value>=throwing            
    <value>=wrapping            
    <value>=saturating          
  --fast-math                 Enable fast-math mode
  --link-options <value>      Options directly passed to linker
  -L, --library-path <value>  Add directory to library search path
  -l, --library <value>       Link library
  -B, --toolchain <value>     Use toolchain binaries and object files at the given directory
  --target <value>            Generate code for the given target platform
  --target-cpu <value>        Generate instructions for the given target processor (Experimental)
  --sysroot <value>           Set the system root directory under which bin, lib and include can be found
  --output-type <value>       Specify output file type
    <value>=exe                 emit executable (default)
    <value>=staticlib           emit static library
    <value>=dylib               emit dynamic library
  -O0                         Optimization level 0 (default)
  -O, -O1                     Optimization level 1
  -O2                         Optimization level 2
  -Os                         Optimization level s, like -O2 with extra optimizations for size
  -Oz                         Optimization level z, like -Os but reduces code size further
  -O<value>                   Set Optimization level
  --module-name <value>       Tell compiler name of the module
  -p, --package               Specify package directory to be compiled
  --import-path <value>       Add .cjo search path
  --incremental-compile       Enable incremental compilation.
  --save-temps <value>        Save intermediate compilation results. <value>: path to save temp files.
  -Woff, --warn-off <value>   Suppress a specific group of warning
    <value>=all                 
    <value>=unused              
    <value>=driver-arg          
    <value>=deprecated          
    <value>=unsupport-compile-source  
    <value>=package-import      
    <value>=parser              
    <value>=semantics           
    <value>=interpreter         
  -Won, --warn-on <value>     Report a specific group of warning
    <value>=all                 
    <value>=unused              
    <value>=driver-arg          
    <value>=deprecated          
    <value>=unsupport-compile-source  
    <value>=package-import      
    <value>=parser              
    <value>=semantics           
    <value>=interpreter         
  --error-count-limit <value> Emit specified <number> of errors only. Available options: all, <number> (8 by default)
  -V, --verbose               Enable verbose
  -v, --version               Print compiler version information 
  -h, --help                  Show usage
  --compile-macro             Options to compile the macro define package
  --coverage                  Enable coverage
  --experimental              Enable experimental options
  -j, --jobs <value>          Number of tasks to run at once
  --apc, --aggressive-parallel-compile
                              Enable agrressive parallel compile
  --fobf-string               Enable string literal obfuscation
  --fno-obf-string            Disable string literal obfuscation
  --fobf-const                Enable constant literal obfuscation
  --fno-obf-const             Disable constant literal obfuscation
  --fobf-layout               Enable code layout obfuscation
  --fno-obf-layout            Disable code layout obfuscation
  --fobf-cf-flatten           Enable control flow flatten obfuscation
  --fno-obf-cf-flatten        Disable control flow flatten obfuscation
  --fobf-cf-bogus             Enable control flow bogus obfuscation
  --fno-obf-cf-bogus          Disable control flow bogus obfuscation
  --fobf-all                  Enable all obfuscations
  --fobf-export-symbols       Obfuscate export symbols when layout obfuscation is enabled
  --fno-obf-export-symbols    Don't obfuscate export symbols when layout obfuscation is enabled
  --obf-sym-input-mapping <value>
                              Specify the input files of symbol mapping for layout obfuscation
  --obf-sym-output-mapping <value>
                              Specify the output file of symbol mapping for layout obfuscation
  --obf-apply-mapping-file <value>
                              Supply user-defined symbol mapping file for layout obfuscation
  --obf-sym-prefix <value>    Specify the prefix of obfuscated symbols for layout obfuscation
  --fobf-source-path          Obfuscate source path of symbols when layout obfuscation is enabled
  --fno-obf-source-path       Don't obfuscate source path of symbols when layout obfuscation is enabled
  --fobf-line-number          Obfuscate line number of symbols when layout obfuscation is enabled
  --fno-obf-line-number       Don't obfuscate line number of symbols when layout obfuscation is enabled
  --obf-config <value>        Specify obfuscation configure file
  --obf-level <value>         Specify obfuscation level. Available value: 1 to 10 (5 by default)
  --obf-seed <value>          Specify random seed for obfuscation algorithm. Available value: <number>
  --disable-reflection        Disable reflection
  --stack-trace-format <value>
                              Specify stack trace format
    <value>=default             
    <value>=simple              
    <value>=all                 
  --pgo-instr-gen             PGO instrumentation
  --pgo-instr-use <value>     Read PGO instrumentation profile
  --discard-eh-frame          Discard the eh_frame section
lwk@qwfys:~$
bash 复制代码
lwk@qwfys:~$ cjpm --help
Cangjie Package Manager

Usage:
  cjpm [subcommand] [option]

Available subcommands:
  init             Init a new cangjie module
  check            Check the dependencies
  update           Update cjpm.lock
  tree             Display the package dependencies in the source code
  build            Compile the current module
  run              Compile and run an executable product
  test             Unittest a local package or module
  clean            Clean up the target directory
  install          Install a cangjie binary
  uninstall        Uninstall a cangjie binary

Available options:
  -h, --help       help for cjpm
  -v, --version    version for cjpm

Use "cjpm [subcommand] --help" for more information about a command.
lwk@qwfys:~$

cjpm

我们再来查看一下命令cjpm是否可以正常使用:

bash 复制代码
lwk@qwfys:~$ cjpm --help
Cangjie Package Manager

Usage:
  cjpm [subcommand] [option]

Available subcommands:
  init             Init a new cangjie module
  check            Check the dependencies
  update           Update cjpm.lock
  tree             Display the package dependencies in the source code
  build            Compile the current module
  run              Compile and run an executable product
  test             Unittest a local package or module
  clean            Clean up the target directory
  install          Install a cangjie binary
  uninstall        Uninstall a cangjie binary

Available options:
  -h, --help       help for cjpm
  -v, --version    version for cjpm

Use "cjpm [subcommand] --help" for more information about a command.
lwk@qwfys:~$

小结

今天我们带领大家完成了仓颉语言运行时环境的在Linux mint 22.1上的安装。以下几点,大家需要着重注意:

  • 版本

从实践角度来说,我们在生产环境始终需要注意的就是安装长期维护版,即LTS。由于截止目前为止,LTS还没有发布,所以这时暂且安装半年维护版。

  • cjpm

仓颉语言提供了仓颉包管理工具cjpm,日后,关于仓颉包管理就可以借助它管理起来。这个包管理工具日后与npm、pip、canda是类似的。

本文是转载文章,点击查看原文
如有侵权,请联系 xyy@jishuzhan.net 删除
相关推荐
New_Teen3 分钟前
正则表达式小结
linux·笔记·学习·正则表达式
可问 可问春风4 小时前
Linux 找回 Root 密码(多发行版本)
linux·运维·chrome
木子欢儿6 小时前
Debian系统清理垃圾
linux·运维·服务器·debian
谷晓光6 小时前
python中print函数的flush如何使用
linux·服务器·数据库
Hacker_Albert6 小时前
Linux 内核模块签名
linux
AdrichPro7 小时前
4、linux c 进程
linux·运维·服务器·c语言
2301_779503769 小时前
K8s的部署
linux·容器·kubernetes
why—空空9 小时前
linux系统CentOS 7版本搭建NFS共享存储
linux·运维·centos
不甘平凡--liang10 小时前
Linux Nginx安装部署、注册服务
linux·运维·服务器
小妖66611 小时前
linux (centos) 的 nodejs 安装全局包后使用命令无效
linux·运维·centos