美文网首页
2022-11-09 flutter下面的.pub-cache目

2022-11-09 flutter下面的.pub-cache目

作者: 我是小胡胡分胡 | 来源:发表于2022-11-08 11:03 被阅读0次

    flutter 安装目录下面的.pub-cache目录
    用户目录下面的.pub-cache目录

    这两个看着差不多

    都是存放了flutter package 什么的

    具体什么区别?
    怎么产生的?

    从flutter命令开始查。

    1、flutter命令过程

    flutter xx
    dart xxx

    source "$BIN_DIR/internal/shared.sh"
    shared::execute "$@"
    
    function upgrade_flutter () (
      mkdir -p "$FLUTTER_ROOT/bin/cache"
    
      local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)"
      local compilekey="$revision:$FLUTTER_TOOL_ARGS"
    
     
      if [[ ! -f "$SNAPSHOT_PATH" || ! -s "$STAMP_PATH" || "$(cat "$STAMP_PATH")" != "$compilekey" || "$FLUTTER_TOOLS_DIR/pubspec.yaml" -nt "$FLUTTER_TOOLS_DIR/pubspec.lock" ]]; then
        
        export PUB_ENVIRONMENT="$PUB_ENVIRONMENT:flutter_install"
        if [[ -d "$FLUTTER_ROOT/.pub-cache" ]]; then
          export PUB_CACHE="${PUB_CACHE:-"$FLUTTER_ROOT/.pub-cache"}"
        fi
    
    
    
        # Compile...
        "$DART" --verbosity=error 
        --disable-dart-dev 
    
        $FLUTTER_TOOL_ARGS 
    
        --snapshot="$SNAPSHOT_PATH" 
    
        --packages="$FLUTTER_TOOLS_DIR/.dart_tool/package_config.json" 
    
        --no-enable-mirrors "$SCRIPT_PATH"
    
        
        echo "$compilekey" > "$STAMP_PATH"
      fi 
      exit $?
    )
    
        if [[ -d "$FLUTTER_ROOT/.pub-cache" ]]; then
          export PUB_CACHE="${PUB_CACHE:-"$FLUTTER_ROOT/.pub-cache"}"
        fi
    

    搜索PUB_CACHE

    
      String? _getRootPubCacheIfAvailable() {
        if (_platform.environment.containsKey(_kPubCacheEnvironmentKey)) {
          return _platform.environment[_kPubCacheEnvironmentKey];
        }
    
        final String cachePath = _fileSystem.path.join(Cache.flutterRoot!, '.pub-cache');
        if (_fileSystem.directory(cachePath).existsSync()) {
          _logger.printTrace('Using $cachePath for the pub cache.');
          return cachePath;
        }
    
        // Use pub's default location by returning null.
        return null;
      }
    

    2,flutter 、dart命令

    function shared::execute() {
     
      BIN_NAME="$(basename "$PROG_NAME")"
      case "$BIN_NAME" in
        flutter*)
     
          exec "$DART" 
    --disable-dart-dev 
    --packages="$FLUTTER_TOOLS_DIR/.dart_tool/package_config.json" $FLUTTER_TOOL_ARGS 
    "$SNAPSHOT_PATH"
     "$@"
    
          ;;
    
    
        dart*)
          exec "$DART" "$@"
          ;;
    
    
        *)
          >&2 echo "Error! Executable name $BIN_NAME not recognized!"
          exit 1
          ;;
      esac
    }
    

    flutter --version
    dart --version
    执行的区别如下:

    
    $FLUTTERROOT/bin/cache/dart-sdk/bin/dart 
    
    --disable-dart-dev 
    
    --packages=$FLUTTERROOT/packages/flutter_tools/.dart_tool/package_config.json 
    
    $FLUTTERROOT/bin/cache/flutter_tools.snapshot 
    
    --version
    
    $FLUTTERROOT/bin/cache/dart-sdk/bin/dart --version
    
    

    dart flutter_tools.snapshot
    dart

    相关文章

      网友评论

          本文标题:2022-11-09 flutter下面的.pub-cache目

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