- Setup the MSVC toolchain in your environment, this can be done with the
code/custom/bin/setup_cl_x64.batscript - call the
package.batscript from the code directory (this builds a distribution in thedistributionsdirectory with all the non-binary dependencies)$ cd 4cc\code.\bin\package.bat
- You can also use the
build.batscript if you want just build the binaries (this produces the build artifacts in thebuilddirectory, this doesn't produce a functional distribution)$ cd 4cc\code$ .\bin\build.bat
In addition to the parameter listed below, you can specify which backend to use by passing one of those parameters to the build scripts:
/DWIN32_OPENGL(default) to use the OpenGL backend./DWIN32_DX11to use the Direct3D 11 backend.
tested on Ubuntu 22.04:
-
Get required libraries (apt names):
$ sudo apt install build-essential libx11-dev libxfixes-dev libglx-dev mesa-common-dev libasound2-dev libfreetype-dev libfontconfig-dev
-
Use the
package-linux.shscript from the code directory (this builds a distribution in thedistributionsdirectory with all the non-binary dependencies)$ cd 4cc/code$ ./bin/package-linux.sh
-
You can also use the
build-linux.shscript if you want just build the binaries, (this produces the build artifacts in thebuilddirectory, this doesn't produce a functional distribution)$ cd 4cc/code$ ./bin/build-linux.sh
4coder targets x86_64. If you are using a M1+ ARM CPU you need to prefix the build scripts commands with:
arch -arch x86_64
-
Use the
package-mac.shscript from the code directory (this builds a distribution in thedistributionsdirectory with all the non-binary dependencies)$ cd 4cc/code$ ./bin/package-mac.sh
-
You can also use the
build-mac.shscript if you want just build the binaries, (this produces the build artifacts in thebuilddirectory, this doesn't produce a functional distribution)$ cd 4cc/code$ ./bin/build-mac.sh
If you are using an older version of mac, such as 10.15.7 Catalina you need to install the realpath command:
$ sudo port install coreutils- macports names the
realpathcommandgrealpath, so make a symbolic link in order to use build-mac.sh:
$ sudo ln -s /opt/local/bin/grealpath /opt/local/bin/realpath
The build script accepts a parameter (mutually exclusive):
/DDEV_BUILDor/DDEV_BUILD_X86(default value) : build without optimizations. Produces debug symbols. Defines:FRED_INTERNAL,FRED_SUPER,DO_CRAZY_EXPENSIVE_ASSERTS(on Windows) macros./DOPT_BUILDor/DOPT_BUILD_X86(similar tobuild_optimizedscript): build with optimizations. Doesn't produce debug symbols. DefinesFRED_SUPERmacro./DPACKAGE_SUPER_X64or/DPACKAGE_SUPER_X86(similar topackagescript): package 4coder for distribution. Turns on optimizations. Produces debug symbols. DefinesSHIP_MODE,FRED_SUPER,DO_CRAZY_EXPENSIVE_ASSERTS(on Windows) macros./DPACKAGE_DEMO_X64or/DPACKAGE_DEMO_X86: packages 4coder demo for distribution. Turns on optimizations. Produces debug symbols. DefinesSHIP_MODE,DO_CRAZY_EXPENSIVE_ASSERTS(on Windows) macros.
4coder uses several small programs to generate some headers and source files. Those do not run automatically, you must build them and run them when needed (which shouldn't really happen).
code\4ed_font_api.cppcreates, incode\generated,font_api.h,font_api.cpp,font_api_constructor.cpp(not used) andfont_api_master_list.h(not used);code\4ed_graphics_api.cppcreates, incode\generated,graphics_api.handgraphics_api.cpp,graphics_api_constructor.cpp(not used) andgraphics_api_master_list.h(not used);code\4ed_system_api.cppcreates, incode\custom\generated,system_api.h,system_api.cpp,system_api_constructor.cpp,system_api_master_list.h;code\4ed_api_parser_main.cppis a little different, as it parses source files passed as parameters to search for functions and type preceded byapi(some_api_name)and creates 4 files in thecode\custom\generated. It is used to generatecustom_api.h,custom_api.cpp,custom_api_constructor.cppandcustom_api_master_list.hby passingcode\4ed_api_implementation.cppas a parameter.
You need to compile one of those file and run it from the code directory.
There is also code\4ed_api_check.cpp to verify the generated file but it's not clear at the moment what to check against.
code\4ed_generate_keycodes.cppis also a bit appart as it generatescode\custom\generated\4coder_event_codes.hwhich are keyboard key codes and some event hook ids.