Skip to content

Commit 171fa0a

Browse files
committed
Merge branch 'master' into macOS
2 parents b8c8c74 + 1545b1b commit 171fa0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+3095
-340
lines changed

3rdPartySrc/FindVisualStudio.cpp

+578
Large diffs are not rendered by default.

3rdPartySrc/FindVisualStudio.hpp

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
3+
struct Find_Result {
4+
int windows_sdk_version; // Zero if no Windows SDK found.
5+
6+
wchar_t *windows_sdk_root = NULL;
7+
wchar_t *windows_sdk_um_library_path = NULL;
8+
wchar_t *windows_sdk_ucrt_library_path = NULL;
9+
wchar_t *windows_sdk_include_path = NULL;
10+
11+
wchar_t *vs_exe_path = NULL;
12+
wchar_t *vs_library_path = NULL;
13+
wchar_t *vs_include_path = NULL;
14+
};
15+
16+
Find_Result find_visual_studio_and_windows_sdk();
17+
18+
void free_resources(Find_Result *result);

3rdPartySrc/FindVisualStudioCLI.cpp

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
struct Find_Result
2+
{
3+
int windows_sdk_version; // Zero if no Windows SDK found.
4+
5+
wchar_t* windows_sdk_root = NULL;
6+
wchar_t* windows_sdk_um_library_path = NULL;
7+
wchar_t* windows_sdk_ucrt_library_path = NULL;
8+
9+
wchar_t* vs_exe_path = NULL;
10+
wchar_t* vs_library_path = NULL;
11+
};
12+
13+
Find_Result find_visual_studio_and_windows_sdk();
14+
15+
int main()
16+
{
17+
Find_Result result = find_visual_studio_and_windows_sdk();
18+
free_resources(&result);
19+
return 0;
20+
}

Bootstrap.cake

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
(skip-build)
2-
31
(set-cakelisp-option executable-output "bin/cakelisp")
42

53
(add-c-search-directory-module "src")
@@ -18,6 +16,7 @@
1816
"ModuleManager.cpp"
1917
"Logging.cpp"
2018
"Build.cpp"
19+
"Metadata.cpp"
2120
"Main.cpp")
2221

2322
(add-build-options "-DUNIX" "-Wall" "-Werror" "-std=c++11")

Bootstrap_MSVC.cake

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
(skip-build)
2-
31
(set-cakelisp-option executable-output "bin/cakelisp.exe")
42

53
(add-c-search-directory-module "src")
4+
(add-c-search-directory-module "3rdPartySrc")
5+
6+
(add-linker-options "Advapi32.lib" "Ole32.lib" "OleAut32.lib")
7+
68
(add-cpp-build-dependency
79
"Tokenizer.cpp"
810
"Evaluator.cpp"
@@ -18,6 +20,8 @@
1820
"ModuleManager.cpp"
1921
"Logging.cpp"
2022
"Build.cpp"
23+
"Metadata.cpp"
24+
"FindVisualStudio.cpp"
2125
"Main.cpp")
2226

2327
(add-build-options "/nologo" "/DWINDOWS" "/DCAKELISP_EXPORTING" "/EHsc"

Build.bat

+21-10
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,18 @@ rem See https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?
44
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" (
55
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
66
) else (
7-
echo This script builds using MSVC.
8-
echo You must download and install MSVC before it will work. Download it here:
9-
echo https://visualstudio.microsoft.com/downloads/
10-
echo Select workloads for C++ projects. Ensure you install the C++ developer tools.
11-
echo If you're still seeing this, you may need to edit Build.bat to your vcvars path
12-
echo Please see the following link:
13-
echo https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-160
14-
goto fail
15-
)
7+
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" (
8+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
9+
) else (
10+
echo This script builds using MSVC.
11+
echo You must download and install MSVC before it will work. Download it here:
12+
echo https://visualstudio.microsoft.com/downloads/
13+
echo Select workloads for C++ projects. Ensure you install the C++ developer tools.
14+
echo If you're still seeing this, you may need to edit Build.bat to your vcvars path
15+
echo Please see the following link:
16+
echo https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-160
17+
goto fail
18+
))
1619

