https://toitlang.org/ logo
Steps to use pkg-cli ?
# help
d
Copy code
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:
Copy code
Usage:
  examples/main.toit <command>
f
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.
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.
That said, you can use the cli package with Jaguar and
jag run -d host
as well.
The usual procedure: install the cli package (
jag pkg install
or
toit.pkg
) and then use it.
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.
d
I was not sure how to use jag, since:
Copy code
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:
Copy code
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
f
aah.
jag run
probably uses the
--help
.
d
Hence the question about how to really execute
f
You can probably
jag run -d host -- main.toit device --help
.
Just tested it. This should work.
d
yes, thx ... will look at jag for
--
after host
btw, have you seen any issues with building the Toit SDK on Ubuntu 22.04.4, I got:
Copy code
-- 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.
f
could you check whether /home/david/toit/tools/toitlsp exists?
It should.
The error message isn't completely clear which file or directory is missing...
f
That said, it's probably not the
cd
that fails. The error message is different there.
d
Copy code
david@MSI-7D43:~/toit$ cmake --version
cmake version 3.22.1
this is right ?
f
We are building on 22.04 on our build servers, so it should work. Not yet sure what the issue could be.
d
ok, hopefully
--
will get me far enough for now (just never had an issue building previously)
thx
f
For some reason Go seems to be unhappy.
d
maybe I need a reboot
go --verion
says go is not found ... strange
... and I had run
sudo apt install build-essential cmake ninja-build golang
go is installed according to
apt
, looks like something is now wrong with my executable path, since
go help
fails ... thx for pointer
5 Views