Files
llgo/cmd/internal/install/install.go

62 lines
1.6 KiB
Go
Raw Normal View History

2023-12-11 09:53:40 +08:00
/*
2024-04-24 07:55:51 +08:00
* Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved.
2023-12-11 09:53:40 +08:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2024-04-25 01:41:44 +08:00
// Package install implements the "llgo install" command.
2024-04-24 07:55:51 +08:00
package install
2023-12-11 09:53:40 +08:00
2024-04-23 00:47:38 +08:00
import (
"fmt"
"os"
2025-04-03 15:52:18 +08:00
"github.com/goplus/llgo/cmd/internal/base"
2025-04-18 12:54:04 +08:00
"github.com/goplus/llgo/cmd/internal/flags"
2025-04-03 15:52:18 +08:00
"github.com/goplus/llgo/internal/build"
"github.com/goplus/llgo/internal/mockable"
2024-04-23 00:47:38 +08:00
)
2024-04-24 07:55:51 +08:00
// llgo install
var Cmd = &base.Command{
UsageLine: "llgo install [build flags] [packages]",
Short: "Compile and install packages and dependencies",
2023-12-11 09:53:40 +08:00
}
2024-04-24 07:55:51 +08:00
func init() {
Cmd.Run = runCmd
2025-09-06 22:25:00 +08:00
flags.AddCommonFlags(&Cmd.Flag)
2025-04-18 12:54:04 +08:00
flags.AddBuildFlags(&Cmd.Flag)
flags.AddEmbeddedFlags(&Cmd.Flag)
2024-04-23 00:47:38 +08:00
}
2024-04-24 07:55:51 +08:00
func runCmd(cmd *base.Command, args []string) {
2025-05-10 07:15:48 +08:00
2025-04-18 12:54:04 +08:00
if err := cmd.Flag.Parse(args); err != nil {
2025-05-10 07:15:48 +08:00
return
2025-04-18 12:54:04 +08:00
}
2024-04-25 00:53:42 +08:00
conf := build.NewDefaultConf(build.ModeInstall)
if err := flags.UpdateConfig(conf); err != nil {
fmt.Fprintln(os.Stderr, err)
mockable.Exit(1)
}
2025-04-18 12:54:04 +08:00
args = cmd.Flag.Args()
_, err := build.Do(args, conf)
if err != nil {
fmt.Fprintln(os.Stderr, err)
2025-01-14 10:50:43 +08:00
mockable.Exit(1)
}
2024-04-24 07:55:51 +08:00
}