1720
if not exist "bin" (
1821
mkdir bin
@@ -39,10 +42,16 @@ CL.exe src/Tokenizer.cpp ^
3942
src/ModuleManager.cpp ^
4043
src/Logging.cpp ^
4144
src/Build.cpp ^
45+
src/Metadata.cpp ^
4246
src/Main.cpp ^
47+
3rdPartySrc/FindVisualStudio.cpp ^
48+
Advapi32.lib Ole32.lib OleAut32.lib ^
49+
/I 3rdPartySrc ^
4350
/EHsc /MP /DWINDOWS /DCAKELISP_EXPORTING ^
4451
/Fe"bin\cakelisp_bootstrap" /Zi /Fd"bin\cakelisp_bootstrap.pdb" /DEBUG:FASTLINK
4552
echo %ERRORLEVEL%
53+
rem Advapi32.lib Ole32.lib OleAut32.lib are for FindVisualStudio.cpp
54+
4655

4756
@if %ERRORLEVEL% == 0 (
4857
echo Success building
@@ -68,7 +77,9 @@ CL.exe src/Tokenizer.cpp ^
6877
goto end
6978

7079
:success
80+
rem TODO Remove
81+
rem bin\cakelisp.exe --find-visual-studio
7182
goto end
7283

7384
:end
74-
pause
85+

Build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ else
2929
src/ModuleManager.cpp \
3030
src/Logging.cpp \
3131
src/Build.cpp \
32+
src/Metadata.cpp \
3233
src/Main.cpp \
3334
-DUNIX || exit $?
3435
# Need -ldl for dynamic loading, --export-dynamic to let compile-time functions resolve to

BuildAndRunTests.sh

+2
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
# Make sure Cakelisp is up to date
44
. ./Build.sh || exit $?
55

6+
./bin/cakelisp --list-built-ins-details || exit $?
7+
68
./bin/cakelisp runtime/Config_Linux.cake test/RunTests.cake || exit $?

Build_RunTests.bat

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
echo off
22
rem Set environment variables. The user may need to adjust this path
33
rem See https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-160#developer_command_file_locations
4+
rem See https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-160#developer_command_file_locations
45
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" (
56
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
67
) else (
7-
echo This script builds using MSVC.
8-
echo You must download and install MSVC before it will work. Download it here:
9-
echo https://visualstudio.microsoft.com/downloads/
10-
echo Select workloads for C++ projects. Ensure you install the C++ developer tools.
11-
echo If you're still seeing this, you may need to edit Build.bat to your vcvars path
12-
echo Please see the following link:
13-
echo https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-160
14-
goto fail
15-
)
8+
if exist "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" (
9+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
10+
) else (
11+
echo This script builds using MSVC.
12+
echo You must download and install MSVC before it will work. Download it here:
13+
echo https://visualstudio.microsoft.com/downloads/
14+
echo Select workloads for C++ projects. Ensure you install the C++ developer tools.
15+
echo If you're still seeing this, you may need to edit Build.bat to your vcvars path
16+
echo Please see the following link:
17+
echo https://docs.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-160
18+
goto fail
19+
))
1620

1721
if not exist "bin" (
1822
mkdir bin
@@ -39,7 +43,11 @@ CL.exe src/Tokenizer.cpp ^
3943
src/ModuleManager.cpp ^
4044
src/Logging.cpp ^
4145
src/Build.cpp ^
46+
src/Metadata.cpp ^
4247
src/Main.cpp ^
48+
3rdPartySrc/FindVisualStudio.cpp ^
49+
Advapi32.lib Ole32.lib OleAut32.lib ^
50+
/I 3rdPartySrc ^
4351
/EHsc /MP /DWINDOWS /DCAKELISP_EXPORTING ^
4452
/Fe"bin\cakelisp_bootstrap" /Zi /Fd"bin\cakelisp_bootstrap.pdb" /DEBUG:FASTLINK
4553
echo %ERRORLEVEL%

Build_SimpleMacros.bat

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ CL.exe src/Tokenizer.cpp ^
3939
src/ModuleManager.cpp ^
4040
src/Logging.cpp ^
4141
src/Build.cpp ^
42+
src/Metadata.cpp ^
4243
src/Main.cpp ^
4344
/EHsc /MP /DWINDOWS /DCAKELISP_EXPORTING ^
4445
/Fe"bin\cakelisp_bootstrap" /Zi /Fd"bin\cakelisp_bootstrap.pdb" /DEBUG:FASTLINK

CrossCompile_Windows.cake

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
(skip-build)
2-
31
(set-cakelisp-option executable-output "bin/cakelisp.exe")
42

53
(add-c-search-directory-module "src")
@@ -18,6 +16,7 @@
1816
"ModuleManager.cpp"
1917
"Logging.cpp"
2018
"Build.cpp"
19+
"Metadata.cpp"
2120
"Main.cpp")
2221

2322
(add-build-options "-DWINDOWS" "-DMINGW" "-DCAKELISP_EXPORTING")

VisualStudio/Cakelisp/Cakelisp.vcxproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<ClCompile Include="..\..\src\Generators.cpp" />
158158
<ClCompile Include="..\..\src\Logging.cpp" />
159159
<ClCompile Include="..\..\src\Main.cpp" />
160+
<ClCompile Include="..\..\src\Metadata.cpp" />
160161
<ClCompile Include="..\..\src\ModuleManager.cpp" />
161162
<ClCompile Include="..\..\src\OutputPreambles.cpp" />
162163
<ClCompile Include="..\..\src\RunProcess.cpp" />
@@ -170,4 +171,4 @@
170171
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
171172
<ImportGroup Label="ExtensionTargets">
172173
</ImportGroup>
173-
</Project>
174+
</Project>

VisualStudio/Cakelisp/Cakelisp.vcxproj.filters

