guild icon
Toit
#Steps to use pkg-cli ?
Thread channel in help
davidg238
davidg238 03/26/2024 06:02 AM
david@MSI-7D43:~/workspaceToit$ git clone https://github.com/toitlang/pkg-cli.git ... etc ... david@MSI-7D43:~/workspaceToit$ cd pkg-cli david@MSI-7D43:~/workspaceToit/pkg-cli$ make all mkdir -p build # We need to set a build type, otherwise cmake won't run nicely on Windows. # The build-type is otherwise unused. cmake -B build -DCMAKE_BUILD_TYPE=Debug TPKG: toit.pkg Failing tests: Skipped tests: -- Configuring done (0.0s) -- Generating done (0.0s) -- Build files have been written to: /home/david/workspaceToit/pkg-cli/build cmake --build build --target install-pkgs gmake[1]: Entering directory '/home/david/workspaceToit/pkg-cli/build' gmake[2]: Entering directory '/home/david/workspaceToit/pkg-cli/build' gmake[3]: Entering directory '/home/david/workspaceToit/pkg-cli/build' gmake[4]: Entering directory '/home/david/workspaceToit/pkg-cli/build' gmake[4]: Leaving directory '/home/david/workspaceToit/pkg-cli/build' gmake[4]: Entering directory '/home/david/workspaceToit/pkg-cli/build' /bin/sh: 1: toit.pkg: not found gmake[4]: *** [tests/CMakeFiles/install-pkgs.dir/build.make:70: tests/CMakeFiles/install-pkgs] Error 127 gmake[4]: Leaving directory '/home/david/workspaceToit/pkg-cli/build' gmake[3]: *** [CMakeFiles/Makefile2:99: tests/CMakeFiles/install-pkgs.dir/all] Error 2 gmake[3]: Leaving directory '/home/david/workspaceToit/pkg-cli/build' gmake[2]: *** [CMakeFiles/Makefile2:106: tests/CMakeFiles/install-pkgs.dir/rule] Error 2 gmake[2]: Leaving directory '/home/david/workspaceToit/pkg-cli/build' gmake[1]: *** [Makefile:134: install-pkgs] Error 2 gmake[1]: Leaving directory '/home/david/workspaceToit/pkg-cli/build' make: *** [Makefile:12: install-pkgs] Error 2 david@MSI-7D43:~/workspaceToit/pkg-cli$
1) How to resolve the above errors ?
2) If no errors, does this create a named executable, that I can run with the args as defined ?
I don't understand the Usage comment in examples/main.toit, reading:
Usage: examples/main.toit <command>
floitsch
floitsch 03/26/2024 11:09 AM
The cli package is just a package like other packages. No need to run make.
There is a makefile because we use it for testing, but you shouldn't need to.
floitsch
floitsch 03/26/2024 11:09 AM
If you want to write a command-line application I recommend to install the Toit SDK, and not just Jaguar. Jaguar is really optimized for device-development; not host development.
floitsch
floitsch 03/26/2024 11:11 AM
That said, you can use the cli package with Jaguar and jag run -d host as well.
floitsch
floitsch 03/26/2024 11:12 AM
The usual procedure: install the cli package (jag pkg install or toit.pkg) and then use it.
floitsch
floitsch 03/26/2024 11:13 AM
If you want to build executables, then you should install the Toit SDK, though.
Start by installing it: the release page of https://github.com/toitlang/toit has prebuilt executables/installers for many platforms.
Then:
- toit.pkg to install packages (same as jag pkg).
- toit.run to run programs (same as jag -d host run)
- toit.compile: this is where things get interesting: toit.compile -o my-exe main.toit will compile main.toit into an executable.
Program your microcontrollers in a fast and robust high-level language. - toitlang/toit
davidg238
davidg238 03/26/2024 04:16 PM
I was not sure how to use jag, since:
david@MSI-7D43:~/workspaceToit/pkg-cli/examples$ jag run -d host main.toit device calling 'emit' Error: Missing subcommand. Manage a particular device. Use the '--device' option to specify a specific device. Otherwise, the last used device is used. ... etc
worked as expected, whereas:
david@MSI-7D43:~/workspaceToit/pkg-cli/examples$ jag run -d host main.toit device --help Run the specified .toit file on a Jaguar device as a new program. If the device is already executing another program, that program is stopped before the new program is started. If you specify the device to be 'host' with the option '-d host', then the ... etc
the --help option was was being used by jag, not main.toit
floitsch
floitsch 03/26/2024 04:17 PM
aah. jag run probably uses the --help.
davidg238
davidg238 03/26/2024 04:17 PM
Hence the question about how to really execute
floitsch
floitsch 03/26/2024 04:17 PM
You can probably jag run -d host -- main.toit device --help.
floitschfloitsch
You can probably jag run -d host -- main.toit device --help.
floitsch
floitsch 03/26/2024 04:18 PM
Just tested it. This should work.
davidg238
davidg238 03/26/2024 04:20 PM
yes, thx ... will look at jag for -- after host
davidg238
davidg238 03/26/2024 04:22 PM
btw, have you seen any issues with building the Toit SDK on Ubuntu 22.04.4, I got:
-- Generating done -- Build files have been written to: /home/david/toit/build/host make[1]: Leaving directory '/home/david/toit' (cd build/host && ninja build_tools) [5/494] Generating sdk/bin/toit.lsp FAILED: sdk/bin/toit.lsp /home/david/toit/build/host/sdk/bin/toit.lsp cd /home/david/toit/tools/toitlsp && /usr/bin/cmake -E env GODEBUG=netdns=go GOOS= GOARCH= go build -ldflags \ -X\ main.date=2024-03-26T16:02:22Z\ -X\ main.version=v2.0.0-alpha.143.4+32145fba -tags netgo\ osusergo -o /home/david/toit/build/host/sdk/bin/toit.lsp No such file or directory [6/494] Generating sdk/bin/toit.pkg FAILED: sdk/bin/toit.pkg /home/david/toit/build/host/sdk/bin/toit.pkg cd /home/david/toit/tools/tpkg && /usr/bin/cmake -E env GODEBUG=netdns=go GOOS= GOARCH= go build -ldflags \ -X\ main.date=2024-03-26T16:02:22Z\ -X\ main.version=v2.0.0-alpha.143.4+32145fba -tags netgo\ osusergo -o /home/david/toit/build/host/sdk/bin/toit.pkg No such file or directory [14/494] Building CXX object src/CMakeFiles/toit_core.dir/flash_registry_posix.cc.o ninja: build stopped: subcommand failed.
floitsch
floitsch 03/26/2024 04:23 PM
could you check whether /home/david/toit/tools/toitlsp exists?
floitsch
floitsch 03/26/2024 04:23 PM
It should.
floitsch
floitsch 03/26/2024 04:24 PM
The error message isn't completely clear which file or directory is missing...
davidg238
davidg238 03/26/2024 04:24 PM
floitsch
floitsch 03/26/2024 04:25 PM
That said, it's probably not the cd that fails. The error message is different there.
davidg238
davidg238 03/26/2024 04:26 PM
david@MSI-7D43:~/toit$ cmake --version cmake version 3.22.1
this is right ?
floitsch
floitsch 03/26/2024 04:26 PM
We are building on 22.04 on our build servers, so it should work.
Not yet sure what the issue could be.
davidg238
davidg238 03/26/2024 04:28 PM
ok, hopefully -- will get me far enough for now (just never had an issue building previously)
davidg238
davidg238 03/26/2024 04:28 PM
thx
floitsch
floitsch 03/26/2024 04:29 PM
For some reason Go seems to be unhappy.
davidg238
davidg238 03/26/2024 04:32 PM
maybe I need a reboot go --verion says go is not found ... strange
davidg238
davidg238 03/26/2024 04:33 PM
... and I had run sudo apt install build-essential cmake ninja-build golang
davidg238
davidg238 03/26/2024 04:39 PM
go is installed according to apt, looks like something is now wrong with my executable path, since go help fails ... thx for pointer
👍1
26 messages in total