Skip to content

Commit ee65eb5

Browse files
authored
Merge pull request #3093 from mgreter/feature/build-file-helper
Add utility perl script to generate MSVC source list
2 parents 8d312a1 + 1901601 commit ee65eb5

File tree

7 files changed

+550
-348
lines changed

7 files changed

+550
-348
lines changed

Makefile.conf

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,90 @@
55
# heavy RAM usage peaks. Other than that the order is arbitrary.
66

77

8+
INCFILES = \
9+
sass.h \
10+
sass2scss.h \
11+
sass/base.h \
12+
sass/context.h \
13+
sass/functions.h \
14+
sass/values.h \
15+
sass/version.h
16+
17+
HPPFILES = \
18+
ast.hpp \
19+
ast2c.hpp \
20+
ast_def_macros.hpp \
21+
ast_fwd_decl.hpp \
22+
ast_helpers.hpp \
23+
ast_selectors.hpp \
24+
ast_supports.hpp \
25+
ast_values.hpp \
26+
backtrace.hpp \
27+
base64vlq.hpp \
28+
bind.hpp \
29+
c2ast.hpp \
30+
check_nesting.hpp \
31+
color_maps.hpp \
32+
constants.hpp \
33+
context.hpp \
34+
cssize.hpp \
35+
dart_helpers.hpp \
36+
debug.hpp \
37+
debugger.hpp \
38+
emitter.hpp \
39+
environment.hpp \
40+
error_handling.hpp \
41+
eval.hpp \
42+
expand.hpp \
43+
extender.hpp \
44+
extension.hpp \
45+
file.hpp \
46+
fn_colors.hpp \
47+
fn_lists.hpp \
48+
fn_maps.hpp \
49+
fn_miscs.hpp \
50+
fn_numbers.hpp \
51+
fn_selectors.hpp \
52+
fn_strings.hpp \
53+
fn_utils.hpp \
54+
inspect.hpp \
55+
json.hpp \
56+
kwd_arg_macros.hpp \
57+
lexer.hpp \
58+
listize.hpp \
59+
mapping.hpp \
60+
memory.hpp \
61+
MurmurHash2.hpp \
62+
operation.hpp \
63+
operators.hpp \
64+
ordered_map.hpp \
65+
output.hpp \
66+
parser.hpp \
67+
permutate.hpp \
68+
plugins.hpp \
69+
position.hpp \
70+
prelexer.hpp \
71+
remove_placeholders.hpp \
72+
sass.hpp \
73+
sass_context.hpp \
74+
sass_functions.hpp \
75+
sass_values.hpp \
76+
settings.hpp \
77+
source.hpp \
78+
source_data.hpp \
79+
source_map.hpp \
80+
stylesheet.hpp \
81+
to_value.hpp \
82+
units.hpp \
83+
utf8_string.hpp \
84+
util.hpp \
85+
util_string.hpp \
86+
values.hpp \
87+
memory/allocator.hpp \
88+
memory/config.hpp \
89+
memory/memory_pool.hpp \
90+
memory/shared_ptr.hpp
91+
892
SOURCES = \
993
ast.cpp \
1094
ast_values.cpp \
@@ -71,4 +155,5 @@ SOURCES = \
71155
utf8_string.cpp \
72156
base64vlq.cpp
73157

74-
CSOURCES = cencode.c
158+
CSOURCES = \
159+
cencode.c

utils/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This directory contains some utilities that are not essential for LibSass.
2+
3+
# perl update-builds.pl
4+
5+
This will update 3rd party build files from `Makefile.conf`, which
6+
is the master index file for all required sources and headers.

utils/build-skeletons/libsass.targets

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<ItemGroup Label="LibSass Includes">{{includes}}</ItemGroup>
3+
<ItemGroup Label="LibSass Headers">{{headers}}</ItemGroup>
4+
<ItemGroup Label="LibSass Sources">{{sources}}</ItemGroup>
5+
<ItemGroup Label="LibSass Compatibility">
6+
<ClCompile Condition="$(VisualStudioVersion) &lt; 14.0" Include="$(LIBSASS_SRC_DIR)\c99func.c" />
7+
</ItemGroup>
8+
</Project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<Filter Include="Resources">
5+
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
6+
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
7+
</Filter>
8+
<Filter Include="Headers">
9+
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
10+
<Extensions>h;hh;hpp;hxx;hm;in;inl;inc;xsd</Extensions>
11+
</Filter>
12+
<Filter Include="Sources">
13+
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
14+
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
15+
</Filter>
16+
</ItemGroup>
17+
<ItemGroup Label="Includes">{{includes}}</ItemGroup>
18+
<ItemGroup Label="Headers">{{headers}}</ItemGroup>
19+
<ItemGroup Label="Sources">{{sources}}</ItemGroup>
20+
</Project>

