Merge pull request #2 from 4coder-community/Monorepo

Incorporate non-source and code repo into 4cc
This commit is contained in:
Jack Punter 2023-10-28 13:15:12 +01:00 committed by GitHub
commit cbeb374b18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
837 changed files with 769639 additions and 494 deletions

7
.gitignore vendored
View File

@ -1,4 +1,3 @@
vc120.pdb
4ed_data.ctm
.DS_Store
*.dSYM
build/
current_dist*/
distributions/

View File

@ -1,78 +1,30 @@
Welcome to the 4coder code base.
# 4Coder Community
This codebase was authored by Allen Webster from 2014-2022, with help from a number of contributors:
+ Casey Muratori
+ "insofaras" Alex Baines
+ Yuval Dolev
+ Ryan Fleury
Welcome to the 4coder community repository.
Also thanks to all those who supported the project, financially and/or through all your detailed feedback.
# Building
As of May 31st 2022, I am freezing this codebase and open sourcing it.
## Windows
1. Setup the MSVC toolchain in your environment, this can be done with the `code/custom/bin/setup_cl_x64.bat` script
2. call the `package.bat` script from the code directory
1. `$ cd 4cc\code`
2. `.\bin\package.bat`
3. You can also use the `build.bat` script if you want just build the binaries, this does not copy the default config, fonts and bindings
1. `$ cd 4cc\code`
2. `$ .\bin\build.bat`
I *DO NOT* recommend learning from this codebase, especially not with an uncritical eye. It may be a useful reference for certain algorithms and architectural ideas, and it certainly contains some cautionary tales. But if you are a beginner, I encourage you to aim for more than emulating the style and structure of this codebase.
I will not be taking pull requests, or any other form of contribution in this repository. Since I am no longer maintaining this codebase, it is my intention that users who rely on 4coder will have the option to fork the codebase, fix their issues, or carry what I started in new directions according to their own vision if they would like.
The license I chose for this codebase is the very permissive MIT license. For the sake of clarity in the community of 4coder users, I ask that new forks of this codebase be given unique names.
In this readme you will find:
1. License (MIT)
2. Build Instructions
3. Notes on Major Issues
# License
Copyright (c) 2022 Allen Webster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# Build Instructions
1. Create an empty folder named "4ed" to contain the codebase.
2. Clone the repository
3. Rename the folder containing the repository to "code"
4. At the same level as the "4ed" folder, clone the "4coder-non-source" repository
5. A. On windows setup the visual studio command line magic sauce so that "cl" works
B. On linux setup g++
C. On mac setup clang
6. Navigate to the "4ed/code" folder.
7. A. On windows run "bin\build.bat"
B. On linux run "bin\build-linux.sh"
C. On linux run "bin\build-mac.sh"
# Notes on Major Issues
1. The build system and organization of files is extremely complicated. There is a 4ed_build.cpp that defines how builds run, and the build scripts have to build and run this C++ file. The file is pretty chaotic since it cannot rely on the codebase's usual helpers. On top of that there is a totally separate build system for the custom layer which is also a big gigantic mess of its own. It involves several stages of compilation, and a number of metaprograms.
2. The documentation system is over complicated & the documentation is incomplete. There is very little documentation for the internals or the complicated layers of helpers.
3. The lexer generator is way too complicated, and the built-in support for language features is not fully developed. The background threaded parsing is not very carefully organized and is not very flexible, so it's hard to add new languages at any level of the system.
4. There are a few layers of overcomplicated configuration parsers.
5. Mac support has not been maintained for several versions.
6. The codebase has a very weak base layer with key features that were added very late, so lots of code was written in the absence of useful features to bind things together. To make matters worse the base layer is split by the distinction of custom layer & core layer, leading to some double definitions and some incosistencies.
## Linux
> tested on Ubuntu 22.04:
1. 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`
2. Use the `package-linux.sh` script to build and package an application
1. `$ cd 4cc/code`
2. `$ ./bin/package-linux.sh`
3. You can also use the `build-linux.sh` script if you want just build the binaries, this does not copy the default config, fonts and bindings
1. `$ cd 4cc/code`
2. `$ ./bin/build-linux.sh`
## Mac (Untested)
1. The steps should be the same as linux but replace the `*-linux.sh` with their `*-mac.sh` equivalents.

View File

@ -1,33 +0,0 @@
#!/bin/sh
if [ "$#" -lt "3" ]
then
echo need 3 parameters
exit
else
fake=$1
maj=$2
min=$3
vr=$fake.$maj.$min
fv=$fake-$maj-$min
flags="--fix-permissions --userversion=$vr"
dir=../current_dist_all_os
butler push $flags $dir/4coder-alpha-$fv-win-x64.zip 4coder/4coder:win-x64-alpha
butler push $flags $dir/4coder-alpha-$fv-linux-x64.zip 4coder/4coder:linux-x64-alpha
butler push $flags $dir/4coder-alpha-$fv-mac-x64.zip 4coder/4coder:osx-x64-alpha
butler push $flags $dir/4coder-alpha-$fv-win-x86.zip 4coder/4coder:win-x86-alpha
butler push $flags $dir/4coder-alpha-$fv-linux-x86.zip 4coder/4coder:linux-x86-alpha
butler push $flags $dir/4coder-alpha-$fv-mac-x86.zip 4coder/4coder:osx-x86-alpha
butler push $flags $dir/4coder-alpha-$fv-super-win-x64.zip 4coder/4coder:win-x64-super
butler push $flags $dir/4coder-alpha-$fv-super-linux-x64.zip 4coder/4coder:linux-x64-super
butler push $flags $dir/4coder-alpha-$fv-super-mac-x64.zip 4coder/4coder:osx-x64-super
butler push $flags $dir/4coder-alpha-$fv-super-win-x86.zip 4coder/4coder:win-x86-super
butler push $flags $dir/4coder-alpha-$fv-super-linux-x86.zip 4coder/4coder:linux-x86-super
butler push $flags $dir/4coder-alpha-$fv-super-mac-x86.zip 4coder/4coder:osx-x86-super
fi

View File

@ -1,22 +0,0 @@
#!/bin/sh
if [ "$#" -lt "3" ]
then
echo need 3 parameters
exit
else
fake=$1
maj=$2
min=$3
vr=$fake.$maj.$min
fv=$fake-$maj-$min
flags="--fix-permissions --userversion=$vr"
dir=../distributions
butler push $flags $dir/demo_x86/4coder-$fv-demo-linux-x86.zip 4coder/4coder:linux-x86-demo
butler push $flags $dir/super_x86/4coder-$fv-super-linux-x86.zip 4coder/4coder:linux-x86
fi

View File

@ -1,22 +0,0 @@
#!/bin/sh
if [ "$#" -lt "3" ]
then
echo need 3 parameters
exit
else
fake=$1
maj=$2
min=$3
vr=$fake.$maj.$min
fv=$fake-$maj-$min
flags="--fix-permissions --userversion=$vr"
dir=../distributions
butler push $flags $dir/demo_x64/4coder-$fv-demo-linux-x64.zip 4coder/4coder:linux-x64-demo
butler push $flags $dir/super_x64/4coder-$fv-super-linux-x64.zip 4coder/4coder:linux-x64
fi

View File

@ -1,22 +0,0 @@
#!/bin/sh
if [ "$#" -lt "3" ]
then
echo need 3 parameters
exit
else
fake=$1
maj=$2
min=$3
vr=$fake.$maj.$min
fv=$fake-$maj-$min
flags="--fix-permissions --userversion=$vr"
dir=../distributions
butler push $flags $dir/demo_x64/4coder-$fv-demo-mac-x64.zip 4coder/4coder:mac-x64-demo
butler push $flags $dir/super_x64/4coder-$fv-super-mac-x64.zip 4coder/4coder:mac-x64
fi

View File

@ -1,26 +0,0 @@
@echo off
IF "%3" == "" (echo need 3 parameters & GOTO END)
SET fake=%1
SET maj=%2
SET min=%3
SET vr=%fake%.%maj%.%min%
SET fv=%fake%-%maj%-%min%
SET flags=--fix-permissions --userversion=%vr%
pushd ..
SET dir=%CD%\distributions
butler push %flags% %dir%\demo_x64\4coder-%fv%-demo-win-x64.zip 4coder/4coder:win-x64-demo
butler push %flags% %dir%\super_x64\4coder-%fv%-super-win-x64.zip 4coder/4coder:win-x64
REM butler push %flags% %dir%\demo_x86\4coder-%fv%-demo-win-x86.zip 4coder/4coder:win-x86-demo
REM butler push %flags% %dir%\super_x86\4coder-%fv%-super-win-x86.zip 4coder/4coder:win-x86
popd
:END

View File

@ -1,5 +0,0 @@
#!/bin/bash
chmod +x bin/build-linux.sh
bin/build-linux.sh "-DPACKAGE_DEMO_X86"
bin/build-linux.sh "-DPACKAGE_SUPER_X86"

View File

@ -1,6 +0,0 @@
@echo off
call bin\build.bat /DPACKAGE_DEMO_X64
call bin\build.bat /DPACKAGE_DEMO_X86
call bin\build.bat /DPACKAGE_SUPER_X64
call bin\build.bat /DPACKAGE_SUPER_X86

4
code/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
vc120.pdb
4ed_data.ctm
.DS_Store
*.dSYM

View File

78
code/README.md Normal file
View File

@ -0,0 +1,78 @@
Welcome to the 4coder code base.
This codebase was authored by Allen Webster from 2014-2022, with help from a number of contributors:
+ Casey Muratori
+ "insofaras" Alex Baines
+ Yuval Dolev
+ Ryan Fleury
Also thanks to all those who supported the project, financially and/or through all your detailed feedback.
As of May 31st 2022, I am freezing this codebase and open sourcing it.
I *DO NOT* recommend learning from this codebase, especially not with an uncritical eye. It may be a useful reference for certain algorithms and architectural ideas, and it certainly contains some cautionary tales. But if you are a beginner, I encourage you to aim for more than emulating the style and structure of this codebase.
I will not be taking pull requests, or any other form of contribution in this repository. Since I am no longer maintaining this codebase, it is my intention that users who rely on 4coder will have the option to fork the codebase, fix their issues, or carry what I started in new directions according to their own vision if they would like.
The license I chose for this codebase is the very permissive MIT license. For the sake of clarity in the community of 4coder users, I ask that new forks of this codebase be given unique names.
In this readme you will find:
1. License (MIT)
2. Build Instructions
3. Notes on Major Issues
# License
Copyright (c) 2022 Allen Webster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# Build Instructions
1. Create an empty folder named "4ed" to contain the codebase.
2. Clone the repository
3. Rename the folder containing the repository to "code"
4. At the same level as the "4ed" folder, clone the "4coder-non-source" repository
5. A. On windows setup the visual studio command line magic sauce so that "cl" works
B. On linux setup g++
C. On mac setup clang
6. Navigate to the "4ed/code" folder.
7. A. On windows run "bin\build.bat"
B. On linux run "bin\build-linux.sh"
C. On linux run "bin\build-mac.sh"
# Notes on Major Issues
1. The build system and organization of files is extremely complicated. There is a 4ed_build.cpp that defines how builds run, and the build scripts have to build and run this C++ file. The file is pretty chaotic since it cannot rely on the codebase's usual helpers. On top of that there is a totally separate build system for the custom layer which is also a big gigantic mess of its own. It involves several stages of compilation, and a number of metaprograms.
2. The documentation system is over complicated & the documentation is incomplete. There is very little documentation for the internals or the complicated layers of helpers.
3. The lexer generator is way too complicated, and the built-in support for language features is not fully developed. The background threaded parsing is not very carefully organized and is not very flexible, so it's hard to add new languages at any level of the system.
4. There are a few layers of overcomplicated configuration parsers.
5. Mac support has not been maintained for several versions.
6. The codebase has a very weak base layer with key features that were added very late, so lots of code was written in the absence of useful features to bind things together. To make matters worse the base layer is split by the distinction of custom layer & core layer, leading to some double definitions and some incosistencies.

View File

@ -112,8 +112,8 @@ char *arch_names[] = {
#define PACK_DIR "../distributions"
#define SITE_DIR "../site"
#define FOREIGN "../4coder-non-source/foreign"
#define FOREIGN_WIN "..\\4coder-non-source\\foreign"
#define FOREIGN "../non-source/foreign"
#define FOREIGN_WIN "..\\non-source\\foreign"
char *includes[] = { "custom", FOREIGN "/freetype2", 0, };
@ -189,7 +189,7 @@ get_defines_from_flags(Arena *arena, u32 flags){
#define CL_LIBS_X64 CL_LIBS_COMMON FOREIGN_WIN "\\x64\\freetype.lib"
#define CL_LIBS_X86 CL_LIBS_COMMON FOREIGN_WIN "\\x86\\freetype.lib"
#define CL_ICON "..\\4coder-non-source\\res\\icon.res"
#define CL_ICON "..\\non-source\\res\\icon.res"
internal void
build(Arena *arena, u32 flags, u32 arch, char *code_path, char **code_files, char *out_path, char *out_file, char **defines, char **exports, char **inc_folders){
@ -654,14 +654,13 @@ package(Arena *arena, char *cdir, Tier_Code tier, Arch_Code arch){
// NOTE(allen): meta
char *build_dir = fm_str(arena, BUILD_DIR);
char *pack_dir = fm_str(arena, PACK_DIR);
char *dist_files[3];
dist_files[0] = fm_str(arena, "../4coder-non-source/dist_files");
char *dist_files[2];
dist_files[0] = fm_str(arena, "../non-source/dist_files");
dist_files[1] = fm_str(arena, "ship_files");
dist_files[2] = fm_str(arena, "ship_files_super");
printf("build dir: %s\n", build_dir);
printf("pack dir: %s\n", pack_dir);
printf("dist files: %s, %s, %s\n", dist_files[0], dist_files[1], dist_files[2]);
printf("dist files: %s, %s\n", dist_files[0], dist_files[1]);
fflush(stdout);
u32 base_flags = SHIP | DEBUG_INFO | OPTIMIZATION;

View File

@ -2,14 +2,19 @@
set location=%cd%
set me="%~dp0"
REM 4cc\code\bin
cd %me%
cd ..
set src_root=%cd%
cd ..\build
set build_root=%cd%
set bin_root=%src_root%\bin
set custom_root=%src_root%\custom
REM 4cc
cd ..\..
set repo_root=%cd%
set src_root=%repo_root%\code
set build_root=%repo_root%\build
set bin_root=%repo_root%\code\bin
set custom_root=%repo_root%\code\custom
set custom_bin=%custom_root\bin
cd %location%
set mode=%1
@ -21,6 +26,8 @@ set opts=%opts% /I%src_root% /I%custom_root%
set opts=%opts% %mode%
set FirstError=0
if not exist "%build_root%" mkdir %build_root%
pushd %build_root%
call cl %opts% kernel32.lib %bin_root%\4ed_build.cpp /Febuild
if %ERRORLEVEL% neq 0 (set FirstError=1)

View File

@ -1,5 +1,4 @@
#!/bin/bash
chmod +x bin/build-linux.sh
bin/build-linux.sh "-DPACKAGE_DEMO_X64"
bin/build-linux.sh "-DPACKAGE_SUPER_X64"

View File

@ -1,5 +1,4 @@
#!/bin/bash
chmod +x bin/build-mac.sh
bin/build-mac.sh "-DPACKAGE_DEMO_X64"
bin/build-mac.sh "-DPACKAGE_SUPER_X64"

3
code/bin/package.bat Normal file
View File

@ -0,0 +1,3 @@
@echo off
call bin\build.bat /DPACKAGE_SUPER_X64

Some files were not shown because too many files have changed in this diff Show More