美文网首页
2021-11-05 dart-sdk编译与调试

2021-11-05 dart-sdk编译与调试

作者: 我是小胡胡分胡 | 来源:发表于2021-11-05 11:36 被阅读0次

    1,获取代码

    mkdir dart-sdk
    cd dart-sdk
    fetch dart
    

    使用fetch dart命令会在目录下生成.gclient文件:

    solutions = [
      {
        "name": "sdk",
        "url": "https://dart.googlesource.com/sdk.git",
        "deps_file": "DEPS",
        "managed": False,
        "custom_deps": {},
      },
    ]
    

    疑惑:与flutter engine 构建时候通过gclient sync同步的dart sdk有什么区别?

    flutter engine构建时用gclient sync下载的dart sdk依赖与fetch dart获取有不同,缺少buildtools/gn,通过下面可以验证:

    拷贝/Volumes/huc/dartvm/flutter_engine/src/third_party/dart到/Volumes/huc/dartvm/dart-sdk-copy/sdk,目录名改为sdk
    cd 到sdk执行编译命令

    huchu58:sdk huchu$ ./tools/build.py --no-goma --mode release --arch x64 create_sdk
    Traceback (most recent call last):
      File "/Volumes/huc/dartvm/dart-sdk-copy/sdk/./tools/build.py", line 308, in <module>
        sys.exit(Main())
      File "/Volumes/huc/dartvm/dart-sdk-copy/sdk/./tools/build.py", line 257, in Main
        gn_py.RunGnOnConfiguredConfigurations(options)
      File "/Volumes/huc/dartvm/dart-sdk-copy/sdk/tools/gn.py", line 582, in RunGnOnConfiguredConfigurations
        BuildGnCommand(args, mode, arch, target_os, sanitizer,
      File "/Volumes/huc/dartvm/dart-sdk-copy/sdk/tools/gn.py", line 556, in BuildGnCommand
        raise Exception("Couldn't find the gn binary at path: " + gn)
    Exception: Couldn't find the gn binary at path: /Volumes/huc/dartvm/dart-sdk-copy/sdk/buildtools/gn
    

    可以看到,直接从dart sdk下载的源代码是没有build相关的资源配置文件的。是无法准备编译的。

    2,编译

    构建64位

    cd sdk
    ./tools/build.py --no-goma --mode release --arch x64 create_sdk
    

    构建arm64

    ./tools/build.py --no-goma -m release -a arm64 -t  create_sdk
    

    构建vm

    ./tools/build.py --no-goma -m release -a arm64 runtime
    

    疑惑:与flutter engine 构建时候通过 --no-prebuilt-dart-sdk指定编译dart sdk,./flutter/tools/gn --unoptimized --no-prebuilt-dart-sdk编译的dart sdk有什么区别?

    3,测试

    测试之前构建的内容:

     ./tools/build.py --no-goma --mode release --arch arm64
    

    4,有什么用

    输出在

    out/ReleaseX64/dart-sdk
    

    相关文章

      网友评论

          本文标题:2021-11-05 dart-sdk编译与调试

          本文链接:https://www.haomeiwen.com/subject/dutrzltx.html