Skip to content

Commit

Permalink
"shrinkwrapped" the cmd-line-compiler.
Browse files Browse the repository at this point in the history
Integrated it with the rest of the code as well.
  • Loading branch information
shlomif committed May 28, 2017
1 parent 4d5f7c3 commit 0192b94
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 6 deletions.
25 changes: 22 additions & 3 deletions fc-solve/scripts/cmd-line-compiler
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,22 @@
use strict;
use warnings;

BEGIN
{
if (!@ARGV or $ARGV[0] ne 'compile')
{
print <<'EOF'
To run do:
export FCS_PATH="`pwd`" FCS_SRC_PATH="`pwd`/../source"
perl ../scripts/cmd-line-compiler compile
EOF
}
};

use Socket qw(:crlf);
use Path::Tiny qw/ path /;
use lib "$ENV{FCS_SRC_PATH}/t/lib";
use FC_Solve::CmdLine::Expand ();
use Socket qw(:crlf);

sub _normalize_lf
{
Expand All @@ -31,7 +44,12 @@ sub compile_cmd_line
);

my $expanded = _normalize_lf_list( $obj->argv() );
my $out = "static inline void my_init_instance(void *const instance)\n{\n";
my $out = <<'EOF';
#pragma once
static inline void my_init_instance(void *const instance)
{
EOF

my %one_param = (
'-dto' => {
Expand Down Expand Up @@ -125,12 +143,13 @@ qq#freecell_solver_user_set_a_star_weight(instance, $pos, $v);\n#;
return;
}


# TEST
compile_cmd_line(
{
argv => [ '-l', 'obf', ],
name => 'obf',
out_fn => 'fc_solve__theme__obf.c',
out_fn => 'fc_solve__precompiled__theme.h',
},
);

Expand Down
2 changes: 2 additions & 0 deletions fc-solve/source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ option (FCS_HARD_CODE_SCANS_SYNERGY_AS_TRUE "Make scan synergy as always true. R
option (FCS_HARD_CODE_REPARENT_STATES_AS_FALSE "Make reparent states as always false. Reduces functionality but may make things faster.")
option (FCS_HARD_CODE_CALC_REAL_DEPTH_AS_FALSE "Make calc-real-depth as always false. Reduces functionality but may make things faster.")
option (FCS_WITHOUT_EXPORTED_RESUME_SOLUTION "Don't export resume_solution. Breaks compat but may make things faseer. Enable at your own risk.")
option (FCS_USE_PRECOMPILED_CMD_LINE_THEME "Hard code a command line theme as generated by the compiler (useful for speedup but breaks functionality.)")


IF (NOT (STATES_TYPE MATCHES "^(INDIRECT_STACK_STATES|COMPACT_STATES)$"))
MESSAGE(FATAL_ERROR "STATES_TYPE should be ('INDIRECT_STACK_STATES', or 'COMPACT_STATES')")
Expand Down
1 change: 1 addition & 0 deletions fc-solve/source/Tatzer
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ my %BOOL_OPTS_WITH_FALSE_DEFAULTS =
'hard-code-calc-real-depth' => 'FCS_HARD_CODE_CALC_REAL_DEPTH_AS_FALSE',
'hard-code-reparent-states' => 'FCS_HARD_CODE_REPARENT_STATES_AS_FALSE',
'hard-code-scans-synergy' => 'FCS_HARD_CODE_SCANS_SYNERGY_AS_TRUE',
'hard-code-theme' => 'FCS_USE_PRECOMPILED_CMD_LINE_THEME',
'omit-frame' => 'OPTIMIZATION_OMIT_FRAME_POINTER',
'rcs' => 'FCS_ENABLE_RCS_STATES',
'secondary' => 'FCS_ENABLE_SECONDARY_HASH_VALUE',
Expand Down
1 change: 1 addition & 0 deletions fc-solve/source/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ extern "C" {
#cmakedefine FCS_DISABLE_NUM_STORED_STATES
#cmakedefine FCS_WITHOUT_EXPORTED_RESUME_SOLUTION
#cmakedefine FCS_DISABLE_STATE_VALIDITY_CHECK
#cmakedefine FCS_USE_PRECOMPILED_CMD_LINE_THEME
/*
* This flag controls a hash behaviour. It seems to improve things somewhat.
* */
Expand Down
12 changes: 9 additions & 3 deletions fc-solve/source/handle_parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ extern "C" {
#endif

#include "rinutils.h"
#ifndef FCS_USE_PRECOMPILED_CMD_LINE_THEME
#include "fcs_cl.h"

#else
#include "fcs_user.h"
#include "fc_solve__precompiled__theme.h"
#endif
enum
{
EXIT_AND_RETURN_0 = FCS_CMD_LINE_USER
Expand All @@ -32,7 +36,9 @@ static inline void *alloc_instance_and_parse(const int argc, char **const argv,
void *const callback_context, const fcs_bool_t only_recognized)
{
void *const instance = freecell_solver_user_alloc();

#ifdef FCS_USE_PRECOMPILED_CMD_LINE_THEME
my_init_instance(instance);
#else
#ifdef FCS_WITH_ERROR_STRS
char *error_string;
#endif
Expand Down Expand Up @@ -70,7 +76,7 @@ static inline void *alloc_instance_and_parse(const int argc, char **const argv,
freecell_solver_user_free(instance);
exit(-1);
}

#endif
return instance;
}

Expand Down

0 comments on commit 0192b94

Please sign in to comment.