utils/update-builds.pl

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/perl
2+
3+
use strict;
4+
use warnings;
5+
6+
# Installed via `cpan install File::Slurp`
7+
# Alternative `cpanm install File::Slurp`
8+
use File::Slurp qw(read_file write_file);
9+
10+
my $tmpl_msvc_head = <<EOTMPL;
11+
<ClInclude Include="\$(LIBSASS_HEADERS_DIR)\\%s" />
12+
EOTMPL
13+
14+
my $tmpl_msvc_inc = <<EOTMPL;
15+
<ClInclude Include="\$(LIBSASS_INCLUDES_DIR)\\%s" />
16+
EOTMPL
17+
18+
my $tmpl_msvc_src = <<EOTMPL;
19+
<ClCompile Include="\$(LIBSASS_SRC_DIR)\\%s" />
20+
EOTMPL
21+
22+
my $tmpl_msvc_filter_head = <<EOTMPL;
23+
<ClInclude Include="\$(LIBSASS_INCLUDES_DIR)\\%s">
24+
<Filter>Library Includes</Filter>
25+
</ClInclude>
26+
EOTMPL
27+
28+
my $tmpl_msvc_filter_inc = <<EOTMPL;
29+
<ClInclude Include="\$(LIBSASS_INCLUDES_DIR)\\%s">
30+
<Filter>LibSass Headers</Filter>
31+
</ClInclude>
32+
EOTMPL
33+
34+
my $tmpl_msvc_filter_src = <<EOTMPL;
35+
<ClCompile Include="\$(LIBSASS_SRC_DIR)\\%s">
36+
<Filter>LibSass Sources</Filter>
37+
</ClCompile>
38+
EOTMPL
39+
40+
# parse source files directly from libsass makefile
41+
open(my $fh, "<", "../Makefile.conf") or
42+
die "../Makefile.conf not found";
43+
my $srcfiles = join "", <$fh>; close $fh;
44+
45+
my (@INCFILES, @HPPFILES, @SOURCES, @CSOURCES);
46+
# parse variable out (this is hopefully tolerant enough)
47+
if ($srcfiles =~ /^\s*INCFILES\s*=\s*((?:.*(?:\\\r?\n))*.*)/m) {
48+
@INCFILES = grep { $_ } split /(?:\s|\\\r?\n)+/, $1;
49+
} else { die "Did not find c++ INCFILES in libsass/Makefile.conf"; }
50+
if ($srcfiles =~ /^\s*HPPFILES\s*=\s*((?:.*(?:\\\r?\n))*.*)/m) {
51+
@HPPFILES = grep { $_ } split /(?:\s|\\\r?\n)+/, $1;
52+
} else { die "Did not find c++ HPPFILES in libsass/Makefile.conf"; }
53+
if ($srcfiles =~ /^\s*SOURCES\s*=\s*((?:.*(?:\\\r?\n))*.*)/m) {
54+
@SOURCES = grep { $_ } split /(?:\s|\\\r?\n)+/, $1;
55+
} else { die "Did not find c++ SOURCES in libsass/Makefile.conf"; }
56+
if ($srcfiles =~ /^\s*CSOURCES\s*=\s*((?:.*(?:\\\r?\n))*.*)/m) {
57+
@CSOURCES = grep { $_ } split /(?:\s|\\\r?\n)+/, $1;
58+
} else { die "Did not find c++ CSOURCES in libsass/Makefile.conf"; }
59+
60+
sub renderTemplate($@) {
61+
my $str = "\n";
62+
my $tmpl = shift;
63+
foreach my $inc (@_) {
64+
$str .= sprintf($tmpl, $inc);
65+
}
66+
$str .= " ";
67+
return $str;
68+
}
69+
70+
@INCFILES = map { s/\//\\/gr } @INCFILES;
71+
@HPPFILES = map { s/\//\\/gr } @HPPFILES;
72+
@SOURCES = map { s/\//\\/gr } @SOURCES;
73+
@CSOURCES = map { s/\//\\/gr } @CSOURCES;
74+
75+
my $targets = read_file("build-skeletons/libsass.targets");
76+
$targets =~s /\{\{includes\}\}/renderTemplate($tmpl_msvc_inc, @INCFILES)/eg;
77+
$targets =~s /\{\{headers\}\}/renderTemplate($tmpl_msvc_head, @HPPFILES)/eg;
78+
$targets =~s /\{\{sources\}\}/renderTemplate($tmpl_msvc_src, @SOURCES, @CSOURCES)/eg;
79+
warn "Generating ../win/libsass.targets\n";
80+
write_file("../win/libsass.targets", $targets);
81+
82+
my $filters = read_file("build-skeletons/libsass.vcxproj.filters");
83+
$filters =~s /\{\{includes\}\}/renderTemplate($tmpl_msvc_filter_inc, @INCFILES)/eg;
84+
$filters =~s /\{\{headers\}\}/renderTemplate($tmpl_msvc_filter_head, @HPPFILES)/eg;
85+
$filters =~s /\{\{sources\}\}/renderTemplate($tmpl_msvc_filter_src, @SOURCES, @CSOURCES)/eg;
86+
warn "Generating ../win/libsass.vcxproj.filters\n";
87+
write_file("../win/libsass.vcxproj.filters", $filters);
88+

0 commit comments

Comments
 (0)