pocketlang/docs/pages/Getting-Started/build-from-source.md

77 lines
2.6 KiB
Markdown
Raw Normal View History

# %% Build From Source %%
## %% Without a build script %%
It can be build from source easily without any dependency, or additional
requirements except for a c99 compatible compiler. And build systems are
2021-06-01 19:50:41 +08:00
optional. It can be compiled with the following command.
2021-05-28 03:27:29 +08:00
Using gcc
```
2021-06-01 19:50:41 +08:00
gcc -o pocket cli/*.c src/*.c -Isrc/include -lm -Wno-int-to-pointer-cast
2021-05-28 03:27:29 +08:00
```
Using MSVC
```
cl /Fepocket cli/*.c src/*.c /Isrc/include && rm *.obj
```
2021-06-01 19:50:41 +08:00
For other compiler/IDE
1. Create an empty project file / makefile.
2. Add all C files in the src directory.
3. Add all C files in the cli directory (**not** recursively).
4. Add `src/include` to include path.
2021-06-01 19:50:41 +08:00
5. Compile.
If you weren't able to compile it, please report by [opening an issue](https://github.com/ThakeeNathees/pocketlang/issues/new).
2021-05-28 03:27:29 +08:00
## %% Using a build script %%
2021-05-28 03:27:29 +08:00
2021-06-01 19:50:41 +08:00
You could find some of the build script for different build system in the `build/`
directory. If you don't find a script for your preferred system, request on github
2021-06-01 19:50:41 +08:00
by [opening an issue](https://github.com/ThakeeNathees/pocketlang/issues/new) or
feel free to contribute one.
2021-05-28 03:27:29 +08:00
## %% Makefile %%
2021-05-28 03:27:29 +08:00
```
cd build && make
```
2021-06-01 19:50:41 +08:00
I haven't tested the makefile on different platforms except for "windows subsystem for linux".
And the makefile is still need to be improved. If you find any problems with the script or
2021-06-01 19:50:41 +08:00
have any improvements, let us know in [github](https://github.com/ThakeeNathees/pocketlang).
## %% Batch script with MSVC %%
2021-05-28 03:27:29 +08:00
```
cd build && build
```
2021-06-01 19:50:41 +08:00
You don't need to run the script from a Visual Studio .NET Command Prompt,
It'll search for the MSVS installation path and use it to compile. But if it
can't, try running on VS command prompt.
2021-05-28 03:27:29 +08:00
## %% SCons %%
2021-05-28 03:27:29 +08:00
2021-06-01 19:50:41 +08:00
pocketlang mainly focused on [scons](https://www.scons.org/), and it's
recommended to use it for contributions since it has various configurations
and compiler support. It's a python based build system. You need to have
python 3.6+ installed in your development environment. To install scons run
`python3 -m pip install scons`. Make sure it's version is 3.0+ and for Visual
Studio 2019 it require v3.1.1+. In Linux if scons using python2 instead of 3
you'll have to edit `/usr/local/bin/scons` or `~/.local/bin/scons` to ensure
that it points to `/usr/bin/env python3` and not `python`
2021-05-28 03:27:29 +08:00
```
cd build && scons
```
2021-06-01 19:50:41 +08:00
You can specify the number of jobs scons to use to speed up the building process
using the -j flag (-j6, -j8). To generate Visual Studio project files add `vsproj=true`
argument when building. To compile using mingw in windows use `use_mingw=true` argument.
If your build failed feel free to [open an issue](https://github.com/ThakeeNathees/pocketlang/issues/new).