merge upstream
This commit is contained in:
2
.github/codecov.yml
vendored
2
.github/codecov.yml
vendored
@@ -1,7 +1,7 @@
|
||||
coverage:
|
||||
ignore:
|
||||
- "chore"
|
||||
- "cmd/internal"
|
||||
- "cmd"
|
||||
- "internal/build"
|
||||
- "internal/llgen"
|
||||
- "internal/mockable"
|
||||
|
||||
2
.github/workflows/fmt.yml
vendored
2
.github/workflows/fmt.yml
vendored
@@ -21,7 +21,7 @@ jobs:
|
||||
run: |
|
||||
for dir in . runtime; do
|
||||
pushd $dir
|
||||
if [ -n "$(go fmt ./...)" ]; then
|
||||
if [ -n "$(go fmt ./... | grep -v gop_autogen.go)" ]; then
|
||||
echo "Some files are not properly formatted. Please run 'go fmt ./...'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
25
cl/_testgo/alias/in.go
Normal file
25
cl/_testgo/alias/in.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
type Point struct {
|
||||
x float64
|
||||
y float64
|
||||
}
|
||||
|
||||
func (p *Point) Scale(factor float64) {
|
||||
p.x *= factor
|
||||
p.y *= factor
|
||||
}
|
||||
|
||||
type MyPoint = Point
|
||||
|
||||
func (p *MyPoint) Move(dx, dy float64) {
|
||||
p.x += dx
|
||||
p.y += dy
|
||||
}
|
||||
|
||||
func main() {
|
||||
pt := &MyPoint{1, 2}
|
||||
pt.Scale(2)
|
||||
pt.Move(3, 4)
|
||||
println(pt.x, pt.y)
|
||||
}
|
||||
75
cl/_testgo/alias/out.ll
Normal file
75
cl/_testgo/alias/out.ll
Normal file
@@ -0,0 +1,75 @@
|
||||
; ModuleID = 'github.com/goplus/llgo/cl/_testgo/alias'
|
||||
source_filename = "github.com/goplus/llgo/cl/_testgo/alias"
|
||||
|
||||
%"github.com/goplus/llgo/cl/_testgo/alias.Point" = type { double, double }
|
||||
|
||||
@"github.com/goplus/llgo/cl/_testgo/alias.init$guard" = global i1 false, align 1
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testgo/alias.(*Point).Move"(ptr %0, double %1, double %2) {
|
||||
_llgo_0:
|
||||
%3 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
|
||||
%4 = load double, ptr %3, align 8
|
||||
%5 = fadd double %4, %1
|
||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
|
||||
store double %5, ptr %6, align 8
|
||||
%7 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
|
||||
%8 = load double, ptr %7, align 8
|
||||
%9 = fadd double %8, %2
|
||||
%10 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
|
||||
store double %9, ptr %10, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testgo/alias.(*Point).Scale"(ptr %0, double %1) {
|
||||
_llgo_0:
|
||||
%2 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
|
||||
%3 = load double, ptr %2, align 8
|
||||
%4 = fmul double %3, %1
|
||||
%5 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
|
||||
store double %4, ptr %5, align 8
|
||||
%6 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
|
||||
%7 = load double, ptr %6, align 8
|
||||
%8 = fmul double %7, %1
|
||||
%9 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
|
||||
store double %8, ptr %9, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testgo/alias.init"() {
|
||||
_llgo_0:
|
||||
%0 = load i1, ptr @"github.com/goplus/llgo/cl/_testgo/alias.init$guard", align 1
|
||||
br i1 %0, label %_llgo_2, label %_llgo_1
|
||||
|
||||
_llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"github.com/goplus/llgo/cl/_testgo/alias.init$guard", align 1
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testgo/alias.main"() {
|
||||
_llgo_0:
|
||||
%0 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64 16)
|
||||
%1 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
|
||||
%2 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
|
||||
store double 1.000000e+00, ptr %1, align 8
|
||||
store double 2.000000e+00, ptr %2, align 8
|
||||
call void @"github.com/goplus/llgo/cl/_testgo/alias.(*Point).Scale"(ptr %0, double 2.000000e+00)
|
||||
call void @"github.com/goplus/llgo/cl/_testgo/alias.(*Point).Move"(ptr %0, double 3.000000e+00, double 4.000000e+00)
|
||||
%3 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 0
|
||||
%4 = load double, ptr %3, align 8
|
||||
%5 = getelementptr inbounds %"github.com/goplus/llgo/cl/_testgo/alias.Point", ptr %0, i32 0, i32 1
|
||||
%6 = load double, ptr %5, align 8
|
||||
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintFloat"(double %4)
|
||||
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 32)
|
||||
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintFloat"(double %6)
|
||||
call void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
declare ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocZ"(i64)
|
||||
|
||||
declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintFloat"(double)
|
||||
|
||||
declare void @"github.com/goplus/llgo/runtime/internal/runtime.PrintByte"(i8)
|
||||
@@ -5,8 +5,8 @@ source_filename = "github.com/goplus/llgo/cl/_testgo/tpnamed"
|
||||
%"github.com/goplus/llgo/runtime/internal/runtime.String" = type { ptr, i64 }
|
||||
%"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[error]" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/runtime/internal/runtime.iface" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" = type { ptr, ptr }
|
||||
%"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" = type { ptr, ptr }
|
||||
|
||||
@"github.com/goplus/llgo/cl/_testgo/tpnamed.init$guard" = global i1 false, align 1
|
||||
|
||||
@@ -40,13 +40,13 @@ _llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
|
||||
define void @"github.com/goplus/llgo/cl/_testgo/tpnamed.main"() {
|
||||
_llgo_0:
|
||||
%0 = call [0 x i8] @"github.com/goplus/llgo/cl/_testgo/tpnamed.RunIO[[0]byte]"(%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1", ptr null })
|
||||
%0 = call [0 x i8] @"github.com/goplus/llgo/cl/_testgo/tpnamed.RunIO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]"(%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1", ptr null })
|
||||
ret void
|
||||
}
|
||||
|
||||
define %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"() {
|
||||
define %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"() {
|
||||
_llgo_0:
|
||||
ret %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1$1", ptr null }
|
||||
ret %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" { ptr @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1$1", ptr null }
|
||||
}
|
||||
|
||||
define [0 x i8] @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$1$1"() {
|
||||
@@ -66,19 +66,19 @@ _llgo_0:
|
||||
ret %"github.com/goplus/llgo/runtime/internal/runtime.iface" %1
|
||||
}
|
||||
|
||||
define linkonce %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"(ptr %0) {
|
||||
define linkonce %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" @"__llgo_stub.github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"(ptr %0) {
|
||||
_llgo_0:
|
||||
%1 = tail call %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"()
|
||||
ret %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" %1
|
||||
%1 = tail call %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" @"github.com/goplus/llgo/cl/_testgo/tpnamed.main$1"()
|
||||
ret %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %1
|
||||
}
|
||||
|
||||
define linkonce [0 x i8] @"github.com/goplus/llgo/cl/_testgo/tpnamed.RunIO[[0]byte]"(%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" %0) {
|
||||
define linkonce [0 x i8] @"github.com/goplus/llgo/cl/_testgo/tpnamed.RunIO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]"(%"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %0) {
|
||||
_llgo_0:
|
||||
%1 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" %0, 1
|
||||
%2 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[[0]byte]" %0, 0
|
||||
%3 = call %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" %2(ptr %1)
|
||||
%4 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" %3, 1
|
||||
%5 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[[0]byte]" %3, 0
|
||||
%1 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %0, 1
|
||||
%2 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.IO[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %0, 0
|
||||
%3 = call %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %2(ptr %1)
|
||||
%4 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %3, 1
|
||||
%5 = extractvalue %"github.com/goplus/llgo/cl/_testgo/tpnamed.Future[github.com/goplus/llgo/cl/_testgo/tpnamed.Void]" %3, 0
|
||||
%6 = call [0 x i8] %5(ptr %4)
|
||||
ret [0 x i8] %6
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,7 @@ source_filename = "github.com/goplus/llgo/cl/_testrt/any"
|
||||
@"github.com/goplus/llgo/cl/_testrt/any.init$guard" = global i1 false, align 1
|
||||
@_llgo_int8 = linkonce global ptr null, align 8
|
||||
@"*_llgo_int8" = linkonce global ptr null, align 8
|
||||
@0 = private unnamed_addr constant [34 x i8] c"type assertion any -> *int8 failed", align 1
|
||||
@0 = private unnamed_addr constant [58 x i8] c"type assertion any -> *github.com/goplus/lib/c.Char failed", align 1
|
||||
@_llgo_string = linkonce global ptr null, align 8
|
||||
@_llgo_int = linkonce global ptr null, align 8
|
||||
@1 = private unnamed_addr constant [32 x i8] c"type assertion any -> int failed", align 1
|
||||
@@ -29,7 +29,7 @@ _llgo_1: ; preds = %_llgo_0
|
||||
_llgo_2: ; preds = %_llgo_0
|
||||
%6 = load ptr, ptr @_llgo_string, align 8
|
||||
%7 = call ptr @"github.com/goplus/llgo/runtime/internal/runtime.AllocU"(i64 16)
|
||||
store %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 34 }, ptr %7, align 8
|
||||
store %"github.com/goplus/llgo/runtime/internal/runtime.String" { ptr @0, i64 58 }, ptr %7, align 8
|
||||
%8 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" undef, ptr %6, 0
|
||||
%9 = insertvalue %"github.com/goplus/llgo/runtime/internal/runtime.eface" %8, ptr %7, 1
|
||||
call void @"github.com/goplus/llgo/runtime/internal/runtime.Panic"(%"github.com/goplus/llgo/runtime/internal/runtime.eface" %9)
|
||||
|
||||
26
cmd/llgo/build_cmd.gox
Normal file
26
cmd/llgo/build_cmd.gox
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import (
|
||||
self "github.com/goplus/llgo/cmd/internal/build"
|
||||
)
|
||||
|
||||
short "Compile packages and dependencies"
|
||||
|
||||
flagOff
|
||||
|
||||
run args => {
|
||||
self.Cmd.Run self.Cmd, args
|
||||
}
|
||||
26
cmd/llgo/clean_cmd.gox
Normal file
26
cmd/llgo/clean_cmd.gox
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import (
|
||||
self "github.com/goplus/llgo/cmd/internal/clean"
|
||||
)
|
||||
|
||||
short "Remove object files and cached files"
|
||||
|
||||
flagOff
|
||||
|
||||
run args => {
|
||||
self.Cmd.Run self.Cmd, args
|
||||
}
|
||||
26
cmd/llgo/cmptest_cmd.gox
Normal file
26
cmd/llgo/cmptest_cmd.gox
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import (
|
||||
self "github.com/goplus/llgo/cmd/internal/run"
|
||||
)
|
||||
|
||||
short "Compile and run with llgo, compare result (stdout/stderr/exitcode) with go or llgo.expect; generate llgo.expect file if -gen is specified"
|
||||
|
||||
flagOff
|
||||
|
||||
run args => {
|
||||
self.CmpTestCmd.Run self.CmpTestCmd, args
|
||||
}
|
||||
20
cmd/llgo/cppkg_cmd.gox
Normal file
20
cmd/llgo/cppkg_cmd.gox
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
short "Manage C/C++ packages"
|
||||
|
||||
run => {
|
||||
help
|
||||
}
|
||||
36
cmd/llgo/cppkg_install_cmd.gox
Normal file
36
cmd/llgo/cppkg_install_cmd.gox
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import (
|
||||
self "github.com/goplus/llgo/xtool/cppkg"
|
||||
)
|
||||
|
||||
short "Install a C/C++ package from github.com/goplus/cppkg"
|
||||
|
||||
long `Installs a C/C++ package with the given name and version. For example:
|
||||
|
||||
llgo cppkg install davegamble/cjson@1.7.18
|
||||
llgo cppkg install davegamble/cjson@latest
|
||||
llgo cppkg install davegamble/cjson
|
||||
`
|
||||
|
||||
run args => {
|
||||
if args.len < 1 {
|
||||
help
|
||||
return
|
||||
}
|
||||
|
||||
self.install args[0], self.DefaultFlags
|
||||
}
|
||||
20
cmd/llgo/get_cmd.gox
Normal file
20
cmd/llgo/get_cmd.gox
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
short "Add dependencies to current module and install them"
|
||||
|
||||
run args => {
|
||||
panic "todo"
|
||||
}
|
||||
247
cmd/llgo/gop_autogen.go
Normal file
247
cmd/llgo/gop_autogen.go
Normal file
@@ -0,0 +1,247 @@
|
||||
// Code generated by gop (Go+); DO NOT EDIT.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/goplus/cobra/xcmd"
|
||||
build1 "github.com/goplus/llgo/cmd/internal/build"
|
||||
clean1 "github.com/goplus/llgo/cmd/internal/clean"
|
||||
install1 "github.com/goplus/llgo/cmd/internal/install"
|
||||
run1 "github.com/goplus/llgo/cmd/internal/run"
|
||||
test1 "github.com/goplus/llgo/cmd/internal/test"
|
||||
"github.com/goplus/llgo/internal/env"
|
||||
cppkg1 "github.com/goplus/llgo/xtool/cppkg"
|
||||
"github.com/qiniu/x/stringutil"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
const _ = true
|
||||
|
||||
type build struct {
|
||||
xcmd.Command
|
||||
*App
|
||||
}
|
||||
type clean struct {
|
||||
xcmd.Command
|
||||
*App
|
||||
}
|
||||
type cmptest struct {
|
||||
xcmd.Command
|
||||
*App
|
||||
}
|
||||
type cppkg struct {
|
||||
xcmd.Command
|
||||
*App
|
||||
}
|
||||
type cppkg_install struct {
|
||||
xcmd.Command
|
||||
*App
|
||||
}
|
||||
type get struct {
|
||||
xcmd.Command
|
||||
*App
|
||||
}
|
||||
type install struct {
|
||||
xcmd.Command
|
||||
*App
|
||||
}
|
||||
type run struct {
|
||||
xcmd.Command
|
||||
*App
|
||||
}
|
||||
type test struct {
|
||||
xcmd.Command
|
||||
*App
|
||||
}
|
||||
type version struct {
|
||||
xcmd.Command
|
||||
*App
|
||||
}
|
||||
type App struct {
|
||||
xcmd.App
|
||||
}
|
||||
|
||||
func (this *App) Main() {
|
||||
_gop_obj0 := &build{App: this}
|
||||
_gop_obj1 := &clean{App: this}
|
||||
_gop_obj2 := &cmptest{App: this}
|
||||
_gop_obj3 := &cppkg{App: this}
|
||||
_gop_obj4 := &cppkg_install{App: this}
|
||||
_gop_obj5 := &get{App: this}
|
||||
_gop_obj6 := &install{App: this}
|
||||
_gop_obj7 := &run{App: this}
|
||||
_gop_obj8 := &test{App: this}
|
||||
_gop_obj9 := &version{App: this}
|
||||
xcmd.Gopt_App_Main(this, _gop_obj0, _gop_obj1, _gop_obj2, _gop_obj3, _gop_obj4, _gop_obj5, _gop_obj6, _gop_obj7, _gop_obj8, _gop_obj9)
|
||||
}
|
||||
//line cmd/llgo/build_cmd.gox:20
|
||||
func (this *build) Main(_gop_arg0 string) {
|
||||
this.Command.Main(_gop_arg0)
|
||||
//line cmd/llgo/build_cmd.gox:20:1
|
||||
this.Short("Compile packages and dependencies")
|
||||
//line cmd/llgo/build_cmd.gox:22:1
|
||||
this.FlagOff()
|
||||
//line cmd/llgo/build_cmd.gox:24:1
|
||||
this.Run__1(func(args []string) {
|
||||
//line cmd/llgo/build_cmd.gox:25:1
|
||||
build1.Cmd.Run(build1.Cmd, args)
|
||||
})
|
||||
}
|
||||
func (this *build) Classfname() string {
|
||||
return "build"
|
||||
}
|
||||
//line cmd/llgo/clean_cmd.gox:20
|
||||
func (this *clean) Main(_gop_arg0 string) {
|
||||
this.Command.Main(_gop_arg0)
|
||||
//line cmd/llgo/clean_cmd.gox:20:1
|
||||
this.Short("Remove object files and cached files")
|
||||
//line cmd/llgo/clean_cmd.gox:22:1
|
||||
this.FlagOff()
|
||||
//line cmd/llgo/clean_cmd.gox:24:1
|
||||
this.Run__1(func(args []string) {
|
||||
//line cmd/llgo/clean_cmd.gox:25:1
|
||||
clean1.Cmd.Run(clean1.Cmd, args)
|
||||
})
|
||||
}
|
||||
func (this *clean) Classfname() string {
|
||||
return "clean"
|
||||
}
|
||||
//line cmd/llgo/cmptest_cmd.gox:20
|
||||
func (this *cmptest) Main(_gop_arg0 string) {
|
||||
this.Command.Main(_gop_arg0)
|
||||
//line cmd/llgo/cmptest_cmd.gox:20:1
|
||||
this.Short("Compile and run with llgo, compare result (stdout/stderr/exitcode) with go or llgo.expect; generate llgo.expect file if -gen is specified")
|
||||
//line cmd/llgo/cmptest_cmd.gox:22:1
|
||||
this.FlagOff()
|
||||
//line cmd/llgo/cmptest_cmd.gox:24:1
|
||||
this.Run__1(func(args []string) {
|
||||
//line cmd/llgo/cmptest_cmd.gox:25:1
|
||||
run1.CmpTestCmd.Run(run1.CmpTestCmd, args)
|
||||
})
|
||||
}
|
||||
func (this *cmptest) Classfname() string {
|
||||
return "cmptest"
|
||||
}
|
||||
//line cmd/llgo/cppkg_cmd.gox:16
|
||||
func (this *cppkg) Main(_gop_arg0 string) {
|
||||
this.Command.Main(_gop_arg0)
|
||||
//line cmd/llgo/cppkg_cmd.gox:16:1
|
||||
this.Short("Manage C/C++ packages")
|
||||
//line cmd/llgo/cppkg_cmd.gox:18:1
|
||||
this.Run__0(func() {
|
||||
//line cmd/llgo/cppkg_cmd.gox:19:1
|
||||
this.Help()
|
||||
})
|
||||
}
|
||||
func (this *cppkg) Classfname() string {
|
||||
return "cppkg"
|
||||
}
|
||||
//line cmd/llgo/cppkg_install_cmd.gox:20
|
||||
func (this *cppkg_install) Main(_gop_arg0 string) {
|
||||
this.Command.Main(_gop_arg0)
|
||||
//line cmd/llgo/cppkg_install_cmd.gox:20:1
|
||||
this.Short("Install a C/C++ package from github.com/goplus/cppkg")
|
||||
//line cmd/llgo/cppkg_install_cmd.gox:22:1
|
||||
this.Long(`Installs a C/C++ package with the given name and version. For example:
|
||||
|
||||
llgo cppkg install davegamble/cjson@1.7.18
|
||||
llgo cppkg install davegamble/cjson@latest
|
||||
llgo cppkg install davegamble/cjson
|
||||
`)
|
||||
//line cmd/llgo/cppkg_install_cmd.gox:29:1
|
||||
this.Run__1(func(args []string) {
|
||||
//line cmd/llgo/cppkg_install_cmd.gox:30:1
|
||||
if len(args) < 1 {
|
||||
//line cmd/llgo/cppkg_install_cmd.gox:31:1
|
||||
this.Help()
|
||||
//line cmd/llgo/cppkg_install_cmd.gox:32:1
|
||||
return
|
||||
}
|
||||
//line cmd/llgo/cppkg_install_cmd.gox:35:1
|
||||
cppkg1.Install(args[0], cppkg1.DefaultFlags)
|
||||
})
|
||||
}
|
||||
func (this *cppkg_install) Classfname() string {
|
||||
return "cppkg_install"
|
||||
}
|
||||
//line cmd/llgo/get_cmd.gox:16
|
||||
func (this *get) Main(_gop_arg0 string) {
|
||||
this.Command.Main(_gop_arg0)
|
||||
//line cmd/llgo/get_cmd.gox:16:1
|
||||
this.Short("Add dependencies to current module and install them")
|
||||
//line cmd/llgo/get_cmd.gox:18:1
|
||||
this.Run__1(func(args []string) {
|
||||
//line cmd/llgo/get_cmd.gox:19:1
|
||||
panic("todo")
|
||||
})
|
||||
}
|
||||
func (this *get) Classfname() string {
|
||||
return "get"
|
||||
}
|
||||
//line cmd/llgo/install_cmd.gox:20
|
||||
func (this *install) Main(_gop_arg0 string) {
|
||||
this.Command.Main(_gop_arg0)
|
||||
//line cmd/llgo/install_cmd.gox:20:1
|
||||
this.Short("Compile and install packages and dependencies")
|
||||
//line cmd/llgo/install_cmd.gox:22:1
|
||||
this.FlagOff()
|
||||
//line cmd/llgo/install_cmd.gox:24:1
|
||||
this.Run__1(func(args []string) {
|
||||
//line cmd/llgo/install_cmd.gox:25:1
|
||||
install1.Cmd.Run(install1.Cmd, args)
|
||||
})
|
||||
}
|
||||
func (this *install) Classfname() string {
|
||||
return "install"
|
||||
}
|
||||
//line cmd/llgo/run_cmd.gox:20
|
||||
func (this *run) Main(_gop_arg0 string) {
|
||||
this.Command.Main(_gop_arg0)
|
||||
//line cmd/llgo/run_cmd.gox:20:1
|
||||
this.Short("Compile and run Go program")
|
||||
//line cmd/llgo/run_cmd.gox:22:1
|
||||
this.FlagOff()
|
||||
//line cmd/llgo/run_cmd.gox:24:1
|
||||
this.Run__1(func(args []string) {
|
||||
//line cmd/llgo/run_cmd.gox:25:1
|
||||
run1.Cmd.Run(run1.Cmd, args)
|
||||
})
|
||||
}
|
||||
func (this *run) Classfname() string {
|
||||
return "run"
|
||||
}
|
||||
//line cmd/llgo/test_cmd.gox:20
|
||||
func (this *test) Main(_gop_arg0 string) {
|
||||
this.Command.Main(_gop_arg0)
|
||||
//line cmd/llgo/test_cmd.gox:20:1
|
||||
this.Short("Compile and run Go test")
|
||||
//line cmd/llgo/test_cmd.gox:22:1
|
||||
this.FlagOff()
|
||||
//line cmd/llgo/test_cmd.gox:24:1
|
||||
this.Run__1(func(args []string) {
|
||||
//line cmd/llgo/test_cmd.gox:25:1
|
||||
test1.Cmd.Run(test1.Cmd, args)
|
||||
})
|
||||
}
|
||||
func (this *test) Classfname() string {
|
||||
return "test"
|
||||
}
|
||||
//line cmd/llgo/version_cmd.gox:22
|
||||
func (this *version) Main(_gop_arg0 string) {
|
||||
this.Command.Main(_gop_arg0)
|
||||
//line cmd/llgo/version_cmd.gox:22:1
|
||||
this.Short("Print LLGo version")
|
||||
//line cmd/llgo/version_cmd.gox:24:1
|
||||
this.Run__0(func() {
|
||||
//line cmd/llgo/version_cmd.gox:25:1
|
||||
fmt.Println(stringutil.Concat("llgo ", env.Version(), " ", runtime.GOOS, "/", runtime.GOARCH))
|
||||
})
|
||||
}
|
||||
func (this *version) Classfname() string {
|
||||
return "version"
|
||||
}
|
||||
func main() {
|
||||
//line cmd/llgo/version_cmd.gox:24:1
|
||||
new(App).Main()
|
||||
}
|
||||
26
cmd/llgo/install_cmd.gox
Normal file
26
cmd/llgo/install_cmd.gox
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import (
|
||||
self "github.com/goplus/llgo/cmd/internal/install"
|
||||
)
|
||||
|
||||
short "Compile and install packages and dependencies"
|
||||
|
||||
flagOff
|
||||
|
||||
run args => {
|
||||
self.Cmd.Run self.Cmd, args
|
||||
}
|
||||
26
cmd/llgo/run_cmd.gox
Normal file
26
cmd/llgo/run_cmd.gox
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import (
|
||||
self "github.com/goplus/llgo/cmd/internal/run"
|
||||
)
|
||||
|
||||
short "Compile and run Go program"
|
||||
|
||||
flagOff
|
||||
|
||||
run args => {
|
||||
self.Cmd.Run self.Cmd, args
|
||||
}
|
||||
26
cmd/llgo/test_cmd.gox
Normal file
26
cmd/llgo/test_cmd.gox
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import (
|
||||
self "github.com/goplus/llgo/cmd/internal/test"
|
||||
)
|
||||
|
||||
short "Compile and run Go test"
|
||||
|
||||
flagOff
|
||||
|
||||
run args => {
|
||||
self.Cmd.Run self.Cmd, args
|
||||
}
|
||||
26
cmd/llgo/version_cmd.gox
Normal file
26
cmd/llgo/version_cmd.gox
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (c) 2025 The GoPlus Authors (goplus.org). All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"github.com/goplus/llgo/internal/env"
|
||||
)
|
||||
|
||||
short "Print LLGo version"
|
||||
|
||||
run => {
|
||||
echo "llgo ${env.version} ${runtime.GOOS}/${runtime.GOARCH}"
|
||||
}
|
||||
11
go.mod
11
go.mod
@@ -1,23 +1,22 @@
|
||||
module github.com/goplus/llgo
|
||||
|
||||
go 1.23.0
|
||||
go 1.23
|
||||
|
||||
toolchain go1.24.1
|
||||
|
||||
require (
|
||||
github.com/goccy/go-yaml v1.17.1
|
||||
github.com/goplus/cobra v1.9.8 //gop:class
|
||||
github.com/goplus/gogen v1.17.3
|
||||
github.com/goplus/lib v0.2.0
|
||||
github.com/goplus/llgo/runtime v0.0.0-00010101000000-000000000000
|
||||
github.com/goplus/llvm v0.8.3
|
||||
github.com/goplus/mod v0.16.0
|
||||
github.com/qiniu/x v1.13.19
|
||||
golang.org/x/mod v0.23.0
|
||||
golang.org/x/tools v0.30.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/goccy/go-yaml v1.17.1
|
||||
golang.org/x/mod v0.23.0
|
||||
golang.org/x/sync v0.11.0 // indirect
|
||||
)
|
||||
require golang.org/x/sync v0.11.0 // indirect
|
||||
|
||||
replace github.com/goplus/llgo/runtime => ./runtime
|
||||
|
||||
2
go.sum
2
go.sum
@@ -2,6 +2,8 @@ github.com/goccy/go-yaml v1.17.1 h1:LI34wktB2xEE3ONG/2Ar54+/HJVBriAGJ55PHls4YuY=
|
||||
github.com/goccy/go-yaml v1.17.1/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/goplus/cobra v1.9.8 h1:4ZvhxUepT35vreZdxjl/bwnJdwhWyWCGnc60+v22x14=
|
||||
github.com/goplus/cobra v1.9.8/go.mod h1:p4LhfNJDKEpiGjGiNn0crUXL5dUPA5DX2ztYpEJR34E=
|
||||
github.com/goplus/gogen v1.17.3 h1:Xhoj2KQw4feRdPEtOYjTUe9lSvNIoxBG4urhdjf+fUg=
|
||||
github.com/goplus/gogen v1.17.3/go.mod h1:owX2e1EyU5WD+Nm6oH2m/GXjLdlBYcwkLO4wN8HHXZI=
|
||||
github.com/goplus/lib v0.2.0 h1:AjqkN1XK5H23wZMMlpaUYAMCDAdSBQ2NMFrLtSh7W4g=
|
||||
|
||||
29
ssa/type.go
29
ssa/type.go
@@ -538,20 +538,15 @@ func PathOf(pkg *types.Package) string {
|
||||
// - method: pkg.T.name, pkg.(*T).name
|
||||
func FuncName(pkg *types.Package, name string, recv *types.Var, org bool) string {
|
||||
if recv != nil {
|
||||
named, ptr := recvNamed(recv.Type())
|
||||
var tName string
|
||||
t := recv.Type()
|
||||
if org {
|
||||
if tp, ok := t.(*types.Pointer); ok {
|
||||
tName = "(*" + tp.Elem().(*types.Named).Obj().Name() + ")"
|
||||
} else {
|
||||
tName = t.(*types.Named).Obj().Name()
|
||||
}
|
||||
tName = named.Obj().Name()
|
||||
} else {
|
||||
if tp, ok := t.(*types.Pointer); ok {
|
||||
tName = "(*" + abi.NamedName(tp.Elem().(*types.Named)) + ")"
|
||||
} else {
|
||||
tName = abi.NamedName(t.(*types.Named))
|
||||
}
|
||||
tName = abi.NamedName(named)
|
||||
}
|
||||
if ptr {
|
||||
tName = "(*" + tName + ")"
|
||||
}
|
||||
return PathOf(pkg) + "." + tName + "." + name
|
||||
}
|
||||
@@ -559,6 +554,18 @@ func FuncName(pkg *types.Package, name string, recv *types.Var, org bool) string
|
||||
return ret
|
||||
}
|
||||
|
||||
func recvNamed(t types.Type) (typ *types.Named, ptr bool) {
|
||||
if tp, ok := t.(*types.Pointer); ok {
|
||||
t = tp.Elem()
|
||||
ptr = true
|
||||
}
|
||||
if _, ok := t.(*types.Alias); ok {
|
||||
t = types.Unalias(t)
|
||||
}
|
||||
typ, _ = t.(*types.Named)
|
||||
return
|
||||
}
|
||||
|
||||
func TypeArgs(typeArgs []types.Type) string {
|
||||
return abi.TypeArgs(typeArgs)
|
||||
}
|
||||
|
||||
@@ -75,7 +75,10 @@ type githubRelease struct {
|
||||
|
||||
func getRelease(pkg *Package, tagPattern string) (ret *githubRelease, err error) {
|
||||
if tagPattern == "" {
|
||||
return nil, errors.New("dynamic tag")
|
||||
return nil, ErrDynamicTag
|
||||
}
|
||||
if pkg.gr != nil {
|
||||
return &githubRelease{PublishedAt: pkg.gr.PublishedAt}, nil
|
||||
}
|
||||
ver := strings.Replace(tagPattern, "*", pkg.Version, 1)
|
||||
gr, err := github.GetRelease(pkg.Path, ver)
|
||||
|
||||
@@ -29,9 +29,6 @@ const (
|
||||
// pkgAndVer: 7bitcoder/7bitconf@1.2.0
|
||||
func Install(pkgAndVer string, flags int) {
|
||||
pkgPath, ver := parsePkgVer(pkgAndVer)
|
||||
if ver == "" {
|
||||
panic("TODO: get latest version")
|
||||
}
|
||||
|
||||
m, err := New("")
|
||||
check(err)
|
||||
|
||||
@@ -19,8 +19,10 @@ package cppkg
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/goccy/go-yaml"
|
||||
"github.com/goplus/llgo/internal/github"
|
||||
"golang.org/x/mod/semver"
|
||||
)
|
||||
|
||||
@@ -73,11 +75,16 @@ type Package struct {
|
||||
Version string
|
||||
Folder string
|
||||
Template *Template
|
||||
|
||||
gr *github.Release // optional
|
||||
}
|
||||
|
||||
var (
|
||||
// ErrVersionNotFound is returned when the specified version is not found.
|
||||
ErrVersionNotFound = errors.New("version not found")
|
||||
|
||||
// ErrDynamicTag is returned when the tag is dynamic.
|
||||
ErrDynamicTag = errors.New("dynamic tag")
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -109,15 +116,32 @@ func (p *Manager) Lookup(pkgPath, ver string, flags int) (_ *Package, err error)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if ver == "" || ver == "latest" {
|
||||
if conf.Template.Tag == "" {
|
||||
return nil, ErrDynamicTag
|
||||
}
|
||||
gr, e := github.GetRelease(pkgPath, "")
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
ver, err = verByTag(gr.TagName, conf.Template.Tag)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
templ := conf.Template
|
||||
return &Package{conf.PkgName, pkgPath, ver, templ.Folder, &templ, gr}, nil
|
||||
}
|
||||
|
||||
if v, ok := conf.Versions[ver]; ok {
|
||||
return &Package{conf.PkgName, pkgPath, ver, v.Folder, nil}, nil
|
||||
return &Package{conf.PkgName, pkgPath, ver, v.Folder, nil, nil}, nil
|
||||
}
|
||||
if compareVer(ver, conf.Template.FromVer) < 0 {
|
||||
err = ErrVersionNotFound
|
||||
return
|
||||
}
|
||||
folder := conf.Template.Folder
|
||||
return &Package{conf.PkgName, pkgPath, ver, folder, &conf.Template}, nil
|
||||
templ := conf.Template
|
||||
return &Package{conf.PkgName, pkgPath, ver, templ.Folder, &templ, nil}, nil
|
||||
}
|
||||
|
||||
func (p *Manager) indexRoot() string {
|
||||
@@ -158,3 +182,15 @@ func indexInit(root string, flags int) (err error) {
|
||||
func compareVer(v1, v2 string) int {
|
||||
return semver.Compare("v"+v1, "v"+v2)
|
||||
}
|
||||
|
||||
func verByTag(tag, tagPattern string) (ver string, err error) {
|
||||
if pos := strings.IndexByte(tagPattern, '*'); pos >= 0 {
|
||||
prefix := tagPattern[:pos]
|
||||
suffix := tagPattern[pos+1:]
|
||||
if strings.HasPrefix(tag, prefix) && strings.HasSuffix(tag, suffix) {
|
||||
ver = tag[pos : len(tag)-len(suffix)]
|
||||
return
|
||||
}
|
||||
}
|
||||
return "", errors.New("tag not match: " + tag + " with " + tagPattern)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user