github.com/shranet/mobile@v0.0.0-20200814083559-5702cdcd481b/internal/binres/genarsc.go (about)

     1  // Copyright 2016 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build ignore
     6  
     7  // Genarsc generates stripped down version of android.jar resources used
     8  // for validation of manifest entries.
     9  //
    10  // Requires ANDROID_HOME be set to the path of the Android SDK and the
    11  // current sdk platform installed that matches MinSDK.
    12  package main
    13  
    14  import (
    15  	"fmt"
    16  	"io/ioutil"
    17  	"log"
    18  	"strconv"
    19  
    20  	"github.com/shranet/mobile/internal/binres"
    21  )
    22  
    23  const tmpl = `// Copyright 2016 The Go Authors.  All rights reserved.
    24  // Use of this source code is governed by a BSD-style
    25  // license that can be found in the LICENSE file.
    26  
    27  // Code generated by genarsc.go. DO NOT EDIT.
    28  
    29  package binres
    30  
    31  var arsc = []byte(%s)`
    32  
    33  func main() {
    34  	arsc, err := binres.PackResources()
    35  	if err != nil {
    36  		log.Fatal(err)
    37  	}
    38  	if err := ioutil.WriteFile("arsc.go", []byte(fmt.Sprintf(tmpl, strconv.Quote(string(arsc)))), 0644); err != nil {
    39  		log.Fatal(err)
    40  	}
    41  }