From 64df39b3c5e75dd3b0876f3ef3e5f66c5138453b Mon Sep 17 00:00:00 2001 From: Li Jie Date: Tue, 9 Sep 2025 15:06:55 +0800 Subject: [PATCH] reorganize: consolidate demo directories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Consolidate _demo, _pydemo, _embdemo into single _demo directory structure - Organize demos by language: _demo/{go,py,c,embed}/ - Categorize demos based on imports: - Python library demos (py imports) → _demo/py/ - C/C++ library demos (c/cpp imports) → _demo/c/ - Go-specific demos → _demo/go/ - Embedded demos → _demo/embed/ - Move C-related demos (asm*, cabi*, cgo*, linkname, targetsbuild) from go/ to c/ - Update all path references in README.md and GitHub workflows - Improve demo organization and navigation as requested in #1256 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/llgo.yml | 16 +++++----- .github/workflows/targets.yml | 4 +-- .github/workflows/test_demo.sh | 4 +-- README.md | 30 +++++++++--------- _demo/{ => c}/asmcall/asmcall.go | 0 _demo/{ => c}/asmfullcall/asmfullcall.go | 0 .../{ => c}/asmfullcall/asmfullcall_darwin.go | 0 .../{ => c}/asmfullcall/asmfullcall_linux.go | 0 _demo/{ => c}/cabi/main.go | 0 _demo/{ => c}/cabi/wrap/wrap.c | 0 _demo/{ => c}/cabisret/main.go | 0 _demo/{ => c}/cargs/demo.go | 0 _demo/{ => c}/catomic/atomic.go | 0 _demo/{ => c}/cexec/exec.go | 0 _demo/{ => c}/cgofull/bar.go | 0 _demo/{ => c}/cgofull/cgofull.go | 4 +-- _demo/{ => c}/cgofull/foo.c | 0 _demo/{ => c}/cgofull/foo.go | 0 _demo/{ => c}/cgofull/foo.h | 0 _demo/{ => c}/cgofull/py.go | 0 _demo/{ => c}/cgofull/pymod1/pymod1.go | 0 _demo/{ => c}/cgofull/pymod2/pymod2.go | 0 _demo/{ => c}/concat/concat.go | 0 _demo/{ => c}/cppintf/cppintf.go | 2 +- _demo/{ => c}/cppintf/foo/bar/bar.cpp | 0 _demo/{ => c}/cppintf/foo/foo.go | 0 _demo/{ => c}/cppmintf/cpp_multi_intf.go | 2 +- _demo/{ => c}/cppmintf/foo/bar/bar.cpp | 0 _demo/{ => c}/cppmintf/foo/foo.go | 0 _demo/{ => c}/cppstr/cppstr.go | 0 _demo/{ => c}/crand/rand.go | 0 _demo/{ => c}/ctime/time.go | 0 _demo/{ => c}/fcntl/fcntl.go | 0 _demo/{ => c}/genints/genints.go | 0 _demo/{ => c}/getcwd/getcwd.go | 0 _demo/c/go.mod | 5 +++ _demo/c/go.sum | 2 ++ _demo/{ => c}/hello/hello.go | 0 _demo/{ => c}/helloc/helloc.go | 0 _demo/{ => c}/linkname/linkname.go | 0 _demo/{ => c}/llama2-c/README.md | 0 _demo/{ => c}/llama2-c/assets/llama_cute.jpg | Bin _demo/{ => c}/llama2-c/run.go | 1 - _demo/{ => c}/llama2-c/tokenizer.bin | Bin _demo/{ => c}/netdbdemo/netdb.go | 0 _demo/{ => c}/qsort/qsort.go | 0 _demo/{ => c}/setjmp/setjmp.go | 0 _demo/{ => c}/socket/client/client.go | 0 _demo/{ => c}/socket/server/server.go | 0 _demo/{ => c}/syncdebug/syncdebug.go | 0 _demo/{ => c}/thread/thd.go | 0 _demo/embed/go.mod | 5 +++ _demo/embed/go.sum | 2 ++ {_embdemo => _demo/embed}/hello-esp32/main.go | 0 {_embdemo => _demo/embed}/hello-esp32/uart.go | 0 _demo/{ => embed}/targetsbuild/C/c.go | 0 _demo/{ => embed}/targetsbuild/build.sh | 6 ++-- _demo/embed/targetsbuild/empty.go | 6 ++++ {_embdemo => _demo/embed}/write-esp32/main.go | 0 _demo/{ => go}/async/async/async.go | 0 _demo/{ => go}/async/main.go | 4 +-- _demo/{ => go}/async/timeout/timeout.go | 2 +- _demo/{ => go}/checkfile/demo.go | 0 _demo/{ => go}/commandrun/commandrun.go | 0 _demo/{ => go}/complex/cmplx.go | 0 _demo/{ => go}/defer/main.go | 0 _demo/{ => go}/failed/stacktrace/main.go | 0 _demo/go/go.mod | 3 ++ _demo/go/go.sum | 0 _demo/{ => go}/goroutine/goroutine.go | 0 _demo/{ => go}/gotime/time.go | 0 _demo/{ => go}/ifaceconv/main.go | 0 _demo/{ => go}/logdemo/log.go | 0 _demo/{ => go}/math/math.go | 0 _demo/{ => go}/mimeheader/mimeheader.go | 0 _demo/{ => go}/mkdirdemo/mkdir.go | 0 _demo/{ => go}/oslookpath/lookpath.go | 0 _demo/{ => go}/randcrypt/rand.go | 0 _demo/{ => go}/randdemo/rand.go | 0 _demo/{ => go}/readdir/main.go | 0 _demo/{ => go}/reflectfunc/reflectfunc.go | 0 _demo/{ => go}/sync/sync.go | 0 _demo/{ => go}/sysexec/exec.go | 0 _demo/{ => go}/timedur/timedur.go | 0 {_pydemo => _demo/py}/callpy/callpy.go | 0 _demo/{ => py}/go.mod | 2 +- _demo/{ => py}/go.sum | 0 {_pydemo => _demo/py}/matrix/matrix.go | 0 {_pydemo => _demo/py}/max/max.go | 0 {_pydemo => _demo/py}/pi/pi.go | 0 {_pydemo => _demo/py}/print/print.go | 0 .../py}/statistics/statistics.go | 0 {_pydemo => _demo/py}/tensor/tensor.go | 0 _demo/targetsbuild/empty.go | 6 ---- _pydemo/go.mod | 5 --- _pydemo/go.sum | 2 -- 96 files changed, 61 insertions(+), 52 deletions(-) rename _demo/{ => c}/asmcall/asmcall.go (100%) rename _demo/{ => c}/asmfullcall/asmfullcall.go (100%) rename _demo/{ => c}/asmfullcall/asmfullcall_darwin.go (100%) rename _demo/{ => c}/asmfullcall/asmfullcall_linux.go (100%) rename _demo/{ => c}/cabi/main.go (100%) rename _demo/{ => c}/cabi/wrap/wrap.c (100%) rename _demo/{ => c}/cabisret/main.go (100%) rename _demo/{ => c}/cargs/demo.go (100%) rename _demo/{ => c}/catomic/atomic.go (100%) rename _demo/{ => c}/cexec/exec.go (100%) rename _demo/{ => c}/cgofull/bar.go (100%) rename _demo/{ => c}/cgofull/cgofull.go (97%) rename _demo/{ => c}/cgofull/foo.c (100%) rename _demo/{ => c}/cgofull/foo.go (100%) rename _demo/{ => c}/cgofull/foo.h (100%) rename _demo/{ => c}/cgofull/py.go (100%) rename _demo/{ => c}/cgofull/pymod1/pymod1.go (100%) rename _demo/{ => c}/cgofull/pymod2/pymod2.go (100%) rename _demo/{ => c}/concat/concat.go (100%) rename _demo/{ => c}/cppintf/cppintf.go (91%) rename _demo/{ => c}/cppintf/foo/bar/bar.cpp (100%) rename _demo/{ => c}/cppintf/foo/foo.go (100%) rename _demo/{ => c}/cppmintf/cpp_multi_intf.go (93%) rename _demo/{ => c}/cppmintf/foo/bar/bar.cpp (100%) rename _demo/{ => c}/cppmintf/foo/foo.go (100%) rename _demo/{ => c}/cppstr/cppstr.go (100%) rename _demo/{ => c}/crand/rand.go (100%) rename _demo/{ => c}/ctime/time.go (100%) rename _demo/{ => c}/fcntl/fcntl.go (100%) rename _demo/{ => c}/genints/genints.go (100%) rename _demo/{ => c}/getcwd/getcwd.go (100%) create mode 100644 _demo/c/go.mod create mode 100644 _demo/c/go.sum rename _demo/{ => c}/hello/hello.go (100%) rename _demo/{ => c}/helloc/helloc.go (100%) rename _demo/{ => c}/linkname/linkname.go (100%) rename _demo/{ => c}/llama2-c/README.md (100%) rename _demo/{ => c}/llama2-c/assets/llama_cute.jpg (100%) rename _demo/{ => c}/llama2-c/run.go (99%) rename _demo/{ => c}/llama2-c/tokenizer.bin (100%) rename _demo/{ => c}/netdbdemo/netdb.go (100%) rename _demo/{ => c}/qsort/qsort.go (100%) rename _demo/{ => c}/setjmp/setjmp.go (100%) rename _demo/{ => c}/socket/client/client.go (100%) rename _demo/{ => c}/socket/server/server.go (100%) rename _demo/{ => c}/syncdebug/syncdebug.go (100%) rename _demo/{ => c}/thread/thd.go (100%) create mode 100644 _demo/embed/go.mod create mode 100644 _demo/embed/go.sum rename {_embdemo => _demo/embed}/hello-esp32/main.go (100%) rename {_embdemo => _demo/embed}/hello-esp32/uart.go (100%) rename _demo/{ => embed}/targetsbuild/C/c.go (100%) rename _demo/{ => embed}/targetsbuild/build.sh (96%) create mode 100644 _demo/embed/targetsbuild/empty.go rename {_embdemo => _demo/embed}/write-esp32/main.go (100%) rename _demo/{ => go}/async/async/async.go (100%) rename _demo/{ => go}/async/main.go (77%) rename _demo/{ => go}/async/timeout/timeout.go (82%) rename _demo/{ => go}/checkfile/demo.go (100%) rename _demo/{ => go}/commandrun/commandrun.go (100%) rename _demo/{ => go}/complex/cmplx.go (100%) rename _demo/{ => go}/defer/main.go (100%) rename _demo/{ => go}/failed/stacktrace/main.go (100%) create mode 100644 _demo/go/go.mod create mode 100644 _demo/go/go.sum rename _demo/{ => go}/goroutine/goroutine.go (100%) rename _demo/{ => go}/gotime/time.go (100%) rename _demo/{ => go}/ifaceconv/main.go (100%) rename _demo/{ => go}/logdemo/log.go (100%) rename _demo/{ => go}/math/math.go (100%) rename _demo/{ => go}/mimeheader/mimeheader.go (100%) rename _demo/{ => go}/mkdirdemo/mkdir.go (100%) rename _demo/{ => go}/oslookpath/lookpath.go (100%) rename _demo/{ => go}/randcrypt/rand.go (100%) rename _demo/{ => go}/randdemo/rand.go (100%) rename _demo/{ => go}/readdir/main.go (100%) rename _demo/{ => go}/reflectfunc/reflectfunc.go (100%) rename _demo/{ => go}/sync/sync.go (100%) rename _demo/{ => go}/sysexec/exec.go (100%) rename _demo/{ => go}/timedur/timedur.go (100%) rename {_pydemo => _demo/py}/callpy/callpy.go (100%) rename _demo/{ => py}/go.mod (54%) rename _demo/{ => py}/go.sum (100%) rename {_pydemo => _demo/py}/matrix/matrix.go (100%) rename {_pydemo => _demo/py}/max/max.go (100%) rename {_pydemo => _demo/py}/pi/pi.go (100%) rename {_pydemo => _demo/py}/print/print.go (100%) rename {_pydemo => _demo/py}/statistics/statistics.go (100%) rename {_pydemo => _demo/py}/tensor/tensor.go (100%) delete mode 100644 _demo/targetsbuild/empty.go delete mode 100644 _pydemo/go.mod delete mode 100644 _pydemo/go.sum diff --git a/.github/workflows/llgo.yml b/.github/workflows/llgo.yml index 72950dde..1f027509 100644 --- a/.github/workflows/llgo.yml +++ b/.github/workflows/llgo.yml @@ -22,14 +22,14 @@ jobs: steps: - name: Download model file run: | - mkdir -p ./_demo/llama2-c - wget -P ./_demo/llama2-c https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.bin + mkdir -p ./_demo/c/llama2-c + wget -P ./_demo/c/llama2-c https://huggingface.co/karpathy/tinyllamas/resolve/main/stories15M.bin - name: Upload model as artifact uses: actions/upload-artifact@v4 with: name: llama2-model - path: ./_demo/llama2-c/stories15M.bin + path: ./_demo/c/llama2-c/stories15M.bin retention-days: 1 llgo: @@ -54,7 +54,7 @@ jobs: uses: actions/download-artifact@v5 with: name: llama2-model - path: ./_demo/llama2-c/ + path: ./_demo/c/llama2-c/ - name: Download platform-specific demo libs run: | if ${{ startsWith(matrix.os, 'macos') }}; then @@ -63,8 +63,8 @@ jobs: DEMO_PKG="cargs_linux_amd64.zip" fi - mkdir -p ./_demo/cargs/libs - cd ./_demo/cargs/libs + mkdir -p ./_demo/c/cargs/libs + cd ./_demo/c/cargs/libs wget https://github.com/goplus/llpkg/releases/download/cargs/v1.0.0/${DEMO_PKG} unzip ${DEMO_PKG} @@ -104,7 +104,7 @@ jobs: echo "Testing demo without RPATH (should fail)..." export LLGO_FULL_RPATH=false pkg-config --libs cargs - if (cd ./_demo/cargs && llgo run .); then + if (cd ./_demo/c/cargs && llgo run .); then echo "ERROR: cargs demo should have failed without RPATH!" exit 1 else @@ -278,7 +278,7 @@ jobs: - name: Test Cross Compilation (wasm) shell: bash - working-directory: _demo + working-directory: _demo/c run: | echo "Testing cross-compilation wasm with Go 1.24.2" diff --git a/.github/workflows/targets.yml b/.github/workflows/targets.yml index 944a87b8..0da8acb0 100644 --- a/.github/workflows/targets.yml +++ b/.github/workflows/targets.yml @@ -3,7 +3,7 @@ name: Targets on: push: - branches: + branches: - "**" - "!dependabot/**" pull_request: @@ -43,5 +43,5 @@ jobs: - name: Build targets run: | - cd _demo/targetsbuild + cd _demo/embed/targetsbuild bash build.sh diff --git a/.github/workflows/test_demo.sh b/.github/workflows/test_demo.sh index 42232e2f..18898348 100644 --- a/.github/workflows/test_demo.sh +++ b/.github/workflows/test_demo.sh @@ -1,11 +1,11 @@ #!/bin/bash set -e -# llgo run subdirectories under _demo and _pydemo that contain *.go files +# llgo run subdirectories under _demo that contain *.go files total=0 failed=0 failed_cases="" -for d in ./_demo/* ./_pydemo/*; do +for d in ./_demo/go/* ./_demo/py/* ./_demo/c/*; do if [ -d "$d" ] && [ -n "$(ls "$d"/*.go 2>/dev/null)" ]; then total=$((total+1)) echo "Testing $d" diff --git a/README.md b/README.md index 241a7043..c0793def 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,14 @@ This is a simple example of calling the C `printf` function to print `Hello worl The `_demo` directory contains some C standard libary related demos (it start with `_` to prevent the `go` command from compiling it): -* [hello](_demo/hello/hello.go): call C `printf` to print `Hello world` -* [concat](_demo/concat/concat.go): call C `fprintf` with `stderr` -* [qsort](_demo/qsort/qsort.go): call C function with a callback (eg. `qsort`) +* [hello](_demo/c/hello/hello.go): call C `printf` to print `Hello world` +* [concat](_demo/c/concat/concat.go): call C `fprintf` with `stderr` +* [qsort](_demo/c/qsort/qsort.go): call C function with a callback (eg. `qsort`) To run these demos (If you haven't installed `llgo` yet, please refer to [How to install](#how-to-install)): ```sh -cd # eg. cd _demo/hello +cd # eg. cd _demo/c/hello llgo run . ``` @@ -88,7 +88,7 @@ import _ "unsafe" // for go:linkname func Sqrt(x float64) float64 ``` -You can directly integrate it into [your own code](_demo/linkname/linkname.go): +You can directly integrate it into [your own code](_demo/c/linkname/linkname.go): @@ -204,17 +204,17 @@ func main() { Here we define two 3x3 matrices a and b, add them to get x, and then print the result. -The `_pydemo` directory contains some python related demos: +The `_demo/py/` directory contains some python related demos: -* [callpy](_pydemo/callpy/callpy.go): call Python standard library function `math.sqrt` -* [pi](_pydemo/pi/pi.go): print python constants `math.pi` -* [statistics](_pydemo/statistics/statistics.go): define a python list and call `statistics.mean` to get the mean -* [matrix](_pydemo/matrix/matrix.go): a basic `numpy` demo +* [callpy](_demo/py/callpy/callpy.go): call Python standard library function `math.sqrt` +* [pi](_demo/py/pi/pi.go): print python constants `math.pi` +* [statistics](_demo/py/statistics/statistics.go): define a python list and call `statistics.mean` to get the mean +* [matrix](_demo/py/matrix/matrix.go): a basic `numpy` demo To run these demos (If you haven't installed `llgo` yet, please refer to [How to install](#how-to-install)): ```sh -cd # eg. cd _pydemo/callpy +cd # eg. cd _demo/py/callpy llgo run . ``` @@ -242,7 +242,7 @@ The currently supported libraries include: Here are some examples related to them: -* [llama2-c](_demo/llama2-c): inference Llama 2 (It's the first llgo AI example) +* [llama2-c](_demo/c/llama2-c): inference Llama 2 (It's the first llgo AI example) * [mkjson](https://github.com/goplus/lib/tree/main/c/cjson/_demo/mkjson/mkjson.go): create a json object and print it * [sqlitedemo](https://github.com/goplus/lib/tree/main/c/sqlite/_demo/sqlitedemo/demo.go): a basic sqlite demo * [tetris](https://github.com/goplus/lib/tree/main/c/raylib/_demo/tetris/tetris.go): a tetris game based on raylib @@ -252,11 +252,11 @@ Here are some examples related to them: All Go syntax (including `cgo`) is already supported. Here are some examples: -* [concat](_demo/concat/concat.go): define a variadic function -* [genints](_demo/genints/genints.go): various forms of closure usage (including C function, recv.method and anonymous function) +* [concat](_demo/c/concat/concat.go): define a variadic function +* [genints](_demo/c/genints/genints.go): various forms of closure usage (including C function, recv.method and anonymous function) * [errors](_cmptest/errors/errors.go): demo to implement error interface * [defer](_cmptest/defer/defer.go): defer demo -* [goroutine](_demo/goroutine/goroutine.go): goroutine demo +* [goroutine](_demo/go/goroutine/goroutine.go): goroutine demo ### Defer diff --git a/_demo/asmcall/asmcall.go b/_demo/c/asmcall/asmcall.go similarity index 100% rename from _demo/asmcall/asmcall.go rename to _demo/c/asmcall/asmcall.go diff --git a/_demo/asmfullcall/asmfullcall.go b/_demo/c/asmfullcall/asmfullcall.go similarity index 100% rename from _demo/asmfullcall/asmfullcall.go rename to _demo/c/asmfullcall/asmfullcall.go diff --git a/_demo/asmfullcall/asmfullcall_darwin.go b/_demo/c/asmfullcall/asmfullcall_darwin.go similarity index 100% rename from _demo/asmfullcall/asmfullcall_darwin.go rename to _demo/c/asmfullcall/asmfullcall_darwin.go diff --git a/_demo/asmfullcall/asmfullcall_linux.go b/_demo/c/asmfullcall/asmfullcall_linux.go similarity index 100% rename from _demo/asmfullcall/asmfullcall_linux.go rename to _demo/c/asmfullcall/asmfullcall_linux.go diff --git a/_demo/cabi/main.go b/_demo/c/cabi/main.go similarity index 100% rename from _demo/cabi/main.go rename to _demo/c/cabi/main.go diff --git a/_demo/cabi/wrap/wrap.c b/_demo/c/cabi/wrap/wrap.c similarity index 100% rename from _demo/cabi/wrap/wrap.c rename to _demo/c/cabi/wrap/wrap.c diff --git a/_demo/cabisret/main.go b/_demo/c/cabisret/main.go similarity index 100% rename from _demo/cabisret/main.go rename to _demo/c/cabisret/main.go diff --git a/_demo/cargs/demo.go b/_demo/c/cargs/demo.go similarity index 100% rename from _demo/cargs/demo.go rename to _demo/c/cargs/demo.go diff --git a/_demo/catomic/atomic.go b/_demo/c/catomic/atomic.go similarity index 100% rename from _demo/catomic/atomic.go rename to _demo/c/catomic/atomic.go diff --git a/_demo/cexec/exec.go b/_demo/c/cexec/exec.go similarity index 100% rename from _demo/cexec/exec.go rename to _demo/c/cexec/exec.go diff --git a/_demo/cgofull/bar.go b/_demo/c/cgofull/bar.go similarity index 100% rename from _demo/cgofull/bar.go rename to _demo/c/cgofull/bar.go diff --git a/_demo/cgofull/cgofull.go b/_demo/c/cgofull/cgofull.go similarity index 97% rename from _demo/cgofull/cgofull.go rename to _demo/c/cgofull/cgofull.go index 18fda6aa..8da0d0c3 100644 --- a/_demo/cgofull/cgofull.go +++ b/_demo/c/cgofull/cgofull.go @@ -106,8 +106,8 @@ import ( "fmt" "unsafe" - "github.com/goplus/llgo/_demo/cgofull/pymod1" - "github.com/goplus/llgo/_demo/cgofull/pymod2" + "github.com/goplus/llgo/_demo/c/cgofull/pymod1" + "github.com/goplus/llgo/_demo/c/cgofull/pymod2" ) //export go_callback_not_use_in_go diff --git a/_demo/cgofull/foo.c b/_demo/c/cgofull/foo.c similarity index 100% rename from _demo/cgofull/foo.c rename to _demo/c/cgofull/foo.c diff --git a/_demo/cgofull/foo.go b/_demo/c/cgofull/foo.go similarity index 100% rename from _demo/cgofull/foo.go rename to _demo/c/cgofull/foo.go diff --git a/_demo/cgofull/foo.h b/_demo/c/cgofull/foo.h similarity index 100% rename from _demo/cgofull/foo.h rename to _demo/c/cgofull/foo.h diff --git a/_demo/cgofull/py.go b/_demo/c/cgofull/py.go similarity index 100% rename from _demo/cgofull/py.go rename to _demo/c/cgofull/py.go diff --git a/_demo/cgofull/pymod1/pymod1.go b/_demo/c/cgofull/pymod1/pymod1.go similarity index 100% rename from _demo/cgofull/pymod1/pymod1.go rename to _demo/c/cgofull/pymod1/pymod1.go diff --git a/_demo/cgofull/pymod2/pymod2.go b/_demo/c/cgofull/pymod2/pymod2.go similarity index 100% rename from _demo/cgofull/pymod2/pymod2.go rename to _demo/c/cgofull/pymod2/pymod2.go diff --git a/_demo/concat/concat.go b/_demo/c/concat/concat.go similarity index 100% rename from _demo/concat/concat.go rename to _demo/c/concat/concat.go diff --git a/_demo/cppintf/cppintf.go b/_demo/c/cppintf/cppintf.go similarity index 91% rename from _demo/cppintf/cppintf.go rename to _demo/c/cppintf/cppintf.go index ab549de6..7b842036 100644 --- a/_demo/cppintf/cppintf.go +++ b/_demo/c/cppintf/cppintf.go @@ -3,7 +3,7 @@ package main import ( "github.com/goplus/lib/c" "github.com/goplus/lib/c/math" - "github.com/goplus/llgo/_demo/cppintf/foo" + "github.com/goplus/llgo/_demo/c/cppintf/foo" ) type Bar struct { diff --git a/_demo/cppintf/foo/bar/bar.cpp b/_demo/c/cppintf/foo/bar/bar.cpp similarity index 100% rename from _demo/cppintf/foo/bar/bar.cpp rename to _demo/c/cppintf/foo/bar/bar.cpp diff --git a/_demo/cppintf/foo/foo.go b/_demo/c/cppintf/foo/foo.go similarity index 100% rename from _demo/cppintf/foo/foo.go rename to _demo/c/cppintf/foo/foo.go diff --git a/_demo/cppmintf/cpp_multi_intf.go b/_demo/c/cppmintf/cpp_multi_intf.go similarity index 93% rename from _demo/cppmintf/cpp_multi_intf.go rename to _demo/c/cppmintf/cpp_multi_intf.go index 80c8ef05..68f21ca4 100644 --- a/_demo/cppmintf/cpp_multi_intf.go +++ b/_demo/c/cppmintf/cpp_multi_intf.go @@ -5,7 +5,7 @@ import ( "github.com/goplus/lib/c" "github.com/goplus/lib/c/math" - "github.com/goplus/llgo/_demo/cppmintf/foo" + "github.com/goplus/llgo/_demo/c/cppmintf/foo" ) type Bar struct { diff --git a/_demo/cppmintf/foo/bar/bar.cpp b/_demo/c/cppmintf/foo/bar/bar.cpp similarity index 100% rename from _demo/cppmintf/foo/bar/bar.cpp rename to _demo/c/cppmintf/foo/bar/bar.cpp diff --git a/_demo/cppmintf/foo/foo.go b/_demo/c/cppmintf/foo/foo.go similarity index 100% rename from _demo/cppmintf/foo/foo.go rename to _demo/c/cppmintf/foo/foo.go diff --git a/_demo/cppstr/cppstr.go b/_demo/c/cppstr/cppstr.go similarity index 100% rename from _demo/cppstr/cppstr.go rename to _demo/c/cppstr/cppstr.go diff --git a/_demo/crand/rand.go b/_demo/c/crand/rand.go similarity index 100% rename from _demo/crand/rand.go rename to _demo/c/crand/rand.go diff --git a/_demo/ctime/time.go b/_demo/c/ctime/time.go similarity index 100% rename from _demo/ctime/time.go rename to _demo/c/ctime/time.go diff --git a/_demo/fcntl/fcntl.go b/_demo/c/fcntl/fcntl.go similarity index 100% rename from _demo/fcntl/fcntl.go rename to _demo/c/fcntl/fcntl.go diff --git a/_demo/genints/genints.go b/_demo/c/genints/genints.go similarity index 100% rename from _demo/genints/genints.go rename to _demo/c/genints/genints.go diff --git a/_demo/getcwd/getcwd.go b/_demo/c/getcwd/getcwd.go similarity index 100% rename from _demo/getcwd/getcwd.go rename to _demo/c/getcwd/getcwd.go diff --git a/_demo/c/go.mod b/_demo/c/go.mod new file mode 100644 index 00000000..a884acab --- /dev/null +++ b/_demo/c/go.mod @@ -0,0 +1,5 @@ +module github.com/goplus/llgo/_demo/c + +go 1.20 + +require github.com/goplus/lib v0.3.0 diff --git a/_demo/c/go.sum b/_demo/c/go.sum new file mode 100644 index 00000000..54e0f00c --- /dev/null +++ b/_demo/c/go.sum @@ -0,0 +1,2 @@ +github.com/goplus/lib v0.3.0 h1:y0ZGb5Q/RikW1oMMB4Di7XIZIpuzh/7mlrR8HNbxXCA= +github.com/goplus/lib v0.3.0/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0= diff --git a/_demo/hello/hello.go b/_demo/c/hello/hello.go similarity index 100% rename from _demo/hello/hello.go rename to _demo/c/hello/hello.go diff --git a/_demo/helloc/helloc.go b/_demo/c/helloc/helloc.go similarity index 100% rename from _demo/helloc/helloc.go rename to _demo/c/helloc/helloc.go diff --git a/_demo/linkname/linkname.go b/_demo/c/linkname/linkname.go similarity index 100% rename from _demo/linkname/linkname.go rename to _demo/c/linkname/linkname.go diff --git a/_demo/llama2-c/README.md b/_demo/c/llama2-c/README.md similarity index 100% rename from _demo/llama2-c/README.md rename to _demo/c/llama2-c/README.md diff --git a/_demo/llama2-c/assets/llama_cute.jpg b/_demo/c/llama2-c/assets/llama_cute.jpg similarity index 100% rename from _demo/llama2-c/assets/llama_cute.jpg rename to _demo/c/llama2-c/assets/llama_cute.jpg diff --git a/_demo/llama2-c/run.go b/_demo/c/llama2-c/run.go similarity index 99% rename from _demo/llama2-c/run.go rename to _demo/c/llama2-c/run.go index 12c3b3e8..5e68e3bd 100644 --- a/_demo/llama2-c/run.go +++ b/_demo/c/llama2-c/run.go @@ -36,7 +36,6 @@ loop: // parse command line arguments // build the Tokenizer via the tokenizer .bin file var tokenizer llama2.Tokenizer llama2.BuildTokenizer(&tokenizer, tokenizerPath, transformer.Config.VocabSize) - // build the Sampler var sampler llama2.Sampler llama2.BuildSampler(&sampler, transformer.Config.VocabSize, temperature, topp, rngSeed) diff --git a/_demo/llama2-c/tokenizer.bin b/_demo/c/llama2-c/tokenizer.bin similarity index 100% rename from _demo/llama2-c/tokenizer.bin rename to _demo/c/llama2-c/tokenizer.bin diff --git a/_demo/netdbdemo/netdb.go b/_demo/c/netdbdemo/netdb.go similarity index 100% rename from _demo/netdbdemo/netdb.go rename to _demo/c/netdbdemo/netdb.go diff --git a/_demo/qsort/qsort.go b/_demo/c/qsort/qsort.go similarity index 100% rename from _demo/qsort/qsort.go rename to _demo/c/qsort/qsort.go diff --git a/_demo/setjmp/setjmp.go b/_demo/c/setjmp/setjmp.go similarity index 100% rename from _demo/setjmp/setjmp.go rename to _demo/c/setjmp/setjmp.go diff --git a/_demo/socket/client/client.go b/_demo/c/socket/client/client.go similarity index 100% rename from _demo/socket/client/client.go rename to _demo/c/socket/client/client.go diff --git a/_demo/socket/server/server.go b/_demo/c/socket/server/server.go similarity index 100% rename from _demo/socket/server/server.go rename to _demo/c/socket/server/server.go diff --git a/_demo/syncdebug/syncdebug.go b/_demo/c/syncdebug/syncdebug.go similarity index 100% rename from _demo/syncdebug/syncdebug.go rename to _demo/c/syncdebug/syncdebug.go diff --git a/_demo/thread/thd.go b/_demo/c/thread/thd.go similarity index 100% rename from _demo/thread/thd.go rename to _demo/c/thread/thd.go diff --git a/_demo/embed/go.mod b/_demo/embed/go.mod new file mode 100644 index 00000000..d4df4485 --- /dev/null +++ b/_demo/embed/go.mod @@ -0,0 +1,5 @@ +module github.com/goplus/llgo/_demo/embed + +go 1.20 + +require github.com/goplus/lib v0.3.0 diff --git a/_demo/embed/go.sum b/_demo/embed/go.sum new file mode 100644 index 00000000..54e0f00c --- /dev/null +++ b/_demo/embed/go.sum @@ -0,0 +1,2 @@ +github.com/goplus/lib v0.3.0 h1:y0ZGb5Q/RikW1oMMB4Di7XIZIpuzh/7mlrR8HNbxXCA= +github.com/goplus/lib v0.3.0/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0= diff --git a/_embdemo/hello-esp32/main.go b/_demo/embed/hello-esp32/main.go similarity index 100% rename from _embdemo/hello-esp32/main.go rename to _demo/embed/hello-esp32/main.go diff --git a/_embdemo/hello-esp32/uart.go b/_demo/embed/hello-esp32/uart.go similarity index 100% rename from _embdemo/hello-esp32/uart.go rename to _demo/embed/hello-esp32/uart.go diff --git a/_demo/targetsbuild/C/c.go b/_demo/embed/targetsbuild/C/c.go similarity index 100% rename from _demo/targetsbuild/C/c.go rename to _demo/embed/targetsbuild/C/c.go diff --git a/_demo/targetsbuild/build.sh b/_demo/embed/targetsbuild/build.sh similarity index 96% rename from _demo/targetsbuild/build.sh rename to _demo/embed/targetsbuild/build.sh index 3f6bd4fe..e62e03dc 100644 --- a/_demo/targetsbuild/build.sh +++ b/_demo/embed/targetsbuild/build.sh @@ -111,7 +111,7 @@ if [ $# -eq 1 ]; then done < "$target_file" else # Use targets from *.json files - for target_file in ../../targets/*.json; do + for target_file in ../../../targets/*.json; do # Extract target name from filename (remove path and .json extension) target=$(basename "$target_file" .json) targets_to_build+=("$target") @@ -127,9 +127,9 @@ for target in "${targets_to_build[@]}"; do continue fi - output=$(../../llgo.sh build -target $target -o hello.out . 2>&1) + output=$(../../../llgo.sh build -target $target -o hello.elf . 2>&1) if [ $? -eq 0 ]; then - echo ✅ $target `file hello.out` + echo ✅ $target `file hello.elf` successful_targets+=("$target") else # Check if output contains warning messages diff --git a/_demo/embed/targetsbuild/empty.go b/_demo/embed/targetsbuild/empty.go new file mode 100644 index 00000000..9ecfe9da --- /dev/null +++ b/_demo/embed/targetsbuild/empty.go @@ -0,0 +1,6 @@ +package main + +import _ "github.com/goplus/llgo/_demo/embed/targetsbuild/C" + +func main() { +} diff --git a/_embdemo/write-esp32/main.go b/_demo/embed/write-esp32/main.go similarity index 100% rename from _embdemo/write-esp32/main.go rename to _demo/embed/write-esp32/main.go diff --git a/_demo/async/async/async.go b/_demo/go/async/async/async.go similarity index 100% rename from _demo/async/async/async.go rename to _demo/go/async/async/async.go diff --git a/_demo/async/main.go b/_demo/go/async/main.go similarity index 77% rename from _demo/async/main.go rename to _demo/go/async/main.go index 6bc63d82..6497992b 100644 --- a/_demo/async/main.go +++ b/_demo/go/async/main.go @@ -3,8 +3,8 @@ package main import ( "time" - "github.com/goplus/llgo/_demo/async/async" - "github.com/goplus/llgo/_demo/async/timeout" + "github.com/goplus/llgo/_demo/go/async/async" + "github.com/goplus/llgo/_demo/go/async/timeout" ) func Sleep(i int, d time.Duration) async.Future[int] { diff --git a/_demo/async/timeout/timeout.go b/_demo/go/async/timeout/timeout.go similarity index 82% rename from _demo/async/timeout/timeout.go rename to _demo/go/async/timeout/timeout.go index 20d632e7..514bbab2 100644 --- a/_demo/async/timeout/timeout.go +++ b/_demo/go/async/timeout/timeout.go @@ -3,7 +3,7 @@ package timeout import ( "time" - "github.com/goplus/llgo/_demo/async/async" + "github.com/goplus/llgo/_demo/go/async/async" ) func Timeout(d time.Duration) async.Future[async.Void] { diff --git a/_demo/checkfile/demo.go b/_demo/go/checkfile/demo.go similarity index 100% rename from _demo/checkfile/demo.go rename to _demo/go/checkfile/demo.go diff --git a/_demo/commandrun/commandrun.go b/_demo/go/commandrun/commandrun.go similarity index 100% rename from _demo/commandrun/commandrun.go rename to _demo/go/commandrun/commandrun.go diff --git a/_demo/complex/cmplx.go b/_demo/go/complex/cmplx.go similarity index 100% rename from _demo/complex/cmplx.go rename to _demo/go/complex/cmplx.go diff --git a/_demo/defer/main.go b/_demo/go/defer/main.go similarity index 100% rename from _demo/defer/main.go rename to _demo/go/defer/main.go diff --git a/_demo/failed/stacktrace/main.go b/_demo/go/failed/stacktrace/main.go similarity index 100% rename from _demo/failed/stacktrace/main.go rename to _demo/go/failed/stacktrace/main.go diff --git a/_demo/go/go.mod b/_demo/go/go.mod new file mode 100644 index 00000000..29e8d2a2 --- /dev/null +++ b/_demo/go/go.mod @@ -0,0 +1,3 @@ +module github.com/goplus/llgo/_demo/go + +go 1.20 diff --git a/_demo/go/go.sum b/_demo/go/go.sum new file mode 100644 index 00000000..e69de29b diff --git a/_demo/goroutine/goroutine.go b/_demo/go/goroutine/goroutine.go similarity index 100% rename from _demo/goroutine/goroutine.go rename to _demo/go/goroutine/goroutine.go diff --git a/_demo/gotime/time.go b/_demo/go/gotime/time.go similarity index 100% rename from _demo/gotime/time.go rename to _demo/go/gotime/time.go diff --git a/_demo/ifaceconv/main.go b/_demo/go/ifaceconv/main.go similarity index 100% rename from _demo/ifaceconv/main.go rename to _demo/go/ifaceconv/main.go diff --git a/_demo/logdemo/log.go b/_demo/go/logdemo/log.go similarity index 100% rename from _demo/logdemo/log.go rename to _demo/go/logdemo/log.go diff --git a/_demo/math/math.go b/_demo/go/math/math.go similarity index 100% rename from _demo/math/math.go rename to _demo/go/math/math.go diff --git a/_demo/mimeheader/mimeheader.go b/_demo/go/mimeheader/mimeheader.go similarity index 100% rename from _demo/mimeheader/mimeheader.go rename to _demo/go/mimeheader/mimeheader.go diff --git a/_demo/mkdirdemo/mkdir.go b/_demo/go/mkdirdemo/mkdir.go similarity index 100% rename from _demo/mkdirdemo/mkdir.go rename to _demo/go/mkdirdemo/mkdir.go diff --git a/_demo/oslookpath/lookpath.go b/_demo/go/oslookpath/lookpath.go similarity index 100% rename from _demo/oslookpath/lookpath.go rename to _demo/go/oslookpath/lookpath.go diff --git a/_demo/randcrypt/rand.go b/_demo/go/randcrypt/rand.go similarity index 100% rename from _demo/randcrypt/rand.go rename to _demo/go/randcrypt/rand.go diff --git a/_demo/randdemo/rand.go b/_demo/go/randdemo/rand.go similarity index 100% rename from _demo/randdemo/rand.go rename to _demo/go/randdemo/rand.go diff --git a/_demo/readdir/main.go b/_demo/go/readdir/main.go similarity index 100% rename from _demo/readdir/main.go rename to _demo/go/readdir/main.go diff --git a/_demo/reflectfunc/reflectfunc.go b/_demo/go/reflectfunc/reflectfunc.go similarity index 100% rename from _demo/reflectfunc/reflectfunc.go rename to _demo/go/reflectfunc/reflectfunc.go diff --git a/_demo/sync/sync.go b/_demo/go/sync/sync.go similarity index 100% rename from _demo/sync/sync.go rename to _demo/go/sync/sync.go diff --git a/_demo/sysexec/exec.go b/_demo/go/sysexec/exec.go similarity index 100% rename from _demo/sysexec/exec.go rename to _demo/go/sysexec/exec.go diff --git a/_demo/timedur/timedur.go b/_demo/go/timedur/timedur.go similarity index 100% rename from _demo/timedur/timedur.go rename to _demo/go/timedur/timedur.go diff --git a/_pydemo/callpy/callpy.go b/_demo/py/callpy/callpy.go similarity index 100% rename from _pydemo/callpy/callpy.go rename to _demo/py/callpy/callpy.go diff --git a/_demo/go.mod b/_demo/py/go.mod similarity index 54% rename from _demo/go.mod rename to _demo/py/go.mod index b5dd0630..ff0c900a 100644 --- a/_demo/go.mod +++ b/_demo/py/go.mod @@ -1,4 +1,4 @@ -module github.com/goplus/llgo/_demo +module github.com/goplus/llgo/_demo/py go 1.20 diff --git a/_demo/go.sum b/_demo/py/go.sum similarity index 100% rename from _demo/go.sum rename to _demo/py/go.sum diff --git a/_pydemo/matrix/matrix.go b/_demo/py/matrix/matrix.go similarity index 100% rename from _pydemo/matrix/matrix.go rename to _demo/py/matrix/matrix.go diff --git a/_pydemo/max/max.go b/_demo/py/max/max.go similarity index 100% rename from _pydemo/max/max.go rename to _demo/py/max/max.go diff --git a/_pydemo/pi/pi.go b/_demo/py/pi/pi.go similarity index 100% rename from _pydemo/pi/pi.go rename to _demo/py/pi/pi.go diff --git a/_pydemo/print/print.go b/_demo/py/print/print.go similarity index 100% rename from _pydemo/print/print.go rename to _demo/py/print/print.go diff --git a/_pydemo/statistics/statistics.go b/_demo/py/statistics/statistics.go similarity index 100% rename from _pydemo/statistics/statistics.go rename to _demo/py/statistics/statistics.go diff --git a/_pydemo/tensor/tensor.go b/_demo/py/tensor/tensor.go similarity index 100% rename from _pydemo/tensor/tensor.go rename to _demo/py/tensor/tensor.go diff --git a/_demo/targetsbuild/empty.go b/_demo/targetsbuild/empty.go deleted file mode 100644 index 71be2ff7..00000000 --- a/_demo/targetsbuild/empty.go +++ /dev/null @@ -1,6 +0,0 @@ -package main - -import _ "github.com/goplus/llgo/_demo/targetsbuild/C" - -func main() { -} diff --git a/_pydemo/go.mod b/_pydemo/go.mod deleted file mode 100644 index c117f8d9..00000000 --- a/_pydemo/go.mod +++ /dev/null @@ -1,5 +0,0 @@ -module github.com/goplus/llgo/_pydemo - -go 1.20 - -require github.com/goplus/lib v0.2.0 diff --git a/_pydemo/go.sum b/_pydemo/go.sum deleted file mode 100644 index 512980a5..00000000 --- a/_pydemo/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -github.com/goplus/lib v0.2.0 h1:AjqkN1XK5H23wZMMlpaUYAMCDAdSBQ2NMFrLtSh7W4g= -github.com/goplus/lib v0.2.0/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0=