+4-1
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
</ClCompile>
104104
<ClCompile Include="..\..\src\Logging.cpp">
105105
<Filter>Source Files</Filter>
106+
</ClCompile>
107+
<ClCompile Include="..\..\src\Metadata.cpp">
108+
<Filter>Source Files</Filter>
106109
</ClCompile>
107110
<ClCompile Include="..\..\src\Main.cpp">
108111
<Filter>Source Files</Filter>
@@ -132,4 +135,4 @@
132135
<ItemGroup>
133136
<None Include="..\..\src\Jamfile" />
134137
</ItemGroup>
135-
</Project>
138+
</Project>

doc/Cakelisp.org

+9-14
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ The ~local~ keyword or suffix is typically relative to module scope. It tells Ca
2727
** Importing modules
2828
The ~import~ function adds the specified file to the environment:
2929
#+BEGIN_SRC lisp
30-
(import "MyFile.cake" "AnotherFile.cake")
30+
(import "MyFile.cake" "AnotherFile.cake")
3131

32-
;; Include MyForwardDeclares.cake's generated header in the current module's generated header
33-
;; You might need to do this if you have non-module-local types/signatures which rely on other types
34-
(import &with-decls "MyForwardDeclares.cake")
32+
;; Include MyForwardDeclares.cake's generated header in the current module's generated header
33+
;; You might need to do this if you have non-module-local types/signatures which rely on other types
34+
(import &with-decls "MyForwardDeclares.cake")
3535

36-
;; Do not include in any generated code. This is essential for comptime-only modules, which won't
37-
;; even generate headers
38-
(import &comptime-only "ComptimeHelpers.cake")
36+
;; Do not build the module, only include its header (its declarations)
37+
(import &decls-only "OnlyHeader.cake")
3938
#+END_SRC
4039

4140
By default, ~&with-defs~ is specified, meaning the generated header will be included in the generated source file only.
@@ -51,7 +50,7 @@ This also means that adding Cakelisp to an existing C/C++ project should be virt
5150
Here are some example imports:
5251
#+BEGIN_SRC lisp
5352
(c-import "<vector>") ;; now just e.g. (var my-vec (<> std::vector int) (array 1 2 3))
54-
(c-import "<cstdio.h>") ;; (printf "Hello %s!\n" "Cakelisp")
53+
(c-import "<cstdio.h>") ;; (fprintf stderr "Hello %s!\n" "Cakelisp")
5554
(c-import "MyHeader.hpp") ;; (call-on updateState myGlobalVar 0.016)
5655

5756
;; Multiple imports are allowed per call:
@@ -131,7 +130,7 @@ The keyword ~&variable-arguments can be used to create a function with variadic
131130
(var list va_list)
132131
(va_start list num-args)
133132
(each-in-range num-args i
134-
(printf "%d\n" (va_arg list int)))
133+
(fprintf stderr "%d\n" (va_arg list int)))
135134
(va_end list))
136135

137136
(defun main (&return int)
@@ -399,11 +398,6 @@ Basic projects don't need any build customization at all. Cakelisp uses its modu
399398
** Example: Bootstrap
400399
For example, Cakelisp itself consists of C++ code. [[file:../Bootstrap.cake][Bootstrap.cake]] builds Cakelisp, and serves as a good demonstration of the build system. I'll explain it here.
401400

402-
#+BEGIN_SRC lisp
403-
(skip-build)
404-
#+END_SRC
405-
This indicates the current module should not be built, nor be linked into the final executable. ~Bootstrap.cake~ doesn't contain any runtime code, so we omit it. Modules which contain only compile-time functions like macros should also ~skip-build~.
406-
407401
#+BEGIN_SRC lisp
408402
(set-cakelisp-option executable-output "bin/cakelisp")
409403
#+END_SRC
@@ -432,6 +426,7 @@ If ~global~ is specified instead, all modules and build dependencies would inclu
432426
"ModuleManager.cpp"
433427
"Logging.cpp"
434428
"Build.cpp"
429+
"Metadata.cpp"
435430
"Main.cpp")
436431
#+END_SRC
437432

doc/NeatUses.org

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ chmod +x MyScript.cake
2525
(c-import "<stdio.h>")
2626

2727
(defun main (&return int)
28-
(printf "Hello, execute!\n")
28+
(fprintf stderr "Hello, execute!\n")
2929
(return 0))
3030
#+END_SRC
3131
* No more build system woes

doc/Roadmap.org

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class MyWindowEventListener : public Ogre::WindowEventListener
6868
public:
6969
virtual void windowClosed(Ogre::Window* window)
7070
{
71-
printf("Window closed!\n");
71+
fprintf(stderr, "Window closed!\n");
7272
g_ogre_window_should_quit = true;
7373
}
7474
};
@@ -117,7 +117,7 @@ In GameLib, almost all loops would be fine with a number range, e.g. here are so
117117
;; Pointer types, end as an expression
118118
;; This is a little bit too clunky for this construct
119119
(each-range (:iter c (* char) buffer (- (+ buffer (array-size buffer)) 1))
120-
(printf "Char is '%c'\n" (deref c)))
120+
(fprintf stderr "Char is '%c'\n" (deref c)))
121121
#+END_SRC
122122

123123
I'm open to input on the topic. I'm not sure I want to take much from ~dolist~ and such.

0 commit comments

Comments
 (0)