Skip to content
This repository was archived by the owner on Aug 11, 2021. It is now read-only.

Commit d770c37

Browse files
authored
[packages,*] Fixes #519. BREAKING CHANGE. Split out preprocessor settings from compiler.
In order to better support standalone preprocessor invocations, the preprocessor has been split out from the compiler into a separate settings interface, C.ICommonPreprocessorSettings. Compilers still implement this, but a new tool C.PreprocessorTool also implements this on each toolchain. This will break a great number of existing settings patches, that use the PreprocessorDefinition and IncludePath properties, since the interface will need to change. Added a new test, PreprocessFile1, in order to exercise the preprocessor.
1 parent 13e7081 commit d770c37

File tree

101 files changed

+2550
-428
lines changed

Some content is hidden

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

101 files changed

+2550
-428
lines changed

.appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ for:
1717
environment:
1818
GCC_VERSION: 7
1919
install:
20-
- cmd: powershell choco install doxygen.install
20+
- cmd: powershell choco install doxygen.portable --version 1.8.11 || exit 0
2121
- sh: ./codingtools/install_ubuntu_dependencies.sh
2222
before_build:
2323
- dotnet --version
@@ -28,7 +28,7 @@ build_script:
2828
- sh: python codingtools/dotnetcore_make_release.py --local
2929
after_build:
3030
- cmd: 7z a bam.zip %APPVEYOR_BUILD_FOLDER%\bam_publish
31-
- cmd: 7z a bam_docs.zip %APPVEYOR_BUILD_FOLDER%\docs
31+
- cmd: 7z a bam_docs.zip %APPVEYOR_BUILD_FOLDER%\docs || exit 0
3232
artifacts:
3333
- path: bam.zip
3434
name: Bam

Bam.Core/Bam.Core.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
3838
</ItemGroup>
3939
<ItemGroup>
40+
<None Update="licenseheader.txt">
41+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
42+
</None>
4043
<None Update="Schema\BamPackageDefinitionV1.xsd">
4144
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
4245
</None>

Changelog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
29-Dec-2018 Fixes #519. BREAKING CHANGE. Split out preprocessor settings from compiler.
2+
In order to better support standalone preprocessor invocations, the preprocessor has been split out from the compiler into a separate settings interface, C.ICommonPreprocessorSettings. Compilers still implement this, but a new tool C.PreprocessorTool also implements this on each toolchain.
3+
This will break a great number of settings patches, that use the PreprocessorDefinition and IncludePath properties, since the interface will need to change.
4+
Added a new test, PreprocessFile1, in order to exercise the preprocessor.
5+
16
22-Dec-2018 Fixes #518. Added ICommonLinkerSettings.ExportedSymbolList to provide a path to a list of symbols to export from a dynamic library.
27

38
29-Nov-2018 Added XcodeBuilder.FileReference.EFileType.GLSLShaderSource.

codingtools/assign_license.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,30 @@
33
from distutils.spawn import find_executable
44
from convert_line_endings import convert_line_endings
55
import os
6+
import platform
7+
import subprocess
68
import sys
79

810
licenseText = []
911

1012

13+
def check_bam_available():
14+
"""
15+
Check if BAM is available on the PATH, and return its root directory.
16+
"""
17+
system = platform.system()
18+
if system == 'Windows':
19+
bam_shell = 'bam.bat'
20+
else:
21+
bam_shell = 'bam'
22+
try:
23+
return subprocess.check_output([bam_shell, '--installdir']).rstrip()
24+
except WindowsError:
25+
raise RuntimeError('Unable to locate BAM on the PATH')
26+
27+
1128
def read_license_text():
12-
bam_path = find_executable('bam')
13-
if not bam_path:
14-
raise RuntimeError('Unable to locate bam')
15-
bam_dir = os.path.dirname(bam_path)
29+
bam_dir = check_bam_available()
1630
license_header_file = os.path.join(bam_dir, 'licenseheader.txt')
1731
with open(license_header_file, 'rt') as licenseFile:
1832
original_license_text = licenseFile.readlines()

codingtools/dotnetcore_make_release.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/python
22

33
from generate_docs import build_documentation
4+
from generate_docs import NoDoxygenError
45
from optparse import OptionParser
56
import os
67
import platform
@@ -172,10 +173,13 @@ def main(options, build_dir, source_dir):
172173
if options.doxygen:
173174
generated_docs_dir = os.path.join(source_dir, 'docs')
174175
delete_directory(generated_docs_dir)
175-
build_documentation(source_dir, options.doxygen)
176-
if options.make_distribution:
177-
zip_dir(os.path.realpath(os.path.join(build_dir, '..', '%s-docs' % bam_version_dir) + '.zip'), generated_docs_dir)
178-
tar_dir(os.path.realpath(os.path.join(build_dir, '..', '%s-docs' % bam_version_dir) + '.tgz'), generated_docs_dir)
176+
try:
177+
build_documentation(source_dir, options.doxygen)
178+
if options.make_distribution:
179+
zip_dir(os.path.realpath(os.path.join(build_dir, '..', '%s-docs' % bam_version_dir) + '.zip'), generated_docs_dir)
180+
tar_dir(os.path.realpath(os.path.join(build_dir, '..', '%s-docs' % bam_version_dir) + '.tgz'), generated_docs_dir)
181+
except NoDoxygenError, e:
182+
log(str(e)) # not fatal, but do complain
179183

