charles-l / zig-odin-raylib-template

A zig-build powered odin template for building games with raylib that compiles to a native exe or an emscripten app.
MIT License
14 stars 2 forks source link

Python script fails to execute the first build task #3

Open nezvers opened 4 months ago

nezvers commented 4 months ago
O:\Projects\Odin\Research\zig-odin-raylib-template> zig build
run python3 (odin): error: Traceback (most recent call last):
  File "O:\Projects\Odin\Research\zig-odin-raylib-template\build_utils.py", line 42, in <module>
    args.func(args)
  File "O:\Projects\Odin\Research\zig-odin-raylib-template\build_utils.py", line 31, in setup_odin
    st = os.stat(f'{target_dir}/odin')
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'O:\\Projects\\Odin\\Research\\zig-odin-raylib-template\\zig-cache\\o\\eaf6cfae0de470e35df4d91ef1b3fad7/odin'

run python3 (odin): error: the following command exited with error code 1:
python3 build_utils.py setup-odin O:\Projects\Odin\Research\zig-odin-raylib-template\zig-cache\o\eaf6cfae0de470e35df4d91ef1b3fad7\odin 
Build Summary: 2/7 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install game transitive failure
   └─ zig build-exe game Debug native transitive failure
      └─ run time transitive failure
         ├─ run python3 (odin) failure
         └─ run python3 (odin) (reused)
error: the following build command failed with exit code 1:
O:\Projects\Odin\Research\zig-odin-raylib-template\zig-cache\o\8bd97e9e0bbf2d31417df0a175a55bee\build.exe D:\Users\nezvers\.zvm\bin\zig.exe O:\Projects\Odin\Research\zig-odin-raylib-template O:\Projects\Odin\Research\zig-odin-raylib-template\zig-cache D:\Users\nezvers\AppData\Local\zig

I had python in PATH but set up from windows store to get python3 name in PATH.

I fail to see the justified existence of Python in the build setup.

A project made with Odin means that a working Odin is already set up. Odin is accessible with PATH or working directory path.

Likewise emsdk is also already set up in PATH. I don't understand what's going on there with --sysroot emsdk/upstream/emscripten.

I'm totally down for utilizing zig as a compiler and build script.

charles-l commented 4 months ago

Thanks for the feedback!

I fail to see the justified existence of Python in the build setup.

It was the quickest way to hack in a download step when I was working on my last project. I also would prefer a zig-only version of the build script though. I might port it when I have time (I also would be happy to accept a PR :))

  • It is used for a task that shouldn't be there (by reading code it looks like it downloads and unpacks

A project made with Odin means that a working Odin is already set up. Odin is accessible with PATH or working directory path.

I wanted to set it up in such a way that only zig and git are required for getting started (hence the download/unpack step -- granted this is written in Python atm, but like I mentioned I was interested in porting this to Zig). When I want to build my project on a new box, I don't want to have to visit both Zig and Odin's respective websites to download/unpack/add binary to the path. If it were just an apt-get or winget install away I wouldn't have this issue. I'll consider moving the dependency install steps to a standalone python/zig script though so it's an optional step for folks who already have odin and zig in the PATH. The tight integration with the zig build process is actually ickier than I was expecting and the whole addOutputFileArg("odin"); bit is a hack anyway.

Likewise emsdk is also already set up in PATH. I don't understand what's going on there with --sysroot emsdk/upstream/emscripten.

The sysroot flag doesn't just let the zig build process know where the emcc binary is, it also adds an important include paths: https://github.com/charles-l/zig-odin-raylib-template/blob/master/build.zig#L77

I based the emcc code off the old pacman.zig WASM demo. It looks like in the latest version this is a packaged in a nicer way, but the hack still lives there. In any case, it's definitely worth "borrowing" the latest sokol-zig emsdk build.zig code so it's nicer to work with :P I hadn't seen those improvements, but I'm happy to use a cleaner approach for the emscripten management code.

nezvers commented 4 months ago

Can you explain what that python script is doing? I tried to bypass it to last instructions by pointing to my Odin's directory in python but I didn't get it to work.

I prefer solid point by point instructions (even mentioning adding stuff to OS environment PATH variable) rather than hit a hole in a wall by getting frustrated from intermingle between languages. Just put needed files right into the repository. THEN think how to automate that. Start with simple SHARABLE version.

My only experience with emscriptem that actually compiles is with Raylib gamejam template. There's a makefile in /src folder. It requires fixing EMSDK_PATH, PYTHON_PATH, NODE_PATH. And on top it lacks a raylib building step, so need to build raylib with PLATFORM_WEB and repo being next to template repo. Could be that in raylib you need to fix those variables too.