180184
run_dotnet_publish(
181185
source_dir,

codingtools/generate_docs.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
import subprocess
66
import sys
77

8+
9+
class NoDoxygenError(Exception):
10+
pass
11+
12+
813
def build_documentation(source_dir, doxygenpath):
914
if not doxygenpath:
1015
raise RuntimeError("Path to doxygen is required")
@@ -15,7 +20,7 @@ def build_documentation(source_dir, doxygenpath):
1520
os.chdir(source_dir)
1621
subprocess.check_call(args)
1722
except OSError:
18-
raise RuntimeError('Unable to run doxygen executable "%s"' % doxygenpath)
23+
raise NoDoxygenError('Unable to run doxygen executable "%s"' % doxygenpath)
1924
finally:
2025
os.chdir(current_dir)
2126

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,15 @@
2929
#endregion // License
3030
namespace C
3131
{
32-
public static partial class VSSolutionSupport
32+
public sealed class RegisterPreprocessorAttribute :
33+
ToolRegistrationAttribute
3334
{
34-
public static void
35-
GenerateHeader(
36-
ProceduralHeaderFileFromToolOutput module)
37-
{
38-
var tool = module.Tool as Bam.Core.ICommandLineTool;
39-
var toolProject = (tool as Bam.Core.Module).MetaData as VSSolutionBuilder.VSProject;
40-
var toolConfig = toolProject.GetConfiguration(tool as Bam.Core.Module);
41-
42-
var commands = new Bam.Core.StringArray();
43-
commands.Add(
44-
$"{CommandLineProcessor.Processor.StringifyTool(tool)} > {module.GeneratedPaths[ProceduralHeaderFileFromToolOutput.HeaderFileKey].ToString()}"
45-
);
46-
47-
VSSolutionBuilder.Support.AddCustomPostBuildStep(
48-
toolConfig,
49-
module,
50-
commands
51-
);
52-
53-
// alias the tool's project so that inter-project dependencies can be set up
54-
module.MetaData = toolProject;
55-
}
35+
public RegisterPreprocessorAttribute(
36+
string toolsetName,
37+
Bam.Core.EPlatform platform,
38+
EBit bitDepth)
39+
:
40+
base(toolsetName, platform, bitDepth)
41+
{}
5642
}
5743
}

packages/C/bam/Scripts/ConsoleApplication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ public System.Collections.Generic.IEnumerable<Bam.Core.Module>
160160

161161
protected Bam.Core.Module.PrivatePatchDelegate ConsolePreprocessor = settings =>
162162
{
163-
var compiler = settings as C.ICommonCompilerSettings;
164-
compiler.PreprocessorDefines.Add("_CONSOLE");
163+
var preprocessor = settings as C.ICommonPreprocessorSettings;
164+
preprocessor.PreprocessorDefines.Add("_CONSOLE");
165165
};
166166

167167
/// <summary>

packages/C/bam/Scripts/CxxDynamicLibrary.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ public sealed override CObjectFileCollection
115115
var collection = base.CreateCSourceContainer(wildcardPath, macroModuleOverride, filter);
116116
collection.PrivatePatch(settings =>
117117
{
118-
var compiler = settings as C.ICommonCompilerSettings;
119-
compiler.PreprocessorDefines.Add("D_BAM_DYNAMICLIBRARY_BUILD");
118+
var preprocessor = settings as C.ICommonPreprocessorSettings;
119+
preprocessor.PreprocessorDefines.Add("D_BAM_DYNAMICLIBRARY_BUILD");
120120
(collection.Tool as C.CompilerTool).CompileAsShared(settings);
121121
});
122122
return collection;
@@ -138,8 +138,8 @@ public sealed override Cxx.ObjectFileCollection
138138
var collection = base.CreateCxxSourceContainer(wildcardPath, macroModuleOverride, filter);
139139
collection.PrivatePatch(settings =>
140140
{
141-
var compiler = settings as C.ICommonCompilerSettings;
142-
compiler.PreprocessorDefines.Add("D_BAM_DYNAMICLIBRARY_BUILD");
141+
var preprocessor = settings as C.ICommonPreprocessorSettings;
142+
preprocessor.PreprocessorDefines.Add("D_BAM_DYNAMICLIBRARY_BUILD");
143143
(collection.Tool as C.CompilerTool).CompileAsShared(settings);
144144
});
145145
return collection;

packages/C/bam/Scripts/CxxGUIApplication.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ protected override void
5454

5555
protected Bam.Core.Module.PrivatePatchDelegate WindowsPreprocessor = settings =>
5656
{
57-
var compiler = settings as C.ICommonCompilerSettings;
58-
compiler.PreprocessorDefines.Remove("_CONSOLE");
59-
compiler.PreprocessorDefines.Add("_WINDOWS");
57+
var preprocessor = settings as C.ICommonPreprocessorSettings;
58+
preprocessor.PreprocessorDefines.Remove("_CONSOLE");
59+
preprocessor.PreprocessorDefines.Add("_WINDOWS");
6060
};
6161

6262
/// <summary>

0 commit comments

Comments
 (0)